Moved LUAh_GameQuit(void) function to the end of the lua_hooklib.c

This commit is contained in:
Zachary McAlpin 2020-03-24 22:55:25 -05:00
parent 21353f1209
commit decce7905b

View file

@ -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;
}
}
}