From 23bdf82d2ba26619f82b7454fd07f085a6190084 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 13 Oct 2024 15:37:29 +0300 Subject: [PATCH] Fix error handler staying on lua stack after lua commands being called --- src/lua_consolelib.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index cc0b3732f..42edfb7c9 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -81,6 +81,9 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum) lua_pushstring(gL, buf); } LUA_Call(gL, (int)argc, 0, 1); // argc is 1-based, so this will cover the player we passed too. + + lua_pop(gL, 1); // Pop LUA_GetErrorMessage (lua_pcall doesn't pop it) + return; deny: @@ -142,7 +145,7 @@ void COM_Lua_f(void) if (netgame && !( flags & COM_LOCAL ))/* don't send local commands */ { // Send the command through the network UINT8 argc; - lua_pop(gL, 1); // pop command info table + lua_pop(gL, 2); // pop command info table and LUA_GetErrorMessage if ((flags & COM_ADMIN) && !server && !IsPlayerAdmin(playernum)) // only server/admin can use this command. { @@ -179,6 +182,8 @@ void COM_Lua_f(void) for (i = 1; i < COM_Argc(); i++) lua_pushstring(gL, COM_Argv(i)); LUA_Call(gL, (int)COM_Argc(), 0, 1); // COM_Argc is 1-based, so this will cover the player we passed too. + + lua_pop(gL, 1); // Pop LUA_GetErrorMessage (lua_pcall doesn't pop it) } // Wrapper for COM_AddCommand