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(w3ddevice): red ctrl+shift attack line, smooth drag strokes

Olcay Seygan98bcd8fe3922
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5e65c60fd..1c749008b 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, drawn like an attack-move line, 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. 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. 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 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/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp
index 681078e86..5f982da8d 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp
@@ -1062,7 +1062,7 @@ void W3DInGameUI::drawFormationLine( void )
const Real width = 2.0f;
// the line says which order it is about to be, in the colours the order hints already use
const UnsignedInt color = isInAttackMoveToMode() ? 0xCCFF66CC
- : isForceAttackArmed() ? 0xCCFF5555
+ : ( isForceAttackArmed() || isForceLineHeld() ) ? 0xCCFF5555
: isGuardArmed() ? 0xCC55CCFF
: 0xCC33FF33; //0xAARRGGBB
const std::vector<ICoord2D>& curve = m_formationDragPoints;
@@ -1070,9 +1070,35 @@ void W3DInGameUI::drawFormationLine( void )
if( points < 2 )
return;
+ // the kept points are a dozen pixels apart or more, and joined straight they read as a jagged
+ // polyline. A Catmull-Rom spline through them draws the same curve smooth and still passes
+ // through every point the order carries, so the picture and the order agree where it matters
+ const Int STEPS = 8;
+ Real lastX = (Real)curve[ 0 ].x;
+ Real lastY = (Real)curve[ 0 ].y;
for( Int i = 1; i < points; ++i )
- TheDisplay->drawLine( curve[ i - 1 ].x, curve[ i - 1 ].y, curve[ i ].x, curve[ i ].y,
- width, color );
+ {
+ const ICoord2D& p0 = curve[ i > 1 ? i - 2 : 0 ];
+ const ICoord2D& p1 = curve[ i - 1 ];
+ const ICoord2D& p2 = curve[ i ];
+ const ICoord2D& p3 = curve[ i + 1 < points ? i + 1 : points - 1 ];
+ for( Int s = 1; s <= STEPS; ++s )
+ {
+ const Real t = (Real)s / (Real)STEPS;
+ const Real t2 = t * t;
+ const Real t3 = t2 * t;
+ const Real x = 0.5f * ( 2.0f * p1.x + ( p2.x - p0.x ) * t
+ + ( 2.0f * p0.x - 5.0f * p1.x + 4.0f * p2.x - p3.x ) * t2
+ + ( 3.0f * p1.x - p0.x - 3.0f * p2.x + p3.x ) * t3 );
+ const Real y = 0.5f * ( 2.0f * p1.y + ( p2.y - p0.y ) * t
+ + ( 2.0f * p0.y - 5.0f * p1.y + 4.0f * p2.y - p3.y ) * t2
+ + ( 3.0f * p1.y - p0.y - 3.0f * p2.y + p3.y ) * t3 );
+ TheDisplay->drawLine( (Int)floorf( lastX + 0.5f ), (Int)floorf( lastY + 0.5f ),
+ (Int)floorf( x + 0.5f ), (Int)floorf( y + 0.5f ), width, color );
+ lastX = x;
+ lastY = y;
+ }
+ }
} // end drawFormationLine