From cb619fad5d762ba8d8dd20e9a979a04ced7c943f Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Wed, 7 Jul 2021 19:57:28 -0500 Subject: [PATCH] Rebase on !1307 --- src/lua_hook.h | 1 + src/lua_hooklib.c | 13 +++++++++++++ src/p_mobj.c | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/lua_hook.h b/src/lua_hook.h index 223b83c61..1af28aac5 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -115,6 +115,7 @@ int LUA_HookTouchSpecial(mobj_t *special, mobj_t *toucher); int LUA_HookShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype); int LUA_HookMobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype); int LUA_HookMobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damagetype); +int LUA_HookMobjMoveBlocked(mobj_t *, mobj_t *, line_t *); int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd); void LUA_HookLinedefExecute(line_t *, mobj_t *, sector_t *); int LUA_HookPlayerMsg(int source, int target, int flags, char *msg); diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index d1b0d3bdd..f2e9b5233 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -713,6 +713,19 @@ int LUA_HookMobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 d MOBJ_HOOK(MobjDeath), 4, res_true); } +int LUA_HookMobjMoveBlocked(mobj_t *t1, mobj_t *t2, line_t *line) +{ + Hook_State hook; + if (prepare_mobj_hook(&hook, 0, MOBJ_HOOK(MobjMoveBlocked), t1->type)) + { + LUA_PushUserdata(gL, t1, META_MOBJ); + LUA_PushUserdata(gL, t2, META_MOBJ); + LUA_PushUserdata(gL, line, META_LINE); + call_hooks(&hook, 3, 1, res_true); + } + return hook.status; +} + typedef struct { mobj_t * tails; ticcmd_t * cmd; diff --git a/src/p_mobj.c b/src/p_mobj.c index 10220fff6..f2fae6cc6 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1844,7 +1844,7 @@ void P_XYMovement(mobj_t *mo) B_MoveBlocked(player); } - if (LUA_HookMobj(mo, MOBJ_HOOK(MobjMoveBlocked))) + if (LUA_HookMobjMoveBlocked(mo, tmhitthing, blockingline)) { if (P_MobjWasRemoved(mo)) return;