From a392996a5437742d5b7a91d0fce9da49c3a8bd76 Mon Sep 17 00:00:00 2001 From: "James R." Date: Thu, 14 Sep 2023 02:47:55 -0700 Subject: [PATCH] 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. --- src/p_mobj.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index dad3be9d8..4e18de08f 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -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); } }