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
feat(gameclient): health bars in the player's colour as an option
Olcay Seygan4b3b3aed9a9f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex fc07a4c49..6462f940f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -933,7 +933,7 @@ A third pass went through the generals' powers, promotions and unit abilities.- You pick who wears one. `HealthBars` in `Options.ini` takes 0 for everyone, 1 for smart, 2 for the selection only and 3 for nobody. Smart is the one worth trying: a bar over a unit at full health tells you what its absence would have told you, so healthy units go bare and anything that has been hit stays marked, with whatever you have selected or are pointing at readable either way. 2 is what the original game did. The default is 0, so nothing changes until you change it.- A health bar keeps its size against the unit at any resolution. It was a fixed number of pixels wide and three tall, so the bigger the screen the thinner the thread over a tank.-- Health bars are green to red again, the way Zero Hour drew them: green at full health, yellow at half, red near the end. For a while they wore the owner's colour, and a red player's healthy tank looked like one about to die. A disabled building keeps the blue.+- Health bars are green to red again, the way Zero Hour drew them: green at full health, yellow at half, red near the end. For a while they wore the owner's colour, and a red player's healthy tank looked like one about to die. A disabled building keeps the blue. If you liked knowing whose a bar was at a glance, the launcher's Options page has it back as a choice: Health Bar Color set to Player Color paints every bar in its owner's colour, and the length alone says how hurt it is. Green to red stays the default.- A building's bar sits above its roof rather than inside its art.- A unit that is inside a transport and also disabled wears the blue bar. Being carried and being knocked out were asked as one question, so the two together answered no: a squad EMP'd inside a bunker, or hacked while riding a Battle Bus, looked perfectly healthy from outside.- A building being captured wears a capture clock under its health bar, filling in the colour of whoever is taking it. The building flashes while a rifleman works on it, which says somebody is at the door and nothing about whether that is nearly over: the choice between driving across to shoot him and carrying on with your fight was made blind. The bar runs from the moment he reaches the door to the moment the building changes hands, and Black Lotus hacking one gets the same bar.diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.hindex f56732819..870ed329e 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h@@ -349,6 +349,7 @@ public:Bool m_debugAIObstacles; ///< Used to display AI obstacle debug informationBool m_showObjectHealth; ///< debug display object healthInt m_healthBarMode; ///< HealthBarModeType: which units wear a bar at all+ Int m_healthBarColors; ///< 0 the green-to-red health ramp, 1 the owner's player colour (client only)Int m_mouseStyle; ///< MOUSE_STYLE_CLASSIC or MOUSE_STYLE_REFORGED, set by -mouse only (client only, never GameLogic)Bool isClassicMouse() const { return m_mouseStyle == MOUSE_STYLE_CLASSIC; }/// which button gives a click on the ground its order. Reforged mouse: the right. Classic: the left,diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cppindex 7a69aca91..7c20d0d0d 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp@@ -966,6 +966,7 @@ GlobalData::GlobalData()m_showObjectHealth = FALSE;// what this fork has always done, so nobody's game changes until they say som_healthBarMode = HEALTH_BAR_ALWAYS;+ m_healthBarColors = 0;// the game's own mouse unless the launcher passes -mouse reforgedm_mouseStyle = MOUSE_STYLE_CLASSIC;// the lobby's own colours until somebody asks for something elsediff --git a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cppindex 5aeba38ce..ce9d2fe0d 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp@@ -98,6 +98,7 @@ OPTION_BOOL_ACCESSORS( m_vsync )OPTION_BOOL_ACCESSORS( m_classicGraphics )OPTION_INT_ACCESSORS( m_lightingStyle )OPTION_INT_ACCESSORS( m_healthBarMode )+OPTION_INT_ACCESSORS( m_healthBarColors )OPTION_INT_ACCESSORS( m_playerColorScheme )OPTION_INT_ACCESSORS( m_textLanguage )OPTION_BOOL_ACCESSORS( m_showOrderLines )@@ -398,6 +399,13 @@ const OptionDef TheOptionCatalog[] =OPTION_ENUM, APPLY_LIVE, 0, HEALTH_BAR_MODE_COUNT - 1,get_m_healthBarMode, set_m_healthBarMode },+ // What a health bar is coloured by: 0 the health, green through yellow to red as retail drew it,+ // 1 the owner's player colour. No control in the game's menu; the launcher writes it. Read every+ // frame by Drawable::drawHealthBar, and a disabled unit keeps its blue either way.+ { "HealthBarColors", "", "",+ OPTION_ENUM, APPLY_LIVE, 0, 1,+ get_m_healthBarColors, set_m_healthBarColors },+// MenuLayout (stretch or fit), HudScale and InterfaceStyle used to sit here. Every menu is// fitted now, and there is one interface at one size.diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cppindex 4c6156b59..d73197ea6 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp@@ -4678,6 +4678,20 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)outlineColor = GameMakeColor( 0, healthRatio * 128.0f, 128, 255 );//dark blue to dark cyan}+ else if( TheGlobalData->m_healthBarColors == 1 &&+ obj->getControllingPlayer() != NULL &&+ obj->getControllingPlayer()->getPlayerColor() != 0 )+ {+ // HealthBarColors 1: the bar wears its owner's colour, the one the minimap and the selection+ // rings use, and the bar's length alone says how hurt it is. The outline is the same colour+ // darkened, so a light player colour still reads against light ground. Civilians, crates+ // and anything else with no colour to borrow keep the ramp below.+ UnsignedByte r, g, b, a;+ GameGetColorComponents( clientPlayerColor( obj->getControllingPlayer() ), &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 //retail's ramp for every owner: green at full health, through yellow, to red{diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex b7be2f1fa..3c0cadbac 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -7737,6 +7737,33 @@ TEST(health_bar_mode_round_trips_through_options_ini)TheWritableGlobalData = saved;}+/** Health bar colours are the launcher's row, not a menu control: green-to-red by default, the+ owner's colour at 1, and nothing past that. */+TEST(health_bar_colors_round_trip_through_options_ini)+{+ const OptionDef *def = findOptionDef( "HealthBarColors" );+ CHECK( def != NULL );+ CHECK_EQ( (Int)def->apply, (Int)APPLY_LIVE );+ CHECK_EQ( def->hi, 1 );++ GlobalData *saved = TheWritableGlobalData;+ TheWritableGlobalData = NEW GlobalData;++ CHECK_EQ( TheGlobalData->m_healthBarColors, 0 );++ UserPreferences pref;+ pref[ AsciiString( "HealthBarColors" ) ] = AsciiString( "1" );+ loadOptionsFromPreferences( pref );+ CHECK_EQ( TheGlobalData->m_healthBarColors, 1 );++ pref[ AsciiString( "HealthBarColors" ) ] = AsciiString( "7" );+ loadOptionsFromPreferences( pref );+ CHECK_EQ( TheGlobalData->m_healthBarColors, 1 );++ delete TheWritableGlobalData;+ TheWritableGlobalData = saved;+}+TEST(player_color_scheme_round_trips_through_options_ini){const OptionDef *def = findOptionDef( "PlayerColors" );