From fa5336cade1d760b691bb83c5e6a4f919b520ea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Gr=C3=BCnbacher?= Date: Wed, 21 May 2014 18:58:51 +0200 Subject: [PATCH] Newmenus: Use Menu::Close everywhere --- amxmodx/CMisc.cpp | 19 ++----------------- amxmodx/amxmodx.cpp | 20 ++------------------ amxmodx/meta_api.cpp | 9 +-------- amxmodx/newmenus.cpp | 40 +++------------------------------------- 4 files changed, 8 insertions(+), 80 deletions(-) diff --git a/amxmodx/CMisc.cpp b/amxmodx/CMisc.cpp index 6309641b..8f2e508b 100755 --- a/amxmodx/CMisc.cpp +++ b/amxmodx/CMisc.cpp @@ -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(ENTINDEX(pEdict)), - static_cast(pMenu->thisId), - static_cast(status)); - } + pMenu->Close(index); } List::iterator iter, end=queries.end(); diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index e44db859..fd09387b 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -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(pPlayer->index), static_cast(menu), static_cast(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(pPlayer->index), static_cast(menu), static_cast(status)); + pMenu->Close(pPlayer->index); } UTIL_FakeClientCommand(pPlayer->pEdict, "menuselect", "10", 0); diff --git a/amxmodx/meta_api.cpp b/amxmodx/meta_api.cpp index 061b922c..86e9b998 100755 --- a/amxmodx/meta_api.cpp +++ b/amxmodx/meta_api.cpp @@ -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(pPlayer->index), - static_cast(menu), - static_cast(MENU_TIMEOUT)); + pMenu->Close(pPlayer->index); RETURN_META(MRES_SUPERCEDE); } diff --git a/amxmodx/newmenus.cpp b/amxmodx/newmenus.cpp index c252bedd..6b75394d 100755 --- a/amxmodx/newmenus.cpp +++ b/amxmodx/newmenus.cpp @@ -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(player), - static_cast(pOther->thisId), - static_cast(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(index), - static_cast(pMenu->thisId), - static_cast(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(i), - static_cast(pMenu->thisId), - static_cast(status)); + pMenu->Close(player->index); } } g_NewMenus[params[1]] = NULL;