mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 02:43:44 +00:00
fix(factions): override_faction 0 keeps the template's factions
The client (LWODestroyableComponent::LoadConfigData 0x00c44cb0) uses a level object's set_faction only when override_faction is absent or true; with override_faction=0 LoadDataFromTemplate (0x00c9f900) puts the DestructibleComponent factionList back. 2948 level objects have override_faction=0, and DLU applied their set_faction anyway. The resolution is now DestroyableComponent::GetLevelFactions, with tests. No wire change. In game: enemies and smashables placed in levels with a set_faction but override_faction=0 (most smashables, many enemies) are targeted and aggro as before for the common case; check a few enemies in AG/GF/FV still fight you and friendly objects are not attacked, and that smashables still smash and give credit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -487,21 +487,11 @@ void Entity::Initialize() {
|
||||
}
|
||||
}
|
||||
|
||||
// Level files can replace the factions with set_faction. The client splits the value on
|
||||
// both ';' and ' ' and replaces its faction list with the result
|
||||
// (LWODestroyableComponent::LoadConfigData), and many values have a trailing space ("13:6 ").
|
||||
const auto setFaction = GetVarAsString(u"set_faction");
|
||||
std::vector<int32_t> factionsToSet;
|
||||
for (const auto& semicolonSplit : GeneralUtils::SplitString(setFaction, ';')) {
|
||||
for (const auto& faction : GeneralUtils::SplitString(semicolonSplit, ' ')) {
|
||||
const auto factionToAdd = GeneralUtils::TryParse<int32_t>(faction);
|
||||
if (factionToAdd) factionsToSet.push_back(factionToAdd.value());
|
||||
}
|
||||
}
|
||||
|
||||
if (!factionsToSet.empty()) {
|
||||
comp->SetFaction(factionsToSet.front(), true);
|
||||
for (const auto faction : factionsToSet | std::views::drop(1)) comp->AddFaction(faction, true);
|
||||
// Level files can replace the factions with set_faction, unless override_faction is 0
|
||||
const auto levelFactions = DestroyableComponent::GetLevelFactions(*this);
|
||||
if (levelFactions && !levelFactions->empty()) {
|
||||
comp->SetFaction(levelFactions->front(), true);
|
||||
for (const auto faction : *levelFactions | std::views::drop(1)) comp->AddFaction(faction, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user