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.

feat(gameclient): colour health bars by their owning player

Olcay Seygan7f6c6d82cabc
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9c6287298..ffa0d7e3e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -137,6 +137,11 @@ Around it, the whole production loop got tightened:
- **Aircraft always show how many attack runs they have left**, selected or not. That is the number
that decides whether you commit them or send them home.
+**Health bars are in the owner's colour.** They used to run green to red by how damaged something
+was — which is what the length of the bar was already telling you — and told you nothing about whose
+it was. In the middle of a fight that is the question you actually have. They now match the colour
+the minimap and the selection rings use, so you can read a brawl without clicking anything.
+
## Twenty-two-year-old bugs, found by testing
Nothing here was guessed at. Every fix in this section came out of a test written against the
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
index 24ddb3c39..8b21715fc 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
@@ -3949,7 +3949,27 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)
outlineColor = GameMakeColor( 0, healthRatio * 128.0f, 128, 255 );//dark blue to dark cyan
}
- else //red to green
+ else if( obj->getControllingPlayer() != NULL &&
+ obj->getControllingPlayer()->getPlayerColor() != 0 )
+ {
+ //
+ // The bar wears its owner's colour. Red-to-green said how hurt a thing was, which the
+ // length of the bar was already saying, and said nothing at all about whose it was -
+ // the one question a glance across a busy fight actually needs answered. Player colour
+ // is what the minimap, the selection rings and the unit tint all use, so a green bar
+ // means the same thing everywhere on screen.
+ //
+ // The outline stays a darkened version of the same colour, so a light player colour
+ // still reads against light terrain. The under-construction / disabled blue above keeps
+ // its own colour: that is a state, not an owner, and it applies to your own buildings.
+ //
+ UnsignedByte r, g, b, a;
+ GameGetColorComponents( obj->getControllingPlayer()->getPlayerColor(), &r, &g, &b, &a );
+
+ color = GameMakeColor( r, g, b, 255 ); // the stored colour's alpha is not ours to trust
+ outlineColor = GameDarkenColor( color, 60 );
+ }
+ else //red to green: civilians, crates, anything with no owning player to borrow a colour from
{
RGBColor inColor, outColor;