New intermission thinker hook

This commit is contained in:
Steel Titanium 2019-10-13 20:50:46 -04:00
parent bf75a4c29f
commit 0f79396757
No known key found for this signature in database
GPG Key ID: 924BA411F18DFDBE
3 changed files with 29 additions and 0 deletions

View File

@ -50,6 +50,7 @@ enum hook {
hook_FollowMobj,
hook_PlayerCanDamage,
hook_PlayerQuit,
hook_IntermissionThinker,
hook_MAX // last hook
};
@ -91,5 +92,6 @@ boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing); // Hook for P_SpawnM
boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj); // Hook for P_PlayerAfterThink Smiles mobj-following
UINT8 LUAh_PlayerCanDamage(player_t *player, mobj_t *mobj); // Hook for P_PlayerCanDamage
void LUAh_PlayerQuit(player_t *plr, int reason); // Hook for player quitting
void LUAh_IntermissionThinker(void); // Hook for Y_Ticker
#endif

View File

@ -61,6 +61,7 @@ const char *const hookNames[hook_MAX+1] = {
"FollowMobj",
"PlayerCanDamage",
"PlayerQuit",
"IntermissionThinker",
NULL
};
@ -1322,4 +1323,25 @@ void LUAh_PlayerQuit(player_t *plr, int reason)
lua_settop(gL, 0);
}
// Hook for Y_Ticker
void LUAh_IntermissionThinker(void)
{
hook_p hookp;
if (!gL || !(hooksAvailable[hook_IntermissionThinker/8] & (1<<(hook_IntermissionThinker%8))))
return;
for (hookp = roothook; hookp; hookp = hookp->next)
if (hookp->type == hook_IntermissionThinker)
{
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

View File

@ -35,6 +35,7 @@
#include "p_local.h"
#include "m_cond.h" // condition sets
#include "lua_hook.h" // IntermissionThinker hook
#ifdef HWRENDER
#include "hardware/hw_main.h"
@ -802,6 +803,10 @@ void Y_Ticker(void)
if (paused || P_AutoPause())
return;
#ifdef HAVE_BLUA
LUAh_IntermissionThinker();
#endif
intertic++;
// Team scramble code for team match and CTF.