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)
This commit is contained in:
James R 2024-02-29 03:36:04 -08:00
parent 4ccb9b22c8
commit 3402c3af64
2 changed files with 6 additions and 12 deletions

View file

@ -447,6 +447,8 @@ struct mobj_t
mobj_t *owner; mobj_t *owner;
INT32 po_movecount; // Polyobject carrying (NOT savegame, NOT Lua)
// WARNING: New fields must be added separately to savegame and Lua. // WARNING: New fields must be added separately to savegame and Lua.
}; };

View file

@ -879,14 +879,10 @@ static void Polyobj_carryThings(polyobj_t *po, fixed_t dx, fixed_t dy)
for (; mo; mo = mo->bnext) for (; mo; mo = mo->bnext)
{ {
// lastlook is used by the SPB to determine targets, do not let it affect it if (mo->po_movecount == pomovecount)
if (mo->type == MT_SPB)
continue; continue;
if (mo->lastlook == pomovecount) mo->po_movecount = pomovecount;
continue;
mo->lastlook = pomovecount;
// Don't scroll objects that aren't affected by gravity // Don't scroll objects that aren't affected by gravity
if (mo->flags & MF_NOGRAVITY) if (mo->flags & MF_NOGRAVITY)
@ -1115,14 +1111,10 @@ static void Polyobj_rotateThings(polyobj_t *po, vector2_t origin, angle_t delta,
for (; mo; mo = mo->bnext) for (; mo; mo = mo->bnext)
{ {
// lastlook is used by the SPB to determine targets, do not let it affect it if (mo->po_movecount == pomovecount)
if (mo->type == MT_SPB)
continue; continue;
if (mo->lastlook == pomovecount) mo->po_movecount = pomovecount;
continue;
mo->lastlook = pomovecount;
// Don't scroll objects that aren't affected by gravity // Don't scroll objects that aren't affected by gravity
if (mo->flags & MF_NOGRAVITY) if (mo->flags & MF_NOGRAVITY)