From 123b2aa60b1af6f20a15506cb49aceecd61de171 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 11 Nov 2023 02:27:06 -0800 Subject: [PATCH] lua_hooklib.c: refactor HUD hook call --- src/lua_hooklib.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 54c39d560..97b86e1bf 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -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;