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.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(gameclient): no health bar over toxin and fire death puppets
Olcay Seygan08740fb14735
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 680c7ff8e..40d9d984b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -830,6 +830,7 @@ 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.- 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.diff --git a/GeneralsMD/Code/GameEngine/Include/Common/ThingTemplate.h b/GeneralsMD/Code/GameEngine/Include/Common/ThingTemplate.hindex 8c394f5e8..8715a4ec1 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/ThingTemplate.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/ThingTemplate.h@@ -412,6 +412,8 @@ public:{return TEST_KINDOFMASK_ANY(m_kindof, anyKindOf);}++ inline const KindOfMaskType& getKindOfMask() const { return m_kindof; }/// set the display nameconst UnicodeString& getDisplayName() const { return m_displayName; } ///< return display namediff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.hindex 04ccd9878..850a305ca 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h@@ -85,6 +85,9 @@ extern Real Drawable_effectiveOpacity( Real explicitOpacity, Real stealthOpacityextern Bool Drawable_structureShowsHealthBar( Bool isBridge, Bool isUnowned, Bool isGarrisonable,Bool isCapturable );+///< whether an object of these kinds is a thing that wears a health bar at all+extern Bool Drawable_kindShowsHealthBar( const KindOfMaskType& kinds );+///< whether the health bar setting lets this object show one right nowextern Bool Drawable_healthBarModeShows( Int healthBarMode, Bool isSelected, Bool isMousedOver,Bool isDamaged );diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cppindex e8f977232..f065c8cce 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp@@ -417,6 +417,48 @@ Bool Drawable_structureShowsHealthBar( Bool isBridge, Bool isUnowned, Bool isGarreturn TRUE;}+//-------------------------------------------------------------------------------------------------+/** Health bars are always on in this fork, so anything with a body would draw one. Effect objects+ * (projectiles in flight, toxin and radiation fields, parachutes, fire walls, wrecked hulks,+ * subobject turrets) are not things the player commands or targets, so their bars are pure+ * clutter.+ *+ * So is the scenery: street lamps, phone boxes, barrels, planters, fire hydrants, rocks, bushes+ * and the odd tree all carry a BodyModule. The rule is fixed-in-place-and-not-a-building, not a+ * list of scenery kinds: the shipped data does not tag that furniture as PROP or SHRUBBERY at all+ * (`KindOf = IMMOBILE CLEARED_BY_BUILD` is the whole of a street lamp), while every real target+ * is either mobile or a STRUCTURE.+ *+ * A booby trap has one hit point and cannot be shot, so its bar was a full green line forever.+ * Everything force-attackable is a civilian fence with one hit point.+ *+ * And a unit the cursor cannot reach at all - no SELECTABLE, which in EA's data means "the mouse+ * can interact with it" - never wore a bar in retail, where a bar needed a selection or a mouse+ * 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. */+//-------------------------------------------------------------------------------------------------+Bool Drawable_kindShowsHealthBar( const KindOfMaskType& kinds )+{+ 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 ) ||+ TEST_KINDOFMASK( kinds, KINDOF_HULK ) ||+ TEST_KINDOFMASK( kinds, KINDOF_CLICK_THROUGH ) ||+ TEST_KINDOFMASK( kinds, KINDOF_CRATE ) ||+ TEST_KINDOFMASK( kinds, KINDOF_FORCEATTACKABLE ) )+ return FALSE;++ if( TEST_KINDOFMASK( kinds, KINDOF_STRUCTURE ) )+ return TRUE;++ return !TEST_KINDOFMASK( kinds, KINDOF_IMMOBILE ) && TEST_KINDOFMASK( kinds, KINDOF_SELECTABLE );+}+//-------------------------------------------------------------------------------------------------/** The health bar setting, applied to one object.*@@ -4452,36 +4494,8 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)if( obj == NULL )return;- //- // health bars are always on in this fork, so anything with a body draws one. Effect- // objects (projectiles in flight, toxin and radiation fields, parachutes, fire walls,- // wrecked hulks, subobject turrets) are not things the player commands or targets, so- // their bars are pure clutter.- //- // So is the scenery: street lamps, phone boxes, barrels, planters, fire hydrants, rocks,- // bushes and the odd tree all carry a BodyModule and so all drew a bar, and a built-up map- // came up wearing hundreds of them over things nobody fights.- //- // The rule is fixed-in-place-and-not-a-building, not a list of scenery kinds: the shipped- // data does not tag that furniture as PROP or SHRUBBERY at all (`KindOf = IMMOBILE- // CLEARED_BY_BUILD` is the whole of a street lamp, and `IMMOBILE` the whole of a rock), so- // a kind list catches almost none of it, while every real target is either mobile or a- // STRUCTURE. Buildings keep their bars - a civilian building is cover to garrison, a tech- // building is worth capturing, bridges are STRUCTURE too - and so does anything that can- // move.- //- // A booby trap has one hit point and cannot be shot, so its bar was a full green line- // forever, over something that is meant to be hidden.- if( obj->isKindOf( KINDOF_PROJECTILE ) ||- obj->isKindOf( KINDOF_BOOBY_TRAP ) ||- obj->isKindOf( KINDOF_INERT ) ||- obj->isKindOf( KINDOF_CLEANUP_HAZARD ) ||- obj->isKindOf( KINDOF_UNATTACKABLE ) ||- obj->isKindOf( KINDOF_PARACHUTE ) ||- obj->isKindOf( KINDOF_HULK ) ||- obj->isKindOf( KINDOF_CLICK_THROUGH ) ||- obj->isKindOf( KINDOF_CRATE ) ||- ( obj->isKindOf( KINDOF_IMMOBILE ) && !obj->isKindOf( KINDOF_STRUCTURE ) ) )+ // effect objects, scenery and death puppets wear none (Drawable_kindShowsHealthBar)+ if( !Drawable_kindShowsHealthBar( obj->getTemplate()->getKindOfMask() ) )return;if( obj->isKindOf( KINDOF_STRUCTURE ) )@@ -4505,15 +4519,6 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)return;}- if( obj->isKindOf( KINDOF_FORCEATTACKABLE ) )- {- //Currently (Nov 2002), everything that is forceattackable are civ fences, and they all have a- //single hit point and they aren't selectable. However, a bug is when you force attack it, it shows- //the healthbar. Well, this stops it, however, should force attackable kindofs change, then this- //will require reevaluation.- return;- }-// get body module of objectBodyModuleInterface *body = obj->getBodyModule();diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 6f72b8f71..193d5df60 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -7309,6 +7309,26 @@ TEST(an_owned_structure_always_wears_a_health_bar)CHECK( Drawable_structureShowsHealthBar( FALSE, FALSE, TRUE, FALSE ) == TRUE );}+static KindOfMaskType healthBarKinds( KindOfType a, KindOfType b = KINDOF_INVALID, KindOfType c = KINDOF_INVALID )+{+ KindOfMaskType m = MAKE_KINDOF_MASK( a );+ if( b != KINDOF_INVALID ) m.set( b );+ if( c != KINDOF_INVALID ) m.set( c );+ return m;+}++/** A soldier killed by toxin or fire is replaced by a ToxicInfantry or FlamingInfantry, a live+ 50 hit point INFANTRY with no SELECTABLE that melts or burns for three seconds. It wore a full bar+ the whole time. A unit the cursor can reach keeps its bar, and so does a building. */+TEST(a_toxin_or_fire_death_puppet_wears_no_health_bar)+{+ CHECK( Drawable_kindShowsHealthBar( healthBarKinds( KINDOF_CAN_CAST_REFLECTIONS, KINDOF_INFANTRY ) ) == FALSE );+ CHECK( Drawable_kindShowsHealthBar( healthBarKinds( KINDOF_INFANTRY, KINDOF_SELECTABLE ) ) == TRUE );+ CHECK( Drawable_kindShowsHealthBar( healthBarKinds( KINDOF_STRUCTURE ) ) == TRUE );+ CHECK( Drawable_kindShowsHealthBar( healthBarKinds( KINDOF_IMMOBILE, KINDOF_SELECTABLE ) ) == FALSE );+ CHECK( Drawable_kindShowsHealthBar( healthBarKinds( KINDOF_PROJECTILE, 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 oldtest asked `isDisabled() && !isDisabledByType(DISABLED_HELD)`, so a held unit that was then EMP'd