fixed bug where deleting oldmenus would make the next key non-unique
This commit is contained in:
parent
1d30d0831b
commit
8502fb51b3
|
@ -47,6 +47,7 @@ MenuMngr::MenuCommand::MenuCommand(CPluginMngr::CPlugin *a, int mi, int k, int f
|
||||||
MenuMngr::~MenuMngr()
|
MenuMngr::~MenuMngr()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
MenuMngr::MenuIdEle::uniqueid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MenuMngr::findMenuId(const char* name, AMX* amx)
|
int MenuMngr::findMenuId(const char* name, AMX* amx)
|
||||||
|
@ -81,6 +82,7 @@ void MenuMngr::removeMenuId(int id)
|
||||||
|
|
||||||
MenuCommand *c = headcmd;
|
MenuCommand *c = headcmd;
|
||||||
MenuCommand *lc = NULL;
|
MenuCommand *lc = NULL;
|
||||||
|
MenuCommand *tmp;
|
||||||
while (c)
|
while (c)
|
||||||
{
|
{
|
||||||
if (c->menuid == id)
|
if (c->menuid == id)
|
||||||
|
@ -89,11 +91,13 @@ void MenuMngr::removeMenuId(int id)
|
||||||
lc->next = c->next;
|
lc->next = c->next;
|
||||||
else
|
else
|
||||||
headcmd = c->next;
|
headcmd = c->next;
|
||||||
|
tmp = c->next;
|
||||||
delete c;
|
delete c;
|
||||||
break;
|
c = tmp;
|
||||||
|
} else {
|
||||||
|
lc = c;
|
||||||
|
c = c->next;
|
||||||
}
|
}
|
||||||
lc = c;
|
|
||||||
c = c->next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,6 @@ class MenuMngr
|
||||||
{
|
{
|
||||||
id = ++uniqueid;
|
id = ++uniqueid;
|
||||||
}
|
}
|
||||||
|
|
||||||
~MenuIdEle() { --uniqueid; }
|
|
||||||
} *headid;
|
} *headid;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -679,7 +679,8 @@ static cell AMX_NATIVE_CALL menu_setprop(AMX *amx, cell *params)
|
||||||
case MPROP_TITLE:
|
case MPROP_TITLE:
|
||||||
{
|
{
|
||||||
char *str = get_amxstring(amx, params[3], 0, len);
|
char *str = get_amxstring(amx, params[3], 0, len);
|
||||||
g_menucmds.removeMenuId(pMenu->menuId);
|
int old = pMenu->menuId;
|
||||||
|
g_menucmds.removeMenuId(old);
|
||||||
pMenu->m_Title.assign(str);
|
pMenu->m_Title.assign(str);
|
||||||
pMenu->menuId = g_menucmds.registerMenuId(str, amx);
|
pMenu->menuId = g_menucmds.registerMenuId(str, amx);
|
||||||
g_menucmds.registerMenuCmd(
|
g_menucmds.registerMenuCmd(
|
||||||
|
@ -687,6 +688,18 @@ static cell AMX_NATIVE_CALL menu_setprop(AMX *amx, cell *params)
|
||||||
pMenu->menuId,
|
pMenu->menuId,
|
||||||
1023,
|
1023,
|
||||||
pMenu->func);
|
pMenu->func);
|
||||||
|
CPlayer *pl;
|
||||||
|
/**
|
||||||
|
* NOTE - this is actually bogus
|
||||||
|
* the client's screen won't actually match the cmd here
|
||||||
|
* I think, this scenario needs to be tested.
|
||||||
|
*/
|
||||||
|
for (int i=1; i<=gpGlobals->maxClients; i++)
|
||||||
|
{
|
||||||
|
pl = GET_PLAYER_POINTER_I(i);
|
||||||
|
if (pl->menu == old)
|
||||||
|
pl->menu = pMenu->menuId;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MPROP_EXITALL:
|
case MPROP_EXITALL:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user