Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 @@ -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:
<!-- - 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not for every abstracttype?

Copy link
Copy Markdown
Collaborator Author

@DeathFishAtEase DeathFishAtEase May 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of the principle of minimizing impact
Or rather, I'm not sure how large a scope it is safe to expand to, and if you think it would be better to do so, I'm afraid I would have to ask for your help.

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