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
This commit is contained in:
James R 2024-02-29 03:36:04 -08:00 committed by NepDisk
parent 0ef5f82b60
commit 6c0306a501
2 changed files with 6 additions and 12 deletions

View file

@ -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.
};

View file

@ -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)