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 queues context clicks, abilities and upgrades
Olcay Seygan0aab932d40c4
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f01adde6e..ca86af013 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -179,6 +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.- 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.txtnew file mode 100644index 000000000..66083b908--- /dev/null+++ b/GeneralsMD/Code/Data/Scenarios/shiftorders.txt@@ -0,0 +1,33 @@+# 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.+#+# 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+# got to the end of its list, the tallies whose supply center it is by then, and the "order queue:"+# lines when each step went out.+#+# generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit+# -map "Maps\Alpine Assault\Alpine Assault.map" -autoskirmish 2 -takeover+# -side 0 FactionChina -side 1 FactionAmerica -seed 1 -maxframes 2400+# -scenario shiftorders -logPrefix shiftorders_+#+# See mobstress.txt for the line grammar.++30 spawn 0 ChinaInfantryBlackLotus 1 760 920+30 spawn 0 ChinaTankOverlord 1 760 1100+30 spawn 1 AmericaSupplyCenter 1 1300 1150++60 shiftmove 0 ChinaInfantryBlackLotus 1000 950+61 shiftpower 0 ChinaInfantryBlackLotus 1 AmericaSupplyCenter SpecialAbilityBlackLotusCaptureBuilding+62 shiftmove 0 ChinaInfantryBlackLotus 800 1250++60 shiftmove 0 ChinaTankOverlord 1000 1300+61 shiftupgrade 0 ChinaTankOverlord Upgrade_ChinaOverlordGattlingCannon+62 shiftmove 0 ChinaTankOverlord 700 1500++63 arrive 0 ChinaInfantryBlackLotus 800 1250 150+63 arrive 0 ChinaTankOverlord 700 1500 150++2390 tally 0 AmericaSupplyCenter+2390 tally 1 AmericaSupplyCenterdiff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.hindex 2723b469d..fc627a346 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h@@ -500,15 +500,21 @@ public: // ********************************************************************ORDER_HINT_CAPTURE, ///< go and take itORDER_HINT_HACK, ///< go and hack itORDER_HINT_GUARD, ///< hold that spot- ORDER_HINT_WAYPOINT ///< walking a path somebody laid down+ ORDER_HINT_WAYPOINT, ///< walking a path somebody laid down+ ORDER_HINT_ABILITY, ///< use an ability where it stands, from a shift list+ ORDER_HINT_UPGRADE ///< buy an upgrade where it stands, from a shift list};struct OrderHint{+ OrderHint( void ) : kind( ORDER_HINT_MOVE ), owner( INVALID_ID ), bornMs( 0 ), step( 0 ), icon( NULL ) {}+Coord3D from; ///< where the unit is nowCoord3D to; ///< where it is goingOrderHintKind kind;ObjectID owner; ///< the selected unit this one belongs toUnsignedInt bornMs; ///< when the marker first appeared, so it can be slid in+ Int step; ///< its place in the order the unit will get to its points, from 1; 0 when it has only the one+ const Image *icon; ///< the upgrade's own button art on an upgrade step, NULL otherwise};const std::vector<OrderHint>& getOrderHints( void ) const { return m_drawnOrderHints; }@@ -1121,7 +1127,8 @@ protected:void addOrderHint( OrderHint& hint, const std::vector<OrderHint>& previous ); ///< keep a marker's age across the frame the list is rebuilt onBool getHeldAircraftOrder( const Object *obj, OrderHintKind& kind, Coord3D& to ) const; ///< the order an aircraft is sitting on until it is airbornevoid addQueuedOrderTail( OrderHint& hint, const OrderChain& chain, const std::vector<OrderHint>& previous ); ///< every order still owed, drawn on from where the hint leaves off- Bool getQueuedOrderHint( const QueuedOrder& order, OrderHintKind& kind, Coord3D& to ) const; ///< the marker a queued order draws, FALSE for none+ Bool getQueuedOrderHint( const QueuedOrder& order, OrderHint& hint ) const; ///< the marker a queued order draws, FALSE for none+ void numberOrderHints( void ); ///< a unit with more than one place to go numbers themBool isHiddenByShroud( const Object *obj ) const; ///< is the shroud over this, for the player at this machineBool m_displayedMaxWarning; ///< keeps the warning from being shown over and overconst CommandButton * m_pendingGUICommand; ///< GUI command that needs additional interaction from the userdiff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/OrderQueue.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/OrderQueue.hindex 8e4dc0ffe..a4d835376 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/OrderQueue.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/OrderQueue.h@@ -34,7 +34,8 @@// The units that were told together form a chain and go through it together: nobody starts the next// order until everyone left alive is done with this one, so an army does not string out across the// map behind its fastest unit. Selecting part of a chain and adding to it splits that part off with-// a copy of the list. An order given without shift ends the list for the units it went to.+// a copy of the list. An order given without shift ends the list for the units it went to. An+// upgrade bought with shift is a step as well, paid for when the chain reaches it.//// Everything here is logic state: it is saved with the player, and a replay rebuilds it from the// recorded messages.@@ -79,6 +80,7 @@ public:Bool isStanding( void ) const { return m_type == GameMessage::MSG_INVALID; }ObjectID getTargetID( void ) const; ///< the object the order names, INVALID_ID for noneBool getDestination( Coord3D *pos ) const; ///< the first location it carries, FALSE for none+ const GameMessageArgumentType& getArgument( Int index ) const { return m_args[ index ]; }void xfer( Xfer *xfer );@@ -141,6 +143,7 @@ public:private: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 appendOrder( OrderChain& chain, GameMessage *msg, Player *owner );void releaseUnits( const std::vector<ObjectID>& ids );diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.hindex 1ffd6f36f..c72ba9208 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h@@ -78,7 +78,9 @@ enum ScenarioActionTypeSCENARIO_ACTION_SHIFTMOVE, ///< shiftmove <slot> <selector> <position>; a shift right click, onto the units' order queueSCENARIO_ACTION_SHIFTATTACKMOVE, ///< shiftattackmove <slot> <selector> <position>; the same with attack moveSCENARIO_ACTION_SHIFTATTACK, ///< shiftattack <slot> <selector> <targetSlot> <targetSelector>; the same with an attack on one unit- SCENARIO_ACTION_SHIFTGUARD ///< shiftguard <slot> <selector> <position>; the same with the guard key+ SCENARIO_ACTION_SHIFTGUARD, ///< shiftguard <slot> <selector> <position>; the same with the guard key+ SCENARIO_ACTION_SHIFTPOWER, ///< shiftpower <slot> <selector> <targetSlot> <targetSelector> <power>; the same with a special power armed, on one object+ SCENARIO_ACTION_SHIFTUPGRADE ///< shiftupgrade <slot> <selector> <upgrade>; shift on an object upgrade button, bought by every unit that matches};/// ScenarioAction::atStart when the position is plain numbers@@ -116,6 +118,7 @@ struct ScenarioActionReal radius; ///< how close to the target counts as arrivedInt targetSlot; ///< whose units to attackAsciiString targetSelector; ///< which of them+ AsciiString name; ///< shiftpower's special power, shiftupgrade's upgrade};/** Turn one line of a scenario file into an action. Pure: no engine state is read, which is whatdiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cppindex 408b8a86e..755021faa 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp@@ -748,8 +748,11 @@ CBCommandStatus ControlBar::processCommandUI( GameWindow *control,if( upgradeT == NULL )break;+ // shift: the unit buys it when its list gets there, and the money is looked at then+ const Bool queued = TheInGameUI->isInWaypointMode();+//Make sure the player can really make this- if( TheUpgradeCenter->canAffordUpgrade( ThePlayerList->getLocalPlayer(), upgradeT, TRUE ) == FALSE )+ if( !queued && TheUpgradeCenter->canAffordUpgrade( ThePlayerList->getLocalPlayer(), upgradeT, TRUE ) == FALSE ){//Kris: Disabled because we can get a valid reason for not being able to afford the upgrade!//TheInGameUI->message( "upgrade unsupported in commandprocessing." );@@ -801,10 +804,12 @@ CBCommandStatus ControlBar::processCommandUI( GameWindow *control,continue;// the logic charges each one as it queues it, so stop at what is in the bank- if( cost > 0 && purse < cost )+ if( !queued && cost > 0 && purse < cost )break;purse -= cost;+ if( queued )+ TheInGameUI->markNextOrderQueued( ORDER_QUEUE_APPEND );GameMessage *msg = TheMessageStream->appendMessage( GameMessage::MSG_QUEUE_UPGRADE );msg->appendObjectIDArgument( target->getID() );msg->appendIntegerArgument( upgradeT->getUpgradeNameKey() );@@ -827,6 +832,8 @@ CBCommandStatus ControlBar::processCommandUI( GameWindow *control,break;// send the message+ if( queued )+ TheInGameUI->markNextOrderQueued( ORDER_QUEUE_APPEND );GameMessage *msg = TheMessageStream->appendMessage( GameMessage::MSG_QUEUE_UPGRADE );msg->appendObjectIDArgument( objID );msg->appendIntegerArgument( upgradeT->getUpgradeNameKey() );@@ -1108,6 +1115,10 @@ CBCommandStatus ControlBar::processCommandUI( GameWindow *control,case GUI_COMMAND_SPECIAL_POWER:{+ // shift: the units use it when their list gets there+ if( TheInGameUI->isInWaypointMode() )+ TheInGameUI->markNextOrderQueued( ORDER_QUEUE_APPEND );+// command needs no additional data, send the messageGameMessage *msg = TheMessageStream->appendMessage( GameMessage::MSG_DO_SPECIAL_POWER );msg->appendIntegerArgument( commandButton->getSpecialPowerTemplate()->getID() );diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex d208673a9..68e0a2375 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -4741,6 +4741,7 @@ void InGameUI::updateOrderHints( void )}collectOrderHints();+ numberOrderHints();bunchOrderHints();}@@ -4774,6 +4775,7 @@ void InGameUI::collectOrderHints( void )hint.owner = obj->getID();Coord3D resolvedGoal;Bool goalResolved = FALSE;+ Bool legsDrawn = FALSE; // the order drew its own threads, and the shift list follows on from themswitch( ai->getCurrentStateID() ){case AI_MOVE_TO:@@ -4848,7 +4850,8 @@ void InGameUI::collectOrderHints( void )hint.from = ( exit != NULL ) ? *exit->getPosition() : hint.to;hint.to = *ai->getTunnelTripGoal();addOrderHint( hint, previous );- continue;+ legsDrawn = TRUE;+ break;}hint.kind = ORDER_HINT_ENTER;break;@@ -4896,46 +4899,48 @@ void InGameUI::collectOrderHints( void )break;}- hint.from = *obj->getPosition();-- if( goalResolved )- {- hint.to = resolvedGoal;- }- else+ if( !legsDrawn ){+ hint.from = *obj->getPosition();+// a queued path is shown point by point: one thread from the unit to its next point and one// from each point to the one after it, so the whole shift queue is on the ground at once and// stays there after the key is let goconst Int pathSize = ai->friend_getWaypointGoalPathSize();const Int pathIndex = ai->friend_getCurrentGoalPathIndex();- if( pathSize > 0 && pathIndex >= 0 && pathIndex < pathSize )+ if( goalResolved )+ {+ hint.to = resolvedGoal;+ }+ else if( pathSize > 0 && pathIndex >= 0 && pathIndex < pathSize ){- for( Int i = pathIndex; i < pathSize; i++ )+ for( Int i = pathIndex; i < pathSize - 1; i++ ){hint.to = *ai->friend_getGoalPathPosition( i );addOrderHint( hint, previous );hint.from = hint.to;}- continue;+ hint.to = *ai->friend_getGoalPathPosition( pathSize - 1 );}-- // a goal object outranks the goal position: a unit chasing something is headed wherever that- // thing is standing now, not where it stood when the order was given. Without one the end of- // the unit's own path is where it is really going: a group sent to one spot is spread over the- // free cells round it, and the order's point is the same for every member. A unit still- // waiting for its path has only the order's point to show- Object *goalObj = ai->getGoalObject();- Path *path = ai->getPath();- if( goalObj )- hint.to = *goalObj->getPosition();- else if( path )- hint.to = *path->getLastNode()->getPosition();else- hint.to = *ai->getGoalPosition();- }+ {+ // a goal object outranks the goal position: a unit chasing something is headed wherever that+ // thing is standing now, not where it stood when the order was given. Without one the end of+ // the unit's own path is where it is really going: a group sent to one spot is spread over the+ // free cells round it, and the order's point is the same for every member. A unit still+ // waiting for its path has only the order's point to show+ Object *goalObj = ai->getGoalObject();+ Path *path = ai->getPath();+ if( goalObj )+ hint.to = *goalObj->getPosition();+ else if( path )+ hint.to = *path->getLastNode()->getPosition();+ else+ hint.to = *ai->getGoalPosition();+ }- addOrderHint( hint, previous );+ addOrderHint( hint, previous );+ }// the rest of the unit's shift queue: every order still owed after this one, each drawn on from// where the last leaves off. The list belongs to the whole chain rather than to one unit, so@@ -4996,9 +5001,10 @@ void InGameUI::collectOrderHints( void )OrderHint hint;hint.owner = *id;hint.from = *member->getPosition();+ hint.to = hint.from;// the order the chain is on now is no longer in its list, so it is drawn from here- if( getQueuedOrderHint( chain->m_active, hint.kind, hint.to ) )+ if( getQueuedOrderHint( chain->m_active, hint ) ){addOrderHint( hint, previous );hint.from = hint.to;@@ -5033,7 +5039,7 @@ void InGameUI::bunchOrderHints( void )for( size_t i = 0; i < m_drawnOrderHints.size(); ++i ){OrderHint& bunch = m_drawnOrderHints[ i ];- if( bunch.kind != hint->kind )+ if( bunch.kind != hint->kind || bunch.step != hint->step || bunch.icon != hint->icon )continue;const Real fromX = bunch.from.x - hint->from.x;const Real fromY = bunch.from.y - hint->from.y;@@ -5076,7 +5082,7 @@ void InGameUI::addQueuedOrderTail( OrderHint& hint, const OrderChain& chain, confor( std::vector<QueuedOrder>::const_iterator order = chain.m_pending.begin();order != chain.m_pending.end(); ++order ){- if( !getQueuedOrderHint( *order, hint.kind, hint.to ) )+ if( !getQueuedOrderHint( *order, hint ) )continue;addOrderHint( hint, previous );@@ -5089,42 +5095,110 @@ void InGameUI::addQueuedOrderTail( OrderHint& hint, const OrderChain& chain, con* than where it stood when the player picked it, so the thread follows a target that is driving* away. One that died while it waited its turn is drawn nowhere: the order will be skipped. Nor* is one that has driven into the shroud since it was picked - the thread would otherwise trace it- * through the fog, which is a look at the map you have not earned. */+ * through the fog, which is a look at the map you have not earned.+ *+ * An upgrade, or an ability that needs no target, is used wherever the step before it ends, which+ * is the hint.to handed in; it is left there, and the marker sits on that spot. *///--------------------------------------------------------------------------------------------------Bool InGameUI::getQueuedOrderHint( const QueuedOrder& order, OrderHintKind& kind, Coord3D& to ) const+Bool InGameUI::getQueuedOrderHint( const QueuedOrder& order, OrderHint& hint ) const{+ hint.icon = NULL;+switch( order.getType() ){case GameMessage::MSG_DO_MOVETO:case GameMessage::MSG_DO_FORCEMOVETO:case GameMessage::MSG_DO_FORMATION_MOVETO:- kind = ORDER_HINT_MOVE;+ case GameMessage::MSG_DO_SALVAGE:+ hint.kind = ORDER_HINT_MOVE;break;case GameMessage::MSG_DO_ATTACKMOVETO:case GameMessage::MSG_DO_FORMATION_ATTACKMOVETO:- kind = ORDER_HINT_ATTACK_MOVE;+ hint.kind = ORDER_HINT_ATTACK_MOVE;break;case GameMessage::MSG_DO_ATTACK_OBJECT:- kind = ORDER_HINT_ATTACK;+ case GameMessage::MSG_DO_WEAPON_AT_OBJECT:+ hint.kind = ORDER_HINT_ATTACK;break;case GameMessage::MSG_DO_FORCE_ATTACK_OBJECT:- kind = ORDER_HINT_FORCE_ATTACK;+ hint.kind = ORDER_HINT_FORCE_ATTACK;break;case GameMessage::MSG_DO_FORCE_ATTACK_GROUND:case GameMessage::MSG_DO_FORMATION_FORCEATTACK:- kind = ORDER_HINT_ATTACK_GROUND;+ case GameMessage::MSG_DO_WEAPON_AT_LOCATION:+ case GameMessage::MSG_DO_SPECIAL_POWER_AT_LOCATION:+ hint.kind = ORDER_HINT_ATTACK_GROUND;break;case GameMessage::MSG_DO_GUARD_POSITION:case GameMessage::MSG_DO_GUARD_OBJECT:case GameMessage::MSG_DO_FORMATION_GUARD:- kind = ORDER_HINT_GUARD;+ hint.kind = ORDER_HINT_GUARD;break;+ case GameMessage::MSG_ENTER:+ case GameMessage::MSG_COMBATDROP_AT_OBJECT:+ case GameMessage::MSG_COMBATDROP_AT_LOCATION:+ hint.kind = ORDER_HINT_ENTER;+ break;++ case GameMessage::MSG_DOCK:+ hint.kind = ORDER_HINT_DOCK;+ break;++ case GameMessage::MSG_GET_REPAIRED:+ hint.kind = ORDER_HINT_GET_REPAIRED;+ break;++ case GameMessage::MSG_GET_HEALED:+ hint.kind = ORDER_HINT_GET_HEALED;+ break;++ case GameMessage::MSG_DO_REPAIR:+ hint.kind = ORDER_HINT_DO_REPAIR;+ break;++ case GameMessage::MSG_DO_SPECIAL_POWER_AT_OBJECT:+ {+ // a capture and a hack have cursors of their own; the rest of what a unit does to one object+ // with an ability - a charge, a sniper round, a satchel - is an attack as far as the marker goes+ const SpecialPowerTemplate *power = TheSpecialPowerStore->findSpecialPowerTemplateByID( order.getArgument( 0 ).integer );+ switch( power ? power->getSpecialPowerType() : SPECIAL_INVALID )+ {+ case SPECIAL_INFANTRY_CAPTURE_BUILDING:+ case SPECIAL_BLACKLOTUS_CAPTURE_BUILDING:+ hint.kind = ORDER_HINT_CAPTURE;+ break;++ case SPECIAL_BLACKLOTUS_DISABLE_VEHICLE_HACK:+ case SPECIAL_BLACKLOTUS_STEAL_CASH_HACK:+ case SPECIAL_HACKER_DISABLE_BUILDING:+ hint.kind = ORDER_HINT_HACK;+ break;++ default:+ hint.kind = ORDER_HINT_ATTACK;+ break;+ }+ break;+ }++ case GameMessage::MSG_DO_SPECIAL_POWER:+ hint.kind = ORDER_HINT_ABILITY;+ return TRUE;++ case GameMessage::MSG_QUEUE_UPGRADE:+ {+ const UpgradeTemplate *upgrade = TheUpgradeCenter->findUpgradeByKey( (NameKeyType)order.getArgument( 1 ).integer );+ hint.kind = ORDER_HINT_UPGRADE;+ hint.icon = upgrade ? upgrade->getButtonImage() : NULL;+ return TRUE;+ }+default:// a hold is wherever each unit happens to be standing, and a list that began behind an// unqueued order has nothing of its own to show for that order@@ -5133,16 +5207,39 @@ Bool InGameUI::getQueuedOrderHint( const QueuedOrder& order, OrderHintKind& kindconst ObjectID targetID = order.getTargetID();if( targetID == INVALID_ID )- return order.getDestination( &to );+ return order.getDestination( &hint.to );const Object *target = TheGameLogic->findObjectByID( targetID );if( target == NULL || target->isEffectivelyDead() || isHiddenByShroud( target ) )return FALSE;- to = *target->getPosition();+ hint.to = *target->getPosition();return TRUE;}+//-------------------------------------------------------------------------------------------------+/** The hints of one unit sit together in the list, in the order it will get to them. A unit with+ * more than one place to go carries a number on each, so a shift list reads first to last on the+ * ground; a unit with one does not, since a lone "1" says nothing. */+//-------------------------------------------------------------------------------------------------+void InGameUI::numberOrderHints( void )+{+ size_t first = 0;+ while( first < m_orderHints.size() )+ {+ size_t end = first + 1;+ while( end < m_orderHints.size() && m_orderHints[ end ].owner == m_orderHints[ first ].owner )+ ++end;++ if( end - first > 1 )+ {+ for( size_t i = first; i < end; ++i )+ m_orderHints[ i ].step = (Int)( i - first ) + 1;+ }+ first = end;+ }+}+//-------------------------------------------------------------------------------------------------/** Add a marker to this frame's list, carrying over when it first appeared. The list is thrown* away and rebuilt from the units every frame, so without this every marker would be newborn ondiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cppindex b0eef5a49..b685e4798 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp@@ -988,10 +988,6 @@ GameMessage::Type CommandTranslator::issueMoveToLocationCommand( const Coord3D *}if( commandType == DO_COMMAND ){- // shift puts the order on the end of the units' list rather than carrying it out now- if( TheInGameUI->isInWaypointMode() )- TheInGameUI->markNextOrderQueued( ORDER_QUEUE_APPEND );-GameMessage *movemsg = TheMessageStream->appendMessage( msgType );if (msgType == GameMessage::MSG_DO_ATTACK_OBJECT)movemsg->appendObjectIDArgument( obj->getID() );@@ -1644,24 +1640,11 @@ GameMessage::Type CommandTranslator::evaluateContextCommand( Drawable *draw,{GameMessage *hintMessage;- if( TheInGameUI->isInWaypointMode() )- {- //Override any *other* commands with waypoint commands.- if( type == DO_COMMAND || type == EVALUATE_ONLY )- {- if( TheTerrainLogic )- {- msgType = issueMoveToLocationCommand( pos, draw, type );- }- }- else- {- msgType = GameMessage::MSG_ADD_WAYPOINT_HINT;- hintMessage = TheMessageStream->appendMessage( msgType );- hintMessage->appendLocationArgument( *pos );- }- return msgType;- }+ // shift used to turn every click into a point on the path. Now whatever the click orders - an+ // attack, a capture, a ride in a transport - goes on the end of the units' list, and the logic+ // keeps it there (OrderQueue.h). A click that orders nothing is dropped by the logic with it+ if( TheInGameUI->isInWaypointMode() && type == DO_COMMAND )+ TheInGameUI->markNextOrderQueued( ORDER_QUEUE_APPEND );CanAttackResult result;@@ -2457,11 +2440,11 @@ GameMessage::Type CommandTranslator::evaluateContextCommand( Drawable *draw,if( type == DO_COMMAND || type == EVALUATE_ONLY ){// issue command- // Note: If draw is valid, then its one of ours and we don't have something more specific- // to do. Therefore, lets not issue a move command, and instead we'll return that there- // wasn't a command for us to perform.-- if ( draw == NULL )+ // Note: If draw is valid, then its one of ours and we don't have something more specific+ // to do. Therefore, lets not issue a move command, and instead we'll return that there+ // wasn't a command for us to perform. Under shift it is a point on the path all the same.++ if ( draw == NULL || TheInGameUI->isInWaypointMode() )msgType = issueMoveToLocationCommand( pos, drawableInWay, type );} // end ifelsediff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cppindex 4d4529631..86334e53c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cpp@@ -396,7 +396,14 @@ GameMessageDisposition GUICommandTranslator::translateGameMessage(const GameMess// do the command actionif( command && !command->isContextCommand() ){- switch( command->getCommandType() )+ // shift: the order this click gives goes on the end of the units' list. A special power+ // goes on to the command translator, which marks it there+ const GUICommandType commandType = command->getCommandType();+ if( TheInGameUI->isInWaypointMode() && commandType != GUI_COMMAND_SPECIAL_POWER+ && commandType != GUI_COMMAND_SPECIAL_POWER_FROM_SHORTCUT )+ TheInGameUI->markNextOrderQueued( ORDER_QUEUE_APPEND );++ switch( commandType ){//---------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/OrderQueue.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/OrderQueue.cppindex 2f0cff108..eb3f7c493 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/OrderQueue.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/OrderQueue.cpp@@ -33,6 +33,7 @@#include "GameLogic/Object.h"#include "GameLogic/Module/AIUpdate.h"#include "GameLogic/Module/JetAIUpdate.h"+#include "GameLogic/Module/SpecialPowerUpdateModule.h"#include <algorithm>#include <iterator>@@ -98,9 +99,14 @@ GameMessage *QueuedOrder::makeMessage( Int playerIndex ) const//-------------------------------------------------------------------------------------------------ObjectID QueuedOrder::getTargetID( void ) const{+ // the object an order at a place carries is whatever stood on that spot, not what it is for+ if( m_type == GameMessage::MSG_DO_SPECIAL_POWER_AT_LOCATION || m_type == GameMessage::MSG_DO_WEAPON_AT_LOCATION )+ return INVALID_ID;++ // MSG_ENTER names the selection first, as INVALID_ID, and what to climb into secondfor( size_t i = 0; i < m_args.size(); i++ ){- if( m_argTypes[ i ] == ARGUMENTDATATYPE_OBJECTID )+ if( m_argTypes[ i ] == ARGUMENTDATATYPE_OBJECTID && m_args[ i ].objectID != INVALID_ID )return m_args[ i ].objectID;}return INVALID_ID;@@ -190,13 +196,31 @@ static Bool OrderQueue_holdsChain( const Object *obj, const Player *owner )return ai != NULL && ai->hasTunnelTrip();}+//-------------------------------------------------------------------------------------------------+/** A capture, a charge being planted, a hack: the ability walks the unit up to its target with orders+ * of its own, so while it runs the unit reads as idle or as told by the AI. */+//-------------------------------------------------------------------------------------------------+static Bool OrderQueue_isUsingAbility( const Object *obj )+{+ for( BehaviorModule **module = obj->getBehaviorModules(); *module; ++module )+ {+ const SpecialPowerUpdateInterface *power = (*module)->getSpecialPowerUpdateInterface();+ if( power != NULL && power->isSpecialAbility() && power->isActive() )+ return TRUE;+ }+ return FALSE;+}+//-------------------------------------------------------------------------------------------------/** Is this unit busy with an order the player gave? A fight it picked for itself while standing* about is not one: the group is done, and the next order takes it off that fight. Nor is a* guard, which never ends. *///--------------------------------------------------------------------------------------------------static Bool OrderQueue_isWorking( const AIUpdateInterface *ai )+static Bool OrderQueue_isWorking( const Object *obj, const AIUpdateInterface *ai ){+ if( OrderQueue_isUsingAbility( obj ) )+ return TRUE;+if( ai->isIdle() || ai->getLastCommandSource() != CMD_FROM_PLAYER )return FALSE;@@ -236,6 +260,23 @@ static Bool OrderQueue_isAttack( GameMessage::Type type )return type == GameMessage::MSG_DO_ATTACK_OBJECT || type == GameMessage::MSG_DO_FORCE_ATTACK_OBJECT;}+//-------------------------------------------------------------------------------------------------+/** A special power that names the object firing it - a superweapon off the shortcut bar - goes to+ * that object whatever is selected, so it is no order to the selection at all. */+//-------------------------------------------------------------------------------------------------+static Bool OrderQueue_namesItsOwnSource( const GameMessage *msg )+{+ Int sourceArg;+ switch( msg->getType() )+ {+ case GameMessage::MSG_DO_SPECIAL_POWER: sourceArg = 2; break;+ case GameMessage::MSG_DO_SPECIAL_POWER_AT_OBJECT: sourceArg = 3; break;+ case GameMessage::MSG_DO_SPECIAL_POWER_AT_LOCATION: sourceArg = 5; break;+ default: return FALSE;+ }+ return msg->getArgument( sourceArg )->objectID != INVALID_ID;+}+//-------------------------------------------------------------------------------------------------/** One line per thing a chain did. The queue is driven by a player's clicks, so no unattended run* reproduces a fault in it and this line is the whole instrument. Never one per frame. */@@ -337,6 +378,13 @@ Bool OrderQueue::isOrder( GameMessage::Type type )case GameMessage::MSG_GET_REPAIRED:case GameMessage::MSG_GET_HEALED:case GameMessage::MSG_DO_REPAIR:+ case GameMessage::MSG_DO_WEAPON_AT_OBJECT:+ case GameMessage::MSG_DO_WEAPON_AT_LOCATION:+ case GameMessage::MSG_COMBATDROP_AT_OBJECT:+ case GameMessage::MSG_COMBATDROP_AT_LOCATION:+ case GameMessage::MSG_DO_SPECIAL_POWER:+ case GameMessage::MSG_DO_SPECIAL_POWER_AT_LOCATION:+ case GameMessage::MSG_DO_SPECIAL_POWER_AT_OBJECT:return TRUE;default:@@ -352,6 +400,7 @@ Bool OrderQueue::isQueueable( GameMessage::Type type )case GameMessage::MSG_DO_MOVETO:case GameMessage::MSG_DO_ATTACKMOVETO:case GameMessage::MSG_DO_FORCEMOVETO:+ case GameMessage::MSG_DO_SALVAGE:case GameMessage::MSG_DO_ATTACK_OBJECT:case GameMessage::MSG_DO_FORCE_ATTACK_OBJECT:case GameMessage::MSG_DO_FORCE_ATTACK_GROUND:@@ -362,6 +411,18 @@ Bool OrderQueue::isQueueable( GameMessage::Type type )case GameMessage::MSG_DO_FORMATION_ATTACKMOVETO:case GameMessage::MSG_DO_FORMATION_FORCEATTACK:case GameMessage::MSG_DO_FORMATION_GUARD:+ case GameMessage::MSG_ENTER:+ case GameMessage::MSG_DOCK:+ case GameMessage::MSG_GET_REPAIRED:+ case GameMessage::MSG_GET_HEALED:+ case GameMessage::MSG_DO_REPAIR:+ case GameMessage::MSG_DO_WEAPON_AT_OBJECT:+ case GameMessage::MSG_DO_WEAPON_AT_LOCATION:+ case GameMessage::MSG_COMBATDROP_AT_OBJECT:+ case GameMessage::MSG_COMBATDROP_AT_LOCATION:+ case GameMessage::MSG_DO_SPECIAL_POWER:+ case GameMessage::MSG_DO_SPECIAL_POWER_AT_LOCATION:+ case GameMessage::MSG_DO_SPECIAL_POWER_AT_OBJECT:return TRUE;default:@@ -404,7 +465,11 @@ Bool OrderQueue::takeMessage( GameMessage *msg, AIGroup *selected, Player *ownerconst Int mode = m_nextOrderMode;m_nextOrderMode = ORDER_QUEUE_NONE;- if( selected == NULL || !isOrder( msg->getType() ) )+ // buying one is no order to the units, so without shift it leaves their list alone+ if( msg->getType() == GameMessage::MSG_QUEUE_UPGRADE )+ return mode != ORDER_QUEUE_NONE && queueUpgrade( msg, selected, owner );++ if( selected == NULL || !isOrder( msg->getType() ) || OrderQueue_namesItsOwnSource( msg ) )return FALSE;std::vector<ObjectID> ids = selected->getAllIDs();@@ -490,7 +555,7 @@ void OrderQueue::queueOrder( GameMessage *msg, const std::vector<ObjectID>& sele{const Object *obj = TheGameLogic->findObjectByID( *it );const AIUpdateInterface *ai = obj ? obj->getAIUpdateInterface() : NULL;- if( ai == NULL || !OrderQueue_isWorking( ai ) )+ if( ai == NULL || !OrderQueue_isWorking( obj, ai ) )continue;anyWorking = TRUE;if( !OrderQueue_isWalking( ai ) )@@ -520,6 +585,41 @@ void OrderQueue::queueOrder( GameMessage *msg, const std::vector<ObjectID>& seleadded.m_pending.back().copyFrom( msg );}+//-------------------------------------------------------------------------------------------------+/** Shift on an upgrade button: the unit buys it when its list gets there, and pays then; if the money+ * is not there by that time the upgrade is passed over. It becomes a step of the chain the unit is+ * in, which does not split for it, since the upgrade names its unit and the rest of the chain has+ * nothing to do but wait a moment. A unit busy with an order given without shift starts a list+ * behind it, and one with nothing to do buys it now. */+//-------------------------------------------------------------------------------------------------+Bool OrderQueue::queueUpgrade( GameMessage *msg, AIGroup *selected, Player *owner )+{+ const ObjectID producerID = msg->getArgument( 0 )->objectID;+ const Object *producer = TheGameLogic->findObjectByID( producerID );+ if( producer == NULL || producer->getControllingPlayer() != owner )+ return FALSE;++ OrderChainList::iterator chain = m_chains.begin();+ while( chain != m_chains.end() && !std::binary_search( chain->m_members.begin(), chain->m_members.end(), producerID ) )+ ++chain;++ if( chain == m_chains.end() )+ {+ const AIUpdateInterface *ai = producer->getAIUpdateInterface();+ if( ai == NULL || !OrderQueue_isWorking( producer, ai ) )+ return FALSE;++ m_chains.push_back( OrderChain() );+ chain = --m_chains.end();+ chain->m_members.push_back( producerID );+ }++ if( selected )+ TheAI->destroyGroup( selected );+ appendOrder( *chain, msg, owner );+ return TRUE;+}+//-------------------------------------------------------------------------------------------------/** A new chain whose first order goes out now. *///-------------------------------------------------------------------------------------------------@@ -647,7 +747,7 @@ Bool OrderQueue::isStepOver( OrderChain& chain, Player *owner )}}- if( OrderQueue_isWorking( ai ) || ai->hasTunnelTrip() )+ if( OrderQueue_isWorking( obj, ai ) || ai->hasTunnelTrip() )anyWorking = TRUE;else if( jet != NULL )anyReadyToGoAgain = TRUE;@@ -699,6 +799,11 @@ Bool OrderQueue::advance( OrderChain& chain, Player *owner )if( target == NULL || target->isEffectivelyDead()|| ( OrderQueue_isAttack( next.getType() ) && IncomingDamageTracker::isAlreadyDoomed( target ) ) )continue;++ // the list was copied when the chain split, and the upgrade belongs to whichever half has the unit+ if( next.getType() == GameMessage::MSG_QUEUE_UPGRADE+ && !std::binary_search( chain.m_members.begin(), chain.m_members.end(), targetID ) )+ continue;}OrderQueue_dispatch( next, chain.m_members, owner );diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cppindex 6d44ef42c..6ceac3532 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp@@ -31,6 +31,7 @@#include "Common/GlobalData.h"#include "Common/Player.h"#include "Common/PlayerList.h"+#include "Common/SpecialPower.h"#include "Common/Team.h"#include "Common/ThingFactory.h"#include "Common/ThingTemplate.h"@@ -79,6 +80,12 @@ static const Int SCENARIO_TOKENS_MOVE = 5;static const Int SCENARIO_TOKENS_ATTACK = 6;static const Int SCENARIO_TOKENS_SPAWN = 6;static const Int SCENARIO_TOKENS_ARRIVE = 5;+static const Int SCENARIO_TOKENS_SHIFTPOWER = 7;+static const Int SCENARIO_TOKENS_SHIFTUPGRADE = 5;++// where the name sits in the lines that carry one+static const Int SCENARIO_SHIFTPOWER_NAME_TOKEN = 6;+static const Int SCENARIO_SHIFTUPGRADE_NAME_TOKEN = 4;// where the position starts in each line that has onestatic const Int SCENARIO_SPAWN_POSITION_TOKEN = 5;@@ -189,6 +196,10 @@ static Bool parseActionType( const AsciiString &token, ScenarioActionType *actio*action = SCENARIO_ACTION_SHIFTATTACK;else if (token == "shiftguard")*action = SCENARIO_ACTION_SHIFTGUARD;+ else if (token == "shiftpower")+ *action = SCENARIO_ACTION_SHIFTPOWER;+ else if (token == "shiftupgrade")+ *action = SCENARIO_ACTION_SHIFTUPGRADE;elsereturn FALSE;@@ -271,6 +282,8 @@ static Int tokensNeededFor( ScenarioActionType action )case SCENARIO_ACTION_SHIFTATTACKMOVE: return SCENARIO_TOKENS_MOVE;case SCENARIO_ACTION_SHIFTGUARD: return SCENARIO_TOKENS_MOVE;case SCENARIO_ACTION_SHIFTATTACK: return SCENARIO_TOKENS_ATTACK;+ case SCENARIO_ACTION_SHIFTPOWER: return SCENARIO_TOKENS_SHIFTPOWER;+ case SCENARIO_ACTION_SHIFTUPGRADE: return SCENARIO_TOKENS_SHIFTUPGRADE;case SCENARIO_ACTION_ATTACK: return SCENARIO_TOKENS_ATTACK;case SCENARIO_ACTION_ENTER: return SCENARIO_TOKENS_ATTACK;case SCENARIO_ACTION_PRODUCE: return SCENARIO_TOKENS_ATTACK;@@ -319,6 +332,7 @@ ScenarioParseResult ScenarioDrill_parseLine( const char *line, ScenarioAction *aaction->radius = SCENARIO_DEFAULT_ARRIVE_RADIUS;action->targetSlot = 0;action->targetSelector.clear();+ action->name.clear();switch (actionType){@@ -360,13 +374,20 @@ ScenarioParseResult ScenarioDrill_parseLine( const char *line, ScenarioAction *acase SCENARIO_ACTION_ATTACK:case SCENARIO_ACTION_ENTER:case SCENARIO_ACTION_SHIFTATTACK:+ case SCENARIO_ACTION_SHIFTPOWER:{if (!parseWholeNumber( tokens[ 4 ], &action->targetSlot ))return SCENARIO_PARSE_BAD_SLOT;action->targetSelector = tokens[ 5 ];+ if (actionType == SCENARIO_ACTION_SHIFTPOWER)+ action->name = tokens[ SCENARIO_SHIFTPOWER_NAME_TOKEN ];break;}+ case SCENARIO_ACTION_SHIFTUPGRADE:+ action->name = tokens[ SCENARIO_SHIFTUPGRADE_NAME_TOKEN ];+ break;+case SCENARIO_ACTION_PRODUCE:{action->targetSelector = tokens[ 4 ]; // what to make@@ -1033,23 +1054,38 @@ static Bool executeShiftOrder( const ScenarioAction &action, Player *player, contype = GameMessage::MSG_DO_ATTACK_OBJECT;verb = "shiftattack";}+ else if (action.action == SCENARIO_ACTION_SHIFTPOWER)+ {+ type = GameMessage::MSG_DO_SPECIAL_POWER_AT_OBJECT;+ verb = "shiftpower";+ }GameMessage *msg = newInstance( GameMessage )( type );msg->friend_setPlayerIndex( player->getPlayerIndex() );- if (type == GameMessage::MSG_DO_ATTACK_OBJECT)+ if (action.action == SCENARIO_ACTION_SHIFTATTACK || action.action == SCENARIO_ACTION_SHIFTPOWER){Player *targetPlayer = findPlayerForSlot( action.targetSlot );Object *target = (targetPlayer != NULL) ? findFirstMatching( targetPlayer, action.targetSelector ) : NULL;- if (target == NULL)+ const SpecialPowerTemplate *power = (action.action == SCENARIO_ACTION_SHIFTPOWER)+ ? TheSpecialPowerStore->findSpecialPowerTemplate( action.name ) : NULL;+ if (target == NULL || (action.action == SCENARIO_ACTION_SHIFTPOWER && power == NULL)){- DEBUG_LOG(("SCENARIO: frame %d %s: slot %d owns nothing matching '%s'\n",- action.frame, verb, action.targetSlot, action.targetSelector.str()));+ DEBUG_LOG(("SCENARIO: frame %d %s: slot %d owns nothing matching '%s', or there is no power '%s'\n",+ action.frame, verb, action.targetSlot, action.targetSelector.str(), action.name.str()));msg->deleteInstance();TheAI->destroyGroup( group );return FALSE;}++ if (power != NULL)+ msg->appendIntegerArgument( power->getID() );msg->appendObjectIDArgument( target->getID() );+ if (power != NULL)+ {+ msg->appendIntegerArgument( 0 ); // the button's options, which a capture never reads+ msg->appendObjectIDArgument( INVALID_ID ); // fired by the selection, as off the command bar+ }}else{@@ -1069,6 +1105,42 @@ static Bool executeShiftOrder( const ScenarioAction &action, Player *player, conreturn TRUE;}+/** Shift on an object upgrade button, once for every unit that matches: the two messages the command+ bar sends, handed to the dispatcher the way they arrive. An upgrade names the unit that buys it, so+ unlike the other shift verbs this one needs nothing selected. */+static Bool executeShiftUpgrade( const ScenarioAction &action, Player *player, AIGroup *group, Int taken )+{+ const std::vector<ObjectID> buyers = group->getAllIDs();+ TheAI->destroyGroup( group );++ const UpgradeTemplate *upgrade = TheUpgradeCenter->findUpgrade( action.name );+ if (upgrade == NULL)+ {+ DEBUG_LOG(("SCENARIO: frame %d shiftupgrade: there is no upgrade '%s'\n", action.frame, action.name.str()));+ return FALSE;+ }++ for (std::vector<ObjectID>::const_iterator it = buyers.begin(); it != buyers.end(); ++it)+ {+ GameMessage *prefix = newInstance( GameMessage )( GameMessage::MSG_QUEUE_NEXT_ORDER );+ prefix->friend_setPlayerIndex( player->getPlayerIndex() );+ prefix->appendIntegerArgument( ORDER_QUEUE_APPEND );+ TheGameLogic->logicMessageDispatcher( prefix, NULL );+ prefix->deleteInstance();++ GameMessage *msg = newInstance( GameMessage )( GameMessage::MSG_QUEUE_UPGRADE );+ msg->friend_setPlayerIndex( player->getPlayerIndex() );+ msg->appendObjectIDArgument( *it );+ msg->appendIntegerArgument( upgrade->getUpgradeNameKey() );+ TheGameLogic->logicMessageDispatcher( msg, NULL );+ msg->deleteInstance();+ }++ DEBUG_LOG(("SCENARIO: frame %d shiftupgrade slot %d '%s' x%d '%s'\n",+ action.frame, action.slot, action.selector.str(), taken, action.name.str()));+ return TRUE;+}+static Bool executeOrder( const ScenarioAction &action, Player *player, const Coord3D &dest ){AIGroup *group = TheAI->createGroup();@@ -1140,8 +1212,12 @@ static Bool executeOrder( const ScenarioAction &action, Player *player, const Cocase SCENARIO_ACTION_SHIFTATTACKMOVE:case SCENARIO_ACTION_SHIFTATTACK:case SCENARIO_ACTION_SHIFTGUARD:+ case SCENARIO_ACTION_SHIFTPOWER:return executeShiftOrder( action, player, dest, group, taken ); // the group is gone either way+ case SCENARIO_ACTION_SHIFTUPGRADE:+ return executeShiftUpgrade( action, player, group, taken );+case SCENARIO_ACTION_STOP:{group->groupIdle( CMD_FROM_SCRIPT );diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.hindex 91dd48627..409203e8a 100644--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.h+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.h@@ -84,6 +84,7 @@ protected:virtual void drawAttackCircle( void ); ///< the circle a left drag is sweeping targets out ofvirtual void drawAllyCursorLights( void ); ///< the patch of an ally's colour lying under their cursorvoid drawAllyCursors( void ); ///< each ally's pointer and name, over the world+ void drawOrderStep( const OrderHint& hint, const ICoord2D& tip, UnsignedInt color ); ///< a shift list step's number and what it isRenderObjClass *m_buildingPlacementAnchor;RenderObjClass *m_buildingPlacementArrow;@@ -92,6 +93,11 @@ protected:/// laying out the same string every frame for every ally is work nobody sees.DisplayString *m_allyCursorNames[ MAX_PLAYER_COUNT ];+ /// The numbers on the steps of a shift list, each laid out once. A step past the last one has no+ /// number, which on a list that long is no loss.+ enum { MAX_ORDER_STEP_NUMBERS = 30 };+ DisplayString *m_orderStepNumbers[ MAX_ORDER_STEP_NUMBERS ];+}; // end class W3DInGameUI#endif // end __W3DINGAMEUI_H_diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cppindex b5988d1c4..1301ad89c 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp@@ -292,6 +292,9 @@ W3DInGameUI::W3DInGameUI()for( Int i = 0; i < MAX_PLAYER_COUNT; ++i )m_allyCursorNames[ i ] = NULL;+ for( Int i = 0; i < MAX_ORDER_STEP_NUMBERS; ++i )+ m_orderStepNumbers[ i ] = NULL;+} // end W3DInGameUI//-------------------------------------------------------------------------------------------------@@ -308,6 +311,13 @@ W3DInGameUI::~W3DInGameUI()m_allyCursorNames[ i ] = NULL;}+ for( Int i = 0; i < MAX_ORDER_STEP_NUMBERS; ++i )+ if( m_orderStepNumbers[ i ] )+ {+ TheDisplayStringManager->freeDisplayString( m_orderStepNumbers[ i ] );+ m_orderStepNumbers[ i ] = NULL;+ }+} // end ~W3DInGameUI// loadText ===================================================================@@ -1093,6 +1103,88 @@ static const Image *orderCursorImage( Mouse::MouseCursor cursor, ICoord2D *hotSpreturn art.image;}+//-------------------------------------------------------------------------------------------------+/** The cursor a kind of order is given with, for the kinds whose colour is the plain green and so+ * says nothing on its own. Mouse::NONE for the rest. */+//-------------------------------------------------------------------------------------------------+static Mouse::MouseCursor orderHintCursor( InGameUI::OrderHintKind kind )+{+ switch( kind )+ {+ case InGameUI::ORDER_HINT_ENTER: return Mouse::ENTER_FRIENDLY;+ case InGameUI::ORDER_HINT_DOCK: return Mouse::DOCK;+ case InGameUI::ORDER_HINT_GET_REPAIRED: return Mouse::GET_REPAIRED;+ case InGameUI::ORDER_HINT_GET_HEALED: return Mouse::GET_HEALED;+ case InGameUI::ORDER_HINT_DO_REPAIR: return Mouse::DO_REPAIR;+ case InGameUI::ORDER_HINT_CAPTURE: return Mouse::CAPTUREBUILDING;+ case InGameUI::ORDER_HINT_HACK: return Mouse::HACK;+ default: return Mouse::NONE;+ }+}++static const Int ORDER_STEP_POINT_SIZE = 11;++//-------------------------------------------------------------------------------------------------+/** How much bigger the step numbers are drawn than at 800x600. Their font grows with the screen,+ * so everything laid out round them grows by the same factor or the number runs into the pointer+ * at 1440p and into the marker beside it at 4K. */+//-------------------------------------------------------------------------------------------------+static Real orderStepScale( void )+{+ return (Real)TheGlobalLanguageData->adjustFontSize( ORDER_STEP_POINT_SIZE ) / (Real)ORDER_STEP_POINT_SIZE;+}++//-------------------------------------------------------------------------------------------------+/** A step of a shift list carries its number, and beside it what the step is: the upgrade's own+ * button art, or the cursor of an order the colour cannot tell apart from a move. The row sits+ * above and to the right of the pointer's tip, clear of the pointer itself, which hangs below it. */+//-------------------------------------------------------------------------------------------------+void W3DInGameUI::drawOrderStep( const OrderHint& hint, const ICoord2D& tip, UnsignedInt color )+{+ const Real NUMBER_OFFSET_X = 10.0f;+ const Real ROW_HEIGHT = 22.0f;+ const Real ICON_GAP = 2.0f;++ const Real scale = orderStepScale();+ const Int rowHeight = REAL_TO_INT( ROW_HEIGHT * scale );+ const UnsignedInt alpha = color & 0xFF000000;+ Int x = tip.x + REAL_TO_INT( NUMBER_OFFSET_X * scale );+ const Int top = tip.y - rowHeight;++ if( hint.step > 0 && hint.step <= MAX_ORDER_STEP_NUMBERS )+ {+ DisplayString *&number = m_orderStepNumbers[ hint.step - 1 ];+ if( number == NULL )+ {+ number = TheDisplayStringManager->newDisplayString();+ number->setFont( TheWindowManager->winFindFont( AsciiString( "Arial" ),+ TheGlobalLanguageData->adjustFontSize( ORDER_STEP_POINT_SIZE ), TRUE ) );+ UnicodeString text;+ text.format( L"%d", hint.step );+ number->setText( text );+ }++ Int width = 0, height = 0;+ number->getSize( &width, &height );+ number->draw( x, top + ( rowHeight - height ) / 2, (Color)color, (Color)alpha );+ x += width + REAL_TO_INT( ICON_GAP * scale );+ }++ const Image *icon = hint.icon;+ if( icon == NULL )+ {+ ICoord2D hotSpot;+ icon = orderCursorImage( orderHintCursor( hint.kind ), &hotSpot );+ }+ if( icon == NULL )+ return;++ // the row's height, and the width the art's own proportions give it: a button cameo is wider+ // than it is tall, and squeezed into a square it reads as a different picture+ const Int iconWidth = rowHeight * icon->getImageWidth() / max( icon->getImageHeight(), 1 );+ TheDisplay->drawImage( icon, x, top, x + iconWidth, top + rowHeight, alpha | 0x00FFFFFF );+}+//-------------------------------------------------------------------------------------------------/** One faint line per bunch of selected units going the same way, from where they stand to where* they are going, with the order's own cursor sitting on the destination. Green for a move, pink@@ -1107,6 +1199,11 @@ void W3DInGameUI::drawOrderHints( void )const Real width = 1.0f;+ // how far right of the spot an upgrade or an ability stands: past the pointer and the number of+ // the step that ends there, both of which grow with the screen+ const Real IN_PLACE_MARKER_OFFSET = 44.0f;+ const Int inPlaceOffset = REAL_TO_INT( IN_PLACE_MARKER_OFFSET * orderStepScale() );+// A new marker slides up out of the bottom right and fades in over this long, so an order that// has just been given announces itself instead of appearing fully formed. Wall clock rather// than frames: the picture is uncapped, so a frame count would run at the frame rate.@@ -1137,9 +1234,15 @@ void W3DInGameUI::drawOrderHints( void )if( TheTacticalView->worldToScreenTriReturn( &it->to, &to ) == View::WTS_INVALID )continue;+ // an upgrade or an ability is used on the spot the step before it ends on, whose marker is+ // already there, so this one stands beside it rather than on top of it and draws no thread+ const Bool inPlace = it->kind == ORDER_HINT_UPGRADE || it->kind == ORDER_HINT_ABILITY;+ if( inPlace )+ to.x += inPlaceOffset;+// Order Lines off in the options takes the lines away and leaves the markers: where a unit is// going is still worth a glance when the thread across the map is not- if( TheGlobalData->m_showOrderLines )+ if( TheGlobalData->m_showOrderLines && !inPlace )TheDisplay->drawLine( from.x, from.y, to.x, to.y, width, lineColor );// the marker is the plain pointer, tinted: its white body takes the order colour and the@@ -1160,6 +1263,14 @@ void W3DInGameUI::drawOrderHints( void )const UnsignedInt markerColor = ( orderHintMarkerColor( it->kind ) & 0x00FFFFFF )| ( (UnsignedInt)REAL_TO_INT( 255.0f * eased ) << 24 );TheDisplay->drawImage( image, x, y, x + w, y + h, markerColor );++ if( it->step > 0 || it->icon )+ {+ ICoord2D tip;+ tip.x = to.x + slide;+ tip.y = to.y + slide;+ drawOrderStep( *it, tip, markerColor );+ }}}diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 2c70a8e09..0a03fcf86 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -13215,6 +13215,14 @@ TEST(order_queue_kinds_nest)CHECK( OrderQueue::isTerminal( GameMessage::MSG_DO_GUARD_POSITION ) );CHECK( OrderQueue::isOrder( GameMessage::MSG_DO_STOP ) );CHECK( !OrderQueue::isQueueable( GameMessage::MSG_DO_STOP ) );++ // a capture, a ride in a transport and a special weapon wait their turn like a move+ CHECK( OrderQueue::isQueueable( GameMessage::MSG_DO_SPECIAL_POWER_AT_OBJECT ) );+ CHECK( OrderQueue::isQueueable( GameMessage::MSG_ENTER ) );+ CHECK( OrderQueue::isQueueable( GameMessage::MSG_DO_WEAPON_AT_LOCATION ) );++ // buying an upgrade without shift must not throw away the list of the unit it is for+ CHECK( !OrderQueue::isOrder( GameMessage::MSG_QUEUE_UPGRADE ) );}TEST(scenario_parses_the_order_lines)@@ -13260,6 +13268,22 @@ TEST(scenario_parses_the_order_lines)CHECK_STR( action.targetSelector.str(), "AmericaCommandCenter" );CHECK_EQ( (Int)ScenarioDrill_parseLine( "200 shiftattack 0 * 1", &action ), (Int)SCENARIO_PARSE_MISSING_ARGS );+ CHECK_EQ( (Int)ScenarioDrill_parseLine( "200 shiftpower 0 * 1 AmericaSupplyCenter SpecialAbilityBlackLotusCaptureBuilding",+ &action ), (Int)SCENARIO_PARSE_OK );+ CHECK_EQ( (Int)action.action, (Int)SCENARIO_ACTION_SHIFTPOWER );+ CHECK_STR( action.targetSelector.str(), "AmericaSupplyCenter" );+ CHECK_STR( action.name.str(), "SpecialAbilityBlackLotusCaptureBuilding" );+ CHECK_EQ( (Int)ScenarioDrill_parseLine( "200 shiftpower 0 * 1 AmericaSupplyCenter", &action ), (Int)SCENARIO_PARSE_MISSING_ARGS );++ CHECK_EQ( (Int)ScenarioDrill_parseLine( "200 shiftupgrade 0 ChinaTankOverlord Upgrade_ChinaOverlordGattlingCannon", &action ),+ (Int)SCENARIO_PARSE_OK );+ CHECK_EQ( (Int)action.action, (Int)SCENARIO_ACTION_SHIFTUPGRADE );+ CHECK_STR( action.name.str(), "Upgrade_ChinaOverlordGattlingCannon" );++ // a line read after one that named something must not carry that name+ CHECK_EQ( (Int)ScenarioDrill_parseLine( "200 shiftmove 0 * 900 700", &action ), (Int)SCENARIO_PARSE_OK );+ CHECK( action.name.isEmpty() );+CHECK_EQ( (Int)ScenarioDrill_parseLine( "1800 tally 1 ChinaGattlingCannon", &action ), (Int)SCENARIO_PARSE_OK );CHECK_EQ( (Int)action.action, (Int)SCENARIO_ACTION_TALLY );CHECK_STR( action.selector.str(), "ChinaGattlingCannon" );