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): keep troop crawler squads out until the fight is over
Olcay Seygan58a12b2fa83d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4076f46ca..b00aa9c4b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1,4 +1,4 @@-# Zero Hour, rebuilt+# Command and Conquer: Generals: Zero Hour: RebornEA released the 2003 source for preservation. It did not compile, did not run, and nobody had touchedthe bugs inside it in twenty-two years. This build compiles, runs and plays.@@ -37,6 +37,7 @@ found and fixed — EA's own, not port damage.**- A unit turns onto whatever is actually shooting it, then resumes the advance.- Ctrl on the attack-move click no longer shells the ground instead.- Troop Crawlers wait for their squad to climb back in, up to ten seconds.+- Their squad stays out until the area is clear, instead of piling back in after every kill.- Attack-move state is saved now, instead of coming back as random memory.## Your units stop shooting corpsesdiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/AssaultTransportAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/AssaultTransportAIUpdate.cppindex 10590c884..65743a113 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/AssaultTransportAIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/AssaultTransportAIUpdate.cpp@@ -342,34 +342,36 @@ UpdateSleepTime AssaultTransportAIUpdate::update( void )}else{- if( m_isAttackMove )+ //The target we deployed for is gone. Find out whether the troops we let out still have+ //something to do - the same rule for both orders, so they no longer climb back in and+ //straight back out once per dead enemy.+ Bool membersOutside = FALSE;+ Bool membersFighting = FALSE;+ for( int i = 0; i < m_currentMembers; i++ ){- //The target we deployed for is gone. Find out whether the troops we let out still have- //something to do.- Bool membersOutside = FALSE;- Bool membersFighting = FALSE;- for( int i = 0; i < m_currentMembers; i++ )+ Object *member = TheGameLogic->findObjectByID( m_memberIDs[ i ] );+ AIUpdateInterface *ai = member ? member->getAI() : NULL;+ if( member && ai && !member->isContained() ){- Object *member = TheGameLogic->findObjectByID( m_memberIDs[ i ] );- AIUpdateInterface *ai = member ? member->getAI() : NULL;- if( member && ai && !member->isContained() )+ membersOutside = TRUE;+ if( ai->getCurrentVictim() != NULL ){- membersOutside = TRUE;- if( ai->getCurrentVictim() != NULL )- {- membersFighting = TRUE;- }+ membersFighting = TRUE;}}+ }- //Only worth a partition scan once the troops are out and nobody is engaged.- Bool areaClear = FALSE;- if( membersOutside && !membersFighting )- {- areaClear = isAssaultAreaClear();- }+ //Only worth a partition scan once the troops are out and nobody is engaged.+ Bool areaClear = FALSE;+ if( membersOutside && !membersFighting )+ {+ areaClear = isAssaultAreaClear();+ }+ Bool retrieve = AssaultTransport_shouldRetrieveMembers( membersOutside, membersFighting, areaClear );- if( AssaultTransport_shouldRetrieveMembers( membersOutside, membersFighting, areaClear ) )+ if( m_isAttackMove )+ {+ if( retrieve ){//Nobody left to shoot at, so pick the troops back up instead of walking them along//behind the transport for the rest of the attack move.@@ -400,8 +402,9 @@ UpdateSleepTime AssaultTransportAIUpdate::update( void )}}}- else if( m_isAttackObject )+ else if( m_isAttackObject && retrieve ){+ //Ordered onto one target: stay out and finish off whatever else is around us first.retrieveMembers();}}diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex e9c8866e2..7684b9298 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -780,7 +780,9 @@ TEST(ctrl_is_force_fire_only_while_the_attack_move_cursor_is_down)}/* AssaultTransportAIUpdate.cpp: the troop crawler deploys its passengers at a target and used to- leave them walking behind it for the rest of the attack move once that target died. */+ leave them walking behind it for the rest of the attack move once that target died - and on a+ plain attack order it re-boarded them the instant the target died, once per dead enemy. Both+ orders now board on this one rule. */extern Bool AssaultTransport_shouldRetrieveMembers( Bool membersOutside, Bool membersFighting, Bool areaClear );extern Bool AssaultTransport_waitingForBoarding( Bool membersOutside, UnsignedInt framesRemaining );