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(gameengine): centre the promotion screen, show the suicide bomb's figures

Olcay Seygan90818c253d6a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2794273bb..bd2037ecc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -24,7 +24,7 @@ found and fixed — EA's own, not port damage.**
- The command bar is one console standing in the middle of the bottom edge: a taller radar, your selection and the build grid side by side, with the power bar over the grid. The idle worker and rank keys sit in a row over your selection, and in multiplayer the smoke signals join them. The red under-attack lamp is gone: the ping on the radar, the voice and the line in the event feed already tell you where you are hit, and the lamp only blinked about it a second time.
- Your general's powers grow out of the console's right end, a column for each F key with its powers stacked up it, and only the powers you have take any room.
-- A single unit's name and health stand beside its portrait, and a veteran gets his gold stars there too. Under them sit its main weapon's damage, damage a second and range, and what its armour does to gunfire, tank shells and rockets: green for less damage taken, red for more. Your own units and your allies' show as they stand, so a veteran's bonus, a Composite Armor upgrade or Hold the Line shows the moment it lands. An enemy's show only what his veterancy stars already tell you, never his upgrades or battle plans. Click an enemy and his health reads as a share, 64%, because 512/800 would tell you he bought Composite Armor; the upgrade icons under his portrait stay grey for everything his side researched, where retail lit Composite Armor or Supply Lines for anyone who clicked, and light only for what the unit visibly carries, a drone or an Overlord's turret. A group shows every type it holds in the same box, five to a row. Click a type there and only those stay selected; shift-click it and they leave the selection, so the two Rangers that tagged along with your tanks are one click from gone. Watching a match with nothing selected, the empty portrait box is gone and the console is the radar alone; click a unit and the box comes back. Following nobody, the experience bar beside the radar is gone too, since there is no general's rank to fill it.
+- A single unit's name and health stand beside its portrait, and a veteran gets his gold stars there too. Under them sit its main weapon's damage, damage a second and range, and how much of the damage from gunfire, tank shells and rockets its armour stops: +50% in green for a unit that takes half, a minus in red for one that takes more. A Terrorist, or a Combat Bike with one riding it, used to read 999,999 damage and millions a second, the figures of the stand-in charge that kills the rider so his real bomb can go off. They read the bomb now, 500 for the Terrorist's dynamite and 700 for the bike's, and a bomb that goes off once has no damage a second. Your own units and your allies' show as they stand, so a veteran's bonus, a Composite Armor upgrade or Hold the Line shows the moment it lands. An enemy's show only what his veterancy stars already tell you, never his upgrades or battle plans. Click an enemy and his health reads as a share, 64%, because 512/800 would tell you he bought Composite Armor; the upgrade icons under his portrait stay grey for everything his side researched, where retail lit Composite Armor or Supply Lines for anyone who clicked, and light only for what the unit visibly carries, a drone or an Overlord's turret. A group shows every type it holds in the same box, five to a row. Click a type there and only those stay selected; shift-click it and they leave the selection, so the two Rangers that tagged along with your tanks are one click from gone. Watching a match with nothing selected, the empty portrait box is gone and the console is the radar alone; click a unit and the box comes back. Following nobody, the experience bar beside the radar is gone too, since there is no general's rank to fill it.
- The match clock hangs from the middle of the top edge with your money in its own box under it. Superweapon countdowns in the top right corner are as big as your general's power buttons. Hold Tab and the scoreboard drops down from it.
- Peace time has its own plate under your money, so the truce clock never pushes the match clock aside. When the last ten seconds start, the countdown hangs straight off that plate.
- A superweapon built, charged or fired anywhere on the map flashes its name in big letters under the clock: "Nuclear Missile launched". Yours are white, an ally's blue, an enemy's red. Each line stays four seconds and fades out. When several land at once they queue and hurry through, two seconds each with one more waiting and one second with a pile behind it, so the last news never sits stale.
@@ -32,6 +32,7 @@ found and fixed — EA's own, not port damage.**
- Point at the attack, hold position or move key and a card says what it does, in English or Turkish. Those three are painted onto the grid rather than given to a unit, so the game had no card for them and showed nothing. The card stands on top of the command bar like every other button's.
- HUD Size grows the console from its middle, and on a narrow screen it stops at the size that still fits.
- The grid under a building you are placing is fainter and its lines thinner, and the red squares where nothing can stand are lighter, so the ground under them shows through. Untick grid placement on the Controls page and the lines go altogether.
+- Your general's promotion screen opens in the middle of the screen, in the Classic interface as well, instead of hanging from the top edge.
## Groups attack-move at their own speed
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
index f9560ffc1..a9cd7c8a6 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h
@@ -835,8 +835,9 @@ struct UnitFigures
};
/** `weapon`'s figures under `bonus`, the build tooltip's and the selected unit's alike
- * (ControlBarPopupDescription.cpp). */
-WeaponFigures ControlBarWeaponFigures( const WeaponTemplate *weapon, const WeaponBonus &bonus );
+ * (ControlBarPopupDescription.cpp); `thing` carries it, and its death weapon stands in for a
+ * suicide dummy. */
+WeaponFigures ControlBarWeaponFigures( const ThingTemplate *thing, const WeaponTemplate *weapon, const WeaponBonus &bonus );
/** `thing`'s weapons in the set `setFlags` picks, each under the bonuses `bonusFlags` give it, into
* `figures`' slots; a template with no such set leaves them as they are. */
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarScheme.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarScheme.cpp
index e337d0a5c..2335fe56b 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarScheme.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarScheme.cpp
@@ -593,6 +593,13 @@ void ControlBarScheme::init(void)
win->winSetPosition( ( TheDisplay->getWidth() - w ) / 2,
REAL_TO_INT_FLOOR( GEN_EXP_DESIGN_TOP * s ) );
}
+ else if( TheGlobalData->isClassicUI() )
+ {
+ // the shipped painting at its shipped size, in the middle of the screen
+ Int w = 0, h = 0;
+ win->winGetSize( &w, &h );
+ win->winSetPosition( ( (Int)TheDisplay->getWidth() - w ) / 2, ( (Int)TheDisplay->getHeight() - h ) / 2 );
+ }
}
//
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarPopupDescription.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarPopupDescription.cpp
index e84ac3490..92f7a0b2d 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarPopupDescription.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarPopupDescription.cpp
@@ -92,6 +92,7 @@
#include "GameClient/DisplayStringManager.h"
#include "GameLogic/GameLogic.h"
#include "GameLogic/Damage.h"
+#include "GameLogic/Module/FireWeaponWhenDeadBehavior.h"
#include "GameLogic/Module/MaxHealthUpgrade.h"
#include "GameLogic/Module/OverchargeBehavior.h"
#include "GameLogic/Module/ProductionUpdate.h"
@@ -185,15 +186,49 @@ static void findUpgradeEffects( const ThingTemplate *thing, UpgradeEffects &effe
}
}
+//-------------------------------------------------------------------------------------------------
+/** The bomb `thing` sets off when it kills itself: the largest death weapon of a FireWeaponWhenDead
+ * module that is on from the start and fires on a SUICIDED death. The Terrorist, and a bike with one
+ * riding it, shoot TerroristSuicideWeapon, 999999 damage that reaches nobody but the shooter, so that
+ * his death fires the real bomb. */
+// ponytail: a bomb an upgrade swaps in (Demo's fire pack, Anthrax Beta and Gamma) is not read; the object's live modules would have it
+//-------------------------------------------------------------------------------------------------
+static const WeaponTemplate *suicideBomb( const ThingTemplate *thing )
+{
+ const WeaponTemplate *best = NULL;
+ const ModuleInfo &modules = thing->getBehaviorModuleInfo();
+ for( Int m = 0; m < modules.getCount(); ++m )
+ {
+ if( modules.getNthName( m ).compareNoCase( "FireWeaponWhenDeadBehavior" ) != 0 )
+ continue;
+ const FireWeaponWhenDeadBehaviorModuleData *data = static_cast< const FireWeaponWhenDeadBehaviorModuleData * >( modules.getNthData( m ) );
+ if( !data->m_initiallyActive || !data->m_upgradeMuxData.m_activationUpgradeNames.empty() || data->m_deathWeapon == NULL
+ || !getDeathTypeFlag( data->m_dieMuxData.m_deathTypes, DEATH_SUICIDED ) )
+ continue;
+ const WeaponBonus none;
+ if( best == NULL || data->m_deathWeapon->getPrimaryDamage( none ) > best->getPrimaryDamage( none ) )
+ best = data->m_deathWeapon;
+ }
+ return best;
+}
+
//-------------------------------------------------------------------------------------------------
/** A clip fires its shots a delay apart and then reloads in place of the last delay. A weapon that
* does no damage, the dummies that hold a slot until an upgrade fills it, is none, and so is one
* that heals, clears or unloads: a dozer's mine disarming "weapon" does 1 damage at a range of 5
- * so that it can be aimed, and an Ambulance's cleanup is the same. */
+ * so that it can be aimed, and an Ambulance's cleanup is the same. A weapon that reaches nobody but
+ * its user stands for the bomb his death fires, and one whose blast kills its user goes off once,
+ * so it has no rate and no damage a second. */
//-------------------------------------------------------------------------------------------------
-WeaponFigures ControlBarWeaponFigures( const WeaponTemplate *weapon, const WeaponBonus &bonus )
+WeaponFigures ControlBarWeaponFigures( const ThingTemplate *thing, const WeaponTemplate *weapon, const WeaponBonus &bonus )
{
WeaponFigures figure = {};
+ if( ( weapon->getAffectsMask() & ( WEAPON_AFFECTS_ALLIES | WEAPON_AFFECTS_ENEMIES | WEAPON_AFFECTS_NEUTRALS ) ) == 0 )
+ {
+ weapon = suicideBomb( thing );
+ if( weapon == NULL )
+ return figure;
+ }
const DamageType type = weapon->getDamageType();
if( type == DAMAGE_HEALING || type == DAMAGE_DISARM || type == DAMAGE_HAZARD_CLEANUP || type == DAMAGE_DEPLOY
|| !IsHealthDamagingDamage( type ) )
@@ -210,7 +245,7 @@ WeaponFigures ControlBarWeaponFigures( const WeaponTemplate *weapon, const Weapo
figure.weapon = weapon;
figure.damage = damage;
figure.range = weapon->getAttackRange( bonus );
- figure.attacksPerSecond = ( clip > 0 ? clip : 1 ) * LOGICFRAMES_PER_SECOND / cycle;
+ figure.attacksPerSecond = weapon->getAffectsMask() & WEAPON_KILLS_SELF ? 0.0f : ( clip > 0 ? clip : 1 ) * LOGICFRAMES_PER_SECOND / cycle;
return figure;
}
@@ -235,7 +270,7 @@ void ControlBarTemplateWeaponFigures( const ThingTemplate *thing, const WeaponSe
TheGlobalData->m_weaponBonusSet->appendBonuses( bonusFlags, bonus );
if( weapon->getExtraBonus() )
weapon->getExtraBonus()->appendBonuses( bonusFlags, bonus );
- figures.slots[ slot ] = ControlBarWeaponFigures( weapon, bonus );
+ figures.slots[ slot ] = ControlBarWeaponFigures( thing, weapon, bonus );
}
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index b24f0c512..ec5158317 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -13435,7 +13435,7 @@ static void putSelectedUnit( HtmlValues &values, HtmlLists &lists, const IRegion
continue;
WeaponBonus bonus;
weapon->computeBonus( object, 0, bonus );
- figures.slots[ slot ] = ControlBarWeaponFigures( weapon->getTemplate(), bonus );
+ figures.slots[ slot ] = ControlBarWeaponFigures( object->getTemplate(), weapon->getTemplate(), bonus );
}
}
else
@@ -13452,14 +13452,15 @@ static void putSelectedUnit( HtmlValues &values, HtmlLists &lists, const IRegion
{
const WeaponFigures &weapon = figures.slots[ main ];
putFigureColumn( weaponColumns, 0, "TOOLTIP:StatDamage", std::to_string( REAL_TO_INT( weapon.damage ) ), "" );
- putFigureColumn( weaponColumns, 1, "TOOLTIP:StatShortDamagePerSecond",
- std::to_string( REAL_TO_INT( weapon.damage * weapon.attacksPerSecond ) ), "" );
+ putFigureColumn( weaponColumns, 1, "TOOLTIP:StatShortDamagePerSecond", weapon.attacksPerSecond > 0.0f
+ ? std::to_string( REAL_TO_INT( weapon.damage * weapon.attacksPerSecond ) ) : "-", "" );
putFigureColumn( weaponColumns, 2, "TOOLTIP:StatRange", std::to_string( REAL_TO_INT( weapon.range ) ), "" );
weaponColumns.resize( WEAPON_FIGURES );
}
// the armour, and for our own the body's damage scalar on top of it, which is where a battle plan
- // such as Hold the Line goes (ActiveBody::attemptDamage)
+ // such as Hold the Line goes (ActiveBody::attemptDamage). Each figure is protection, the share of
+ // that damage the armour stops: +50% for a unit that takes half, -25% for one that takes a quarter more
ArmorSetFlags armorFlags;
for( Int set = 0; set < ARMORSET_COUNT; set++ )
if( object->testArmorSetFlag( (ArmorSetType)set ) && ( ours || set != ARMORSET_PLAYER_UPGRADE ) )
@@ -13469,9 +13470,9 @@ static void putSelectedUnit( HtmlValues &values, HtmlLists &lists, const IRegion
const Int shownArmor = (Int)ARRAY_SIZE( SHOWN_ARMOR );
for( Int each = 0; each < shownArmor; each++ )
{
- const Int change = REAL_TO_INT_FLOOR( armor.adjustDamage( SHOWN_ARMOR[ each ].type, PERCENT ) * scalar + 0.5f ) - PERCENT;
+ const Int stopped = PERCENT - REAL_TO_INT_FLOOR( armor.adjustDamage( SHOWN_ARMOR[ each ].type, PERCENT ) * scalar + 0.5f );
putFigureColumn( armorColumns, each, SHOWN_ARMOR[ each ].label,
- ( change > 0 ? "+" : "" ) + std::to_string( change ) + "%", change < 0 ? "strong" : change > 0 ? "weak" : "" );
+ ( stopped > 0 ? "+" : "" ) + std::to_string( stopped ) + "%", stopped > 0 ? "strong" : stopped < 0 ? "weak" : "" );
}
armorColumns.resize( shownArmor );
}
@@ -14405,8 +14406,8 @@ static void placePromotionWindow( const std::string &name, Int x, Int y, Int wid
* row a grid five places wide in command button cells with a hair of steel between them, the way
* the command bar's grid is, in a well of its own with its heading, a plate's margin between one
* well and the next; the rank's name and the points on one line with the bar under them, and the
- * close button in the last row's fifth place, which no side fills. Centred across the screen, its
- * top under the players' strip. `layout` gets every place, filled or not, the headings and the wells,
+ * close button in the last row's fifth place, which no side fills. Centred on the screen, its
+ * top never over the players' strip. `layout` gets every place, filled or not, the headings and the wells,
* in screen pixels. */
//-------------------------------------------------------------------------------------------------
static void layoutPromotionScreen( GameWindow *parent, PromotionLayout &layout )
@@ -14430,15 +14431,19 @@ static void layoutPromotionScreen( GameWindow *parent, PromotionLayout &layout )
placePromotionWindow( "ProgressBarExperience", margin, margin + titleHeight + Page::px( PROMOTION_BAR_GAP, scale ),
width - 3 * margin - pointsWidth, Page::px( PROMOTION_BAR, scale ) );
- // the parent goes first, across the middle of the screen just under the players hanging from its
+ // each row's well stands a margin under the one before, the first a margin under the bar and the
+ // points, and the heading and the cells an inset inside it
+ Int y = margin + titleHeight + Page::px( PROMOTION_BAR_GAP + PROMOTION_BAR, scale );
+ Int height = y + margin;
+ for( Int row = 0; row < (Int)ARRAY_SIZE( PROMOTION_ROWS ); row++ )
+ height += margin + 2 * inset + heading + PROMOTION_ROWS[ row ].depth * ( cellHeight + gap ) - gap;
+
+ // the parent goes first, in the middle of the screen but never over the players hanging from its
// top edge, so the places can be handed out in screen pixels
const Int parentX = ( TheDisplay->getWidth() - width ) / 2;
- const Int parentY = Page::px( PROMOTION_TOP, scale );
+ const Int parentY = max( Page::px( PROMOTION_TOP, scale ), ( (Int)TheDisplay->getHeight() - height ) / 2 );
parent->winSetPosition( parentX, parentY );
- // each row's well stands a margin under the one before, the first a margin under the bar and the
- // points, and the heading and the cells an inset inside it
- Int y = margin + titleHeight + Page::px( PROMOTION_BAR_GAP + PROMOTION_BAR, scale );
const Int left = margin + inset;
layout.places.clear();
layout.headings.clear();
@@ -14493,7 +14498,7 @@ static void layoutPromotionScreen( GameWindow *parent, PromotionLayout &layout )
layout.wells.push_back( well );
}
- parent->winSetSize( width, y + margin );
+ parent->winSetSize( width, height );
}
/** The screen's picture, drawn by the page while it is there. */
@@ -16588,6 +16593,8 @@ static void putBuildTooltipCard( const BuildTooltipCard &card, HtmlValues &value
snprintf( speed, sizeof( speed ), "%.2f", card.attacksPerSecond );
values[ "speed" ] = speed + WideCharStringToMultiByte( TheGameText->fetch( "TOOLTIP:StatPerSecond" ).str() );
values[ "dps" ] = std::to_string( card.damagePerSecond );
+ if( card.attacksPerSecond <= 0.0f ) // a bomb that kills its carrier goes off once
+ values[ "speed" ] = values[ "dps" ] = "-";
values[ "stats.shown" ] = card.hasStats ? "shown" : "hidden";
values[ "health.shown" ] = card.hasStats && card.health > 0 ? "shown" : "hidden";
values[ "weapon.shown" ] = card.hasStats && card.damage > 0 ? "shown" : "hidden";