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.

feat(gameclient): shift drag draws the move line over a walking selection

Olcay Seygan1e136d6819f4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1c749008b..8e12d052b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -349,12 +349,12 @@ 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 and you draw a freehand attack line, red like the circle, and on release the enemies near it are shared out as targets. Ctrl alone still draws the fire circle. 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 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 a freehand attack line, red like the circle, and on release the enemies near it are shared out as targets. Ctrl alone still draws the fire circle. Shift alone and a drag draws the move line V draws, as long as something you have selected can walk it; with nothing like that selected, Shift and a drag is still the box that adds to your selection, and a Shift click still adds one unit. 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.
- An isometric camera, on Options > Controls. It looks at the battlefield from far off through a narrow lens, so a tank at the top of the screen is drawn the same size as one at the bottom and a base reads like a city-builder's plan instead of shrinking into the distance. It buys no extra sight. The normal camera's corners, edges and centre are laid over the isometric screen as closely as a flat picture allows, hills and ultrawide screens included: the normal camera still sees a little more at the far corners and the isometric one the same amount more at the near corners, because a perspective view is wider at the back than at the front and an isometric one is not. Pan across a ridge and the picture holds its size and its angle; it does not rise and dip with the ground under it. Campaign cinematics are filmed with the normal camera whatever the box says, and the isometric view comes back when the black bars go. They are shot from ten feet off the ground looking up at a rocket leaving its pad or a skyline, and the isometric camera turned each of those shots into a view from above of somewhere else: the picture lurched sideways every time the shot tilted, and a low shot ran off the edge of the map into a white screen. With the box ticked, USA 1's opening now plays the way it does without it. You still turn and zoom it the way you always did, and the box takes effect the moment you tick it, mid-match included.
-- Press V, or the move button, then drag the left button and you draw a line: the selection spreads itself evenly along it, in the order the units already stand, so a column arrives as a firing line instead of a queue. While you drag, it is drawn as a smooth curve through the points the order carries; it used to be a jagged chain of short straight pieces. It is the line you actually drew, curves and all, however far you keep drawing it: a long sweep used to give up partway through and finish as one straight run to the cursor, and now it holds its shape to the end. Letting go over the sidebar finishes the order rather than leaving the line stuck to the cursor. A line pulled up past the horizon into the sky ends where the ground does: the stretch over the sky used to land in one corner of the map, and the units whose stations fell on it walked off there. A soldier riding in a transport or sitting in a bunker gets no station on a move or attack-move line, as a plain click has always left him where he is, so the units that can walk share the whole line instead of leaving gaps where the riders were counted. Draw the line with the left button while attack move is armed and the whole line is an attack move: artillery spread across a front, each gun firing on what walks into it, instead of one clump on one spot. Guard draws the same way. Every line is drawn with the left button, the one armed orders are aimed with, and the right button never draws one: its drag is the camera. Without an order armed a left drag is the selection box it always was. Armed with attack instead, every unit fires on its own station along the line, which is a barrage laid across a ridge in one drag. `FormationDrag = no` in Options.ini turns the line off if you would rather an armed drag did nothing.
+- Press V, or the move button, then drag the left button, or just hold Shift and drag, and you draw a line: the selection spreads itself evenly along it, in the order the units already stand, so a column arrives as a firing line instead of a queue. While you drag, it is drawn as a smooth curve through the points the order carries; it used to be a jagged chain of short straight pieces. It is the line you actually drew, curves and all, however far you keep drawing it: a long sweep used to give up partway through and finish as one straight run to the cursor, and now it holds its shape to the end. Letting go over the sidebar finishes the order rather than leaving the line stuck to the cursor. A line pulled up past the horizon into the sky ends where the ground does: the stretch over the sky used to land in one corner of the map, and the units whose stations fell on it walked off there. A soldier riding in a transport or sitting in a bunker gets no station on a move or attack-move line, as a plain click has always left him where he is, so the units that can walk share the whole line instead of leaving gaps where the riders were counted. Draw the line with the left button while attack move is armed and the whole line is an attack move: artillery spread across a front, each gun firing on what walks into it, instead of one clump on one spot. Guard draws the same way. Every line is drawn with the left button, the one armed orders are aimed with, and the right button never draws one: its drag is the camera. Without an order armed a left drag is the selection box it always was. Armed with attack instead, every unit fires on its own station along the line, which is a barrage laid across a ridge in one drag. `FormationDrag = no` in Options.ini turns the line off if you would rather an armed drag did nothing.
- Selected units draw a line to wherever they are going, and it looks like a building's rally point: EA's blue rally line, with the rally flag in your colour planted on the ground they are headed for. A selected factory shows that one flag at the rally you set; a second disc used to sit at the door as well, so the path around the building read as two destinations. Every order draws one: move, attack move, attack, force fire, ground fire, enter, dock, repair, heal, capture, hack, guard, a waypoint path. An order aimed at something rather than somewhere, a tank to kill, a building to shoot, take or climb into, a unit to guard, ends on the line's joint instead of a flag, a small disc sitting just over the target and riding along with it while it drives, so a flag never stands on a tank. A shift list runs one line through all its stops, a joint on each and the flag on the last bit of ground. With order lines on, that last point gets a joint under its flag as well, so the end of the line reads the same as every stop before it. Units standing together and headed the same way share one thread, from the middle of the knot to the middle of where they are going, so twenty tanks sent across the map draw one line instead of twenty laid on top of each other; a selection spread over the map draws one per knot, and a flank sent on its own still shows. An angry mob draws one thread for the whole mob, not one per rioter. An attack move and a shot at the ground both point at the spot you clicked: the attack move's thread used to wander off to whichever free ground each unit was steering for, and ground fire pointed at the middle of the nearest map cell. An attack move stays pink from start to finish, too. A unit that stopped to fight used to swing its thread onto the enemy it was fighting, and only swung it back to your destination once the enemy was dead. It is not a flash at the moment of the order: the line is asked of the unit every frame, so it lasts until the unit gets there, changes its mind or leaves your selection, and it shows on the formation line while you are still drawing it. A unit that has walked off the edge of the screen still draws its line, which is how you see where the half of your army you cannot see is headed. The animated ring the ground used to sprout wherever you clicked is gone: it flashed for a second and told you nothing the flag on the destination does not, and the flag stays for as long as the order does. Aircraft draw their thread from the click, not from the moment they leave the runway. A plane parked on its airfield answers an order by starting its takeoff and puts the order itself aside until the wheels are up, so the taxi and the climb, which is exactly the stretch where you are wondering whether the strike went out at all, used to show nothing.
- A unit standing guard draws its marker on the ground it is guarding. A guard order clears the unit's goal on the way in, so every guard marker used to sit in the bottom left corner of the map with a thread running the whole way across it, whatever the unit was actually watching.
- A is attack and D is attack move, each arming the next order click. A click on the ground with A held down is a shot at that ground, on your own tank a shot at your own tank, and the mode drops again the moment the order goes out, so nothing stays armed behind your back. The click keeps your group, too: an attack click that was not a drag used to run the same deselect an ordinary left click runs, so the order arrived a moment after the units it was meant for had been dropped. Both orders are aimed with the left button, the way a special power is, and a right click puts the key down again without giving any order. Holding ctrl no longer forces fire: A is the one way to shoot the ground, and ctrl on a move is only the shared pace. The two keys turn each other off, and the letters they took were sitting on grid commands that moved. With A armed, pointing at something nothing in your selection can shoot shows the game's can't-do-that pointer: a Sentry Drone before its gun is researched has no weapon at all, and the pointer used to look ready while the click did nothing.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
index 2d6f4ebcd..372829f23 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
@@ -1142,6 +1142,7 @@ public: // ********************************************************************
Bool isMoveArmed( void ) const { return m_moveArmed; }
Bool isLineOrderArmed( void ) const { return m_attackMoveToMode || m_guardArmed || m_moveArmed; } ///< a left drag draws a move, attack move or guard line; force fire's left drag is the attack circle
Bool isForceLineHeld( void ) const; ///< the Force Attack hold with shift: a left drag draws the attack line, not the circle
+ Bool isMoveLineHeld( void ) const; ///< shift alone over a selection that can walk: a left drag draws the move line, not the box
// zeroing the repeat clock makes the first quantized step happen on the very next update, so a
// tap of the key is one eighth and a hold is one eighth every CAMERA_SNAP_REPEAT_MS.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/SelectionXlat.h b/GeneralsMD/Code/GameEngine/Include/GameClient/SelectionXlat.h
index 94e21f833..1a797ffc8 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/SelectionXlat.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/SelectionXlat.h
@@ -49,6 +49,7 @@ private:
Bool m_leftMouseButtonIsDown;
Bool m_dragSelecting;
+ Bool m_leftDragIsLine; ///< latched at the press: this left drag draws an order line, so no box grows (fork)
Bool m_dragOrderJustIssued; ///< an attack circle or a left-drawn order line just went out, so eat the click that ends it (fork)
UnsignedInt m_lastGroupSelTime;
Int m_lastGroupSelGroup;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index b92ba6e1d..9151d91f3 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -4976,6 +4976,29 @@ Bool InGameUI::isForceLineHeld( void ) const
return m_forceAttackMode && !isLineOrderArmed() && TheKeyboard->isShift();
}
+//-------------------------------------------------------------------------------------------------
+/** Shift with no key armed draws the move line, the one V draws, when something selected of yours
+ * can walk it. With nothing that walks selected there is no line to draw and shift's drag stays
+ * the box that adds to the selection. Ctrl and Alt on top keep their own meanings, and a GUI
+ * command or a structure on the cursor (shift drags a row of them) owns the drag. */
+//-------------------------------------------------------------------------------------------------
+Bool InGameUI::isMoveLineHeld( void ) const
+{
+ if( !TheKeyboard->isShift() || TheKeyboard->isCtrl() || TheKeyboard->isAlt() )
+ return FALSE;
+ if( !TheGlobalData->m_formationDrag || isOrderKeyArmed() || m_forceAttackMode
+ || getGUICommand() != NULL || m_pendingPlaceType != NULL )
+ return FALSE;
+
+ for( DrawableList::const_iterator it = m_selectedDrawables.begin(); it != m_selectedDrawables.end(); ++it )
+ {
+ const Object *obj = (*it)->getObject();
+ if( obj && obj->isLocallyControlled() && !obj->isKindOf( KINDOF_IMMOBILE ) && obj->getAIUpdateInterface() != NULL )
+ return TRUE;
+ }
+ return FALSE;
+}
+
//-------------------------------------------------------------------------------------------------
/// Get drawable ID under cursor
//-------------------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
index 5936e2bf8..1d1a0aef1 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
@@ -4104,12 +4104,12 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
// A formation line is drawn with the left button, and only once the move, attack move or guard
// key is armed: a left drag without one is a selection box. The attack key and the Force
// Attack hold keep their left drag for the attack circle; shift on the hold draws the attack
- // line here instead, aimed at the enemies near it.
+ // line here instead, aimed at the enemies near it. Shift alone draws the move line.
case GameMessage::MSG_RAW_MOUSE_LEFT_DOUBLE_CLICK:
case GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_DOWN:
{
const Bool forceLine = TheInGameUI->isForceLineHeld();
- if( TheInGameUI->isLineOrderArmed() || forceLine )
+ if( TheInGameUI->isLineOrderArmed() || forceLine || TheInGameUI->isMoveLineHeld() )
{
m_formationDragAnchor = msg->getArgument( 0 )->pixel;
m_formationDragArmed = isFormationDragArmed();
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
index cb2f61589..bae987497 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
@@ -303,6 +303,7 @@ SelectionTranslator::SelectionTranslator()
{
m_leftMouseButtonIsDown = FALSE;
m_dragSelecting = FALSE;
+ m_leftDragIsLine = FALSE;
m_dragOrderJustIssued = FALSE;
m_lastGroupSelTime = 0;
m_lastGroupSelGroup = -1;
@@ -456,7 +457,7 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
// with attack move or guard armed a left drag draws the order line over in CommandXlat, so
// no selection box grows under it, whichever mouse is set. A drag with no key armed is the box
- const Bool leftDragIsOrder = ( TheInGameUI->isLineOrderArmed() || TheInGameUI->isForceLineHeld()
+ const Bool leftDragIsOrder = ( TheInGameUI->isLineOrderArmed() || m_leftDragIsLine
|| TheInGameUI->isFormationDragging() )
&& TheInGameUI->getSelectCount() > 0;
if (m_leftMouseButtonIsDown && !leftDragIsOrder)
@@ -1103,6 +1104,11 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
m_leftMouseButtonIsDown = true;
m_selectFeedbackAnchor = msg->getArgument( 0 )->pixel;
+ // the line keys are asked again on every move; the two holds are latched here, the same
+ // moment CommandXlat latches the line, so letting go of shift mid-drag cannot grow a box
+ // under a line that is already being drawn
+ m_leftDragIsLine = TheInGameUI->isForceLineHeld() || TheInGameUI->isMoveLineHeld();
+
// 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, and shift on top