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): g drags a guard line again, ctrl circle back to red

Olcay Seygan82bf6769ac0f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8f4ba232f..bcc50a72b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -312,8 +312,8 @@ found and fixed — EA's own, not port damage.**
- 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. 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.
-- G is guard, armed the same way and aimed with the same left button. A left click posts the selection on that spot: they hold it, shoot what walks into range and do not chase it off the post you put them on. G looks the way Zero Hour's own guard button always looked: the targeting cross, with the guard range laid on the ground under it, and the mouse wheel still zooms the camera. A right click puts the key down again. Hold position, which posts every unit on the spot it is already standing on, has moved to H.
-- With A armed, or with Ctrl held down, hold the left button and drag a circle instead: the enemies you can see inside it are split across the units that can shoot, as evenly as the numbers allow, in the order both sides stand around the circle. The tank on the left of your group takes the enemy on the left of theirs. Ten of yours against three of theirs put four guns on one and three on each of the others. Three of yours against ten of theirs each take a run of three or four and work down that run. One enemy, and every selected gun takes it. When a unit's target dies the next of its own goes out the same frame, so a strike group clears a circle without you clicking once per tank. It moves on from a target the group has stopped working on, too, rather than only from a dead one: something none of them can reach or hurt used to sit at the head of the list and hold every other target behind it for the rest of the match. That list is the same queue a shift-clicked attack builds, so you can see it: every target still owed has its own thread and marker, in the order they will be taken, instead of one line to whatever is being shot at this second. Hold shift while you draw the circle and its targets go on the end of what the group is already working through; draw it without shift and the circle replaces the lot. The circle's rim is drawn in green with the same line as your order lines, and the ground inside it is washed red while you drag it, painted on the map rather than over it, so it runs up the hills inside the circle and your own tanks stand on top of it. Any order you give by hand ends the list. Losing a unit does not: the list belongs to the group that was told and carries on with whoever is left, which is worth saying because for a while it did not, and one tank dying threw away every target still owed. Running out of ammo does not cost you the list either. A flight that empties its racks flies home, lands, rearms and comes back to the target it left, and the queue waits for it instead of counting the trip as the group giving up: a circle drawn for four planes used to be empty by the time they were back in the air, one entry lost every two seconds they were away. The threads stay on the ground for the whole trip, too. A plane flying home has no target and no order to read, so the list it was still holding used to vanish off the map the moment it turned for base and reappear only when it was shooting again, which looks exactly like the list being thrown away. What the circle picks up is what you can shoot: a shell or a missile crossing it is on the enemy's side like everything else and used to go on the list as a target, costing the group a two second stall on something that was about to stop existing. A target that has driven into the shroud since you picked it keeps its place in the list but stops drawing its thread, so the line cannot be used to trace it through the fog. An attack-move queued behind other orders keeps the force fire it was given rather than losing it when the attack key drops. A stroke drawn across enemies splits them across the units that can shoot, as evenly as the numbers allow, in the order both sides stand along the stroke. The unit nearest the start takes the enemy nearest the start. Ten guns on three enemies put four on one and three on each of the others. Three guns on ten each work down a run of three or four. The whole group used to walk one list and pour every gun into each enemy in turn. Before that the line poured fire into the ground under it and hit whatever happened to be standing there. A stroke that crosses nobody still fires on the ground along it.
+- G is guard, armed the same way and aimed with the same left button. A left click posts the selection on that spot: they hold it, shoot what walks into range and do not chase it off the post you put them on. G looks the way Zero Hour's own guard button always looked: the targeting cross, with the guard range laid on the ground under it, and the mouse wheel still zooms the camera. The guard button on the command bar arms the same key, so it clicks and drags the same way. Drag the left button with G armed and they post along the line you draw, one unit per station, the way an attack move line spreads them, which is how a hill or a bridge approach gets covered in one gesture instead of a click per tank. A right click puts the key down again. Hold position, which posts every unit on the spot it is already standing on, has moved to H.
+- With A armed, or with Ctrl held down, hold the left button and drag a circle instead: the enemies you can see inside it are split across the units that can shoot, as evenly as the numbers allow, in the order both sides stand around the circle. The tank on the left of your group takes the enemy on the left of theirs. Ten of yours against three of theirs put four guns on one and three on each of the others. Three of yours against ten of theirs each take a run of three or four and work down that run. One enemy, and every selected gun takes it. When a unit's target dies the next of its own goes out the same frame, so a strike group clears a circle without you clicking once per tank. It moves on from a target the group has stopped working on, too, rather than only from a dead one: something none of them can reach or hurt used to sit at the head of the list and hold every other target behind it for the rest of the match. That list is the same queue a shift-clicked attack builds, so you can see it: every target still owed has its own thread and marker, in the order they will be taken, instead of one line to whatever is being shot at this second. Hold shift while you draw the circle and its targets go on the end of what the group is already working through; draw it without shift and the circle replaces the lot. The circle's rim is red and the ground inside it is washed the same red while you drag it, painted on the map rather than over it, so it runs up the hills inside the circle and your own tanks stand on top of it. Any order you give by hand ends the list. Losing a unit does not: the list belongs to the group that was told and carries on with whoever is left, which is worth saying because for a while it did not, and one tank dying threw away every target still owed. Running out of ammo does not cost you the list either. A flight that empties its racks flies home, lands, rearms and comes back to the target it left, and the queue waits for it instead of counting the trip as the group giving up: a circle drawn for four planes used to be empty by the time they were back in the air, one entry lost every two seconds they were away. The threads stay on the ground for the whole trip, too. A plane flying home has no target and no order to read, so the list it was still holding used to vanish off the map the moment it turned for base and reappear only when it was shooting again, which looks exactly like the list being thrown away. What the circle picks up is what you can shoot: a shell or a missile crossing it is on the enemy's side like everything else and used to go on the list as a target, costing the group a two second stall on something that was about to stop existing. A target that has driven into the shroud since you picked it keeps its place in the list but stops drawing its thread, so the line cannot be used to trace it through the fog. An attack-move queued behind other orders keeps the force fire it was given rather than losing it when the attack key drops. A stroke drawn across enemies splits them across the units that can shoot, as evenly as the numbers allow, in the order both sides stand along the stroke. The unit nearest the start takes the enemy nearest the start. Ten guns on three enemies put four on one and three on each of the others. Three guns on ten each work down a run of three or four. The whole group used to walk one list and pour every gun into each enemy in turn. Before that the line poured fire into the ground under it and hit whatever happened to be standing there. A stroke that crosses nobody still fires on the ground along it.
- 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.
@@ -336,7 +336,7 @@ found and fixed — EA's own, not port damage.**
- A Chinook unloads its passengers one at a time, not stacked in one frame.
- Campaign reinforcements flown in by Chinook land again. That one-at-a-time unloading sent a mission's scripted Chinooks home with their cargo still aboard, so on the second American mission the dozers announced at the docks never got off, and neither did the next one.
- A guarding unit no longer fights itself between returning to post and shooting back.
-- Guard covers the ground you draw. A click with G armed, or with the guard button, is the guard Zero Hour always had. Hold the left button and drag instead, and the circle you pull out is what the whole group guards: one circle for everyone, drawn in green as you drag it. Rangers and Missile Defenders posted on one spot used to hold circles of 180 and 270 of their own, so a raider standing between the two was only shot by half the group. Every unit of yours on guard carries a small steel shield over its head, selected or not, in place of the blocky "G" it used to wear. The shield has smooth edges and a lit and a shaded half, and it shrinks as you zoom out the way the health bars do: at 1080p it was 24 pixels tall over every unit at every zoom, and it is now 18 up close and 11 from the opening camera, about the height of an infantryman's head.
+- Every unit of yours on guard carries a small steel shield over its head, selected or not, in place of the blocky "G" it used to wear. The shield has smooth edges and a lit and a shaded half, and it shrinks as you zoom out the way the health bars do: at 1080p it was 24 pixels tall over every unit at every zoom, and it is now 18 up close and 11 from the opening camera, about the height of an infantryman's head.
- An Ambulance cleans up the toxins around it without being told. Its hose reaches 100, and that was all it ever looked at, so one parked a truck's length from a toxin pool sat and watched it. Standing idle or on guard, it now notices a pool, an anthrax cloud or a radiation field up to 300 away, drives over, washes off every one in that circle, and goes back to where it stood; one that was on guard is back on guard. A unit you are moving is never pulled off its order, and any order you give while it is cleaning ends the cleanup. Put down 150 to 250 from two Ambulances, one idle and one guarding, three poison fields were gone inside 16 seconds, both trucks were back on their spots, and a third Ambulance driving past a fourth field went straight on to where it was sent. The Cleanup Area button works better for it too: an Ambulance sent to clean an area used to shoot only at what was already in reach once it got there and stood still in front of the rest, and once the area was clean it never counted as idle again, so it ignored the next spill. Replays recorded before this change play out differently.
- Jets on guard attack what is inside the circle you drew. A plane on guard flies to its post and circles it, and since guards stopped shooting at enemies hidden in fog it only went after what that loop brought into its own sight: a Raptor guarding a circle of 700 hung over the post for the whole 80 seconds of the test with a power plant 550 out, and an Aurora circled for ten seconds before it found the same one. Aircraft are back on the original rule and take anything in the circle, fog or not. The Raptor's first missiles now land 11 seconds after the order and the Aurora's bomb after 9, and neither flies over the post first. Ground units still leave alone what they cannot see. A replay recorded before this change plays back differently.
- H now sets a stance for the group. Defensive is how your units have always behaved: they fire on what comes into range and stay put. Aggressive lets them go after anything they can see, the way the computer's own units do, so a group left on aggressive clears the ground around it without being told. The button shows the stance the selection holds.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
index aa92cbbf4..d17d6bd74 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h
@@ -511,10 +511,8 @@ public: // ********************************************************************
// A circle dragged out with the left button while the attack key is armed or Ctrl is held. The
// enemies inside it are shared across the units that can shoot, in the order both sides stand
- // around the circle, and each unit works down its own share. Dragged with a guard armed (the G
- // key or EA's guard button) the circle is the ground the group guards instead.
- void beginAttackCircle( const ICoord2D& pt, Bool guards );
- Bool isGuardCircling( void ) const { return m_isAttackCircling && m_attackCircleGuards; }
+ // around the circle, and each unit works down its own share.
+ void beginAttackCircle( const ICoord2D& pt );
void updateAttackCircle( const ICoord2D& pt );
Bool issueAttackCircle( void ); ///< FALSE when the press never became a drag, so it was an ordinary attack click
Int issueAttackLine( const std::vector<Coord3D>& line ); ///< enemies the stroke crosses, shared along it across the units that can shoot
@@ -1130,8 +1128,9 @@ public: // ********************************************************************
// and the guard key arms guard the same way: the next order click posts the selection on that
// spot, or on that object, and a drag posts them along the line instead of stacking them all
// on one point. All the armed keys are one mode at a time
- void toggleGuardArmed( void ) { m_guardArmed = !m_guardArmed; m_attackMoveToMode = FALSE; m_forceAttackArmed = FALSE; m_moveArmed = FALSE; }
+ void toggleGuardArmed( void ) { m_guardArmed = !m_guardArmed; m_guardArmedMode = GUARDMODE_GUARD_WITHOUT_PURSUIT; m_attackMoveToMode = FALSE; m_forceAttackArmed = FALSE; m_moveArmed = FALSE; }
Bool isGuardArmed( void ) const { return m_guardArmed; }
+ GuardMode getGuardArmedMode( void ) const { return m_guardArmedMode; } ///< what the armed guard's click gives: the key's, or the EA button's own
/** One of the page's keys past attack, hold position and move, an OrderKeyExtra (ControlBar.h),
* pressed with the mouse or its grid key: the stance key puts the selection on the other
@@ -1142,7 +1141,7 @@ public: // ********************************************************************
// that move, and a left drag draws the formation line
void toggleMoveArmed( void ) { m_moveArmed = !m_moveArmed; m_attackMoveToMode = FALSE; m_forceAttackArmed = FALSE; m_guardArmed = FALSE; }
Bool isMoveArmed( void ) const { return m_moveArmed; }
- Bool isLineOrderArmed( void ) const { return m_attackMoveToMode || m_moveArmed; } ///< a left drag draws a move or attack move line; force fire's and guard's left drag is a circle
+ 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
// 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.
@@ -1325,7 +1324,6 @@ protected:
std::vector<OrderHint> m_drawnOrderHints; ///< the same, units headed the same way bunched into one
Bool m_isAttackCircling; ///< TRUE while an attack circle is being dragged (fork)
- Bool m_attackCircleGuards; ///< the circle being dragged is a guard area, not a target list
ICoord2D m_attackCircleAnchor; ///< where the circle was started, in pixels
ICoord2D m_attackCircleCursor; ///< where the cursor is now, which is the rim
@@ -1564,6 +1562,7 @@ protected:
Bool m_attackMoveToMode; ///< are we in attack move mode?
Bool m_forceAttackArmed; ///< is the attack key holding force fire for the next click?
Bool m_guardArmed; ///< is the guard key holding a guard order for the next click?
+ GuardMode m_guardArmedMode; ///< the mode that guard order carries
Bool m_moveArmed; ///< is the move key holding a move for the next click?
Bool m_orderKeyKeptByShift; ///< an armed key was clicked with under shift, and drops when shift comes up
Bool m_preferSelection; ///< the shift key has been depressed.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index a99a27f98..9460e16a9 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -1224,11 +1224,11 @@ InGameUI::InGameUI()
m_attackMoveToMode = false;
m_forceAttackArmed = false;
m_guardArmed = false;
+ m_guardArmedMode = GUARDMODE_GUARD_WITHOUT_PURSUIT;
m_moveArmed = false;
m_orderKeyKeptByShift = false;
m_preferSelection = false;
m_isAttackCircling = FALSE;
- m_attackCircleGuards = FALSE;
m_curRcType = RADIUSCURSOR_NONE;
@@ -2718,11 +2718,11 @@ void InGameUI::reset( void )
m_attackMoveToMode = false;
m_forceAttackArmed = false;
m_guardArmed = false;
+ m_guardArmedMode = GUARDMODE_GUARD_WITHOUT_PURSUIT;
m_moveArmed = false;
m_orderKeyKeptByShift = false;
m_preferSelection = false;
m_isAttackCircling = FALSE;
- m_attackCircleGuards = FALSE;
m_clientQuiet = false;
// TheSuperHackers @bugfix A key or button still held when the game ended left its camera
@@ -3917,10 +3917,9 @@ void InGameUI::addOrderHint( OrderHint& hint, const std::vector<OrderHint>& prev
/** The attack key is armed and the player has pressed the left button: from here a drag draws a
* circle rather than a selection box. */
//-------------------------------------------------------------------------------------------------
-void InGameUI::beginAttackCircle( const ICoord2D& pt, Bool guards )
+void InGameUI::beginAttackCircle( const ICoord2D& pt )
{
m_isAttackCircling = TRUE;
- m_attackCircleGuards = guards;
m_attackCircleAnchor = pt;
m_attackCircleCursor = pt;
DEBUG_LOG(("attack circle: begun at %d,%d with %d selected\n", pt.x, pt.y, getSelectCount()));
@@ -3950,10 +3949,6 @@ Bool InGameUI::getAttackCircleGround( Coord3D& center, Real& radius ) const
const Real dy = rim.y - center.y;
radius = (Real)sqrt( dx * dx + dy * dy );
- // logic caps a guard's circle, so the one drawn stops where the order will
- if( m_attackCircleGuards )
- radius = min( radius, GUARD_RADIUS_MAX );
-
// a press that has not been dragged anywhere is a click, not a circle
return radius >= 1.0f;
}
@@ -3981,29 +3976,6 @@ Bool InGameUI::issueAttackCircle( void )
if( !wasDragged )
return FALSE;
- // a guard circle is one order: the group guards its centre and everything inside its rim
- if( m_attackCircleGuards )
- {
- GuardMode mode = GUARDMODE_GUARD_WITHOUT_PURSUIT; // what the G key's click gives
- const CommandButton *command = getGUICommand();
- if( command && command->getCommandType() == GUI_COMMAND_GUARD )
- mode = GUARDMODE_NORMAL;
- else if( command && command->getCommandType() == GUI_COMMAND_GUARD_FLYING_UNITS_ONLY )
- mode = GUARDMODE_GUARD_FLYING_UNITS_ONLY;
- if( command )
- setGUICommand( NULL );
-
- if( isInWaypointMode() )
- markNextOrderQueued( ORDER_QUEUE_APPEND );
- GameMessage *guard = TheMessageStream->appendMessage( GameMessage::MSG_DO_GUARD_POSITION );
- guard->appendLocationArgument( center );
- guard->appendIntegerArgument( mode );
- guard->appendRealArgument( radius );
- pickAndPlayUnitVoiceResponse( getAllSelectedDrawables(), GameMessage::MSG_DO_GUARD_POSITION );
- DEBUG_LOG(("guard circle: radius %.0f at %.0f,%.0f\n", radius, center.x, center.y));
- return TRUE;
- }
-
const Player *local = ThePlayerList->getLocalPlayer();
// who can actually shoot. a dozer standing in the selection is not given somebody else's target.
@@ -5059,6 +5031,22 @@ void InGameUI::setGUICommand( const CommandButton *command )
if (TheRecorder->getMode() == RECORDERMODETYPE_PLAYBACK)
return;
+ // EA's guard buttons, and their hotkey, arm the guard key with the button's own mode instead of
+ // waiting as a pending command, so a button press and the key click and drag the same way
+ if( command && ( command->getCommandType() == GUI_COMMAND_GUARD ||
+ command->getCommandType() == GUI_COMMAND_GUARD_WITHOUT_PURSUIT ||
+ command->getCommandType() == GUI_COMMAND_GUARD_FLYING_UNITS_ONLY ) )
+ {
+ const GuardMode mode = command->getCommandType() == GUI_COMMAND_GUARD ? GUARDMODE_NORMAL
+ : command->getCommandType() == GUI_COMMAND_GUARD_WITHOUT_PURSUIT ? GUARDMODE_GUARD_WITHOUT_PURSUIT
+ : GUARDMODE_GUARD_FLYING_UNITS_ONLY;
+ setGUICommand( NULL );
+ clearAttackMoveToMode();
+ m_guardArmed = TRUE;
+ m_guardArmedMode = mode;
+ return;
+ }
+
// sanity
if( command )
{
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
index b0871ada1..f98b81184 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
@@ -1012,9 +1012,9 @@ GameMessage::Type CommandTranslator::issueMoveToLocationCommand( const Coord3D *
movemsg->appendLocationArgument( *pos );
// a posted unit holds its spot and shoots what walks into range, rather than chasing it
- // off the post the player put it on
+ // off the post the player put it on. EA's guard button armed it with its own mode
if (msgType == GameMessage::MSG_DO_GUARD_POSITION)
- movemsg->appendIntegerArgument( GUARDMODE_GUARD_WITHOUT_PURSUIT );
+ movemsg->appendIntegerArgument( TheInGameUI->getGuardArmedMode() );
} // end if
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cpp
index 245d09614..4260a3c28 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cpp
@@ -208,59 +208,6 @@ static CommandStatus doFireWeaponCommand( const CommandButton *command, const IC
} // end fire weapon
-//-------------------------------------------------------------------------------------------------
-//-------------------------------------------------------------------------------------------------
-static CommandStatus doGuardCommand( const CommandButton *command, GuardMode guardMode, const ICoord2D *mouse )
-{
- // sanity
- if( command == NULL || mouse == NULL )
- return COMMAND_COMPLETE;
-
- if( TheInGameUI->getSelectCount() == 0 )
- return COMMAND_COMPLETE;
-
- GameMessage *msg = NULL;
-
- if ( msg == NULL && BitTest( command->getOptions(), COMMAND_OPTION_NEED_OBJECT_TARGET ) )
- {
- // get the target object under the cursor
- Object* target = validUnderCursor( mouse, command, PICK_TYPE_SELECTABLE );
- if( target )
- {
- msg = TheMessageStream->appendMessage( GameMessage::MSG_DO_GUARD_OBJECT );
- msg->appendObjectIDArgument( target->getID() );
- msg->appendIntegerArgument(guardMode);
- pickAndPlayUnitVoiceResponse(TheInGameUI->getAllSelectedDrawables(), GameMessage::MSG_DO_GUARD_OBJECT);
- }
- }
-
- if( msg == NULL )
- {
- Coord3D world;
- if (BitTest( command->getOptions(), NEED_TARGET_POS ))
- {
- // translate the mouse location into world coords
- TheTacticalView->screenToTerrain( mouse, &world );
- }
- else
- {
- Drawable *draw = TheInGameUI->getFirstSelectedDrawable();
- if( draw == NULL || draw->getObject() == NULL )
- return COMMAND_COMPLETE;
- world = *draw->getObject()->getPosition();
- }
-
- // create the message and append arguments
- msg = TheMessageStream->appendMessage( GameMessage::MSG_DO_GUARD_POSITION );
- msg->appendLocationArgument(world);
- msg->appendIntegerArgument(guardMode);
- pickAndPlayUnitVoiceResponse(TheInGameUI->getAllSelectedDrawables(), GameMessage::MSG_DO_GUARD_POSITION);
- }
-
- return COMMAND_COMPLETE;
-
-}
-
//-------------------------------------------------------------------------------------------------
/** Do the attack move command: Classic's attack move button, a GUI command as in 1.04 */
//-------------------------------------------------------------------------------------------------
@@ -435,26 +382,7 @@ GameMessageDisposition GUICommandTranslator::translateGameMessage(const GameMess
break;
}
- //---------------------------------------------------------------------------------------
- case GUI_COMMAND_GUARD:
- {
- commandStatus = doGuardCommand( command, GUARDMODE_NORMAL, &mouse );
- break;
- }
-
- //---------------------------------------------------------------------------------------
- case GUI_COMMAND_GUARD_WITHOUT_PURSUIT:
- {
- commandStatus = doGuardCommand( command, GUARDMODE_GUARD_WITHOUT_PURSUIT, &mouse );
- break;
- }
-
- //---------------------------------------------------------------------------------------
- case GUI_COMMAND_GUARD_FLYING_UNITS_ONLY:
- {
- commandStatus = doGuardCommand( command, GUARDMODE_GUARD_FLYING_UNITS_ONLY, &mouse );
- break;
- }
+ // EA's guard buttons never wait here: setGUICommand arms the guard key instead
//Special weapons are now always context commands...
//---------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
index 4c1d2b224..4b6cef748 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
@@ -629,10 +629,7 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
if( command )
{
- if( command->getCommandType() == GUI_COMMAND_ATTACK_MOVE ||
- command->getCommandType() == GUI_COMMAND_GUARD ||
- command->getCommandType() == GUI_COMMAND_GUARD_WITHOUT_PURSUIT ||
- command->getCommandType() == GUI_COMMAND_GUARD_FLYING_UNITS_ONLY )
+ if( command->getCommandType() == GUI_COMMAND_ATTACK_MOVE )
{
//These GUI commands can take care of themselves -- don't let
//the selection translator meddle.
@@ -1120,19 +1117,11 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
m_selectFeedbackAnchor = msg->getArgument( 0 )->pixel;
// with the attack key armed or Ctrl held the left button draws a circle instead of a
- // selection box, and everything hostile inside it becomes a target list. With a guard armed
- // the circle is the ground to guard
- if( TheInGameUI->getSelectCount() > 0 && TheInGameUI->getPendingPlaceType() == NULL )
- {
- const CommandButton *command = TheInGameUI->getGUICommand();
- const Bool guardCommand = command && ( command->getCommandType() == GUI_COMMAND_GUARD ||
- command->getCommandType() == GUI_COMMAND_GUARD_WITHOUT_PURSUIT ||
- command->getCommandType() == GUI_COMMAND_GUARD_FLYING_UNITS_ONLY );
- if( TheInGameUI->isGuardArmed() || guardCommand )
- TheInGameUI->beginAttackCircle( m_selectFeedbackAnchor, TRUE );
- else if( TheInGameUI->isForceFireOn() && command == NULL )
- TheInGameUI->beginAttackCircle( m_selectFeedbackAnchor, FALSE );
- }
+ // selection box, and everything hostile inside it becomes a target list. An armed line key
+ // (move, attack move, guard) keeps its line under Ctrl
+ if( TheInGameUI->isForceFireOn() && !TheInGameUI->isLineOrderArmed() && TheInGameUI->getSelectCount() > 0
+ && TheInGameUI->getGUICommand() == NULL && TheInGameUI->getPendingPlaceType() == NULL )
+ TheInGameUI->beginAttackCircle( m_selectFeedbackAnchor );
break;
}
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.h
index 5eed7a92f..070290cb6 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DInGameUI.h
@@ -82,6 +82,7 @@ protected:
virtual void drawBuildGrid( void ); ///< the pathfinder's build grid under a pending structure
virtual void drawAttackCircleFill( void ); ///< the wash on the ground inside an attack circle
virtual void drawFormationLine( void ); ///< the line an armed left drag is spreading the selection along
+ virtual void drawAttackCircle( void ); ///< the circle a left drag is sweeping targets out of
RenderObjClass *m_buildingPlacementAnchor;
RenderObjClass *m_buildingPlacementArrow;
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp
index 42c3ae99a..88bba1847 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp
@@ -402,6 +402,8 @@ void W3DInGameUI::reset( void )
} // end reset
+static void drawGroundRing( const Coord3D& center, Real radius, UnsignedInt color, Real width );
+
/// -directorrecord's lines between panes and the radar's frame: the brand's gold (zerohour.gg's
/// --gold, #f2c230) between two edges of its ground (--bg, #0c1220), so they read on snow and on
/// night maps alike
@@ -595,6 +597,10 @@ void W3DInGameUI::draw( void )
if( m_isFormationDragging )
drawFormationLine();
+ // the attack circle, while the left button is still sweeping it out
+ if( isAttackCircling() )
+ drawAttackCircle();
+
// for each view draw hints
/// @todo should the UI be iterating through views like this?
if( TheDisplay )
@@ -975,7 +981,7 @@ void W3DInGameUI::drawAttackCircleFill( void )
{
Coord3D center;
Real radius;
- if( isGuardCircling() || !getAttackCircleGround( center, radius ) )
+ if( !getAttackCircleGround( center, radius ) )
return;
enum { FILL_SEGMENTS = 48, FILL_RINGS = 6 };
@@ -1054,6 +1060,7 @@ void W3DInGameUI::drawFormationLine( void )
// 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
+ : isGuardArmed() ? 0xCC55CCFF
: 0xCC33FF33; //0xAARRGGBB
const std::vector<ICoord2D>& curve = m_formationDragPoints;
const Int points = (Int)curve.size();
@@ -1066,6 +1073,60 @@ void W3DInGameUI::drawFormationLine( void )
} // end drawFormationLine
+//-------------------------------------------------------------------------------------------------
+/** A circle on the ground, not on the screen, so it follows the terrain the way the units it is
+ * about do */
+//-------------------------------------------------------------------------------------------------
+static void drawGroundRing( const Coord3D& center, Real radius, UnsignedInt color, Real width )
+{
+ const Int segments = 48;
+
+ ICoord2D previous;
+ Bool havePrevious = FALSE;
+ for( Int i = 0; i <= segments; ++i )
+ {
+ const Real angle = 2.0f * PI * (Real)i / (Real)segments;
+ Coord3D world;
+ world.x = center.x + radius * (Real)cos( angle );
+ world.y = center.y + radius * (Real)sin( angle );
+ world.z = TheTerrainLogic->getGroundHeight( world.x, world.y );
+
+ ICoord2D screen;
+ if( TheTacticalView->worldToScreenTriReturn( &world, &screen ) == View::WTS_INVALID )
+ {
+ havePrevious = FALSE;
+ continue;
+ }
+
+ if( havePrevious )
+ TheDisplay->drawLine( previous.x, previous.y, screen.x, screen.y, width, color );
+
+ previous = screen;
+ havePrevious = TRUE;
+ }
+}
+
+//-------------------------------------------------------------------------------------------------
+/** draw the circle a left drag is sweeping targets out of */
+//-------------------------------------------------------------------------------------------------
+void W3DInGameUI::drawAttackCircle( void )
+{
+ Coord3D center;
+ Real radius;
+ if( !getAttackCircleGround( center, radius ) )
+ return;
+
+ drawGroundRing( center, radius, 0xCCFF5555, 2.0f ); // the attack red the hints use
+
+ // and the radius itself, so the drag reads as a radius rather than a rubber band
+ ICoord2D middle;
+ center.z = TheTerrainLogic->getGroundHeight( center.x, center.y );
+ if( TheTacticalView->worldToScreenTriReturn( &center, &middle ) != View::WTS_INVALID )
+ TheDisplay->drawLine( middle.x, middle.y, getAttackCircleCursor().x,
+ getAttackCircleCursor().y, 1.0f, 0x66FF5555 );
+
+} // end drawAttackCircle
+
//-------------------------------------------------------------------------------------------------
/** EA's animated ring on the ground where a move order landed, 40 client frames each. EA's own
* code, deleted by fec052cc and brought back (InGameUI::createMoveHint fills it). */
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3dWaypointBuffer.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3dWaypointBuffer.cpp
index c6fc75102..eb894f4bd 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3dWaypointBuffer.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3dWaypointBuffer.cpp
@@ -141,10 +141,6 @@ void W3DWaypointBuffer::queueLine( Int numPoints, Vector3 *points )
{
if( m_linesUsed >= (Int)m_linePool.size() )
m_linePool.push_back( new SegmentedLineClass( *m_line ) ); // copies texture, shader, width, color
- // a pooled line keeps the colour it was made with, so it takes the current one every time
- Vector3 color;
- m_line->Get_Color( color );
- m_linePool[ m_linesUsed ]->Set_Color( color );
m_linePool[ m_linesUsed++ ]->Set_Points( numPoints, points );
}
@@ -344,9 +340,7 @@ void W3DWaypointBuffer::drawWaypoints(RenderInfoClass &rinfo)
m_line->Set_Width( 3.0f );
m_line->Set_Points( numPoints, points );
- m_line->Render( localRinfo );
- setDefaultLineStyle(); // queueLine takes m_line's colour
- }
+ m_line->Render( localRinfo ); }
}
//////////////////////////////////////////////////////////////////////
@@ -607,26 +601,6 @@ void W3DWaypointBuffer::drawWaypoints(RenderInfoClass &rinfo)
}
}
- // the circle a left drag is sweeping out (attack key, Ctrl, guard) is drawn with the order lines'
- // own line, in green, lying on the ground it covers
- Coord3D center;
- Real radius;
- if( TheInGameUI->getAttackCircleGround( center, radius ) && !ShaderClass::Is_Backface_Culling_Inverted() )
- {
- enum { RING_SEGMENTS = 48 };
- Vector3 ring[ RING_SEGMENTS + 1 ];
- for( Int i = 0; i <= RING_SEGMENTS; ++i )
- {
- const Real angle = 2.0f * PI * (Real)i / (Real)RING_SEGMENTS;
- const Real x = center.x + radius * (Real)cos( angle );
- const Real y = center.y + radius * (Real)sin( angle );
- ring[ i ].Set( x, y, TheTerrainLogic->getGroundHeight( x, y ) );
- }
- m_line->Set_Color( Vector3( 0.2f, 1.0f, 0.2f ) );
- queueLine( RING_SEGMENTS + 1, ring );
- setDefaultLineStyle();
- }
-
// every line of every block above goes out after the last puck
if( m_linesUsed > 0 )
{