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.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(gameengine): reset the world before shutting the subsystems down
Olcay Seyganb2d7b01d762e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 50655ad95..b897abe5b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -285,8 +285,13 @@ looks right to you.were handing back registers they had quietly destroyed. On a 2003 compiler it happened to beharmless. On a modern one it took the whole game down — and the crash pointed at a completelyinnocent part of the engine.-- **It crashed every single time you quit.** Quitting is now instant, instead of hanging for three- seconds and then faulting twice on the way out.+- **It crashed every single time you quit** — and it took two goes to kill. The first cause was+ fixed, the freeze stayed, and the reason turned out to be older and further down: on the way out+ the game throws away the list of players before it throws away their armies, so every unit still+ standing was handed back to a commander who no longer existed. It faulted twice on every exit,+ and each fault stopped to write itself up out of an eighty-megabyte symbol file. That is the+ several seconds you sat looking at a frozen window. Quitting takes about half a second now, from+ the main menu or out of a live match, and the log it leaves behind is clean.- **A long chat message or an unusual map name could kill the process outright.**- The window used to go grey and *Not Responding* during the scripted camera moves on the menu.- Half a dozen rarer crashes in combat — poison clouds, mine clearing, killing a garrisoned building,diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cppindex df09a3d05..0420835d6 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp@@ -207,6 +207,16 @@ GameEngine::~GameEngine()TheGameResultsQueue->endThreads();+ // Tear the game world down while every subsystem can still see every other one.+ // shutdownAll deletes in reverse registration order, which kills ThePlayerList and+ // TheRadar before TheTeamFactory and TheGameLogic - and Player::~Player NULLs the+ // owning player of each team prototype on its way out, so TeamFactory's own teardown+ // then walked dead pointers and faulted twice on every exit. Each fault cost a full+ // dbghelp symbolization of an 80MB pdb: that was the several-second stall on quit.+ // resetAll() is the same call made between games, and PlayerList::reset() clears the+ // teams before the players, so afterwards shutdownAll has an empty world to free.+ TheSubsystemList->resetAll();+TheSubsystemList->shutdownAll();delete TheSubsystemList;TheSubsystemList = NULL;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cppindex 5f51848c4..1361aedcf 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp@@ -834,7 +834,7 @@ void Object::setTeam( Team *team ){// In order to prevent spawning useful units for a player after he dies, we// just assign objects to the neutral player if we try to misbehave.- if (team && !team->getControllingPlayer()->isPlayerActive())+ if (team && team->getControllingPlayer() && !team->getControllingPlayer()->isPlayerActive())team = ThePlayerList->getNeutralPlayer()->getDefaultTeam();setTemporaryTeam(team);@@ -865,7 +865,8 @@ void Object::setOrRestoreTeam( Team* team, Bool restoring )if (m_team->isInList_TeamMemberList(this)){m_team->removeFrom_TeamMemberList(this);- m_team->getControllingPlayer()->becomingTeamMember(this, false);+ if (m_team->getControllingPlayer())+ m_team->getControllingPlayer()->becomingTeamMember(this, false);}}@@ -878,7 +879,8 @@ void Object::setOrRestoreTeam( Team* team, Bool restoring )if (!m_team->isInList_TeamMemberList(this)){m_team->prependTo_TeamMemberList(this);- m_team->getControllingPlayer()->becomingTeamMember(this, true);+ if (m_team->getControllingPlayer())+ m_team->getControllingPlayer()->becomingTeamMember(this, true);}// now, adjust the attitude of the unit to its new team.@@ -923,8 +925,8 @@ void Object::setOrRestoreTeam( Team* team, Bool restoring )}// Tell TheInGameUI that the object has changed hands- Int oldPlayerIndex = (oldTeam)?(oldTeam->getControllingPlayer()->getPlayerIndex()):-1;- Int newPlayerIndex = (m_team)?(m_team->getControllingPlayer()->getPlayerIndex()):-1;+ Int oldPlayerIndex = (oldTeam && oldTeam->getControllingPlayer())?(oldTeam->getControllingPlayer()->getPlayerIndex()):-1;+ Int newPlayerIndex = (m_team && m_team->getControllingPlayer())?(m_team->getControllingPlayer()->getPlayerIndex()):-1;if (oldPlayerIndex != newPlayerIndex)TheInGameUI->objectChangedTeam(this, oldPlayerIndex, newPlayerIndex);}