diff --git a/SPID/CMakeLists.txt b/SPID/CMakeLists.txt index 4ef91bb..6a20d9a 100644 --- a/SPID/CMakeLists.txt +++ b/SPID/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20) set(NAME "po3_SpellPerkItemDistributor" CACHE STRING "") -set(VERSION 6.7.0 CACHE STRING "") +set(VERSION 6.7.1 CACHE STRING "") set(AE_VERSION 1) set(VR_VERSION 1) diff --git a/SPID/src/DistributeManager.cpp b/SPID/src/DistributeManager.cpp index 1d03bdc..b409452 100644 --- a/SPID/src/DistributeManager.cpp +++ b/SPID/src/DistributeManager.cpp @@ -110,6 +110,10 @@ namespace Distribute { func(a_this, a_templateForms); + if (!a_this) { + return; + } + std::call_once(distributeInit, []() { if (shouldDistribute = Lookup::DoFormLookup(); shouldDistribute) { SetupDistribution(); diff --git a/SPID/src/LookupNPC.cpp b/SPID/src/LookupNPC.cpp index e0bdeb4..0d6c32d 100644 --- a/SPID/src/LookupNPC.cpp +++ b/SPID/src/LookupNPC.cpp @@ -31,50 +31,58 @@ namespace NPC npc(a_npc), actor(nullptr), name(a_npc->GetName()), - race(npc->GetRace()), - level(npc->GetLevel()), - sex(npc->GetSex()), - unique(npc->IsUnique()), - summonable(npc->IsSummonable()), - child(race->IsChildRace() || race->formEditorID.contains("RaceChild")), + race(a_npc->GetRace()), + level(a_npc->GetLevel()), + sex(a_npc->GetSex()), + unique(a_npc->IsUnique()), + summonable(a_npc->IsSummonable()), + child(race && (race->IsChildRace() || race->formEditorID.contains("RaceChild"))), leveled(a_npc->UsesTemplate()) { - npc->ForEachKeyword([&](const RE::BGSKeyword& a_keyword) { - keywords.emplace(a_keyword.GetFormEditorID()); - return RE::BSContainer::ForEachResult::kContinue; - }); - race->ForEachKeyword([&](const RE::BGSKeyword& a_keyword) { + a_npc->ForEachKeyword([&](const RE::BGSKeyword& a_keyword) { keywords.emplace(a_keyword.GetFormEditorID()); return RE::BSContainer::ForEachResult::kContinue; }); - IDs.emplace_back(npc); + + if (race) { + race->ForEachKeyword([&](const RE::BGSKeyword& a_keyword) { + keywords.emplace(a_keyword.GetFormEditorID()); + return RE::BSContainer::ForEachResult::kContinue; + }); + } + + IDs.emplace_back(a_npc); std::call_once(init, [&] { potentialFollowerFaction = RE::TESForm::LookupByID(0x0005C84D); }); if (potentialFollowerFaction) { - teammate = npc->IsInFaction(potentialFollowerFaction); + teammate = a_npc->IsInFaction(potentialFollowerFaction); } } Data::Data(RE::Actor* a_actor, RE::TESNPC* a_npc) : npc(a_npc), actor(a_actor), - name(actor->GetName()), - race(npc->GetRace()), - level(npc->GetLevel()), - sex(npc->GetSex()), - unique(npc->IsUnique()), - summonable(npc->IsSummonable()), - child(actor->IsChild() || race->formEditorID.contains("RaceChild")) + name(a_actor->GetName()), + race(a_npc->GetRace()), + 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")) { npc->ForEachKeyword([&](const RE::BGSKeyword& a_keyword) { keywords.emplace(a_keyword.GetFormEditorID()); return RE::BSContainer::ForEachResult::kContinue; }); - race->ForEachKeyword([&](const RE::BGSKeyword& a_keyword) { - keywords.emplace(a_keyword.GetFormEditorID()); - return RE::BSContainer::ForEachResult::kContinue; - }); - if (const auto extraLvlCreature = actor->extraList.GetByType()) { + + if (race) { + race->ForEachKeyword([&](const RE::BGSKeyword& a_keyword) { + keywords.emplace(a_keyword.GetFormEditorID()); + return RE::BSContainer::ForEachResult::kContinue; + }); + } + + if (const auto extraLvlCreature = a_actor->extraList.GetByType()) { if (const auto originalBase = extraLvlCreature->originalBase) { IDs.emplace_back(originalBase); } diff --git a/SPID/vcpkg.json b/SPID/vcpkg.json index 7f4403b..1ddd4f0 100644 --- a/SPID/vcpkg.json +++ b/SPID/vcpkg.json @@ -1,6 +1,6 @@ { "name": "spid", - "version-string": "6.7.0", + "version-string": "6.7.1", "description": "Spell Perk Item Distributor", "homepage": "https://github.com/powerof3/Spell-Perk-Item-Distributor", "license": "MIT",