mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-29 20:50:58 +00:00
Created GameQuit hook, but I need to decide where to execute it
This commit is contained in:
parent
ddc0762ecc
commit
bb08b55b43
2 changed files with 26 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue