From 47a43d054425d91e06a543794ae4b80e6e0a96d2 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Tue, 12 Aug 2025 14:50:43 +0200 Subject: [PATCH 1/3] Fix loops so that they work in all directions --- src/objects/loops.cpp | 85 +++---------------------------------------- src/p_loop.c | 14 +++---- 2 files changed, 11 insertions(+), 88 deletions(-) diff --git a/src/objects/loops.cpp b/src/objects/loops.cpp index ddb401891..cb512d396 100644 --- a/src/objects/loops.cpp +++ b/src/objects/loops.cpp @@ -151,81 +151,6 @@ get_binary_direction } } -static std::optional -intersect -( const mobj_t * anchor, - const mobj_t * toucher) -{ - struct Line - { - angle_t a; - vector2_t o; - - angle_t k = AbsAngle(a); - - Line(vector2_t o_, angle_t a_) : a(a_), o(o_) {} - - bool vertical() const { return k == ANGLE_90; } - - fixed_t m() const - { - // tangent table is offset 90 degrees - return FTAN(a - ANGLE_90); - } - - fixed_t b() const - { - return o.y - FixedMul(o.x, m()); - } - - fixed_t y(fixed_t x) const - { - return FixedMul(m(), x) + b(); - } - }; - - if (toucher->momx == 0 && toucher->momy == 0) - { - // undefined angle - return {}; - } - - Line a({toucher->x, toucher->y}, - R_PointToAngle2(0, 0, toucher->momx, toucher->momy)); - - Line b({anchor->x, anchor->y}, anchor->angle + ANGLE_90); - - if (a.k == b.k) - { - // parallel lines do not intersect - return {}; - } - - vector2_t v; - - auto v_intersect = [&v](Line &a, Line &b) - { - if (a.vertical()) - { - return false; - } - - v.x = b.o.x; - v.y = a.y(v.x); - - return true; - }; - - if (!v_intersect(a, b) && !v_intersect(b, a)) - { - // untested! - v.x = FixedDiv(a.b() - b.b(), b.m() - a.m()); - v.y = a.y(v.x); - } - - return v; -} - mobj_t * Obj_FindLoopCenter (const mtag_t tag) { @@ -330,10 +255,12 @@ Obj_LoopEndpointCollide { set_shiftxy(player, anchor); - vector2_t i = intersect(anchor, toucher) - .value_or(vector2_t {px, py}); - - s->origin_shift = {i.x - px, i.y - py}; + const fixed_t magnitude = R_PointToDist2(0, 0, px, py); + const fixed_t newX = FixedDiv(px, magnitude); + const fixed_t newY = FixedDiv(py, magnitude); + + s->origin_shift = {FixedMul(newX, FCOS(anchor->angle)), + FixedMul(newY, FSIN(anchor->angle))}; } flip = get_binary_direction(pitch, toucher); diff --git a/src/p_loop.c b/src/p_loop.c index 9ddf22f7b..93ef4c060 100644 --- a/src/p_loop.c +++ b/src/p_loop.c @@ -101,7 +101,7 @@ boolean P_PlayerOrbit(player_t *player) fixed_t r, xy, z; fixed_t xs, ys; - fixed_t step, th, left; + fixed_t step, left; fixed_t grav; @@ -136,16 +136,12 @@ boolean P_PlayerOrbit(player_t *player) // XY shift is transformed on wave scale; less movement // at start and end of rotation, more halfway. - th = FSIN(pitch_normal - ANGLE_90); - - xs = FixedMul(s->shift.x, th); - ys = FixedMul(s->shift.y, th); + xs = FixedMul(s->shift.x, FCOS(pitch_normal)); + ys = FixedMul(s->shift.y, FSIN(pitch_normal - ANGLE_90)); // Interpolate 0-1 over entire rotation. - th = FSIN(pitch_normal / 2); - - xs += FixedMul(s->origin_shift.x, th); - ys += FixedMul(s->origin_shift.y, th); + xs += FixedMul(s->origin_shift.x, FCOS(pitch_normal)); + ys += FixedMul(s->origin_shift.y, FSIN(pitch_normal - ANGLE_90)); xs += FixedMul(xy, FCOS(s->yaw)); ys += FixedMul(xy, FSIN(s->yaw)); From ac7249fc54402f684187c4f041477b7f555baf9a Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 13 Aug 2025 10:14:09 +0100 Subject: [PATCH 2/3] Fix direct skin assignment in netsave + Heavy Magician Was not caught by compiler because these are void pointers :face_holding_back_tears: --- src/r_skins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_skins.c b/src/r_skins.c index fb16314d3..2e8cd5aa9 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -518,7 +518,7 @@ void SetFakePlayerSkin(player_t* player, INT32 skinid) player->charflags = skins[skinid]->flags; } - player->mo->skin = &skins[skinid]; + player->mo->skin = skins[skinid]; } // Loudly rerandomize From c4464fa87c4bec84a7332a838664034b12f746f3 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Fri, 15 Aug 2025 19:54:46 +0200 Subject: [PATCH 3/3] =?UTF-8?q?Lua:=20Hook=20PlayerMsg=20to=20code,=20remo?= =?UTF-8?q?ve=20vestigial=20mute=20variable=20from=20it=C2=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hu_stuff.c | 3 +++ src/lua_hook.h | 2 +- src/lua_hooklib.c | 3 +-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index a62058d53..60fa08249 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -705,6 +705,9 @@ static void Got_Saycmd(const UINT8 **p, INT32 playernum) } } } + + if (LUA_HookPlayerMsg(playernum, target, flags, msg)) + return; // If it's a CSAY, just CECHO and be done with it. if (flags & HU_CSAY) diff --git a/src/lua_hook.h b/src/lua_hook.h index 24e2ebf25..13d19447d 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -137,7 +137,7 @@ int LUA_HookMobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 int LUA_HookMobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damagetype); int LUA_HookMobjMoveBlocked(mobj_t *, mobj_t *, line_t *); void LUA_HookSpecialExecute(activator_t *activator, INT32 *args, char **stringargs); -int LUA_HookPlayerMsg(int source, int target, int flags, char *msg, int mute); +int LUA_HookPlayerMsg(int source, int target, int flags, char *msg); int LUA_HookHurtMsg(player_t *, mobj_t *inflictor, mobj_t *source, UINT8 damagetype); int LUA_HookMapThingSpawn(mobj_t *, mapthing_t *); int LUA_HookFollowMobj(player_t *, mobj_t *); diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index ad6254a7b..0bdb83bdb 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -842,7 +842,7 @@ void LUA_HookSpecialExecute(activator_t *activator, INT32 *args, char **stringar } } -int LUA_HookPlayerMsg(int source, int target, int flags, char *msg, int mute) +int LUA_HookPlayerMsg(int source, int target, int flags, char *msg) { Hook_State hook; if (prepare_hook(&hook, false, HOOK(PlayerMsg))) @@ -862,7 +862,6 @@ int LUA_HookPlayerMsg(int source, int target, int flags, char *msg, int mute) LUA_PushUserdata(gL, &players[target-1], META_PLAYER); // target } lua_pushstring(gL, msg); // msg - lua_pushboolean(gL, mute); // the message was supposed to be eaten by spamprotecc. call_hooks(&hook, 1, res_true); }