From 947fa0ca5c153af9ee8932be76a0938166591be5 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Fri, 13 Sep 2024 18:40:17 +0200 Subject: [PATCH] Deprecate performance-sensitive type-agnostic mobj hooks --- src/lua_hooklib.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 54381e4ae..14781986e 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -498,6 +498,22 @@ static int call_string_hooks(Hook_State *hook) static int call_mobj_type_hooks(Hook_State *hook, mobjtype_t mobj_type) { + if (mobj_type == MT_NULL && ( + hook->hook_type == MOBJ_HOOK(MobjThinker ) + || hook->hook_type == MOBJ_HOOK(MobjCollide ) + || hook->hook_type == MOBJ_HOOK(MobjLineCollide) + || hook->hook_type == MOBJ_HOOK(MobjMoveCollide) + || hook->hook_type == MOBJ_HOOK(MobjFuse ) + || hook->hook_type == MOBJ_HOOK(MobjThinker ) + || hook->hook_type == MOBJ_HOOK(BossThinker ) + || hook->hook_type == MOBJ_HOOK(MobjMoveBlocked) + || hook->hook_type == MOBJ_HOOK(FollowMobj ) + )) + LUA_UsageWarning(L, va( + "%s hooks not attached to a specific mobj type are deprecated and will be removed.", + mobjHookNames[hook->hook_type]) + ); + return call_mapped(hook, &mobjHookIds[mobj_type][hook->hook_type]); } @@ -751,7 +767,7 @@ static void hook_think_frame(int type) PS_SetThinkFrameHookInfo(hook_index, time_taken, ar.short_src); else if (type == 6) PS_SetPostThinkFrameHookInfo(hook_index, time_taken, ar.short_src); - + hook_index++; } }