Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(gamelogic): break out of the message switch so the AIGroup is destroyed

Olcay Seygan0221a77bb55e
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp
index 679e4b479..cd95cc3ec 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp
@@ -264,6 +264,7 @@ Bool AIGroup::removeAnyObjectsNotOwnedByPlayer( const Player *ownerPlayer )
for (it = m_memberList.begin(); it != m_memberList.end(); /* empty */) {
Object *obj = (*it);
if (!obj) {
+ ++it; // the increment is in the body of this loop, so skipping it spins forever
continue;
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp
index b55790b4b..6e89272c4 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp
@@ -1573,7 +1573,7 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
// get the unit production interface
ProductionUpdateInterface *pu = producer->getProductionUpdateInterface();
if( pu == NULL )
- return;
+ break; // break, not return: the tail of this function destroys currentlySelectedGroup
// cancel the production
pu->cancelUnitCreate( productionID );