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): sell a multi-building selection without freed nodes
Olcay Seygan8349b63b0470
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d22df4589..1cf6e0a38 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1249,6 +1249,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same## It does not crash- Starting a match with the Direct3D 11 picture on took the game down. Both devices were presenting into the same window, the old one lost itself, and the fog texture then locked a surface that was never made.+- Selling with more than one building selected no longer takes the game down. Each building that goes up for sale is taken out of the selection, and that rebuilt the group the sell order was still working through, so the second building was read from memory that had already been handed back. A player lost a match an hour in this way.- A machine whose graphics stack faults while the Direct3D 11 picture is being set up starts the game anyway, on the Direct3D 9 picture. A player's report showed the fault happening inside Windows' own graphics library, before the game got an answer back, and it ended in "Uncaught Exception during initialization". An overlay hooking the graphics calls or a stray dxgi.dll in the game folder is the usual cause. Until now the only way past it was typing -d3d9.- A campaign mission could crash on its very first frame with the Direct3D 11 picture on, if the screen had been reset before it by an alt-tab or a change on the display options page. The reset threw some textures away, the new picture kept drawing with them, and the first water reflection of the next map read freed memory. A reset now clears every texture from the new picture as well as the old one.- The opening movies froze on their first frame with that picture on. A movie writes a new image every frame into a texture the copy had already taken.diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cppindex 16ff26a40..c68f4eee0 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp@@ -3667,18 +3667,15 @@ static Bool mayPlayerSell( const Object *obj )*/void AIGroup::groupSell( CommandSourceType cmdSource ){- std::list<Object *>::iterator i, thisIterator;- Object *obj;-- for( i = m_memberList.begin(); i != m_memberList.end(); /*empty*/ )+ // sellObject deselects what it sells, and deselecting rebuilds the player's selection as a new+ // group: every other member leaves this one, which deletes itself once it is empty. Walking+ // m_memberList through that read freed list nodes on the second building of a selection.+ const VecObjectID members = getAllIDs();+ for( VecObjectID::const_iterator i = members.begin(); i != members.end(); ++i ){-- // work off of 'thisIterator' as we may change the contents of this list- thisIterator = i;- ++i;-- // get object- obj = *thisIterator;+ Object *obj = TheGameLogic->findObjectByID( *i );+ if( obj == NULL )+ continue;if( cmdSource == CMD_FROM_PLAYER && !mayPlayerSell( obj ) )continue;@@ -3794,15 +3791,15 @@ void AIGroup::groupCombatDrop( Object *target, const Coord3D &pos, CommandSource//-------------------------------------------------------------------------------------void AIGroup::groupDoCommandButton( const CommandButton *commandButton, CommandSourceType cmdSource ){- std::list<Object *>::iterator i;- Object *source;-- for( i = m_memberList.begin(); i != m_memberList.end(); ++i )+ // A sell button sells through BuildAssistant::sellObject, which empties and deletes this group+ // the way groupSell explains, so the members are taken down first.+ const VecObjectID members = getAllIDs();+ for( VecObjectID::const_iterator i = members.begin(); i != members.end(); ++i ){+ Object *source = TheGameLogic->findObjectByID( *i );+ if( source == NULL )+ continue;- // get object- source = *i;-source->doCommandButton( commandButton, cmdSource );} // end for, i}