From bb08b55b43ed1bcca313e5d294c355d9d8628c3f Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Thu, 12 Mar 2020 12:22:04 -0500 Subject: [PATCH 01/23] Created GameQuit hook, but I need to decide where to execute it --- src/lua_hook.h | 2 ++ src/lua_hooklib.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/lua_hook.h b/src/lua_hook.h index 265700e4f..380e45991 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -58,6 +58,7 @@ enum hook { hook_ViewpointSwitch, hook_SeenPlayer, hook_PlayerThink, + hook_GameQuit, hook_MAX // last hook }; @@ -110,5 +111,6 @@ UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend); // Hook for MT_NAMECHECK #endif #define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink +void LUAh_GameQuit(void); // Hook for game quitting #endif diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index c29edbd61..dc66b39e8 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -69,6 +69,7 @@ const char *const hookNames[hook_MAX+1] = { "ViewpointSwitch", "SeenPlayer", "PlayerThink", + "GameQuit", NULL }; @@ -1660,4 +1661,27 @@ boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend) } #endif // SEENAMES +// Hook for game quitting +void LUAh_GameQuit(void) +{ + hook_p hookp; + if (!gL || !(hooksAvailable[hook_GameQuit/8] & (1<<(hook_GameQuit%8)))) + return; + + for (hookp = roothook; hookp; hookp = hookp->next) + { + if (hookp->type != hook_GameQuit) + continue; + + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + if (lua_pcall(gL, 0, 0, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + } + } +} + #endif From 4d7f64a53d7837b4e15fa0d983e3802684bf45cf Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Thu, 12 Mar 2020 12:45:41 -0500 Subject: [PATCH 02/23] Let's call LUAh_GameQuit in D_QuitNetGame since that function is still called outside of netgames However, the D_QuitNetGame function returns early if you are not in a netgame. --- src/d_clisrv.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index ae9b91ec5..0cdf3fb73 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3188,6 +3188,10 @@ static inline void SV_GenContext(void) // void D_QuitNetGame(void) { +#ifdef HAVE_BLUA + LUAh_GameQuit(); +#endif + if (!netgame || !netbuffer) return; From 4d144f2e400987173fd36e1e7f9babdf573d78f9 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Thu, 12 Mar 2020 19:59:50 -0500 Subject: [PATCH 03/23] No longer call LUAh_GameQuit in D_QuitNetGame --- src/d_clisrv.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 0cdf3fb73..ae9b91ec5 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3188,10 +3188,6 @@ static inline void SV_GenContext(void) // void D_QuitNetGame(void) { -#ifdef HAVE_BLUA - LUAh_GameQuit(); -#endif - if (!netgame || !netbuffer) return; From 2b16971137ed0d29055708181e83415c0e94f91f Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Thu, 12 Mar 2020 20:15:21 -0500 Subject: [PATCH 04/23] Call LUAh_GameQuit in Command_ExitGame_f --- src/d_netcmd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c6ea974ae..eca80907a 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4235,6 +4235,10 @@ void Command_ExitGame_f(void) { INT32 i; +#ifdef HAVE_BLUA + LUAh_GameQuit(); +#endif + D_QuitNetGame(); CL_Reset(); CV_ClearChangedFlags(); From bef49f56605e61fb7f3fc0092577b6804d179131 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Thu, 12 Mar 2020 20:51:16 -0500 Subject: [PATCH 05/23] Don't execute LUAh_GameQuit in Command_ExitGame_f if you are in a multiplayer game --- src/d_netcmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index eca80907a..8d21d62a2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4236,7 +4236,8 @@ void Command_ExitGame_f(void) INT32 i; #ifdef HAVE_BLUA - LUAh_GameQuit(); + if (!multiplayer) + LUAh_GameQuit(); #endif D_QuitNetGame(); From 7ec241c59e71e0a219766b2252fe54a30990e83f Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Thu, 12 Mar 2020 22:31:39 -0500 Subject: [PATCH 06/23] Revert "Don't execute LUAh_GameQuit in Command_ExitGame_f if you are in a multiplayer game" This reverts commit bef49f56605e61fb7f3fc0092577b6804d179131. --- src/d_netcmd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 8d21d62a2..eca80907a 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4236,8 +4236,7 @@ void Command_ExitGame_f(void) INT32 i; #ifdef HAVE_BLUA - if (!multiplayer) - LUAh_GameQuit(); + LUAh_GameQuit(); #endif D_QuitNetGame(); From f97187f59b60b7768fae167fc1bb09fd5394a94e Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Thu, 12 Mar 2020 22:31:48 -0500 Subject: [PATCH 07/23] Revert "Call LUAh_GameQuit in Command_ExitGame_f" This reverts commit 2b16971137ed0d29055708181e83415c0e94f91f. --- src/d_netcmd.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index eca80907a..c6ea974ae 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4235,10 +4235,6 @@ void Command_ExitGame_f(void) { INT32 i; -#ifdef HAVE_BLUA - LUAh_GameQuit(); -#endif - D_QuitNetGame(); CL_Reset(); CV_ClearChangedFlags(); From a329ca43bad7341a28ceaa25c038406cdb87ac35 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Sun, 15 Mar 2020 00:53:05 -0400 Subject: [PATCH 08/23] Call ``LUAh_GameQuit`` in 2 places. --- src/sdl/i_system.c | 4 ++++ src/sdl/i_video.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index a86af316e..ca135a96b 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -171,6 +171,7 @@ static char returnWadPath[256]; #include "../d_net.h" #include "../g_game.h" #include "../filesrch.h" +#include "../lua_hook.h" #include "endtxt.h" #include "sdlmain.h" @@ -303,6 +304,9 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) FUNCNORETURN static ATTRNORETURN void quit_handler(int num) { +#ifdef HAVE_BLUA + LUAh_GameQuit(); +#endif signal(num, SIG_DFL); //default signal action raise(num); I_Quit(); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index c2f492000..78c5e8170 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -73,6 +73,7 @@ #include "../console.h" #include "../command.h" #include "../r_main.h" +#include "../lua_hook.h" #include "sdlmain.h" #ifdef HWRENDER #include "../hardware/hw_main.h" @@ -1059,6 +1060,9 @@ void I_GetEvent(void) M_SetupJoystickMenu(0); break; case SDL_QUIT: +#ifdef HAVE_BLUA + LUAh_GameQuit(); +#endif I_Quit(); M_QuitResponse('y'); break; From b067d1e134d3f165c2ff9fb4c425ade1b2a2b50d Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Sun, 15 Mar 2020 00:08:57 -0500 Subject: [PATCH 09/23] Revert "Call ``LUAh_GameQuit`` in 2 places." This reverts commit a329ca43bad7341a28ceaa25c038406cdb87ac35. --- src/sdl/i_system.c | 4 ---- src/sdl/i_video.c | 4 ---- 2 files changed, 8 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index ca135a96b..a86af316e 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -171,7 +171,6 @@ static char returnWadPath[256]; #include "../d_net.h" #include "../g_game.h" #include "../filesrch.h" -#include "../lua_hook.h" #include "endtxt.h" #include "sdlmain.h" @@ -304,9 +303,6 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) FUNCNORETURN static ATTRNORETURN void quit_handler(int num) { -#ifdef HAVE_BLUA - LUAh_GameQuit(); -#endif signal(num, SIG_DFL); //default signal action raise(num); I_Quit(); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 78c5e8170..c2f492000 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -73,7 +73,6 @@ #include "../console.h" #include "../command.h" #include "../r_main.h" -#include "../lua_hook.h" #include "sdlmain.h" #ifdef HWRENDER #include "../hardware/hw_main.h" @@ -1060,9 +1059,6 @@ void I_GetEvent(void) M_SetupJoystickMenu(0); break; case SDL_QUIT: -#ifdef HAVE_BLUA - LUAh_GameQuit(); -#endif I_Quit(); M_QuitResponse('y'); break; From 0e56202d638fe0d2b71f78a1056ea7efd21f0e1d Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Sun, 15 Mar 2020 00:28:41 -0500 Subject: [PATCH 10/23] Let's just call LUAh_GameQuit in Command_ExitGame_f during its execution if you are in game and are not a dedicated server --- src/d_netcmd.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c6ea974ae..582e4d0a3 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4235,6 +4235,11 @@ void Command_ExitGame_f(void) { INT32 i; +#ifdef HAVE_BLUA + if ((maptol) && (!dedicated)) + LUAh_GameQuit(); +#endif + D_QuitNetGame(); CL_Reset(); CV_ClearChangedFlags(); From 7c65577336884b69bb0a9dd509e55d7926292a1d Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Sun, 15 Mar 2020 00:39:46 -0500 Subject: [PATCH 11/23] Let's just call LUAh_GameQuit in I_Quit anyways --- src/sdl/i_system.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index a86af316e..ed8a55039 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -190,6 +190,8 @@ static char returnWadPath[256]; #include "../byteptr.h" #endif +#include "../lua_hook.h" + /** \brief The JoyReset function \param JoySet Joystick info to reset @@ -2279,6 +2281,9 @@ void I_Quit(void) if (quiting) goto death; SDLforceUngrabMouse(); quiting = SDL_FALSE; +#ifdef HAVE_BLUA + LUAh_GameQuit(); +#endif M_SaveConfig(NULL); //save game config, cvars.. #ifndef NONET D_SaveBan(); // save the ban list From 766ca2f5a54a82864dcdf642f5c905fa5329c756 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Sun, 15 Mar 2020 00:54:06 -0500 Subject: [PATCH 12/23] Since exitgame shuts down the server if you are running a dedicated server I may as well allow the hook to run for the dedicated server as well --- src/d_netcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 582e4d0a3..498aebad2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4236,7 +4236,7 @@ void Command_ExitGame_f(void) INT32 i; #ifdef HAVE_BLUA - if ((maptol) && (!dedicated)) + if (maptol) LUAh_GameQuit(); #endif From 8b7f93d50aa1d36c53ce72f87bd4bbb3668ea3a7 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Sun, 15 Mar 2020 10:33:24 -0500 Subject: [PATCH 13/23] Revert "Let's just call LUAh_GameQuit in I_Quit anyways" This reverts commit 7c65577336884b69bb0a9dd509e55d7926292a1d. --- src/sdl/i_system.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index ed8a55039..a86af316e 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -190,8 +190,6 @@ static char returnWadPath[256]; #include "../byteptr.h" #endif -#include "../lua_hook.h" - /** \brief The JoyReset function \param JoySet Joystick info to reset @@ -2281,9 +2279,6 @@ void I_Quit(void) if (quiting) goto death; SDLforceUngrabMouse(); quiting = SDL_FALSE; -#ifdef HAVE_BLUA - LUAh_GameQuit(); -#endif M_SaveConfig(NULL); //save game config, cvars.. #ifndef NONET D_SaveBan(); // save the ban list From 2052ee1144e4ed39c668104ae70e0a5ba102890a Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Sun, 15 Mar 2020 10:34:43 -0500 Subject: [PATCH 14/23] Check if you are playing a game then execute ``LUAh_GameQuit`` if you are in Command_quit_f and Command_ExitGame_f --- src/d_netcmd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 498aebad2..b80214d8a 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3574,6 +3574,10 @@ static void Command_Playintro_f(void) */ FUNCNORETURN static ATTRNORETURN void Command_Quit_f(void) { +#ifdef HAVE_BLUA + if (Playing()) + LUAh_GameQuit(); +#endif I_Quit(); } @@ -4236,7 +4240,7 @@ void Command_ExitGame_f(void) INT32 i; #ifdef HAVE_BLUA - if (maptol) + if (Playing()) LUAh_GameQuit(); #endif From 569034d3a9be35b09fbc4c71c80b3917d4d4aba8 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Sun, 15 Mar 2020 10:47:55 -0500 Subject: [PATCH 15/23] Call LUAh_GameQuit in I_GetEvent in if the event is SDL_Quit and if you are in a playing session Time for the ultimate testing to see if I get any undefined reference compiling errors --- src/sdl/i_video.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index c2f492000..21fd29bb5 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -73,6 +73,7 @@ #include "../console.h" #include "../command.h" #include "../r_main.h" +#include "../lua_hook.h" #include "sdlmain.h" #ifdef HWRENDER #include "../hardware/hw_main.h" @@ -1059,6 +1060,10 @@ void I_GetEvent(void) M_SetupJoystickMenu(0); break; case SDL_QUIT: +#ifdef HAVE_BLUA + if (Playing()) + LUAh_GameQuit(); +#endif I_Quit(); M_QuitResponse('y'); break; From decce7905bc318e96daf966b174afe4f0fd0a7f4 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Tue, 24 Mar 2020 22:55:25 -0500 Subject: [PATCH 16/23] Moved LUAh_GameQuit(void) function to the end of the lua_hooklib.c --- src/lua_hooklib.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index f4860f85a..88f1b291d 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1663,29 +1663,6 @@ boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend) } #endif // SEENAMES -// Hook for game quitting -void LUAh_GameQuit(void) -{ - hook_p hookp; - if (!gL || !(hooksAvailable[hook_GameQuit/8] & (1<<(hook_GameQuit%8)))) - return; - - for (hookp = roothook; hookp; hookp = hookp->next) - { - if (hookp->type != hook_GameQuit) - continue; - - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - if (lua_pcall(gL, 0, 0, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - } - } -} - boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname) { hook_p hookp; @@ -1727,4 +1704,27 @@ boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname) hud_running = false; return keepplaying; +} + +// Hook for game quitting +void LUAh_GameQuit(void) +{ + hook_p hookp; + if (!gL || !(hooksAvailable[hook_GameQuit/8] & (1<<(hook_GameQuit%8)))) + return; + + for (hookp = roothook; hookp; hookp = hookp->next) + { + if (hookp->type != hook_GameQuit) + continue; + + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + if (lua_pcall(gL, 0, 0, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + } + } } \ No newline at end of file From 28de6b1f93d853f87b4e5d5f7a97d57923f116ff Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Fri, 3 Apr 2020 17:44:57 -0500 Subject: [PATCH 17/23] Execute LUAh_GameQuit in 2 additional places in m_menu.c --- src/m_menu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index f8240d403..0303b0de0 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -44,6 +44,7 @@ #include "p_local.h" #include "p_setup.h" #include "f_finale.h" +#include "lua_hook.h" #ifdef HWRENDER #include "hardware/hw_main.h" @@ -6864,6 +6865,8 @@ static void M_SelectableClearMenus(INT32 choice) static void M_UltimateCheat(INT32 choice) { (void)choice; + if (Playing()) + LUAh_GameQuit(); I_Quit(); } @@ -12535,6 +12538,8 @@ void M_QuitResponse(INT32 ch) I_Sleep(); } } + if (Playing()) + LUAh_GameQuit(); I_Quit(); } From f6120410fb24b1ae17d6173f012c6a8e4b6fbbb9 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Thu, 23 Apr 2020 17:38:08 -0500 Subject: [PATCH 18/23] Execute LUAh_GameQuit earlier in M_QuitResponse It just feels a bit funny to execute LUAh_GameQuit if you are playing a session after the quit screen appears instead of before. --- src/m_menu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 6ff13a19c..e4d2c9039 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -12535,6 +12535,8 @@ void M_QuitResponse(INT32 ch) if (ch != 'y' && ch != KEY_ENTER) return; + if (Playing()) + LUAh_GameQuit(); if (!(netgame || cv_debug)) { S_ResetCaptions(); @@ -12551,8 +12553,6 @@ void M_QuitResponse(INT32 ch) I_Sleep(); } } - if (Playing()) - LUAh_GameQuit(); I_Quit(); } From 530d0e342127733d6281d8e51cb94a68be4cf379 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Mon, 18 May 2020 14:56:10 -0500 Subject: [PATCH 19/23] Remove redundant M_QuitResponse call --- src/sdl/i_video.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index cff73e068..8835a763b 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1064,7 +1064,6 @@ void I_GetEvent(void) if (Playing()) LUAh_GameQuit(); I_Quit(); - M_QuitResponse('y'); break; } } From bb1e3fdf13816da0af01ba7704fbb5764ad95432 Mon Sep 17 00:00:00 2001 From: Louis-Antoine Date: Wed, 27 May 2020 14:58:10 +0200 Subject: [PATCH 20/23] Add a few missing calls to GameQuit hook --- src/d_clisrv.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index ed0b8e528..184e0e800 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3036,6 +3036,8 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) if (pnum == consoleplayer) { + if (Playing()) + LUAh_GameQuit(); #ifdef DUMPCONSISTENCY if (msg == KICK_MSG_CON_FAIL) SV_SavedGame(); #endif @@ -3701,6 +3703,8 @@ static void HandleConnect(SINT8 node) static void HandleShutdown(SINT8 node) { (void)node; + if (Playing()) + LUAh_GameQuit(); D_QuitNetGame(); CL_Reset(); D_StartTitle(); @@ -3715,6 +3719,8 @@ static void HandleShutdown(SINT8 node) static void HandleTimeout(SINT8 node) { (void)node; + if (Playing()) + LUAh_GameQuit(); D_QuitNetGame(); CL_Reset(); D_StartTitle(); From ca66c5e7ee624a43551c055042ff35aa69fba329 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Fri, 5 Jun 2020 13:18:22 -0500 Subject: [PATCH 21/23] Updated LUAh_GameQuit --- src/lua_hooklib.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 62bb5b663..0d8aa1ffb 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1783,8 +1783,7 @@ void LUAh_GameQuit(void) if (hookp->type != hook_GameQuit) continue; - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); + PushHook(gL, hookp); if (lua_pcall(gL, 0, 0, 0)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); From 0d70e16b0bf13fc80fc8e43c309f47a51c837c5c Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Thu, 11 Jun 2020 15:11:01 -0500 Subject: [PATCH 22/23] Updated LUAh_GameQuit to use new error handler --- src/lua_hooklib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 0d8aa1ffb..854f3ddfe 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1778,13 +1778,15 @@ void LUAh_GameQuit(void) if (!gL || !(hooksAvailable[hook_GameQuit/8] & (1<<(hook_GameQuit%8)))) return; + lua_pushcfunction(gL, LUA_GetErrorMessage); + for (hookp = roothook; hookp; hookp = hookp->next) { if (hookp->type != hook_GameQuit) continue; PushHook(gL, hookp); - if (lua_pcall(gL, 0, 0, 0)) { + if (lua_pcall(gL, 0, 0, 1)) { if (!hookp->error || cv_debug & DBG_LUA) CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); From 6eccc7030d8afccec76f285b70f2aa5a1ddf1897 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Fri, 12 Jun 2020 07:50:57 -0500 Subject: [PATCH 23/23] I forgot to pop the error handler --- src/lua_hooklib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 854f3ddfe..5cfd1bd3d 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1793,4 +1793,6 @@ void LUAh_GameQuit(void) hookp->error = true; } } -} \ No newline at end of file + + lua_pop(gL, 1); // Pop error handler +}