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): drop the shared pace on attack move
Olcay Seyganefd3070abc3f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex b5b6eabd8..673e6fc5e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,10 @@ found and fixed — EA's own, not port damage.**---+## Groups attack-move at their own speed++- An attack move used to hold the whole group to its slowest member when you held Ctrl on the click, and the computer's groups did that every time. A damaged truck walked the tanks in. Each unit now goes at its own speed. A replay recorded before this, of a group attack-moving that way, will not play back the same.+## The frame rate cap is gone- The picture now runs uncapped; the rules keep their own steady clock.diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.hindex a05f17ecb..e2045cc8d 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h@@ -1214,8 +1214,7 @@ public:}void groupAttackTeam( const Team *team, Int maxShotsToFire, CommandSourceType cmdSource ); ///< attack the given teamvoid groupAttackPosition( const Coord3D *pos, Int maxShotsToFire, CommandSourceType cmdSource ); ///< attack given spot- void groupAttackMoveToPosition( const Coord3D *pos, Int maxShotsToFire, CommandSourceType cmdSource, Bool matchSpeeds = TRUE ); ///< Attack move to the location- Bool getMatchSpeeds( void ) const { return m_matchSpeeds; } ///< does the last attack move hold everyone to the slowest member?+ void groupAttackMoveToPosition( const Coord3D *pos, Int maxShotsToFire, CommandSourceType cmdSource ); ///< Attack move to the locationvoid groupHunt( CommandSourceType cmdSource ); ///< begin "seek and destroy"void groupRepair( Object *obj, CommandSourceType cmdSource ); ///< repair the given objectvoid groupResumeConstruction( Object *obj, CommandSourceType cmdSource ); ///< resume construction on the object@@ -1323,7 +1322,6 @@ private:UnsignedInt m_memberListSize; ///< the size of the list of member ObjectsReal m_speed; ///< maximum speed of group (slowest member)- Bool m_matchSpeeds; ///< last attack move asked for one shared speed (see groupAttackMoveToPosition)Bool m_dirty; ///< "dirty bit" - if true then group speed, leader, needs recomputeUnsignedInt m_id; ///< the unique ID of this groupdiff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/AIStateMachine.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/AIStateMachine.hindex d472c4f81..cca54aa4e 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/AIStateMachine.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/AIStateMachine.h@@ -606,7 +606,6 @@ protected:Bool canHitFromHere( const Object *victim ); ///< can we shoot it without moving an inch?Bool mayEngageYet( void ); ///< has the required progress toward the goal been made?void requireProgressTowardGoal( void ); ///< refuse to fight again until we are closer to the goal- void applyGroupSpeed( void ); ///< hold this unit to the ordered group's speedCommandSourceType m_commandSrc; // Original command source. We switch to CMD_FROM_AI when auto-acquiring.StateMachine *m_attackMoveMachine;@@ -618,7 +617,6 @@ protected:UnsignedInt m_frameToScanOn; ///< next frame we may look for a targetUnsignedInt m_frameToApproachOn; ///< until this frame we only take targets we can already shootReal m_reengageGoalDistSqr; ///< no new fight until we are this close to the goal (0 = no gate)- Real m_groupSpeed; ///< speed of the slowest member of the ordered groupBool m_isEngaging; ///< true while the attack sub-machine owns usBool m_chaseWasAllowed; ///< the owner's chase flag, saved while we engageprotected:diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cppindex 0aa8c8534..f54a40075 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp@@ -349,7 +349,6 @@ WindowMsgHandledType LeftHUDInput( GameWindow *window, UnsignedInt msg,GameMessage *msg = TheMessageStream->appendMessage( GameMessage::MSG_DO_ATTACKMOVETO );msg->appendLocationArgument( world );- msg->appendBooleanArgument( TheInGameUI->isInForceAttackMode() ); // ctrl: arrive together// Play the unit voice responsepickAndPlayUnitVoiceResponse(TheInGameUI->getAllSelectedDrawables(), GameMessage::MSG_DO_ATTACKMOVETO);diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex dad31869e..71432d20f 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -6566,7 +6566,7 @@ void InGameUI::createCommandHint( const GameMessage *msg )}//--------------------------------------------------------------------------------------------------/** Force fire is the attack key alone; ctrl held is the shared pace on a move. */+/** Force fire is the attack key alone. *///-------------------------------------------------------------------------------------------------Bool InGameUI::isForceFireOn( void ) const{diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cppindex 8bc8507f8..bba64e313 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp@@ -104,8 +104,7 @@//-------------------------------------------------------------------------------------------------/*** Is the next order click a force fire?- * Under Modern only the attack key arms it: ctrl is the "one shared pace" modifier on a move (see- * issueMoveToLocationCommand), so a ctrl click could not ask for both.+ * Only the attack key arms it. An attack-move click stays an attack move.*/Bool CommandXlat_isForceAttackTargeting( Bool forceAttackArmed, Bool attackMoveArmed ){@@ -1003,11 +1002,6 @@ GameMessage::Type CommandTranslator::issueMoveToLocationCommand( const Coord3D *elsemovemsg->appendLocationArgument( *pos );- // ctrl on an attack move click asks for one shared pace - the force attack modifier is- // the ctrl key, and it means nothing else while the attack move cursor is up- if (msgType == GameMessage::MSG_DO_ATTACKMOVETO)- movemsg->appendBooleanArgument( TheInGameUI->isInForceAttackMode() );-// a posted unit holds its spot and shoots what walks into range, rather than chasing it// off the post the player put it onif (msgType == GameMessage::MSG_DO_GUARD_POSITION)diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cppindex 86334e53c..7e6804ea9 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cpp@@ -287,7 +287,6 @@ static CommandStatus doAttackMoveCommand( const CommandButton *command, const IC// send the message to set the rally pointGameMessage *msg = TheMessageStream->appendMessage( GameMessage::MSG_DO_ATTACKMOVETO );msg->appendLocationArgument( world );- msg->appendBooleanArgument( TheInGameUI->isInForceAttackMode() ); // ctrl: arrive together// Play the unit voice responsepickAndPlayUnitVoiceResponse(TheInGameUI->getAllSelectedDrawables(), GameMessage::MSG_DO_ATTACKMOVETO);diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cppindex d3f2c2d07..251565bc4 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp@@ -83,7 +83,6 @@ AIGroup::AIGroup( void )// DEBUG_LOG(("***AIGROUP %x is being constructed.\n", this));m_groundPath = NULL;m_speed = 0.0f;- m_matchSpeeds = TRUE;m_dirty = false;m_id = TheAI->getNextGroupID();m_memberListSize = 0;@@ -3035,7 +3034,7 @@ void AIGroup::groupAttackPosition( const Coord3D *pos, Int maxShotsToFire, Comma/*** Attack move to a location*/-void AIGroup::groupAttackMoveToPosition( const Coord3D *pos, Int maxShotsToFire, CommandSourceType cmdSource, Bool matchSpeeds )+void AIGroup::groupAttackMoveToPosition( const Coord3D *pos, Int maxShotsToFire, CommandSourceType cmdSource ){//// This used to hand every member the same single coordinate, so a group attack move arrived as@@ -3043,13 +3042,6 @@ void AIGroup::groupAttackMoveToPosition( const Coord3D *pos, Int maxShotsToFire,// destination the way groupMoveToPosition does (each member keeps its offset from the group// centroid).//- // Holding the ground units to the speed of the slowest one keeps the group together on the way- // in, but it also means one damaged truck walks the tanks in at its own pace, and that is not- // always what you asked for. So it is the player's call, taken from the ctrl key on the click:- // ctrl-click an attack move and they arrive together, click it plainly and they each go at- // their own speed. AIAttackMoveToState::onEnter reads it back off the group.- //- m_matchSpeeds = matchSpeeds;if (m_dirty)recompute();diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cppindex e636a9e2e..44319e0ff 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp@@ -3598,7 +3598,6 @@ AIAttackMoveToState::AIAttackMoveToState( StateMachine *machine ) : AIMoveToStatm_frameToScanOn = 0;m_frameToApproachOn = 0;m_reengageGoalDistSqr = 0.0f;- m_groupSpeed = FAST_AS_POSSIBLE;m_isEngaging = FALSE;m_chaseWasAllowed = FALSE;m_attackMoveMachine = newInstance(AIAttackMoveStateMachine)(getMachineOwner(), "AIAttackMoveMachine");@@ -3645,7 +3644,9 @@ void AIAttackMoveToState::xfer( Xfer *xfer )}if (version>=4) {xfer->xferReal(&m_reengageGoalDistSqr);- xfer->xferReal(&m_groupSpeed);+ // Attack-move groups used to save a shared speed here. The stream still has the real.+ Real savedGroupSpeed = 0.0f;+ xfer->xferReal(&savedGroupSpeed);}if (version>=5) {// m_isEngaging has been saved since version 3, so a load could resume a fight with this@@ -3699,38 +3700,7 @@ StateReturnType AIAttackMoveToState::onEnter()// spread the scans of a group that was all ordered on the same frame over the scan interval.m_frameToScanOn = TheGameLogic->getFrame() + ((UnsignedInt)owner->getID() % ATTACK_MOVE_SCAN_RATE);- // An attack move can arrive as a group or as a queue of single units, and which one you want- // is the player's call: ctrl on the click asks for one shared pace, the slowest member's. The- // order is still running inside the AIGroup that issued it, so the group - and the flag it- // carries - is still reachable here; it is gone by the next update.- m_groupSpeed = FAST_AS_POSSIBLE;- AIGroup *group = ai->getGroup();- if (group != NULL && group->getMatchSpeeds() && ai->isDoingGroundMovement())- {- Real speed = group->getSpeed();- if (speed > 0.0f && speed < FAST_AS_POSSIBLE)- m_groupSpeed = speed;- }-- StateReturnType ret = AIMoveToState::onEnter();- // AIInternalMoveToState::onEnter resets the desired speed, so this has to follow it.- applyGroupSpeed();- return ret;-}--//-----------------------------------------------------------------------------------------------------------/**- * Hold this unit to the group's speed. Called after every (re)path, since entering the move state- * puts the speed back to FAST_AS_POSSIBLE.- */-void AIAttackMoveToState::applyGroupSpeed( void )-{- if (m_groupSpeed >= FAST_AS_POSSIBLE)- return;-- AIUpdateInterface *ai = getMachineOwner()->getAI();- if (ai != NULL)- ai->setDesiredSpeed(m_groupSpeed);+ return AIMoveToState::onEnter();}//----------------------------------------------------------------------------------------------------------@@ -4210,7 +4180,6 @@ StateReturnType AIAttackMoveToState::update(){AIMoveToState::onEnter();forceRepath();- applyGroupSpeed(); // re-entering the move state put the speed back to FAST_AS_POSSIBLE}StateReturnType ret = AIMoveToState::update();diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cppindex 702b8dc53..ab5609483 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp@@ -956,13 +956,11 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, AIGroup *orderedGroup{Coord3D dest = msg->getArgument( 0 )->location;- // ctrl held on the click means "arrive together" - see AIGroup::groupAttackMoveToPosition- Bool matchSpeeds = ( msg->getArgumentCount() > 1 ) ? msg->getArgument( 1 )->boolean : FALSE;-+ // Older recordings append a boolean after the point. It is not read.if (currentlySelectedGroup){currentlySelectedGroup->releaseWeaponLockForGroup(LOCKED_TEMPORARILY); // release any temporary locks.- currentlySelectedGroup->groupAttackMoveToPosition( &dest, NO_MAX_SHOTS_LIMIT, CMD_FROM_PLAYER, matchSpeeds );+ currentlySelectedGroup->groupAttackMoveToPosition( &dest, NO_MAX_SHOTS_LIMIT, CMD_FROM_PLAYER );}break;diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 190b54921..0377b4154 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -1040,8 +1040,8 @@ TEST(physics_forward_speed_is_the_projection_not_a_per_axis_norm)CHECK_NEAR( PhysicsBehavior::calcForwardSpeed( climb, up ), 12.0f, 0.01f );}-/* CommandXlat.cpp: only the attack key arms force fire. Holding ctrl did it too, and ctrl is the- "one shared pace" modifier, so a ctrl click on the ground shelled the dirt instead of moving. */+/* CommandXlat.cpp: only the attack key arms force fire. Holding ctrl used to do it too, so a+ ctrl click on the ground shelled the dirt instead of moving. */extern Bool CommandXlat_isForceAttackTargeting( Bool forceAttackArmed, Bool attackMoveArmed );TEST(force_fire_is_the_attack_key_and_nothing_else)