From 88f0125fe815bb76b04fe78b2513fcaa6945d80a Mon Sep 17 00:00:00 2001 From: Noble_Fish <1065703286@qq.com> Date: Mon, 4 May 2026 00:35:21 +0800 Subject: [PATCH 1/2] initial --- docs/Whats-New.md | 1 + src/Utilities/TemplateDef.h | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 2e4916855f..9a28dfaaec 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -694,6 +694,7 @@ Phobos fixes: - Fixed combat light ignoring / behaving differently from vanilla game regarding detail level and framerate checks (by Starkku) - Fixed a bug causing transfering AttachEffects (e.g on `DeploysInto`/`UndeploysInto`) not to immediately recalculate stats or tint (by Starkku) - Fixed a bug where updating the `OpenTopped` attribute during convert did not update the coordinates of passengers (by NetsuNegi) +- Fixed the bug where `WeaponRange.AllowWeapons` and `WeaponRange.DisallowWeapons` only support weapons listed in the `[WeaponTypes]` list (by Noble_Fish) Fixes / interactions with other extensions: diff --git a/src/Utilities/TemplateDef.h b/src/Utilities/TemplateDef.h index 856355209f..1d61f99230 100644 --- a/src/Utilities/TemplateDef.h +++ b/src/Utilities/TemplateDef.h @@ -1679,6 +1679,23 @@ void __declspec(noinline) ValueableVector::Read(INI_EX& parser, const char* p } } +// Specialization: use FindOrAllocate for weapon vectors, avoiding dependency on [WeaponTypes] registration +template <> +inline void ValueableVector::Read(INI_EX& parser, const char* pSection, const char* pKey) +{ + if (parser.ReadString(pSection, pKey)) + { + this->clear(); + char* str = parser.value(); + char* context = nullptr; + for (char* cur = strtok_s(str, Phobos::readDelims, &context); cur; cur = strtok_s(nullptr, Phobos::readDelims, &context)) + { + if (auto pWeapon = WeaponTypeClass::FindOrAllocate(cur)) + this->push_back(pWeapon); + } + } +} + template bool ValueableVector::Load(PhobosStreamReader& Stm, bool RegisterForChange) { From c83a669e7961ddcafbcd08159f0d6c385b9cf34e Mon Sep 17 00:00:00 2001 From: Noble_Fish <1065703286@qq.com> Date: Mon, 4 May 2026 00:50:17 +0800 Subject: [PATCH 2/2] WarheadTypeFindOrAllocate --- src/Utilities/TemplateDef.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Utilities/TemplateDef.h b/src/Utilities/TemplateDef.h index 1d61f99230..ec0fd1e1a7 100644 --- a/src/Utilities/TemplateDef.h +++ b/src/Utilities/TemplateDef.h @@ -1696,6 +1696,23 @@ inline void ValueableVector::Read(INI_EX& parser, const char* } } +// Specialization: use FindOrAllocate for warhead vectors, avoiding dependency on [Warheads] table +template <> +inline void ValueableVector::Read(INI_EX& parser, const char* pSection, const char* pKey) +{ + if (parser.ReadString(pSection, pKey)) + { + this->clear(); + char* str = parser.value(); + char* context = nullptr; + for (char* cur = strtok_s(str, Phobos::readDelims, &context); cur; cur = strtok_s(nullptr, Phobos::readDelims, &context)) + { + if (auto pWarhead = WarheadTypeClass::FindOrAllocate(cur)) + this->push_back(pWarhead); + } + } +} + template bool ValueableVector::Load(PhobosStreamReader& Stm, bool RegisterForChange) {