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): reload bar for weapons that wait over three seconds
Olcay Seygan7e06cc88d27d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex b3bdc52dc..ae51f010e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -775,6 +775,7 @@ A third pass went through the generals' powers, promotions and unit abilities.- 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.- 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 wait longer than 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. Artillery, the Inferno Cannon, SCUD and Tomahawk launchers, the Scorpion's and the Comanche's missiles and the rocket buggy's clip all wear it.- 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 > Gameplay 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/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cppindex bf4a3cf61..d53907b7b 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp@@ -4306,6 +4306,48 @@ static Int drawOwnCountdown( DisplayString *&countdown, Int seconds, Int x, Intreturn textH;}+//-------------------------------------------------------------------------------------------------+/** How far the slowest long reload on this object has come, 0 to 1, or -1 when none is running.+ *+ * Only a wait longer than three seconds counts. Every direct-fire tank gun in the game waits two+ * (the Laser General's Crusader 2.3), so a lower line would hang a bar on every main battle tank+ * that fires and empty it again before it could be read. Above it sit the weapons whose wait is+ * the whole decision: the Nuke Cannon's ten seconds, artillery, the Inferno Cannon, SCUD and+ * Tomahawk launchers, the Scorpion's and the Comanche's missiles, the rocket buggy's clip.+ *+ * A weapon that does less than one point of damage is a dummy that only drives an animation+ * (the Battle Bus and Troop Crawler passengers' ten-second one, the angry mob's) and the SCUD+ * Storm's, whose launch already has its own charge bar; none of those is a reload anyone waits on.+ *+ * This reads the two frame numbers and nothing else. Weapon::getStatus() writes m_status, which+ * the logic CRC covers, so calling it from a draw would be the client writing logic state. */+//-------------------------------------------------------------------------------------------------+static Real reloadBarFraction( const Object *obj )+{+ const UnsignedInt RELOAD_BAR_MIN_FRAMES = 3 * LOGICFRAMES_PER_SECOND;+ const UnsignedInt now = TheGameLogic->getFrame();+ Real least = -1.0f;++ for( Int i = 0; i < WEAPONSLOT_COUNT; ++i )+ {+ const Weapon *weapon = obj->getWeaponInWeaponSlot( (WeaponSlotType)i );+ if( weapon == NULL || weapon->getTemplate()->getPrimaryDamage( WeaponBonus() ) < 1.0f )+ continue;++ // 0x7fffffff is an empty clip that does not reload itself (a jet waiting for its airfield)+ const UnsignedInt ready = weapon->getPossibleNextShotFrame();+ const UnsignedInt started = weapon->getLastReloadStartedFrame();+ if( ready <= now || ready == 0x7fffffff || ready - started <= RELOAD_BAR_MIN_FRAMES )+ continue;++ Real fraction = INT_TO_REAL( now - started ) / INT_TO_REAL( ready - started );+ if( least < 0.0f || fraction < least )+ least = fraction;+ }++ return least;+}+//-------------------------------------------------------------------------------------------------void Drawable::drawHealthBar(const IRegion2D* healthBarRegion){@@ -4554,6 +4596,28 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)elsefreeOwnCountdown( m_productionTimeDisplayString );+ //+ // A weapon on a long reload, on a unit of ours the player is looking at: selected or under+ // the cursor, the same two cases the ammo pips go by. Nothing else on screen said when a+ // Nuke Cannon could fire again; it just sat there for ten seconds after every shell. The+ // fill is amber rather than white so it does not read as production or a superweapon.+ //+ if( showsOwnerDetail( obj ) &&+ ( isSelected() || ( TheInGameUI != NULL && TheInGameUI->getMousedOverDrawableID() == getID() ) ) )+ {+ const Real reload = reloadBarFraction( obj );+ if( reload >= 0.0f )+ {+ Int reloadY = stackY - healthBoxHeight;+ TheDisplay->drawOpenRect( healthBarRegion->lo.x, reloadY, healthBoxWidth, healthBoxHeight,+ healthBoxOutlineSize, GameMakeColor( 255, 255, 255, 255 ) );+ TheDisplay->drawFillRect( healthBarRegion->lo.x + 1, reloadY + 1,+ (healthBoxWidth - 2) * reload, healthBoxHeight - 2,+ GameMakeColor( 255, 190, 40, 255 ) );+ stackY = reloadY - 3;+ }+ }+//// A superweapon charging, or a building on a timed payout (the supply drop zone), gets the// same white bar the production queue uses - stacked above it rather than on top of it,