diff --git a/src/p_mobj.c b/src/p_mobj.c index a7a8f9c09..00fb09ca8 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -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}};