Skip to content

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.

fix(gameclient): ctrl+shift drag draws the queued fire circle

Olcay Seygan0138b80c290a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 95ea7880c..10b9b0873 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -53,7 +53,7 @@ found and fixed — EA's own, not port damage.**
- The choice between a Classic and a Reforged interface is gone. There is one, laid out the way Zero Hour shipped, and the orders Reforged added now live on the keys you already know: A attack-moves, holding Ctrl fires on whatever is under the cursor as it did in 2003 (that hold is yours to move on the launcher's Command bar page), a guard order can cover a patch of ground instead of one spot, and orders queue up one after another. Everything your base is building stands on the screen as a line of text each, the six closest to done first and "+N more" for the rest. Superweapon countdowns are listed the same way, up to eighteen. Both lists are in bold type, the build list in white and each countdown in its owner's colour. The promotion screen no longer darkens the battlefield behind it. Whether the right button gives orders, or the left as in 1.04, is a setting in the launcher.
- An attack move and a Ctrl attack fire on the left click in every mouse setup. With the right button giving orders, A then a right click attack-moved, and Ctrl fired only on a right click, so the same hands did different things depending on one checkbox. Now A, or Ctrl held, then a left click is the attack everywhere, and a right click with A armed puts the key down without an order. Ctrl with a right click gives none. Plain orders stay on whichever button your setup gives them.
-- Combat units that attack-move now have a Force Attack button on the command bar, under Attack Move and left of Stop. Base defences that shoot have it too: the Patriot Battery of every general, the Gattling Cannon, the Fire Base, the Stinger Site and the Bunker, wherever their bar has a free place, so a defence can fire on the ground or on a friendly. So does the Air Force General's Combat Chinook. In the Bunker and the Chinook it is the soldiers inside who fire, and Ctrl on a garrisoned Bunker now takes a unit as its target as well as the ground; before, only the ground. A Tunnel Network's bar is full, and so is the Infantry General's ten-man Bunker, so neither gets the button. It arms the same fire-on-whatever-is-under-the-pointer mode the hold key has always given. The hold is Ctrl until you change it on the launcher's Hotkeys page, Command bar tab, and the button wears whatever you bound. Shift plus that hold still draws a selection box. This version's data checksum differs, so it cannot join a game hosted on an older one.
+- Combat units that attack-move now have a Force Attack button on the command bar, under Attack Move and left of Stop. Base defences that shoot have it too: the Patriot Battery of every general, the Gattling Cannon, the Fire Base, the Stinger Site and the Bunker, wherever their bar has a free place, so a defence can fire on the ground or on a friendly. So does the Air Force General's Combat Chinook. In the Bunker and the Chinook it is the soldiers inside who fire, and Ctrl on a garrisoned Bunker now takes a unit as its target as well as the ground; before, only the ground. A Tunnel Network's bar is full, and so is the Infantry General's ten-man Bunker, so neither gets the button. It arms the same fire-on-whatever-is-under-the-pointer mode the hold key has always given. The hold is Ctrl until you change it on the launcher's Hotkeys page, Command bar tab, and the button wears whatever you bound. Shift on top of that hold keeps it: the pointer stays the force-fire one and a drag still draws the fire circle, its targets queued. This version's data checksum differs, so it cannot join a game hosted on an older one.
- The dark plate behind Exit, Restart and the options screen in a match covers the whole picture. It used to sit in a 4:3 frame in the middle, so a widescreen left the battlefield bright down both sides. The box itself keeps the shape it was drawn in.
- Buildings select together again, which the one interface had taken away. Shift-click them, drag a box over them, or double-click one for every building of its kind on the screen; select four War Factories and each tank you click goes to whichever has the shortest queue. Double-click a unit and every one of that kind whose feet sit in the picture is taken, including the ones sitting past the camera's far clip that used to be skipped. A building and a unit still never share a selection.
- Formation lines are back for everyone. With move, attack move or guard armed, a left drag spreads the selection along the line you draw again; since the one interface it drew a selection box instead, because the line was switched off for the Classic mouse that every player now runs. A drag with no order armed is still the selection box.
@@ -349,7 +349,7 @@ found and fixed — EA's own, not port damage.**
## Selecting and ordering with the mouse
- Ctrl+Q now takes infantry only, not every armed thing you own.
-- A box drawn with Ctrl held takes those units back out of your selection instead of replacing it, so a group is trimmed by dragging over the corner of it rather than picked again from scratch. Held with Alt the box keeps only what can shoot: drag across your base and you get the tanks, not the dozers and supply trucks standing among them. Both are drag-only, and a single click still means exactly what it always did. Hold Ctrl and Shift and drag: the units in the box are selected. Ctrl alone still draws the fire circle.
+- A box drawn with Ctrl held takes those units back out of your selection instead of replacing it, so a group is trimmed by dragging over the corner of it rather than picked again from scratch. Held with Alt the box keeps only what can shoot: drag across your base and you get the tanks, not the dozers and supply trucks standing among them. Both are drag-only, and a single click still means exactly what it always did. Hold Ctrl and Shift and drag and you draw the fire circle, the same as with Ctrl alone, and its targets go on the end of what the group is already working through. Pressing Shift used to let go of the Ctrl hold, so the pointer turned back into the ordinary one and the drag grew a selection box instead.
- A box dragged over your army and your economy together takes the army. The dozers, workers, supply trucks and hackers standing among the tanks stay where they are, and ambulances and troop carriers go with the soldiers they look after. A box with nobody military in it takes the workers the way it always did.
- The three buttons are split cleanly now. Left selects, and only selects. A right click gives the order, and a right drag scrolls the map the way it did in 2003: the spot you pressed on stays put, and the further you pull away from it the faster the map runs. The drag only starts once the pointer has really travelled, so a click your hand wobbles a pixel or two is still an order and the camera does not twitch. A pan never throws away the building on your cursor or the power you were about to aim. The middle button turns the view, with no key held, and a middle click without a drag puts the camera back where it started. The wheel zooms toward whatever the cursor is over and the screen edges still scroll. The classic scheme, where left both selected and commanded and right scrolled and deselected, is gone rather than switched off, and the two checkboxes that used to choose between them are out of the options screen.
- How far the pointer travels before a click becomes a drag is yours to set. Drag Threshold on Options > Controls runs from 2 to 50 pixels, and the game's own value was 25. Raise it if selection boxes start by accident, lower it if your drags are read as clicks.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index d58a82a18..8863a9487 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -4086,8 +4086,8 @@ Bool InGameUI::issueAttackCircle( void )
previousAttacker = attacker.id;
// each unit's first shot starts that unit's list. the rest of its run is queued behind it.
- // shift appends the whole run onto whatever that one unit was already doing.
- const Bool startsList = firstForThisAttacker && !isInWaypointMode();
+ // shift, or the waypoint key, appends the whole run onto whatever that one unit was already doing.
+ const Bool startsList = firstForThisAttacker && !isInWaypointMode() && !TheKeyboard->isShift();
markNextOrderQueued( startsList ? ORDER_QUEUE_FRESH : ORDER_QUEUE_APPEND );
GameMessage *attack = TheMessageStream->appendMessage( GameMessage::MSG_DO_ATTACK_OBJECT );
attack->appendObjectIDArgument( target.id );
@@ -4280,8 +4280,8 @@ Int InGameUI::issueAttackLine( const std::vector<Coord3D>& line )
previousAttacker = attacker.id;
// each unit's first shot starts that unit's list. the rest of its run is queued behind it.
- // shift appends the whole run onto whatever that one unit was already doing.
- const Bool startsList = firstForThisAttacker && !isInWaypointMode();
+ // shift, or the waypoint key, appends the whole run onto whatever that one unit was already doing.
+ const Bool startsList = firstForThisAttacker && !isInWaypointMode() && !TheKeyboard->isShift();
markNextOrderQueued( startsList ? ORDER_QUEUE_FRESH : ORDER_QUEUE_APPEND );
GameMessage *attack = TheMessageStream->appendMessage( GameMessage::MSG_DO_ATTACK_OBJECT );
attack->appendObjectIDArgument( target.id );
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
index 2a69fe6c4..ad977328e 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
@@ -451,13 +451,17 @@ static const char * findGameMessageNameByType(GameMessage::Type type)
/** The command bar slot keys have to behave exactly like a click on the cell they press, and a
* shift-click on a build button queues a whole batch instead of one unit. Holding shift must
* therefore not stop the slot from matching. Every other modifier still has to match exactly,
- * and a slot the player deliberately bound to shift is compared as-is. */
+ * and a slot the player deliberately bound to shift is compared as-is. The Force Attack hold is
+ * the same: shift on top of it queues the circle, so pressing shift must neither end the hold nor
+ * stop it from starting. */
//-------------------------------------------------------------------------------------------------
static Bool metaIgnoresShift(const MetaMapRec *map)
{
- return map->m_meta >=GameMessage::MSG_META_COMMAND_SLOT01 &&
- map->m_meta <= GameMessage::MSG_META_COMMAND_SLOT18 &&
- (map->m_modState & SHIFT) == 0;
+ const Bool slot = map->m_meta >= GameMessage::MSG_META_COMMAND_SLOT01 &&
+ map->m_meta <= GameMessage::MSG_META_COMMAND_SLOT18;
+ const Bool forceAttackHold = map->m_meta == GameMessage::MSG_META_BEGIN_FORCEATTACK ||
+ map->m_meta == GameMessage::MSG_META_END_FORCEATTACK;
+ return ( slot || forceAttackHold ) && (map->m_modState & SHIFT) == 0;
}
//-------------------------------------------------------------------------------------------------
@@ -529,6 +533,10 @@ GameMessageDisposition MetaEventTranslator::translateGameMessage(const GameMessa
if( map->m_modState != wantedModState )
continue;
+ // letting go of shift alone does not end what never needed shift
+ if( metaIgnoresShift( map ) && ( ( newModState | SHIFT ) & heldModState ) == heldModState )
+ continue;
+
TheMessageStream->appendMessage( map->m_meta );
}
}
@@ -563,13 +571,17 @@ GameMessageDisposition MetaEventTranslator::translateGameMessage(const GameMessa
- // check for the special case of mods-only-changed.
+ // check for the special case of mods-only-changed. A record that ignores shift sees the
+ // modifiers without it, so shift going down or up under Ctrl is no change at all to it.
+ const Int modMask = metaIgnoresShift(map) ? ~SHIFT : ~0;
+ const Int lastMods = m_lastModState & modMask;
+ const Int newMods = newModState & modMask;
if (
- map->m_key == MK_NONE &&
- newModState != m_lastModState &&
+ map->m_key == MK_NONE &&
+ newMods != lastMods &&
(
- (map->m_transition == UP && map->m_modState == m_lastModState) ||
- (map->m_transition == DOWN && map->m_modState == newModState)
+ (map->m_transition == UP && map->m_modState == lastMods) ||
+ (map->m_transition == DOWN && map->m_modState == newMods)
)
)
{
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
index 8bc59fa32..9ef24dfc9 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
@@ -1104,12 +1104,10 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
// with the attack key armed or the Force Attack hold down the left button draws a circle
// instead of a selection box, and everything hostile inside it becomes a target list. An
- // armed line key (move, attack move, guard) keeps its line under the hold. Hold+Shift is
- // the box: you can pick units without dropping force-fire. Shift with the attack key
- // armed still queues a circle.
+ // armed line key (move, attack move, guard) keeps its line under the hold. Shift on top
+ // of the hold or the attack key still draws the circle and queues its targets.
if( TheInGameUI->isForceFireOn() && !TheInGameUI->isLineOrderArmed() && TheInGameUI->getSelectCount() > 0
- && TheInGameUI->getGUICommand() == NULL && TheInGameUI->getPendingPlaceType() == NULL
- && !( TheInGameUI->isInForceAttackMode() && TheKeyboard->isShift() ) )
+ && TheInGameUI->getGUICommand() == NULL && TheInGameUI->getPendingPlaceType() == NULL )
TheInGameUI->beginAttackCircle( m_selectFeedbackAnchor );
break;
}