From 72dfb77f7c7c6c4e2571b07da3114c4009417ebc Mon Sep 17 00:00:00 2001 From: Coronia <2217891145@qq.com> Date: Mon, 24 Feb 2025 21:40:28 +0800 Subject: [PATCH] [Minor] Fix Insignia.Weapon parsing (#1530) Separate the fix from https://github.com/Phobos-developers/Phobos/pull/1365 to a standalone pull request, which should fix the issue in https://github.com/Phobos-developers/Phobos/issues/1528. - previous Insignia(.Frame/.Frames).WeaponN settings can't be read or overridden from maps, which is fixed now --- docs/Whats-New.md | 1 + src/Ext/TechnoType/Body.cpp | 31 +++++++++++++++---------------- src/Ext/TechnoType/Body.h | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 85d6205b6c..4fe0ac86f4 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -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. diff --git a/src/Ext/TechnoType/Body.cpp b/src/Ext/TechnoType/Body.cpp index 71780524f4..345be5f9ff 100644 --- a/src/Ext/TechnoType/Body.cpp +++ b/src/Ext/TechnoType/Body.cpp @@ -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(-1)); + Valueable> frames; + frames = Vector3D(-1, -1, -1); + this->InsigniaFrames_Weapon.resize(weaponCount, frames); + } + + for (size_t i = 0; i < weaponCount; i++) { - Promotable 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 frame = Promotable(-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> frames; - frames = Vector3D(-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); } } diff --git a/src/Ext/TechnoType/Body.h b/src/Ext/TechnoType/Body.h index 23326c0be9..f36bbf39b1 100644 --- a/src/Ext/TechnoType/Body.h +++ b/src/Ext/TechnoType/Body.h @@ -182,7 +182,7 @@ class TechnoTypeExt Nullable Insignia_ShowEnemy; std::vector> Insignia_Weapon; std::vector> InsigniaFrame_Weapon; - std::vector> InsigniaFrames_Weapon; + std::vector>> InsigniaFrames_Weapon; Nullable TiltsWhenCrushes_Vehicles; Nullable TiltsWhenCrushes_Overlays;