diff --git a/SPID/include/Distribute.h b/SPID/include/Distribute.h index f222af3..065a1ac 100644 --- a/SPID/include/Distribute.h +++ b/SPID/include/Distribute.h @@ -116,28 +116,6 @@ namespace Distribute } #pragma endregion - // TODO: Is this unused? - // outfits/sleep outfits - template - void for_each_form( - const NPCData& a_npcData, - Forms::Distributables
& a_distributables, - std::function a_callback, - DistributedForms* accumulatedForms = nullptr) - { - auto& vec = a_distributables.GetForms(false); - - for (auto& formData : vec) { // Vector is reversed in FinishLookupForms - if (!a_npcData.HasMutuallyExclusiveForm(formData.form) && detail::passed_filters(a_npcData, formData) && a_callback(formData.form)) { - if (accumulatedForms) { - accumulatedForms->insert({ formData.form, formData.path }); - } - ++formData.npcCount; - break; - } - } - } - #pragma region Items // countable items template diff --git a/SPID/src/Distribute.cpp b/SPID/src/Distribute.cpp index 6a6c6eb..7ef6e96 100644 --- a/SPID/src/Distribute.cpp +++ b/SPID/src/Distribute.cpp @@ -20,8 +20,9 @@ namespace Distribute /// General information about NPC that is being processed. /// Leveling information about NPC that is being processed. /// A set of forms that should be distributed to NPC. + /// If true, overwritable forms (like Outfits) will be to overwrite last distributed form on NPC. /// An optional pointer to a set that will accumulate all distributed forms. - void distribute(NPCData& npcData, const PCLevelMult::Input& input, Forms::DistributionSet& forms, DistributedForms* accumulatedForms) + void distribute(NPCData& npcData, const PCLevelMult::Input& input, Forms::DistributionSet& forms, bool allowOverwrites, DistributedForms* accumulatedForms) { const auto npc = npcData.GetNPC(); @@ -124,7 +125,7 @@ namespace Distribute for_each_form( npcData, forms.outfits, input, [&](auto* a_outfit) { - if (npc->defaultOutfit != a_outfit && !npc->HasKeyword(processedOutfit)) { + if (npc->defaultOutfit != a_outfit && (allowOverwrites || !npc->HasKeyword(processedOutfit))) { npc->AddKeyword(processedOutfit); npc->defaultOutfit = a_outfit; return true; @@ -193,13 +194,13 @@ namespace Distribute DistributedForms distributedForms{}; - detail::distribute(npcData, input, entries, &distributedForms); + detail::distribute(npcData, input, entries, false, &distributedForms); // TODO: We can now log per-NPC distributed forms. if (!distributedForms.empty()) { - // This only does one-level linking. So that linked entries won't trigger another level of distribution. + // TODO: This only does one-level linking. So that linked entries won't trigger another level of distribution. LinkedDistribution::Manager::GetSingleton()->ForEachLinkedDistributionSet(distributedForms, [&](Forms::DistributionSet& set) { - detail::distribute(npcData, input, set, nullptr); // TODO: Accumulate forms here? to log what was distributed. + detail::distribute(npcData, input, set, true, nullptr); // TODO: Accumulate forms here? to log what was distributed. }); } } @@ -229,12 +230,12 @@ namespace Distribute Forms::DistributionSet::empty() }; - detail::distribute(npcData, input, entries, &distributedForms); + detail::distribute(npcData, input, entries, false, &distributedForms); // TODO: We can now log per-NPC distributed forms. if (!distributedForms.empty()) { LinkedDistribution::Manager::GetSingleton()->ForEachLinkedDeathDistributionSet(distributedForms, [&](Forms::DistributionSet& set) { - detail::distribute(npcData, input, set, nullptr); // TODO: Accumulate forms here? to log what was distributed. + detail::distribute(npcData, input, set, true, nullptr); // TODO: Accumulate forms here? to log what was distributed. }); } }