Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ Phobos fixes:
- 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 `Shrapnel.AffectsBuildings=true` shrapnel weapons being able to hit the building itself, potentially multiple times, if it had foundation larger than 1x1 (by Starkku)
- 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:
<!-- - Allowed `AuxBuilding` and Ares' `SW.Aux/NegBuildings` to count building upgrades (by Ollerus) -->
Expand Down
34 changes: 34 additions & 0 deletions src/Utilities/TemplateDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,40 @@ void __declspec(noinline) ValueableVector<T>::Read(INI_EX& parser, const char* p
}
}

// Specialization: use FindOrAllocate for weapon vectors, avoiding dependency on [WeaponTypes] registration
Comment thread
Coronia marked this conversation as resolved.
template <>
inline void ValueableVector<WeaponTypeClass*>::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);
}
}
}

// Specialization: use FindOrAllocate for warhead vectors, avoiding dependency on [Warheads] table
template <>
inline void ValueableVector<WarheadTypeClass*>::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 <typename T>
bool ValueableVector<T>::Load(PhobosStreamReader& Stm, bool RegisterForChange)
{
Expand Down
Loading