From 2e8ce87c23f8c67eb215650114b19dcd3e88c1f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Gr=C3=BCnbacher?= Date: Wed, 21 May 2014 18:45:40 +0200 Subject: [PATCH] Newmenus: Add MENU_TIMEOUT status code and pass it where necessary --- amxmodx/CMisc.cpp | 8 +++++++- amxmodx/amxmodx.cpp | 14 ++++++++++++-- amxmodx/newmenus.cpp | 27 ++++++++++++++++++++++----- amxmodx/newmenus.h | 1 + 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/amxmodx/CMisc.cpp b/amxmodx/CMisc.cpp index 3cf9957f..6309641b 100755 --- a/amxmodx/CMisc.cpp +++ b/amxmodx/CMisc.cpp @@ -70,13 +70,19 @@ void CPlayer::Disconnect() 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(MENU_EXIT)); + static_cast(status)); } } diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index 94b0e73a..e44db859 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -1298,10 +1298,15 @@ 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(MENU_EXIT)); + executeForwards(pMenu->func, static_cast(pPlayer->index), static_cast(menu), static_cast(status)); } UTIL_FakeClientCommand(pPlayer->pEdict, "menuselect", "10", 0); @@ -1340,10 +1345,15 @@ 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(MENU_EXIT)); + executeForwards(pMenu->func, static_cast(pPlayer->index), static_cast(menu), static_cast(status)); } UTIL_FakeClientCommand(pPlayer->pEdict, "menuselect", "10", 0); diff --git a/amxmodx/newmenus.cpp b/amxmodx/newmenus.cpp index 26ceeef4..d94d6f45 100755 --- a/amxmodx/newmenus.cpp +++ b/amxmodx/newmenus.cpp @@ -794,14 +794,19 @@ static cell AMX_NATIVE_CALL menu_display(AMX *amx, cell *params) break; } - Menu *pOther = g_NewMenus[menu]; + 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(MENU_EXIT)); + static_cast(status)); /* Infinite loop counter */ if (++loops >= 10) @@ -1047,13 +1052,19 @@ 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(MENU_EXIT)); + static_cast(status)); return 1; } @@ -1074,13 +1085,19 @@ 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(MENU_EXIT)); + static_cast(status)); } } g_NewMenus[params[1]] = NULL; diff --git a/amxmodx/newmenus.h b/amxmodx/newmenus.h index d759dcf2..0e7f6579 100755 --- a/amxmodx/newmenus.h +++ b/amxmodx/newmenus.h @@ -32,6 +32,7 @@ #ifndef _INCLUDE_NEWMENUS_H #define _INCLUDE_NEWMENUS_H +#define MENU_TIMEOUT -4 #define MENU_EXIT -3 #define MENU_BACK -2 #define MENU_MORE -1