Newmenus: Use Menu::Close everywhere

This commit is contained in:
Valentin Grünbacher 2014-05-21 18:58:51 +02:00
parent 34337fb959
commit fa5336cade
4 changed files with 8 additions and 80 deletions

View File

@ -65,25 +65,10 @@ void CPlayer::Disconnect()
authorized = false;
teamIdsInitialized = false;
if (newmenu != -1)
if (newmenu >= 0 && newmenu < (int)g_NewMenus.size() && g_NewMenus[newmenu])
{
Menu *pMenu = g_NewMenus[newmenu];
if (pMenu)
{
int status;
if (gpGlobals->time > menuexpire)
status = MENU_TIMEOUT;
else
status = MENU_EXIT;
//prevent recursion
newmenu = -1;
menu = 0;
executeForwards(pMenu->func,
static_cast<cell>(ENTINDEX(pEdict)),
static_cast<cell>(pMenu->thisId),
static_cast<cell>(status));
}
pMenu->Close(index);
}
List<ClientCvarQuery_Info *>::iterator iter, end=queries.end();

View File

@ -1298,15 +1298,7 @@ static cell AMX_NATIVE_CALL show_menu(AMX *amx, cell *params) /* 3 param */
if (menu >= 0 && menu < (int)g_NewMenus.size() && g_NewMenus[menu])
{
Menu *pMenu = g_NewMenus[menu];
int status;
if (gpGlobals->time > pPlayer->menuexpire)
status = MENU_TIMEOUT;
else
status = MENU_EXIT;
pPlayer->newmenu = -1;
executeForwards(pMenu->func, static_cast<cell>(pPlayer->index), static_cast<cell>(menu), static_cast<cell>(status));
pMenu->Close(pPlayer->index);
}
UTIL_FakeClientCommand(pPlayer->pEdict, "menuselect", "10", 0);
@ -1345,15 +1337,7 @@ static cell AMX_NATIVE_CALL show_menu(AMX *amx, cell *params) /* 3 param */
if (menu >= 0 && menu < (int)g_NewMenus.size() && g_NewMenus[menu])
{
Menu *pMenu = g_NewMenus[menu];
int status;
if (gpGlobals->time > pPlayer->menuexpire)
status = MENU_TIMEOUT;
else
status = MENU_EXIT;
pPlayer->newmenu = -1;
executeForwards(pMenu->func, static_cast<cell>(pPlayer->index), static_cast<cell>(menu), static_cast<cell>(status));
pMenu->Close(pPlayer->index);
}
UTIL_FakeClientCommand(pPlayer->pEdict, "menuselect", "10", 0);

View File

@ -967,14 +967,7 @@ void C_ClientCommand(edict_t *pEntity)
if (menu >= 0 && menu < (int)g_NewMenus.size() && g_NewMenus[menu])
{
Menu *pMenu = g_NewMenus[menu];
pPlayer->newmenu = -1;
pPlayer->menu = 0;
executeForwards(pMenu->func,
static_cast<cell>(pPlayer->index),
static_cast<cell>(menu),
static_cast<cell>(MENU_TIMEOUT));
pMenu->Close(pPlayer->index);
RETURN_META(MRES_SUPERCEDE);
}

View File

@ -815,18 +815,7 @@ static cell AMX_NATIVE_CALL menu_display(AMX *amx, cell *params)
}
Menu *pOther = g_NewMenus[menu];
int status;
if (gpGlobals->time > pPlayer->menuexpire)
status = MENU_TIMEOUT;
else
status = MENU_EXIT;
pPlayer->newmenu = -1;
pPlayer->menu = 0;
executeForwards(pOther->func,
static_cast<cell>(player),
static_cast<cell>(pOther->thisId),
static_cast<cell>(status));
pOther->Close(pPlayer->index);
/* Infinite loop counter */
if (++loops >= 10)
@ -1072,19 +1061,7 @@ static cell AMX_NATIVE_CALL menu_cancel(AMX *amx, cell *params)
return 0;
Menu *pMenu = g_NewMenus[menu];
int status;
if (gpGlobals->time > player->menuexpire)
status = MENU_TIMEOUT;
else
status = MENU_EXIT;
player->newmenu = -1;
player->menu = 0;
executeForwards(pMenu->func,
static_cast<cell>(index),
static_cast<cell>(pMenu->thisId),
static_cast<cell>(status));
pMenu->Close(player->index);
return 1;
}
@ -1106,18 +1083,7 @@ static cell AMX_NATIVE_CALL menu_destroy(AMX *amx, cell *params)
player = GET_PLAYER_POINTER_I(i);
if (player->newmenu == pMenu->thisId)
{
int status;
if (gpGlobals->time > player->menuexpire)
status = MENU_TIMEOUT;
else
status = MENU_EXIT;
player->newmenu = -1;
player->menu = 0;
executeForwards(pMenu->func,
static_cast<cell>(i),
static_cast<cell>(pMenu->thisId),
static_cast<cell>(status));
pMenu->Close(player->index);
}
}
g_NewMenus[params[1]] = NULL;