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): shift keeps order keys armed, posts end a list
Olcay Seyganf6578a2ee17b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ca86af013..276b261f3 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -179,7 +179,7 @@ found and fixed — EA's own, not port damage.**- Shift queues a guard as well, and it is where the line of orders stops. Hold shift with G armed and click, and the group takes up its post once it has finished everything queued in front of it: clear that ridge, then sit on it, in one set of clicks instead of standing over the fight waiting to give the last order. Nothing goes behind a guard, because a posted unit has no next place to be. The thread to the post is drawn in the guard colour like any other guard.- Shift queues an attack now, not only a move. A or F held down while you shift-click adds a force-attack or an attack-move to the line of orders a group is already holding, and it fires the moment the order in front of it is finished - a target dead, or nobody left chasing an attack-move point. The coloured thread that shows a queued order covers it too, so a queue of "go here, then attack that, then attack-move over there" reads as one continuous line in three colours. The game's own white waypoint markings, which used to draw over the same ground the moment shift went down, are gone - they only ever duplicated what the coloured thread already showed, and doing both left a queued attack sitting under two different pictures of itself.- The shift queue takes any mix of orders now and stays with the units you gave it to. Move, attack-move, attack a target, draw a formation line, then guard: hold shift, click them in whatever order you like, and the group works down the list by itself. Queue an army's whole route, select something else, go back to your base, and the army keeps going. Before, clicking anything else threw the list away. Each step also starts the moment the one before it is done. It used to wait for the order to travel to the other players and back, which on a 250ms connection was a quarter of a second standing still at every corner. The group keeps together: nobody starts the next order until everyone still alive has finished this one, so a column does not string out behind its fastest tank. Select part of a group and shift-click, and that part takes its own copy of the list with the new order on the end while the others carry on with theirs. Shift-click a group that is already on an ordinary move and the new point goes behind the move instead of replacing it.-- Shift queues whatever a right-click orders, not just moves. Shift-right-click an enemy tank and killing it goes on the list; do it on a building with a Black Lotus selected and taking the building goes on the list. A transport to climb into, a repair bay, a hospital and a supply dock work the same way, and so does an ability armed from the command bar. "Walk here, take that supply center, walk on" is one set of clicks, and the list waits for the capture to finish before anyone sets off for the next point. Upgrades queue as well: shift-click the Overlord's Gatling cannon and it is bought when the Overlord gets there and paid for then. If the money is not in the bank by that time the upgrade is passed over and the list carries on. Each unit with more than one place to go numbers its markers in the order it will reach them, and a step the colour cannot tell apart from a move carries its own cursor next to the number, or the upgrade's picture. A shift-click on one of your own units is still a point on the path. Replays recorded before this version that shift-clicked an upgrade, or gave a unit holding a list an ability without shift, play back differently.+- Shift queues whatever a right-click orders, not just moves. Shift-right-click an enemy tank and killing it goes on the list; do it on a building with a Black Lotus selected and taking the building goes on the list. A transport to climb into, a repair bay, a hospital and a supply dock work the same way, and so does an ability armed from the command bar. "Walk here, take that supply center, walk on" is one set of clicks, and the list waits for the capture to finish before anyone sets off for the next point. Upgrades queue as well: shift-click the Overlord's Gatling cannon and it is bought when the Overlord gets there and paid for then. If the money is not in the bank by that time the upgrade is passed over and the list carries on. Each unit with more than one place to go numbers its markers in the order it will reach them, and a step the colour cannot tell apart from a move carries its own cursor next to the number, or the upgrade's picture. A shift-click on one of your own units is still a point on the path. Keep shift down after pressing F, A or G and the key stays armed, so five targets are one key and five clicks instead of five of each; it drops when shift comes up. A guard, a hold or fire on the ground ends a list for good. Nothing queues behind one, whether it was given with shift or without, until an order without shift takes the units off it. Replays recorded before this version that shift-clicked an upgrade, or gave a unit holding a list an ability without shift, play back differently.- What the circle picks up is what you can see, and a stealthed unit is not that. Shroud was the only test, so a hidden tank parked in ground you had already cleared went on the list like anything else: drag a circle over open country and the group opened fire on air, one order per hidden unit, which is a stealth detector drawn with the mouse. An undetected unit is not in the circle.- Ctrl+D takes every unit of the kinds you have selected that is on the screen, and pressed twice inside half a second takes them across the whole map. One tank selected and two keystrokes is your whole armour, wherever it is standing. It was on Shift+Ctrl+E, which is three fingers for something you do in every fight, and it only ever reached across the map when the screen had nothing left to give - so the wide selection happened to you instead of being asked for.diff --git a/GeneralsMD/Code/Data/Scenarios/shiftorders.txt b/GeneralsMD/Code/Data/Scenarios/shiftorders.txtindex 66083b908..6f2d4d072 100644--- a/GeneralsMD/Code/Data/Scenarios/shiftorders.txt+++ b/GeneralsMD/Code/Data/Scenarios/shiftorders.txt@@ -1,6 +1,7 @@# Two orders that are not moves wait their turn in a shift queue. A Black Lotus walks to a point,# takes an American supply center when she gets there, and walks on. An Overlord walks to a point,-# buys its Gatling cannon there, paid for then, and drives on.+# buys its Gatling cannon there, paid for then, drives on and takes up a guard, and a move queued+# behind the guard is turned away.## The capture holds the list while it runs: the ability walks her up to the building with orders of# its own, which the queue must not read as her being done. The two arrive lines say whether each@@ -25,9 +26,16 @@60 shiftmove 0 ChinaTankOverlord 1000 130061 shiftupgrade 0 ChinaTankOverlord Upgrade_ChinaOverlordGattlingCannon62 shiftmove 0 ChinaTankOverlord 700 1500+63 shiftguard 0 ChinaTankOverlord 700 1500+1500 shiftmove 0 ChinaTankOverlord 950 1750-63 arrive 0 ChinaInfantryBlackLotus 800 1250 150-63 arrive 0 ChinaTankOverlord 700 1500 150+65 arrive 0 ChinaInfantryBlackLotus 800 1250 150+65 arrive 0 ChinaTankOverlord 700 1500 150++# The guard is a post, and nothing goes behind it: the move at frame 1500, given once the Overlord is+# already standing guard, is turned away, so it must never reach 950,1750, a short drive from its+# post. This line has to report 0 of 1.+65 arrive 0 ChinaTankOverlord 950 1750 1002390 tally 0 AmericaSupplyCenter2390 tally 1 AmericaSupplyCenterdiff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.hindex fc627a346..af63f4d4b 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h@@ -907,14 +907,19 @@ public: // ********************************************************************Bool isInPreferSelectionMode( void ) const { return m_preferSelection; }void setClientQuiet( Bool enabled ) { m_clientQuiet = enabled; }- void setWaypointMode( Bool enabled ) { m_waypointMode = enabled; }+ void setWaypointMode( Bool enabled ) { m_waypointMode = enabled; if( !enabled && m_orderKeyKeptByShift ) clearAttackMoveToMode(); }void setForceMoveMode( Bool enabled ) { m_forceMoveToMode = enabled; }void setForceAttackMode( Bool enabled ) { m_forceAttackMode = enabled; }void setPreferSelectionMode( Bool enabled ) { m_preferSelection = enabled; }void toggleAttackMoveToMode( void ) { m_attackMoveToMode = !m_attackMoveToMode; m_forceAttackArmed = FALSE; m_guardArmed = FALSE; }Bool isInAttackMoveToMode( void ) const { return m_attackMoveToMode; }- void clearAttackMoveToMode( void ) { m_attackMoveToMode = FALSE; m_forceAttackArmed = FALSE; m_guardArmed = FALSE; }+ void clearAttackMoveToMode( void ) { m_attackMoveToMode = FALSE; m_forceAttackArmed = FALSE; m_guardArmed = FALSE; m_orderKeyKeptByShift = FALSE; }++ // an order click with one of the three keys armed spends the key, unless shift is down: then it+ // stays armed for the next click, so a row of targets is one key and a row of clicks, and it drops+ // when shift comes up+ void spendOrderKey( void ) { if( m_waypointMode ) m_orderKeyKeptByShift = TRUE; else clearAttackMoveToMode(); }// the attack key arms force fire the way the attack move key arms an attack move: the next// order click shoots whatever is under it, ground included, and the mode drops again with the@@ -1485,6 +1490,7 @@ protected:Bool m_attackMoveToMode; ///< are we in attack move mode?Bool m_forceAttackArmed; ///< is the attack key holding force fire for the next click?Bool m_guardArmed; ///< is the guard key holding a guard order for the next click?+ Bool m_orderKeyKeptByShift; ///< an armed key was clicked with under shift, and drops when shift comes upBool m_preferSelection; ///< the shift key has been depressed.// wall clock of the previous update(), so a held camera key can be stepped by elapseddiff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/OrderQueue.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/OrderQueue.hindex a4d835376..d2709bf8c 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/OrderQueue.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/OrderQueue.h@@ -139,12 +139,13 @@ public:static Bool isOrder( GameMessage::Type type ); ///< a hand-given order to the selected unitsstatic Bool isQueueable( GameMessage::Type type ); ///< an order that can wait its turn in a chain- static Bool isTerminal( GameMessage::Type type ); ///< an order that never finishes, so it ends its chain+ static Bool isTerminal( GameMessage::Type type ); ///< an order that never finishes: a post, and nothing can be queued behind itprivate:void queueOrder( GameMessage *msg, const std::vector<ObjectID>& selected, Player *owner );Bool queueUpgrade( GameMessage *msg, AIGroup *selected, Player *owner ); ///< FALSE: bought now, not queuedvoid startChain( GameMessage *msg, const std::vector<ObjectID>& members, Player *owner );+ void addChain( GameMessage *msg, const std::vector<ObjectID>& members );void appendOrder( OrderChain& chain, GameMessage *msg, Player *owner );void releaseUnits( const std::vector<ObjectID>& ids );Bool isStepOver( OrderChain& chain, Player *owner );diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex 68e0a2375..128a99bb4 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -1302,6 +1302,7 @@ InGameUI::InGameUI()m_attackMoveToMode = false;m_forceAttackArmed = false;m_guardArmed = false;+ m_orderKeyKeptByShift = false;m_preferSelection = false;m_isAttackCircling = FALSE;clearAllyCursors();@@ -3847,6 +3848,7 @@ void InGameUI::reset( void )m_attackMoveToMode = false;m_forceAttackArmed = false;m_guardArmed = false;+ m_orderKeyKeptByShift = false;m_preferSelection = false;m_isAttackCircling = FALSE;clearAllyCursors();diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cppindex b685e4798..08fdb596b 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp@@ -1483,7 +1483,7 @@ void CommandTranslator::finishFormationDrag( const ICoord2D& lift )newMsg->appendLocationArgument( world );}- TheInGameUI->clearAttackMoveToMode();+ TheInGameUI->spendOrderKey();const DrawableList *selected = TheInGameUI->getAllSelectedDrawables();if( selected && !selected->empty() )@@ -4236,7 +4236,7 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage}disp = DESTROY_MESSAGE;- TheInGameUI->clearAttackMoveToMode();+ TheInGameUI->spendOrderKey();//issueMoveToLocationCommand( &pos, draw, DO_COMMAND );}diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cppindex 2cac126fc..9c5b12bbc 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp@@ -1093,7 +1093,7 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa// and the click that follows this release is the order. Only a real circle eats itif( TheInGameUI->issueAttackCircle() ){- TheInGameUI->clearAttackMoveToMode();+ TheInGameUI->spendOrderKey();m_dragOrderJustIssued = TRUE;}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/OrderQueue.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/OrderQueue.cppindex eb3f7c493..7436a9e49 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/OrderQueue.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/OrderQueue.cpp@@ -478,6 +478,11 @@ Bool OrderQueue::takeMessage( GameMessage *msg, AIGroup *selected, Player *ownerif( mode == ORDER_QUEUE_NONE || !isQueueable( msg->getType() ) ){releaseUnits( ids );++ // a guard, a hold or a shot at the ground given without shift is a post all the same, and a+ // shift click behind it is turned away like one behind a queued guard+ if( isTerminal( msg->getType() ) )+ addChain( msg, ids );return FALSE;}@@ -517,12 +522,16 @@ void OrderQueue::queueOrder( GameMessage *msg, const std::vector<ObjectID>& seleif( part.empty() )continue;- touched.push_back( it );- parts.push_back( part );-std::vector<ObjectID> rest;std::set_difference( loose.begin(), loose.end(), part.begin(), part.end(), std::back_inserter( rest ) );loose.swap( rest );++ // units on a post have no next place to be, so the order is not theirs+ if( isTerminal( it->m_active.getType() ) )+ continue;++ touched.push_back( it );+ parts.push_back( part );}for( size_t i = 0; i < touched.size(); i++ )@@ -603,6 +612,10 @@ Bool OrderQueue::queueUpgrade( GameMessage *msg, AIGroup *selected, Player *ownewhile( chain != m_chains.end() && !std::binary_search( chain->m_members.begin(), chain->m_members.end(), producerID ) )++chain;+ // a unit on a post has nothing to wait for, so it buys it now+ if( chain != m_chains.end() && isTerminal( chain->m_active.getType() ) )+ return FALSE;+if( chain == m_chains.end() ){const AIUpdateInterface *ai = producer->getAIUpdateInterface();@@ -626,11 +639,16 @@ Bool OrderQueue::queueUpgrade( GameMessage *msg, AIGroup *selected, Player *ownevoid OrderQueue::startChain( GameMessage *msg, const std::vector<ObjectID>& members, Player *owner ){OrderQueue_dispatch( msg, members );+ addChain( msg, members );+}- // a guard is not a list, just an order- if( isTerminal( msg->getType() ) )- return;-+//-------------------------------------------------------------------------------------------------+/** A chain on the order msg, which the caller has seen carried out. On a guard, a hold or a shot at+ * the ground it is a post: it holds nothing, it never moves on, and it is there only so a shift+ * click behind it can be turned away, until an order without shift takes the units off it. */+//-------------------------------------------------------------------------------------------------+void OrderQueue::addChain( GameMessage *msg, const std::vector<ObjectID>& members )+{OrderChain chain;chain.m_members = members;chain.m_active.copyFrom( msg );@@ -641,7 +659,8 @@ void OrderQueue::startChain( GameMessage *msg, const std::vector<ObjectID>& membvoid OrderQueue::appendOrder( OrderChain& chain, GameMessage *msg, Player *owner ){// nothing after a guard would ever come round- if( !chain.m_pending.empty() && isTerminal( chain.m_pending.back().getType() ) )+ if( isTerminal( chain.m_active.getType() )+ || ( !chain.m_pending.empty() && isTerminal( chain.m_pending.back().getType() ) ) )return;if( msg->getType() == GameMessage::MSG_DO_MOVETO && chain.m_pending.empty()@@ -717,6 +736,10 @@ Bool OrderQueue::isStepOver( OrderChain& chain, Player *owner )return TRUE;}+ // a post never ends by itself; the object it guards dying is the one way off it, above+ if( isTerminal( chain.m_active.getType() ) )+ return FALSE;+Bool anyWorking = FALSE;Bool anyRearming = FALSE;Bool anyReadyToGoAgain = FALSE;@@ -807,16 +830,11 @@ Bool OrderQueue::advance( OrderChain& chain, Player *owner )}OrderQueue_dispatch( next, chain.m_members, owner );- if( isTerminal( next.getType() ) )- {- OrderQueue_log( "last order out, it never ends", chain, owner );- return FALSE;- }chain.m_active = next;chain.m_settledFrames = 0;chain.m_waitingForRearm = FALSE;- OrderQueue_log( "next order out", chain, owner );+ OrderQueue_log( isTerminal( next.getType() ) ? "last order out, a post" : "next order out", chain, owner );Coord3D dest;while( next.getType() == GameMessage::MSG_DO_MOVETO && !chain.m_pending.empty()