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): draw the guard marker on the guarded spot

Olcay Seygan1bfbe03055c1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8f9a30921..b049f5b98 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -123,6 +123,7 @@ found and fixed — EA's own, not port damage.**
- The three buttons each do one thing now. Left selects, and only selects. Right gives orders, and nothing it does moves the camera. The camera is on the middle button, and it scrolls the way the right button used to: the spot you pressed on stays put, and the further you pull away from it the faster the map runs. Hold Ctrl and the same drag turns the view instead. 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.
- Drag the right 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. Draw the same line with attack move 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. 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. This is what the right button freed up. `FormationDrag = no` in Options.ini turns it off if you would rather a slipped click did nothing.
- Selected units draw a thread to wherever they are going, and the marker on the spot is the game's own cursor. Every order that has a cursor gets that cursor: move, attack move, attack, force fire, ground fire, enter, dock, repair, heal, capture, hack, guard, a waypoint path. Green for a move, pink for an attack-move, red for anything that shoots, so a group told three different things reads as three different colours. 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 marker sitting on the destination does not, and that marker stays for as long as the order does. A marker that has just appeared slides the last few pixels up out of the bottom right and fades in as it lands, over about an eighth of a second, so a fresh order catches your eye without anything flashing. 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 F 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. Ctrl still forces fire while you hold it. The two keys turn each other off, and the letters they took were sitting on grid commands that moved.
- With A armed, hold the left button and drag a circle instead: everything hostile you can see inside it becomes a target list, nearest first, and the selection works down that list on its own. When the current target dies the next order 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 ground inside the circle 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. A target with enough of your fire already in the air to kill it counts as done, so the rest of the group takes the next thing on the list rather than emptying itself into something that is dead and has not fallen over yet. Aircraft are what this is for: a flight fires from range and the missiles are seconds behind, and four planes used to spend all four loads on the first tank in the circle. 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.
- 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.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index 938741d24..791a07ab1 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -91,6 +91,7 @@
#include "GameLogic/Object.h"
#include "GameLogic/GameLogic.h"
#include "GameLogic/PartitionManager.h"
+#include "GameLogic/PolygonTrigger.h"
#include "GameLogic/TerrainLogic.h"
#include "GameLogic/ScriptEngine.h"
#include "GameLogic/Module/ContainModule.h"
@@ -3037,6 +3038,42 @@ Bool InGameUI::getHeldAircraftOrder( const Object *obj, OrderHintKind& kind, Coo
return TRUE;
}
+//-------------------------------------------------------------------------------------------------
+/** The spot a guarding unit is holding. A guard order clears the state machine before it starts,
+ * so the machine's goal position is the origin and reading it drew every guard marker in the
+ * bottom left corner of the map. What the unit is guarding is kept on the AI itself. */
+//-------------------------------------------------------------------------------------------------
+static Bool getGuardedSpot( const AIUpdateInterface *ai, Coord3D& spot )
+{
+ switch( ai->getGuardTargetType() )
+ {
+ case GUARDTARGET_LOCATION:
+ spot = *ai->getGuardLocation();
+ return TRUE;
+
+ case GUARDTARGET_OBJECT:
+ {
+ const Object *guarded = TheGameLogic->findObjectByID( ai->getGuardObject() );
+ if( guarded == NULL )
+ return FALSE;
+ spot = *guarded->getPosition();
+ return TRUE;
+ }
+
+ case GUARDTARGET_AREA:
+ {
+ const PolygonTrigger *area = ai->getAreaToGuard();
+ if( area == NULL )
+ return FALSE;
+ area->getCenterPoint( &spot );
+ return TRUE;
+ }
+
+ default:
+ return FALSE;
+ }
+}
+
//-------------------------------------------------------------------------------------------------
/** Where each selected unit is going, asked of the unit rather than remembered from the order. A
* line therefore lives exactly as long as the order behind it: it appears the frame the unit
@@ -3068,8 +3105,8 @@ void InGameUI::updateOrderHints( void )
OrderHint hint;
hint.owner = obj->getID();
- Coord3D heldOrderGoal;
- Bool isHoldingOrder = FALSE;
+ Coord3D resolvedGoal;
+ Bool goalResolved = FALSE;
switch( ai->getCurrentStateID() )
{
case AI_MOVE_TO:
@@ -3133,25 +3170,33 @@ void InGameUI::updateOrderHints( void )
case AI_GUARD:
case AI_GUARD_RETALIATE:
case AI_GUARD_TUNNEL_NETWORK:
+ {
+ // A guard order clears the state machine on its way in, so the goal position it leaves
+ // behind is the origin - and the marker landed in the bottom left corner of the map
+ // every time. The spot being guarded lives on the AI itself, so ask it there.
hint.kind = ORDER_HINT_GUARD;
+ if( !getGuardedSpot( ai, resolvedGoal ) )
+ continue;
+ goalResolved = TRUE;
break;
+ }
default:
// a parked aircraft is running its own takeoff state machine, not the order the player
// gave it, and that order is held out of reach of the goal until the wheels are up.
// Ask for it, or an air strike shows nothing at all during the seconds the plane spends
// taxiing, which is exactly when the player wants to see where it is going
- if( !getHeldAircraftOrder( obj, hint.kind, heldOrderGoal ) )
+ if( !getHeldAircraftOrder( obj, hint.kind, resolvedGoal ) )
continue;
- isHoldingOrder = TRUE;
+ goalResolved = TRUE;
break;
}
hint.from = *obj->getPosition();
- if( isHoldingOrder )
+ if( goalResolved )
{
- hint.to = heldOrderGoal;
+ hint.to = resolvedGoal;
}
else
{