Skip to content

Commit

Permalink
[Minor] Fix Insignia.Weapon parsing (#1530)
Browse files Browse the repository at this point in the history
Separate the fix from
#1365 to a standalone
pull request, which should fix the issue in
#1528.
- previous Insignia(.Frame/.Frames).WeaponN settings can't be read or
overridden from maps, which is fixed now
  • Loading branch information
Coronia authored Feb 24, 2025
1 parent 9768b1c commit 72dfb77
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ Phobos fixes:
- Fixed `Ammo.DeployUnlockMinimumAmount`/`Ammo.DeployUnlockMaximumAmount` behavior inside tank bunkers (by Fryone)
- Fixed `Ammo.AddOnDeploy` behavior inside tank bunkers for non-converters (by Fryone)
- Fixed an issue that caused new attack and move script actions to pick buildings with `InvisibleInGame=yes` as targets (FS-21)
- Fix `Insignia.Weapon` failing to parse in map (by Ollerus)

Fixes / interactions with other extensions:
- Weapons fired by EMPulse superweapons *(Ares feature)* now fully respect the firing building's FLH.
Expand Down
31 changes: 15 additions & 16 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,30 +487,29 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)

char tempBuffer[32];

if (this->OwnerObject()->Gunner && this->Insignia_Weapon.empty())
if (this->OwnerObject()->Gunner)
{
int weaponCount = this->OwnerObject()->WeaponCount;
this->Insignia_Weapon.resize(weaponCount);
this->InsigniaFrame_Weapon.resize(weaponCount);
this->InsigniaFrames_Weapon.resize(weaponCount);
size_t weaponCount = this->OwnerObject()->WeaponCount;

for (int i = 0; i < weaponCount; i++)
if (this->Insignia_Weapon.empty() || this->Insignia_Weapon.size() != weaponCount)
{
this->Insignia_Weapon.resize(weaponCount);
this->InsigniaFrame_Weapon.resize(weaponCount, Promotable<int>(-1));
Valueable<Vector3D<int>> frames;
frames = Vector3D<int>(-1, -1, -1);
this->InsigniaFrames_Weapon.resize(weaponCount, frames);
}

for (size_t i = 0; i < weaponCount; i++)
{
Promotable<SHPStruct*> insignia;
_snprintf_s(tempBuffer, sizeof(tempBuffer), "Insignia.Weapon%d.%s", i + 1, "%s");
insignia.Read(exINI, pSection, tempBuffer);
this->Insignia_Weapon[i] = insignia;
this->Insignia_Weapon[i].Read(exINI, pSection, tempBuffer);

Promotable<int> frame = Promotable<int>(-1);
_snprintf_s(tempBuffer, sizeof(tempBuffer), "InsigniaFrame.Weapon%d.%s", i + 1, "%s");
frame.Read(exINI, pSection, tempBuffer);
this->InsigniaFrame_Weapon[i] = frame;
this->InsigniaFrame_Weapon[i].Read(exINI, pSection, tempBuffer);

Valueable<Vector3D<int>> frames;
frames = Vector3D<int>(-1, -1, -1);
_snprintf_s(tempBuffer, sizeof(tempBuffer), "InsigniaFrames.Weapon%d", i + 1);
frames.Read(exINI, pSection, tempBuffer);
this->InsigniaFrames_Weapon[i] = frames;
this->InsigniaFrames_Weapon[i].Read(exINI, pSection, tempBuffer);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Ext/TechnoType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class TechnoTypeExt
Nullable<bool> Insignia_ShowEnemy;
std::vector<Promotable<SHPStruct*>> Insignia_Weapon;
std::vector<Promotable<int>> InsigniaFrame_Weapon;
std::vector<Vector3D<int>> InsigniaFrames_Weapon;
std::vector<Valueable<Vector3D<int>>> InsigniaFrames_Weapon;

Nullable<bool> TiltsWhenCrushes_Vehicles;
Nullable<bool> TiltsWhenCrushes_Overlays;
Expand Down

0 comments on commit 72dfb77

Please sign in to comment.