Skip to content

Commit

Permalink
Fix race and leveled filters
Browse files Browse the repository at this point in the history
  • Loading branch information
powerof3 committed Feb 15, 2024
1 parent bc9ba8c commit ee8e8cb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 34 deletions.
6 changes: 0 additions & 6 deletions SPID/include/LookupNPC.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ namespace NPC
[[nodiscard]] bool HasFormFilter(const FormVec& a_forms, bool all = false) const;

[[nodiscard]] std::uint16_t GetLevel() const;
[[nodiscard]] RE::SEX GetSex() const;
[[nodiscard]] bool IsUnique() const;
[[nodiscard]] bool IsSummonable() const;
[[nodiscard]] bool IsChild() const;
[[nodiscard]] bool IsLeveled() const;
[[nodiscard]] bool IsTeammate() const;
Expand Down Expand Up @@ -55,9 +52,6 @@ namespace NPC
std::string name;
StringSet keywords{};
std::uint16_t level;
RE::SEX sex;
bool unique;
bool summonable;
bool child;
bool teammate;
bool leveled;
Expand Down
8 changes: 5 additions & 3 deletions SPID/src/LookupFilters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,16 @@ namespace Filter

Result Data::passed_trait_filters(const NPCData& a_npcData) const
{
auto npc = a_npcData.GetNPC();

// Traits
if (traits.sex && a_npcData.GetSex() != *traits.sex) {
if (traits.sex && npc->GetSex() != *traits.sex) {
return Result::kFail;
}
if (traits.unique && a_npcData.IsUnique() != *traits.unique) {
if (traits.unique && npc->IsUnique() != *traits.unique) {
return Result::kFail;
}
if (traits.summonable && a_npcData.IsSummonable() != *traits.summonable) {
if (traits.summonable && npc->IsSummonable() != *traits.summonable) {
return Result::kFail;
}
if (traits.child && a_npcData.IsChild() != *traits.child) {
Expand Down
27 changes: 3 additions & 24 deletions SPID/src/LookupNPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ namespace NPC
Data::Data(RE::Actor* a_actor, RE::TESNPC* a_npc) :
npc(a_npc),
actor(a_actor),
race(a_npc->GetRace()),
race(a_actor->GetRace()),
name(a_actor->GetName()),
level(a_npc->GetLevel()),
sex(a_npc->GetSex()),
unique(a_npc->IsUnique()),
summonable(a_npc->IsSummonable()),
child(a_actor->IsChild() || race && race->formEditorID.contains("RaceChild"))
child(a_actor->IsChild() || race && race->formEditorID.contains("RaceChild")),
leveled(a_actor->IsLeveled())
{
npc->ForEachKeyword([&](const RE::BGSKeyword* a_keyword) {
keywords.emplace(a_keyword->GetFormEditorID());
Expand All @@ -48,11 +46,7 @@ namespace NPC
IDs.emplace_back(originalBase);
}
if (const auto templateBase = extraLvlCreature->templateBase) {
leveled = true;
IDs.emplace_back(templateBase);
if (const auto templateRace = templateBase->As<RE::TESNPC>()->GetRace()) {
race = templateRace;
}
}
} else {
IDs.emplace_back(npc);
Expand Down Expand Up @@ -193,21 +187,6 @@ namespace NPC
return level;
}

RE::SEX Data::GetSex() const
{
return sex;
}

bool Data::IsUnique() const
{
return unique;
}

bool Data::IsSummonable() const
{
return summonable;
}

bool Data::IsChild() const
{
return child;
Expand Down

0 comments on commit ee8e8cb

Please sign in to comment.