Skip to content

Commit

Permalink
Fix distribution on load
Browse files Browse the repository at this point in the history
  • Loading branch information
powerof3 committed Feb 14, 2024
1 parent 406ae03 commit 451cc22
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions SPID/include/DependencyResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class DependencyResolver
for (const auto& pair : nodes) {
delete pair.second;
}
nodes.clear();
}

/// Attempts to create a dependency rule between `parent` and `dependency` objects.
Expand Down
14 changes: 12 additions & 2 deletions SPID/src/DistributeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,16 @@ namespace Distribute
static bool thunk(RE::Character* a_this)
{
if (const auto npc = a_this->GetActorBase()) {
if (detail::should_process_NPC(npc)) {
const auto process = detail::should_process_NPC(npc);
const auto processOnLoad = detail::should_process_NPC(npc, processedOnLoad);
if (process || processOnLoad) {
auto npcData = NPCData(a_this, npc);
Distribute(npcData, false);
if (process) {
Distribute(npcData, false, true);
}
if (processOnLoad) {
DistributeItemOutfits(npcData, { a_this, npc, false });
}
}
}

Expand Down Expand Up @@ -113,6 +120,9 @@ namespace Distribute
if (processedOutfit = factory->Create(); processedOutfit) {
processedOutfit->formEditorID = "SPID_ProcessedOutfit";
}
if (processedOnLoad = factory->Create(); processedOnLoad) {
processedOnLoad->formEditorID = "SPID_ProcessedOnLoad";
}
}

if (Forms::GetTotalLeveledEntries() > 0) {
Expand Down
11 changes: 7 additions & 4 deletions SPID/src/KeywordDependencies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ void Dependencies::ResolveKeywords()
return;
}

const auto startTime = std::chrono::steady_clock::now();
Timer timer;
timer.start();

// Pre-build a map of all available keywords by names.
StringMap<RE::BGSKeyword*> allKeywords{};
Expand Down Expand Up @@ -140,7 +141,8 @@ void Dependencies::ResolveKeywords()
}

const auto result = resolver.resolve();
const auto endTime = std::chrono::steady_clock::now();

timer.end();

keywordForms.clear();
logger::info("\tSorted keywords :");
Expand All @@ -154,6 +156,7 @@ void Dependencies::ResolveKeywords()
}
}

const auto duration = std::chrono::duration_cast<std::chrono::microseconds>(endTime - startTime).count();
logger::info("\tKeyword resolution took {}μs / {}ms", duration, duration / 1000.0f);
logger::info("\tKeyword resolution took {}μs / {}ms", timer.duration_μs(), timer.duration_ms());

allKeywords.clear();
}

0 comments on commit 451cc22

Please sign in to comment.