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): strike and cargo planes wear health bars again
Olcay Seyganded8a42a0693
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 23f648fc3..ed0e45ecf 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -836,6 +836,7 @@ A third pass went through the generals' powers, promotions and unit abilities.- Lamps, barrels, rocks and bushes no longer wear health bars.- 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 planes a general's power calls in wear their health bars again. A-10s, B-52s, B-3s, the MiG napalm strike, the carrier's Raptors, the carpet bomber and every side's cargo plane with its paratroopers or supply crates cannot be clicked either, and the change above took their bars along with the dead soldiers'. Your anti-air is shooting at them, and now you can see it working.- 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.diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cppindex d295ab452..3813ad0af 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp@@ -430,7 +430,7 @@ Bool Drawable_structureShowsHealthBar( Bool isBridge, Bool isUnowned, Bool isGar* 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.+ * Everything force-attackable on the ground 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@@ -439,6 +439,15 @@ Bool Drawable_structureShowsHealthBar( Bool isBridge, Bool isUnowned, Bool isGar* 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.*+ * Aircraft are the exception to both rules. The planes a general's power or a support building+ * sends over - the A-10s, the B-52 and B-3, the MiG napalm strike, the carrier's Raptors, the+ * American, Chinese and GLA cargo planes with their paradrops and supply crates, the Chinese+ * carpet bomber - carry no SELECTABLE, and the cargo planes and the carpet bomber are+ * FORCEATTACKABLE besides, yet every one of them is a target with real hit points that anti-air+ * is meant to bring down. So an AIRCRAFT keeps its bar whether the cursor can reach it or not.+ * The only plane left bare by the list above is the Chinese artillery barrage's dummy, which is+ * UNATTACKABLE. The civilian airliner a map sends over gains one too, and it can be shot down.+ ** 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@@ -456,8 +465,13 @@ Bool Drawable_kindShowsHealthBar( const KindOfMaskType& kinds )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 ) )+ TEST_KINDOFMASK( kinds, KINDOF_CRATE ) )+ return FALSE;++ if( TEST_KINDOFMASK( kinds, KINDOF_AIRCRAFT ) )+ return TRUE;++ if( TEST_KINDOFMASK( kinds, KINDOF_FORCEATTACKABLE ) )return FALSE;if( TEST_KINDOFMASK( kinds, KINDOF_STRUCTURE ) )@@ -3066,7 +3080,15 @@ static Bool computeHealthRegion( const Drawable *draw, IRegion2D& region )Real healthBoxWidth, healthBoxHeight;if (!obj->getHealthBoxDimensions(healthBoxHeight, healthBoxWidth))- return FALSE;+ {+ // IGNORED_IN_GUI has no box, and the planes a general's power sends over are all IGNORED_IN_GUI;+ // they wear a bar anyway (Drawable_kindShowsHealthBar), sized as any other unit's would be+ if( !obj->isKindOf( KINDOF_AIRCRAFT ) )+ return FALSE;+ const GeometryInfo& geom = obj->getGeometryInfo();+ healthBoxHeight = 3.0f;+ healthBoxWidth = 2.0f * MAX( 20.0f, MIN( 150.0f, geom.getMajorRadius() + geom.getMinorRadius() ) );+ }// scale the health bars according to the zoomReal zoom = TheTacticalView->getZoom();diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 27e0ccf42..7a00feaa0 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -7338,6 +7338,19 @@ TEST(the_spy_drone_wears_a_health_bar_and_a_toxin_field_does_not)CHECK( Drawable_kindShowsHealthBar( healthBarKinds( KINDOF_INERT, KINDOF_SELECTABLE ) ) == FALSE );}+/** The planes a general's power sends over carry no SELECTABLE, and the cargo planes and the+ carpet bomber are FORCEATTACKABLE as well. The death puppet rule took their bars; anti-air+ shoots them down, so an aircraft keeps one. The artillery barrage's UNATTACKABLE dummy does not. */+TEST(a_strike_or_cargo_plane_wears_a_health_bar)+{+ CHECK( Drawable_kindShowsHealthBar( healthBarKinds( KINDOF_VEHICLE, KINDOF_AIRCRAFT, KINDOF_CAN_ATTACK ) ) == TRUE ); // A-10, B-52, MiG+ CHECK( Drawable_kindShowsHealthBar( healthBarKinds( KINDOF_AIRCRAFT, KINDOF_TRANSPORT, KINDOF_FORCEATTACKABLE ) ) == TRUE ); // cargo plane+ CHECK( Drawable_kindShowsHealthBar( healthBarKinds( KINDOF_AIRCRAFT, KINDOF_SELECTABLE ) ) == TRUE ); // a Raptor you built+ CHECK( Drawable_kindShowsHealthBar( healthBarKinds( KINDOF_AIRCRAFT, KINDOF_UNATTACKABLE ) ) == FALSE ); // artillery barrage dummy+ CHECK( Drawable_kindShowsHealthBar( healthBarKinds( KINDOF_FORCEATTACKABLE ) ) == FALSE ); // a fence+ CHECK( Drawable_kindShowsHealthBar( healthBarKinds( KINDOF_INFANTRY ) ) == FALSE ); // a pedestrian, a death puppet+}+/** Only a slow gun wears the amber reload bar: over three seconds a shot, a clip's reload spreadover the shots in it. Frames, at 30 a second. */TEST(only_a_slow_firing_weapon_wears_a_reload_bar)