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): no reload bar on mine-clearing weapons

Olcay Seygan6c98e71f1a16
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ed0e45ecf..8c8084946 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -830,6 +830,7 @@ A third pass went through the generals' powers, promotions and unit abilities.
- The progress bar stacked over the health bar is white, wherever it turns up - a factory turning out a tank, a silo charging, a supply drop counting down to its payout. It was yellow, which is a colour the game already spends on your own units and on damage, and a strip of it sitting directly above a coloured health bar read as part of the same bar.
- A slow gun shows when it can fire again. A Nuke Cannon sat still for ten seconds after every shell with nothing on screen to say when the next would come. Now an amber bar over the health bar fills through the reload, on your own unit while it is selected or under the pointer. Only a gun that fires slower than one shot in three seconds gets one: every tank gun in the game reloads in about two, and a bar that empties before you can read it is noise. The Nuke Cannon, the Inferno Cannon, the artillery platform, SCUD and Tomahawk launchers, the Scorpion's missile and the Comanche's anti-tank missiles wear it.
- The reload bar stays off the quick shooters. It used to go up whenever a wait ran past three seconds, and a reload after a fast clip does that too: a Paladin that zapped one infantryman with its point defence laser wore the bar for the next four seconds, and so did a Rocket Buggy after every volley and a Comanche after its rocket pods. Those fire about as often as a tank does, so the bar now goes by how many shots a gun gets off in a minute, reload included.
+- A Dozer clearing mines no longer wears the reload bar. Its scoop takes four seconds between mines, which counted as a slow gun, so the bar came up over every Dozer sweeping a minefield as if it were waiting to fire. Clearing mines is not firing, and the Worker's clearing goes without the bar too.
- Every garrisonable building shows how full it is, whoever holds it. An empty one shows it too, and so does your own Barracks: ten grey boxes over it for the whole match, because soldiers can walk in to heal. Untick Empty Building Slots on Options > Interface and a building wears its row only while somebody is inside.
- 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.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h
index e5df8508a..d47958aaa 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h
@@ -88,8 +88,9 @@ extern Bool Drawable_structureShowsHealthBar( Bool isBridge, Bool isUnowned, Boo
///< whether an object of these kinds is a thing that wears a health bar at all
extern Bool Drawable_kindShowsHealthBar( const KindOfMaskType& kinds );
-///< whether a weapon fires slowly enough (over three seconds a shot, clip and reload counted) to wear a reload bar
-extern Bool Drawable_weaponWearsReloadBar( Int clipSize, UnsignedInt delayFrames, UnsignedInt clipReloadFrames );
+///< whether a weapon fires slowly enough (over three seconds a shot, clip and reload counted) to wear a reload bar;
+///< a mine-clearing weapon (DamageType DISARM) never does
+extern Bool Drawable_weaponWearsReloadBar( Int clipSize, UnsignedInt delayFrames, UnsignedInt clipReloadFrames, Bool disarms );
///< how far a weapon's wait has come, 0 to 1, or -1 when there is no wait worth a bar
extern Real Drawable_reloadBarFraction( UnsignedInt now, UnsignedInt started, UnsignedInt ready, UnsignedInt longest );
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
index 3813ad0af..cd7b71c4c 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
@@ -4477,11 +4477,18 @@ static Int drawOwnCountdown( DisplayString *&countdown, Int seconds, Int x, Int
* it - the Rocket Buggy's six rockets, the Comanche's rocket pods, the Paladin's point defence
* laser - which fire about as often as a tank does. The old test was the
* length of whichever wait was running, and those clip reloads all ran past three seconds, so a
- * Paladin that touched an infantryman with its laser wore an amber bar for the next four. */
+ * Paladin that touched an infantryman with its laser wore an amber bar for the next four.
+ *
+ * A weapon of DamageType DISARM is not a gun at all. The Dozer's mine-clearing scoop is one shot
+ * and a four-second reload, so the Dozer wore an amber bar after every mine it lifted. The
+ * Worker's clearing weapon is DISARM too, and those two are the only DISARM weapons in the data. */
//-------------------------------------------------------------------------------------------------
-Bool Drawable_weaponWearsReloadBar( Int clipSize, UnsignedInt delayFrames, UnsignedInt clipReloadFrames )
+Bool Drawable_weaponWearsReloadBar( Int clipSize, UnsignedInt delayFrames, UnsignedInt clipReloadFrames, Bool disarms )
{
const UnsignedInt RELOAD_BAR_MIN_FRAMES = 3 * LOGICFRAMES_PER_SECOND;
+ if( disarms )
+ return FALSE;
+
if( clipSize <= 0 )
return delayFrames > RELOAD_BAR_MIN_FRAMES;
@@ -4541,7 +4548,7 @@ static Real reloadBarFraction( const Object *obj )
const UnsignedInt delay = (UnsignedInt)tmpl->getMaxDelayBetweenShots();
const UnsignedInt clipReload = (UnsignedInt)tmpl->getClipReloadTime( WeaponBonus() );
- if( !Drawable_weaponWearsReloadBar( tmpl->getClipSize(), delay, clipReload ) )
+ if( !Drawable_weaponWearsReloadBar( tmpl->getClipSize(), delay, clipReload, tmpl->getDamageType() == DAMAGE_DISARM ) )
continue;
const UnsignedInt longest = tmpl->getClipSize() > 0 && clipReload > delay ? clipReload : delay;
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index 7a00feaa0..0a301f6b1 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -7355,15 +7355,24 @@ TEST(a_strike_or_cargo_plane_wears_a_health_bar)
over the shots in it. Frames, at 30 a second. */
TEST(only_a_slow_firing_weapon_wears_a_reload_bar)
{
- CHECK( Drawable_weaponWearsReloadBar( 0, 300, 0 ) == TRUE ); // Nuke Cannon, 10 s
- CHECK( Drawable_weaponWearsReloadBar( 0, 120, 0 ) == TRUE ); // Inferno Cannon, 4 s
- CHECK( Drawable_weaponWearsReloadBar( 1, 0, 300 ) == TRUE ); // SCUD, one missile and a 10 s reload
- CHECK( Drawable_weaponWearsReloadBar( 2, 6, 450 ) == TRUE ); // Scorpion's two missiles, 15 s reload
- CHECK( Drawable_weaponWearsReloadBar( 0, 60, 0 ) == FALSE ); // a tank gun, 2 s
- CHECK( Drawable_weaponWearsReloadBar( 0, 90, 0 ) == FALSE ); // exactly three seconds is not over three
- CHECK( Drawable_weaponWearsReloadBar( 6, 6, 180 ) == FALSE ); // Rocket Buggy, six rockets, 6 s reload
- CHECK( Drawable_weaponWearsReloadBar( 2, 7, 120 ) == FALSE ); // Paladin's point defence laser
- CHECK( Drawable_weaponWearsReloadBar( 20, 6, 900 ) == FALSE ); // Comanche rocket pods
+ CHECK( Drawable_weaponWearsReloadBar( 0, 300, 0, FALSE ) == TRUE ); // Nuke Cannon, 10 s
+ CHECK( Drawable_weaponWearsReloadBar( 0, 120, 0, FALSE ) == TRUE ); // Inferno Cannon, 4 s
+ CHECK( Drawable_weaponWearsReloadBar( 1, 0, 300, FALSE ) == TRUE ); // SCUD, one missile and a 10 s reload
+ CHECK( Drawable_weaponWearsReloadBar( 2, 6, 450, FALSE ) == TRUE ); // Scorpion's two missiles, 15 s reload
+ CHECK( Drawable_weaponWearsReloadBar( 0, 60, 0, FALSE ) == FALSE ); // a tank gun, 2 s
+ CHECK( Drawable_weaponWearsReloadBar( 0, 90, 0, FALSE ) == FALSE ); // exactly three seconds is not over three
+ CHECK( Drawable_weaponWearsReloadBar( 6, 6, 180, FALSE ) == FALSE ); // Rocket Buggy, six rockets, 6 s reload
+ CHECK( Drawable_weaponWearsReloadBar( 2, 7, 120, FALSE ) == FALSE ); // Paladin's point defence laser
+ CHECK( Drawable_weaponWearsReloadBar( 20, 6, 900, FALSE ) == FALSE ); // Comanche rocket pods
+}
+
+/** The Dozer's mine-clearing scoop is one shot and a 4 s reload, slow enough for the bar on the
+ numbers alone, and the Dozer wore it after every mine. A DISARM weapon is not a gun. */
+TEST(a_mine_clearing_weapon_wears_no_reload_bar)
+{
+ CHECK( Drawable_weaponWearsReloadBar( 1, 0, 120, FALSE ) == TRUE ); // the same numbers on a gun
+ CHECK( Drawable_weaponWearsReloadBar( 1, 0, 120, TRUE ) == FALSE ); // DozerMineDisarmingWeapon
+ CHECK( Drawable_weaponWearsReloadBar( 0, 30, 0, TRUE ) == FALSE ); // WorkerMineDisarmingWeapon
}
/** A launcher that shares its reload is told when it can fire next and keeps an old start frame;