Resolve GameQuit hook conflicts

This commit is contained in:
James R 2020-12-12 02:05:21 -08:00
parent 2778cc3ce9
commit 9ddeb5f589
6 changed files with 19 additions and 8 deletions

View file

@ -3032,7 +3032,7 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum)
if (pnum == consoleplayer)
{
LUAh_GameQuit(false);
LUA_HookBool(false, Hook(GameQuit));
#ifdef DUMPCONSISTENCY
if (msg == KICK_MSG_CON_FAIL) SV_SavedGame();
#endif
@ -3732,7 +3732,7 @@ static void HandleConnect(SINT8 node)
static void HandleShutdown(SINT8 node)
{
(void)node;
LUAh_GameQuit(false);
LUA_HookBool(false, Hook(GameQuit));
D_QuitNetGame();
CL_Reset();
D_StartTitle();
@ -3747,7 +3747,7 @@ static void HandleShutdown(SINT8 node)
static void HandleTimeout(SINT8 node)
{
(void)node;
LUAh_GameQuit(false);
LUA_HookBool(false, Hook(GameQuit));
D_QuitNetGame();
CL_Reset();
D_StartTitle();

View file

@ -3612,7 +3612,7 @@ static void Command_Playintro_f(void)
*/
FUNCNORETURN static ATTRNORETURN void Command_Quit_f(void)
{
LUAh_GameQuit(true);
LUA_HookBool(true, Hook(GameQuit));
I_Quit();
}
@ -4274,7 +4274,7 @@ void Command_ExitGame_f(void)
{
INT32 i;
LUAh_GameQuit(false);
LUA_HookBool(false, Hook(GameQuit));
D_QuitNetGame();
CL_Reset();

View file

@ -84,6 +84,7 @@ void LUA_Hook(int hook);
int LUA_HookMobj(mobj_t *, int hook);
int LUA_Hook2Mobj(mobj_t *, mobj_t *, int hook);
void LUA_HookInt(INT32 integer, int hook);
void LUA_HookBool(boolean value, int hook);
int LUA_HookPlayer(player_t *, int hook);
int LUA_HookTiccmd(player_t *, ticcmd_t *, int hook);

View file

@ -561,6 +561,16 @@ void LUA_HookInt(INT32 number, int hook_type)
}
}
void LUA_HookBool(boolean value, int hook_type)
{
Hook_State hook;
if (prepare_hook(&hook, 0, hook_type))
{
lua_pushboolean(gL, value);
call_hooks(&hook, 1, 0, res_none);
}
}
int LUA_HookPlayer(player_t *player, int hook_type)
{
Hook_State hook;

View file

@ -6937,7 +6937,7 @@ static void M_SelectableClearMenus(INT32 choice)
static void M_UltimateCheat(INT32 choice)
{
(void)choice;
LUAh_GameQuit(true);
LUA_HookBool(true, Hook(GameQuit));
I_Quit();
}
@ -13371,7 +13371,7 @@ void M_QuitResponse(INT32 ch)
if (ch != 'y' && ch != KEY_ENTER)
return;
LUAh_GameQuit(true);
LUA_HookBool(true, Hook(GameQuit));
if (!(netgame || cv_debug))
{
S_ResetCaptions();

View file

@ -1057,7 +1057,7 @@ void I_GetEvent(void)
M_SetupJoystickMenu(0);
break;
case SDL_QUIT:
LUAh_GameQuit(true);
LUA_HookBool(true, Hook(GameQuit));
I_Quit();
break;
}