From 6c0306a501195b5a298c9a1512b0aaca7e331ac4 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 29 Feb 2024 03:36:04 -0800 Subject: [PATCH] Polyobjects: add po_movecount member to mobj_t instead of using lastlook - Polyobject carrying set lastlook on mobjs for internal tracking - lastlook is used by some objects to track their own state - Ring Shooter uses lastlook to remember which player summoned it - A Ring Shooter spawned right next to a polyobject would become buggy; If its owner player pressed the respawn button again before the Ring Shooter despawned, that player would be teleported back to the Ring Shooter instead of spawning a new Ring Shooter (which would be the correct behavior) Nep: We don't have a ring shooter but this would still be a useful fix --- src/p_mobj.h | 2 ++ src/p_polyobj.c | 16 ++++------------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/p_mobj.h b/src/p_mobj.h index 01bab7ad1..371cbe1db 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -448,6 +448,8 @@ struct mobj_t INT32 script_args[NUM_SCRIPT_ARGS]; char *script_stringargs[NUM_SCRIPT_STRINGARGS]; + INT32 po_movecount; // Polyobject carrying (NOT savegame, NOT Lua) + // WARNING: New fields must be added separately to savegame and Lua. }; diff --git a/src/p_polyobj.c b/src/p_polyobj.c index bf6638708..3b3bdc192 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -882,14 +882,10 @@ static void Polyobj_carryThings(polyobj_t *po, fixed_t dx, fixed_t dy) for (; mo; mo = mo->bnext) { - // lastlook is used by the SPB to determine targets, do not let it affect it - if (mo->type == MT_SPB) + if (mo->po_movecount == pomovecount) continue; - if (mo->lastlook == pomovecount) - continue; - - mo->lastlook = pomovecount; + mo->po_movecount = pomovecount; // Don't scroll objects that aren't affected by gravity if (mo->flags & MF_NOGRAVITY) @@ -1118,14 +1114,10 @@ static void Polyobj_rotateThings(polyobj_t *po, vector2_t origin, angle_t delta, for (; mo; mo = mo->bnext) { - // lastlook is used by the SPB to determine targets, do not let it affect it - if (mo->type == MT_SPB) + if (mo->po_movecount == pomovecount) continue; - if (mo->lastlook == pomovecount) - continue; - - mo->lastlook = pomovecount; + mo->po_movecount = pomovecount; // Don't scroll objects that aren't affected by gravity if (mo->flags & MF_NOGRAVITY)