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): spy drone shows its health bar again

Olcay Seyganbaf8dbf79475
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 40d9d984b..b433b8892 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -830,8 +830,9 @@ A third pass went through the generals' powers, promotions and unit abilities.
- A vehicle's load stays private.
- What you have selected wears a white frame just outside its bar, so a selection is still readable in a crowd where every unit carries a bar - and the bar itself keeps its owner colour all the way round.
- Lamps, barrels, rocks and bushes no longer wear health bars.
-- A soldier killed by toxin or fire no longer melts or runs burning under a full health bar. The game swaps the dead man for a stand-in that plays the death for three seconds, and with bars on for everyone that stand-in wore one, full to the end. Anything you cannot click, which the townsfolk walking about a map also are, goes without a bar now, as it did in the original.
- Nor does a booby trap. It cannot be shot and has one hit point, so its bar was a full green line that never moved, hanging over something that is meant to be hidden.
+- A soldier killed by toxin or fire no longer melts or runs burning under a full health bar. The game swaps the dead man for a stand-in that plays the death for three seconds, and with bars on for everyone that stand-in wore one, full to the end. Anything you cannot click, which the townsfolk walking about a map also are, goes without a bar now, as it did in the original.
+- The Spy Drone shows its health to its owner. It never had a bar: it is marked as something nothing can interact with, so enemies leave it alone, and the rule that keeps poison clouds bare took the drone's bar along with theirs. EA's own note on the drone's other marking says you can point at it to see its health, and now you can.
- Bridges no longer float a health bar over the middle of the river. There was never anything under it: the span is part of the terrain, and the bar belonged to an invisible marker standing in the water.
- The bar is part of the unit now: click it and you select whoever it belongs to. Zoomed out, an infantryman is a few pixels of helmet under a bar that is far easier to hit, and a unit half behind a building still has its bar in the clear. It only answers clicks that would have missed everything anyway, so it never takes a click away from the unit you were actually pointing at, and right-clicking bare ground under a bar still orders a move. And it stands down the moment you have something selected: with a force in hand your clicks are aimed at the ground, and a bar hanging over that ground used to cost you the whole selection and hand you back a single passer-by.
- The city itself stops wearing them too. A building nobody owns shows a bar only if there is something to do about it - troops can go inside, or it can be taken. A row of houses does not, and neither does the concrete apron each of them stands on, which is a separate two-thousand-point object that was drawing a second bar down at street level.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
index f065c8cce..8fcf77a67 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
@@ -437,13 +437,20 @@ Bool Drawable_structureShowsHealthBar( Bool isBridge, Bool isUnowned, Bool isGar
* over. The ones that matter are the death puppets: a soldier killed by toxin or fire is removed
* and a ToxicInfantry or FlamingInfantry takes his place, a live 50 hit point INFANTRY that melts
* or runs burning for three seconds, and always-on bars put a full one over every one of them.
- * Buildings keep their own rule below. */
+ * Buildings keep their own rule below.
+ *
+ * INERT is what the toxin and radiation fields carry, and the Spy Drone too: EA tags it INERT so
+ * nothing targets it and NO_SELECT so it cannot be selected, and NO_SELECT is commented in
+ * KindOf.h as "you can mouse over it to see its health (drones!)". So a NO_SELECT object keeps
+ * its bar whatever else it is; without that the owner never saw his drone's health at all. */
//-------------------------------------------------------------------------------------------------
Bool Drawable_kindShowsHealthBar( const KindOfMaskType& kinds )
{
+ if( TEST_KINDOFMASK( kinds, KINDOF_INERT ) && !TEST_KINDOFMASK( kinds, KINDOF_NO_SELECT ) )
+ return FALSE;
+
if( TEST_KINDOFMASK( kinds, KINDOF_PROJECTILE ) ||
TEST_KINDOFMASK( kinds, KINDOF_BOOBY_TRAP ) ||
- TEST_KINDOFMASK( kinds, KINDOF_INERT ) ||
TEST_KINDOFMASK( kinds, KINDOF_CLEANUP_HAZARD ) ||
TEST_KINDOFMASK( kinds, KINDOF_UNATTACKABLE ) ||
TEST_KINDOFMASK( kinds, KINDOF_PARACHUTE ) ||
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index 193d5df60..63cb4f091 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -7329,6 +7329,15 @@ TEST(a_toxin_or_fire_death_puppet_wears_no_health_bar)
CHECK( Drawable_kindShowsHealthBar( healthBarKinds( KINDOF_PROJECTILE, KINDOF_SELECTABLE ) ) == FALSE );
}
+/** The Spy Drone is VEHICLE DRONE SELECTABLE INERT NO_SELECT. INERT kept the toxin fields bare and
+ took the drone's bar with them, so its owner never saw its health. A field stays bare. */
+TEST(the_spy_drone_wears_a_health_bar_and_a_toxin_field_does_not)
+{
+ CHECK( Drawable_kindShowsHealthBar( healthBarKinds( KINDOF_SELECTABLE, KINDOF_INERT, KINDOF_NO_SELECT ) ) == TRUE );
+ CHECK( Drawable_kindShowsHealthBar( healthBarKinds( KINDOF_INERT ) ) == FALSE );
+ CHECK( Drawable_kindShowsHealthBar( healthBarKinds( KINDOF_INERT, KINDOF_SELECTABLE ) ) == FALSE );
+}
+
/** Being carried is not a malfunction, so a unit inside a transport keeps its owner's colour.
Anything else that disables it turns the bar blue - and the pair together used to fail: the old
test asked `isDisabled() && !isDisabledByType(DISABLED_HELD)`, so a held unit that was then EMP'd