Skip to content

Commit 437444f

Browse files
committed
Fix PowersUpToLevel=-1 upgrade animations
1 parent 36a7afe commit 437444f

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

docs/Whats-New.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ You can use the migration utility (can be found on [Phobos supplementaries repo]
1212

1313
- `Vertical=true` projectiles no longer move horizontally if fired by aircraft by default. To re-enable this behaviour set `Vertical.AircraftFix=false` on the projectile.
1414
- Weapons with `Airstrike=true` on Warhead will now check target eligibility for airstrikes regardless of weapon slot. Use `AirstrikeTargets=all` on `Primary` airstrike weapon Warhead to restore previous behaviour.
15-
- `PowersUpNAnim` is now used instead of the upgrade building's image file for upgrade animation if set. Note that displaying a damaged version will still require setting `PowerUpXDamagedAnim` explicitly in all cases, as the fallback to upgrade building image does not extend to it, nor would it be safe to add.
15+
- `PowersUpNAnim` is now used instead of the upgrade building's image file for upgrade animation if set. Note that displaying a damaged version will still require setting `PowerUpXDamagedAnim` explicitly in all cases, as the fallback to upgrade building image does not extend to it, nor would it be safe to add. `PowersUpToLevel=-1` upgrades still do not work correctly `PowersUpNAnim` and such buildings should forgo using explicit upgrade animations.
1616
- `[CrateRules] -> FreeMCV` now controls whether or not player is forced to receive unit from `[General] -> BaseUnit` from goodie crate if they own no buildings or any existing `[General] -> BaseUnit` vehicles and own more than `[CrateRules] -> FreeMCV.CreditsThreshold` (defaults to 1500) credits.
1717
- Translucent RLE SHPs will now be drawn using a more precise and performant algorithm that has no green tint and banding. Can be disabled with `rulesmd.ini -> [General] -> FixTransparencyBlitters=no`.
1818
- Iron Curtain status is now preserved by default when converting between TechnoTypes via `DeploysInto` / `UndeploysInto`. This behavior can be turned off per-TechnoType and global basis using `[TechnoType]/[CombatDamage] -> IronCurtain.KeptOnDeploy=no`.

src/Ext/BuildingType/Body.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ void BuildingTypeExt::ExtData::Serialize(T& Stm)
336336
.Process(this->BunkerWallsDownSound)
337337
.Process(this->BuildingRepairedSound)
338338
.Process(this->Refinery_UseNormalActiveAnim)
339+
.Process(this->HasPowerUpAnim)
339340
;
340341
}
341342

src/Ext/BuildingType/Body.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ class BuildingTypeExt
9797

9898
Valueable<bool> Refinery_UseNormalActiveAnim;
9999

100+
ValueableVector<bool> HasPowerUpAnim;
101+
100102
ExtData(BuildingTypeClass* OwnerObject) : Extension<BuildingTypeClass>(OwnerObject)
101103
, PowersUp_Owner { AffectedHouse::Owner }
102104
, PowersUp_Buildings {}
@@ -158,6 +160,7 @@ class BuildingTypeExt
158160
, BunkerWallsDownSound {}
159161
, BuildingRepairedSound {}
160162
, Refinery_UseNormalActiveAnim { false }
163+
, HasPowerUpAnim {}
161164
{ }
162165

163166
// Ares 0.A functions

src/Ext/BuildingType/Hooks.Upgrade.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,23 @@ DEFINE_HOOK(0x464749, BuildingTypeClass_ReadINI_PowerUpAnims, 0x6)
142142

143143
GET(BuildingTypeClass*, pThis, EBP);
144144

145+
auto const pTypeExt = BuildingTypeExt::ExtMap.Find(pThis);
145146
auto const pINI = &CCINIClass::INI_Art;
146147

147148
int index = 1;
148149
char buffer[0x20];
149150

151+
pTypeExt->HasPowerUpAnim.clear();
152+
150153
while (index - 1 < 3)
151154
{
152155
auto const animData = &pThis->BuildingAnim[index - 1];
153156

154157
sprintf_s(buffer, "PowerUp%01dAnim", index);
155158
pINI->GetString(pThis->ImageFile, buffer, animData->Anim);
156159

160+
pTypeExt->HasPowerUpAnim.emplace_back(GeneralUtils::IsValidString(animData->Anim));
161+
157162
sprintf_s(buffer, "PowerUp%01dDamagedAnim", index);
158163
pINI->GetString(pThis->ImageFile, buffer, animData->Damaged);
159164

@@ -206,8 +211,8 @@ DEFINE_HOOK(0x440988, BuildingClass_Unlimbo_UpgradeAnims, 0x7)
206211

207212
auto const animData = &pTarget->Type->BuildingAnim[animIndex];
208213

209-
// Only copy image name to BuildingType anim struct if it is not already set.
210-
if (!GeneralUtils::IsValidString(animData->Anim))
214+
// Only copy image name to BuildingType anim struct if theres no explicit PowersUpAnim for this level.
215+
if (!pTargetExt->TypeExtData->HasPowerUpAnim[animIndex])
211216
strncpy(animData->Anim, pThis->Type->ImageFile, 16u);
212217

213218
return SkipGameCode;

0 commit comments

Comments
 (0)