fix P_RemoveSavegameMobj triggering assert in P_UnlinkThinker

This commit is contained in:
Alug committed 2025-04-23 13:45:47 +02:00
1 parent 4c15826848
commit bb26a33889
1 file changed
+8 -2
+8 -2
View File
@@ -10367,8 +10367,10 @@ void P_FreePrecipMobj(precipmobj_t *mobj)
// Clearing out stuff for savegames
void P_RemoveSavegameMobj(mobj_t *mobj)
{
thinker_t *th = (thinker_t*)mobj;
// unlink from sector and block lists
if (((thinker_t *)mobj)->function.acp1 == (actionf_p1)P_NullPrecipThinker)
if (th->function.acp1 == (actionf_p1)P_NullPrecipThinker)
{
P_UnsetPrecipThingPosition((precipmobj_t *)mobj);
}
@@ -10389,9 +10391,13 @@ void P_RemoveSavegameMobj(mobj_t *mobj)
S_StopSound(mobj);
R_RemoveMobjInterpolator(mobj);
// just set its reference count to 0 to not trigger the assert in P_UnlinkThinker
if (th->references != 0)
th->references = 0;
// free block
// Here we use the same code as R_RemoveThinkerDelayed, but without reference counting (we're removing everything so it shouldn't matter) and without touching currentthinker since we aren't in P_RunThinkers
P_UnlinkThinker((thinker_t*)mobj);
P_UnlinkThinker(th);
}
static CV_PossibleValue_t respawnitemtime_cons_t[] = {{1, "MIN"}, {300, "MAX"}, {0, NULL}};