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
feat(gameengine): deploy every passenger of an assault transport
Olcay Seygan80dec7bc7cc8
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a1fa9569c..62ea116cf 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -38,6 +38,7 @@ found and fixed — EA's own, not port damage.**- 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.+- Every man aboard gets out to fight; a scratch or a late boarding used to bench him.- Attack-move state is saved now, instead of coming back as random memory.## Your units stop shooting corpses@@ -210,6 +211,7 @@ found and fixed — EA's own, not port damage.**- Widescreen resolutions are back in the options menu.- Zoom further out, with the whole map drawn instead of black corners.- The zoom-out ceiling is the same for everyone; no setting buys you a wider view.+- The wheel covers that whole range in about thirteen notches instead of thirty-eight.- Zoom toward the cursor works; the spot under your pointer stays there.- The camera turns in whole 45-degree steps, instantly, while you hold the key.- Edge scrolling works windowed, and scroll speed no longer follows your frame rate.diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AssaultTransportAIUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AssaultTransportAIUpdate.hindex ee72c133b..d4c6b4377 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AssaultTransportAIUpdate.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AssaultTransportAIUpdate.h@@ -108,13 +108,11 @@ public:Bool isAssaultAreaClear() const; //Nothing hostile left near the transport?void retrieveMembers();void giveFinalOrders();- Bool isAttackPointless() const;protected:ObjectID m_memberIDs[ MAX_TRANSPORT_SLOTS ];Bool m_memberHealing[ MAX_TRANSPORT_SLOTS ];- Bool m_newMember[ MAX_TRANSPORT_SLOTS ];Coord3D m_attackMoveGoalPos;mutable ObjectID m_designatedTarget;AssaultStateTypes m_state;@@ -122,7 +120,6 @@ protected:Int m_currentMembers;Bool m_isAttackMove;Bool m_isAttackObject;- Bool m_newOccupantsAreNewMembers;};#endifdiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/AssaultTransportAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/AssaultTransportAIUpdate.cppindex 65743a113..be207eecd 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/AssaultTransportAIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/AssaultTransportAIUpdate.cpp@@ -62,6 +62,15 @@ Bool AssaultTransport_shouldRetrieveMembers( Bool membersOutside, Bool membersFireturn membersOutside && !membersFighting && areaClear;}+//-------------------------------------------------------------------------------------------------+/** Does this passenger get out and fight?+ * Everybody aboard does, whatever he is and however scratched he is - the only man who stays in+ * is one who is still being patched up. */+Bool AssaultTransport_shouldDeployMember( Bool contained, Bool beingHealed )+{+ return contained && !beingHealed;+}+//-------------------------------------------------------------------------------------------------/** Does the transport hold still this frame instead of driving on with the attack move?* Only while troops are still outside and the boarding wait has not run out; see@@ -89,7 +98,6 @@ void AssaultTransportAIUpdate::reset(){m_memberIDs[ i ] = INVALID_ID;m_memberHealing[ i ] = FALSE;- m_newMember[ i ] = FALSE;}m_currentMembers = 0;m_attackMoveGoalPos.zero();@@ -98,7 +106,6 @@ void AssaultTransportAIUpdate::reset()m_framesRemaining = 0;m_isAttackMove = FALSE;m_isAttackObject = FALSE;- m_newOccupantsAreNewMembers = FALSE;}//-------------------------------------------------------------------------------------------------@@ -195,14 +202,12 @@ UpdateSleepTime AssaultTransportAIUpdate::update( void )//Move the last slot to this slot to keep array contiguous.m_memberIDs[ i ] = m_memberIDs[ m_currentMembers - 1 ];m_memberHealing[ i ] = m_memberHealing[ m_currentMembers - 1 ];- m_newMember[ i ] = m_newMember[ m_currentMembers - 1 ];}else{//Just clean out last slot.m_memberIDs[ i ] = INVALID_ID;m_memberHealing[ i ] = FALSE;- m_newMember[ i ] = FALSE;}if( ai ){@@ -263,22 +268,10 @@ UpdateSleepTime AssaultTransportAIUpdate::update( void ){m_memberHealing[ m_currentMembers ] = TRUE;}- if( m_newOccupantsAreNewMembers )- {- //New members won't eject out until a new attack order is issued.- m_newMember[ m_currentMembers ] = TRUE;- }m_currentMembers++;}}- m_newOccupantsAreNewMembers = TRUE;- }-- if( isAttackPointless() )- {- aiIdle( CMD_FROM_AI );- return UPDATE_SLEEP_NONE;}//Keep track of the average position of all combat units assigned to me.@@ -305,19 +298,26 @@ UpdateSleepTime AssaultTransportAIUpdate::update( void ){Bool contained = member->isContained();Bool wounded = isMemberWounded( member );- if( contained && isMemberHealthy( member ) && !m_newMember[ i ] )+ if( isMemberHealthy( member ) )+ {+ //Patched up - he is a fighter again.+ m_memberHealing[ i ] = FALSE;+ }+ if( AssaultTransport_shouldDeployMember( contained, m_memberHealing[ i ] ) ){- //This contained member is healthy so order him to exit to start fighting!- //New members are exempt!+ //Everyone rides out to fight - a scratch or a late boarding used to keep a man+ //inside for the whole battle.ai->aiExit( transport, CMD_FROM_AI );}if( !contained ){if( wounded ){+ //Order wounded members back to get healed, and keep them in until they are+ //whole again rather than bouncing them straight back out.+ m_memberHealing[ i ] = TRUE;if( ai->getAIStateType() != AI_ENTER ){- //Order wounded members back to get healed.ai->aiEnter( transport, CMD_FROM_AI );}}@@ -460,31 +460,6 @@ UpdateSleepTime AssaultTransportAIUpdate::update( void )return UPDATE_SLEEP_NONE;}-//--------------------------------------------------------------------------------------------------Bool AssaultTransportAIUpdate::isAttackPointless() const-{- //If all members are new members (thus can't attack), and the transport itself- //is still attacking, stop!- const Object *transport = getObject();- if( transport->testStatus( OBJECT_STATUS_IS_ATTACKING ) )- {- for( int i = 0; i < m_currentMembers; i++ )- {- if( !m_newMember[ i ] )- {- //We have a non-new member, so attack is valid.- return FALSE;- }- }-- //We are trying to attack, but can't because all our members are new.- return TRUE;- }-- //We aren't trying to attack, so everything is good.- return FALSE;-}-//-------------------------------------------------------------------------------------------------Bool AssaultTransportAIUpdate::isMemberWounded( const Object *member ) const{diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 7684b9298..a257e8c4f 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -785,6 +785,21 @@ TEST(ctrl_is_force_fire_only_while_the_attack_move_cursor_is_down)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 );+extern Bool AssaultTransport_shouldDeployMember( Bool contained, Bool beingHealed );++TEST(troop_crawler_deploys_everyone_aboard)+{+ /* aboard and fit to fight: out he goes, whatever he is and however scratched. Retail wanted+ full health and exempted anyone who boarded after the attack order, so a squad that had+ fought once rode the rest of the battle out inside. */+ CHECK( AssaultTransport_shouldDeployMember( true, false ) );++ /* still being patched up: he stays in until whole, or he would bounce straight back out. */+ CHECK( !AssaultTransport_shouldDeployMember( true, true ) );++ /* already outside: nothing to order. */+ CHECK( !AssaultTransport_shouldDeployMember( false, false ) );+}TEST(troop_crawler_picks_its_troops_back_up_only_when_the_fight_is_over){