lua_hooklib.c: refactor HUD hook call

This commit is contained in:
James R authored and Alug committed 2025-08-01 21:04:30 +02:00
1 parent bd82a8db29
commit 123b2aa60b
1 file changed
+12 -6
+12 -6
View File
@@ -393,6 +393,16 @@ FUNCINLINE static ATTRINLINE boolean prepare_string_hook
return false;
}
static boolean prepare_hud_hook
(
Hook_State * hook,
int hook_type
){
return init_hook_type(hook, 0,
hook_type, 0, NULL,
hudHookIds[hook_type].numHooks);
}
FUNCINLINE static ATTRINLINE void init_hook_call
(
Hook_State * hook,
@@ -663,20 +673,16 @@ int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type)
void LUA_HookHUD(int hook_type, huddrawlist_h list)
{
const hook_t * map = &hudHookIds[hook_type];
Hook_State hook;
if (map->numHooks > 0)
if (prepare_hud_hook(&hook, hook_type))
{
start_hook_stack();
begin_hook_values(&hook);
LUA_SetHudHook(hook_type, list);
hud_running = true; // local hook
hud_interpcounter = 0;
hud_interpolate = hud_interpstring = hud_interplatch = false;
init_hook_call(&hook, 1, res_hud);
call_mapped(&hook, map);
call_mapped(&hook, &hudHookIds[hook_type]);
lua_settop(gL, 0); // destroy le stack!! >:3
hud_running = false;