From 50858bd4d1995476630bc48517582e5ad41bdd95 Mon Sep 17 00:00:00 2001 From: adya Date: Mon, 15 Jul 2024 21:04:06 +0000 Subject: [PATCH] maintenance --- SPID/include/DeathDistribution.h | 2 +- SPID/include/Distribute.h | 4 ++-- SPID/include/DistributeManager.h | 2 +- SPID/include/OutfitManager.h | 9 +++++---- SPID/src/DeathDistribution.cpp | 2 +- SPID/src/Distribute.cpp | 16 ++++++++-------- SPID/src/DistributeManager.cpp | 4 ++-- SPID/src/OutfitManager.cpp | 30 +++++++++++++++--------------- 8 files changed, 35 insertions(+), 34 deletions(-) diff --git a/SPID/include/DeathDistribution.h b/SPID/include/DeathDistribution.h index 10f925b..fd9c100 100644 --- a/SPID/include/DeathDistribution.h +++ b/SPID/include/DeathDistribution.h @@ -35,7 +35,7 @@ namespace DeathDistribution /// /// Performs Death Distribution on a given NPC. - /// + /// /// NPC passed to this method must be Dead in order to be processed. /// /// diff --git a/SPID/include/Distribute.h b/SPID/include/Distribute.h index 1306db0..2aae160 100644 --- a/SPID/include/Distribute.h +++ b/SPID/include/Distribute.h @@ -235,8 +235,8 @@ namespace Distribute void Distribute(NPCData& npcData, const PCLevelMult::Input& input, Forms::DistributionSet& forms, bool allowOverwrites, DistributedForms* accumulatedForms = nullptr); /// - /// Invokes appropriate distribution for given NPC. - /// + /// Invokes appropriate distribution for given NPC. + /// /// When NPC is dead a Death Distribution will be invoked, otherwise a normal distribution takes place. /// /// General information about NPC that is being processed. diff --git a/SPID/include/DistributeManager.h b/SPID/include/DistributeManager.h index 038443a..963f9e3 100644 --- a/SPID/include/DistributeManager.h +++ b/SPID/include/DistributeManager.h @@ -3,7 +3,7 @@ namespace Distribute { inline RE::BGSKeyword* processed{ nullptr }; - inline RE::BGSKeyword* processedOutfit{ nullptr }; // TODO: If OutfitManager works out we won't need this keyword. + inline RE::BGSKeyword* processedOutfit{ nullptr }; // TODO: If OutfitManager works out we won't need this keyword. namespace detail { diff --git a/SPID/include/OutfitManager.h b/SPID/include/OutfitManager.h index a2e6ecf..f696da5 100644 --- a/SPID/include/OutfitManager.h +++ b/SPID/include/OutfitManager.h @@ -9,7 +9,7 @@ namespace Outfits /// /// Sets given outfit as default outfit for the actor. - /// + /// /// This method also makes sure to properly remove previously distributed outfit. /// /// Target Actor for whom the outfit will be set. @@ -18,7 +18,7 @@ namespace Outfits /// /// Indicates that given actor didn't receive any distributed outfit and will be using the original one. - /// + /// /// This method helps distinguish cases when there was no outfit distribution for the actor vs when we're reloading the save and replacements cache was cleared. /// void UseOriginalOutfit(RE::Actor*); @@ -39,7 +39,8 @@ namespace Outfits OutfitReplacement() = default; OutfitReplacement(RE::BGSOutfit* original) : original(original), distributed(nullptr) {} - OutfitReplacement(RE::BGSOutfit* original, RE::BGSOutfit* distributed): original(original), distributed(distributed) {} + OutfitReplacement(RE::BGSOutfit* original, RE::BGSOutfit* distributed) : + original(original), distributed(distributed) {} bool UsesOriginalOutfit() const { @@ -67,7 +68,7 @@ struct fmt::formatter { if (replacement.UsesOriginalOutfit()) { return fmt::format_to(a_ctx.out(), "NO REPLACEMENT (Uses {})", *replacement.original); - } else if (replacement.original && replacement.distributed){ + } else if (replacement.original && replacement.distributed) { return fmt::format_to(a_ctx.out(), "{} -> {}", *replacement.original, *replacement.distributed); } else { return fmt::format_to(a_ctx.out(), "INVALID REPLACEMENT"); diff --git a/SPID/src/DeathDistribution.cpp b/SPID/src/DeathDistribution.cpp index 1b4bc07..345b383 100644 --- a/SPID/src/DeathDistribution.cpp +++ b/SPID/src/DeathDistribution.cpp @@ -209,7 +209,7 @@ namespace DeathDistribution assert(data.IsDead()); // We mark NPCs that were processed by Death Distribution with SPID_Dead keyword, - // to ensure that NPCs who received Death Distribution once won't get another Death Distribution + // to ensure that NPCs who received Death Distribution once won't get another Death Distribution // (which might happen if cell or game is reloaded with dead NPC laying there) if (data.GetNPC()->HasKeyword(SPID_Dead)) return; diff --git a/SPID/src/Distribute.cpp b/SPID/src/Distribute.cpp index 8c46a8d..846859e 100644 --- a/SPID/src/Distribute.cpp +++ b/SPID/src/Distribute.cpp @@ -1,9 +1,9 @@ #include "Distribute.h" +#include "DeathDistribution.h" #include "DistributeManager.h" -#include "OutfitManager.h" #include "LinkedDistribution.h" -#include "DeathDistribution.h" +#include "OutfitManager.h" namespace Distribute { @@ -105,13 +105,13 @@ namespace Distribute accumulatedForms); if (!for_first_form( - npcData, forms.outfits, input, [&](auto* a_outfit) { - return Outfits::Manager::GetSingleton()->SetDefaultOutfit(npcData.GetActor(), a_outfit, allowOverwrites); - }, - accumulatedForms)) { + npcData, forms.outfits, input, [&](auto* a_outfit) { + return Outfits::Manager::GetSingleton()->SetDefaultOutfit(npcData.GetActor(), a_outfit, allowOverwrites); + }, + accumulatedForms)) { Outfits::Manager::GetSingleton()->UseOriginalOutfit(npcData.GetActor()); } - + for_first_form( npcData, forms.sleepOutfits, input, [&](auto* a_outfit) { if (npc->sleepOutfit != a_outfit) { @@ -179,7 +179,7 @@ namespace Distribute if (npcData.IsDead()) { // If NPC is already dead, perform the On Death Distribution. DeathDistribution::Manager::GetSingleton()->Distribute(npcData); - } + } } void LogDistribution(const DistributedForms& forms, NPCData& npcData) diff --git a/SPID/src/DistributeManager.cpp b/SPID/src/DistributeManager.cpp index 3234c1b..3f2c018 100644 --- a/SPID/src/DistributeManager.cpp +++ b/SPID/src/DistributeManager.cpp @@ -1,8 +1,8 @@ #include "DistributeManager.h" -#include "OutfitManager.h" #include "DeathDistribution.h" #include "Distribute.h" #include "DistributePCLevelMult.h" +#include "OutfitManager.h" namespace Distribute { @@ -53,7 +53,7 @@ namespace Distribute static void thunk(RE::Character* a_this, RE::BGSLoadFormBuffer* a_buf) { func(a_this, a_buf); - + if (const auto npc = a_this->GetActorBase()) { // some leveled npcs are completely reset upon loading if (a_this->Is3DLoaded()) { diff --git a/SPID/src/OutfitManager.cpp b/SPID/src/OutfitManager.cpp index 0d16b2d..7b6226a 100644 --- a/SPID/src/OutfitManager.cpp +++ b/SPID/src/OutfitManager.cpp @@ -48,8 +48,8 @@ namespace Outfits namespace Data { constexpr std::uint32_t recordType = 'OTFT'; - - template + + template bool Load(SKSE::SerializationInterface* interface, T*& output) { RE::FormID id = 0; @@ -58,7 +58,7 @@ namespace Outfits return false; } - if (!id) { // If ID was 0 it means we don't have the outfit stored in this record. + if (!id) { // If ID was 0 it means we don't have the outfit stored in this record. output = nullptr; return true; } @@ -70,7 +70,7 @@ namespace Outfits if (const auto form = RE::TESForm::LookupByID(id); form) { output = form; return true; - } + } return false; } @@ -177,16 +177,16 @@ namespace Outfits { logger::info("{:*^30}", "LOADING"); - auto* manager = Manager::GetSingleton(); + auto* manager = Manager::GetSingleton(); std::unordered_map loadedReplacements; - auto& newReplacements = manager->replacements; - + auto& newReplacements = manager->replacements; + std::uint32_t type, version, length; while (a_interface->GetNextRecordInfo(type, version, length)) { if (type == Data::recordType) { - RE::Actor* actor; + RE::Actor* actor; RE::BGSOutfit* original; RE::BGSOutfit* distributed; if (Data::Load(a_interface, actor, original, distributed)) { @@ -213,12 +213,12 @@ namespace Outfits std::uint32_t revertedCount = 0; for (const auto& it : loadedReplacements) { - const auto& actor = it.first; + const auto& actor = it.first; const auto& replacement = it.second; if (auto newIt = newReplacements.find(actor); newIt != newReplacements.end()) { - if (newIt->second.UsesOriginalOutfit()) { // If new replacement uses original outfit - if (!replacement.UsesOriginalOutfit() && replacement.distributed == actor->GetActorBase()->defaultOutfit) { // but previous one doesn't and NPC still wears the distributed outfit + if (newIt->second.UsesOriginalOutfit()) { // If new replacement uses original outfit + if (!replacement.UsesOriginalOutfit() && replacement.distributed == actor->GetActorBase()->defaultOutfit) { // but previous one doesn't and NPC still wears the distributed outfit #ifndef NDEBUG logger::info("\tReverting Outfit Replacement for {}", *actor); logger::info("\t\t{}", replacement); @@ -227,12 +227,12 @@ namespace Outfits ++revertedCount; } } - } else { // If new replacement + } else { // If new replacement newIt->second.original = replacement.original; // if there was a previous distribution we want to forward original outfit from there to new distribution. } - - } else { // If there is no new distribution, we want to keep the old one, assuming that whatever outfit is stored in this replacement is what NPC still wears in this save file - newReplacements[actor] = replacement; + + } else { // If there is no new distribution, we want to keep the old one, assuming that whatever outfit is stored in this replacement is what NPC still wears in this save file + newReplacements[actor] = replacement; } }