P_RemoveMobj: only repair hnext linked list is object is a part of the list

This indirectly fixes a bug with Rocket Sneakers:

- Give yourself Rocket Sneakers, use them up completely.
- Instantly give yourself and deploy Orbinauts (may want
  to use a bind for this, since it has to be quick).
- Wait a moment for the exploded Rocket Sneakers to fall
  to the ground. When this happens, the Orbinauts will
  stop following the player -- they will enter a buggy
  state.

So many items uses hnext/hprev, that I decided to make
a general fix that probably covers most bugs that could
arise from poor handling of hnext/hprev.
This commit is contained in:
James R. 2023-09-14 02:47:55 -07:00
parent c8cf6a4621
commit a392996a54

View file

@ -11331,13 +11331,21 @@ void P_RemoveMobj(mobj_t *mobj)
if (mobj->hnext && !P_MobjWasRemoved(mobj->hnext))
{
P_SetTarget(&mobj->hnext->hprev, mobj->hprev);
if (mobj->hnext->hprev == mobj)
{
P_SetTarget(&mobj->hnext->hprev, mobj->hprev);
}
P_SetTarget(&mobj->hnext, NULL);
}
if (mobj->hprev && !P_MobjWasRemoved(mobj->hprev))
{
P_SetTarget(&mobj->hprev->hnext, cachenext);
if (mobj->hprev->hnext == mobj)
{
P_SetTarget(&mobj->hprev->hnext, cachenext);
}
P_SetTarget(&mobj->hprev, NULL);
}
}