Skip to content

Commit 228f7fe

Browse files
authored
[GEN][ZH] Prevent executing death modules and spawning new objects to avoid asserts and crashes when unloading a map and destroying all objects (#898)
1 parent 27a5005 commit 228f7fe

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

Generals/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,18 @@ Bool GameLogic::isInSinglePlayerGame( void )
293293
//-------------------------------------------------------------------------------------------------
294294
void GameLogic::destroyAllObjectsImmediate()
295295
{
296-
// destroy all remaining objects
297296
Object *obj;
298297
Object *nextObj;
298+
299+
// TheSuperHackers @bugfix xezon 22/05/2025 Set all remaining objects effectively dead to avoid triggering their
300+
// death modules that eventually would spawn new objects, such as debris, which could then crash the game.
301+
// See https://github.com/TheSuperHackers/GeneralsGameCode/issues/896
302+
for( obj = m_objList; obj; obj = obj->getNextObject() )
303+
{
304+
obj->setEffectivelyDead(true);
305+
}
306+
307+
// destroy all remaining objects
299308
for( obj = m_objList; obj; obj = nextObj )
300309
{
301310
nextObj = obj->getNextObject();

GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,18 @@ Bool GameLogic::isInSinglePlayerGame( void )
308308
//-------------------------------------------------------------------------------------------------
309309
void GameLogic::destroyAllObjectsImmediate()
310310
{
311-
// destroy all remaining objects
312311
Object *obj;
313312
Object *nextObj;
313+
314+
// TheSuperHackers @bugfix xezon 22/05/2025 Set all remaining objects effectively dead to avoid triggering their
315+
// death modules that eventually would spawn new objects, such as debris, which could then crash the game.
316+
// See https://github.com/TheSuperHackers/GeneralsGameCode/issues/896
317+
for( obj = m_objList; obj; obj = obj->getNextObject() )
318+
{
319+
obj->setEffectivelyDead(true);
320+
}
321+
322+
// destroy all remaining objects
314323
for( obj = m_objList; obj; obj = nextObj )
315324
{
316325
nextObj = obj->getNextObject();

0 commit comments

Comments
 (0)