diff --git a/src/mechanics.cpp b/src/mechanics.cpp index 79c76f65f50..d56dae5777b 100644 --- a/src/mechanics.cpp +++ b/src/mechanics.cpp @@ -39,7 +39,7 @@ bool mechanicsShutdown() { for (BASE_OBJECT* psObj : psDestroyedObj) { - objmemDestroy(psObj); + objmemDestroy(psObj, true); } psDestroyedObj.clear(); diff --git a/src/objmem.cpp b/src/objmem.cpp index e491183efbd..12c3457fbf3 100644 --- a/src/objmem.cpp +++ b/src/objmem.cpp @@ -203,7 +203,7 @@ static bool checkReferences(BASE_OBJECT *psVictim) /* Remove an object from the destroyed list, finally freeing its memory * Hopefully by this time, no pointers still refer to it! */ -bool objmemDestroy(BASE_OBJECT *psObj) +bool objmemDestroy(BASE_OBJECT *psObj, bool checkRefs) { switch (psObj->type) { @@ -222,7 +222,7 @@ bool objmemDestroy(BASE_OBJECT *psObj) default: ASSERT(!"unknown object type", "unknown object type in destroyed list at 0x%p", static_cast(psObj)); } - if (!checkReferences(psObj)) + if (checkRefs && !checkReferences(psObj)) { return false; } @@ -259,7 +259,7 @@ void objmemUpdate() { if ((*it)->died <= gameTime - deltaGameTime) { - objmemDestroy(*it); + objmemDestroy(*it, true); it = psDestroyedObj.erase(it); } else diff --git a/src/objmem.h b/src/objmem.h index 924dec133d4..9946c857079 100644 --- a/src/objmem.h +++ b/src/objmem.h @@ -76,7 +76,7 @@ void objmemUpdate(); /* Remove an object from the destroyed list, finally freeing its memory * Hopefully by this time, no pointers still refer to it! */ -bool objmemDestroy(BASE_OBJECT* psObj); +bool objmemDestroy(BASE_OBJECT* psObj, bool checkRefs); /// Generates a new, (hopefully) unique object id. uint32_t generateNewObjectId();