Skip to content

Commit

Permalink
maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
adya authored and github-actions[bot] committed Jul 15, 2024
1 parent d89a356 commit 50858bd
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 34 deletions.
2 changes: 1 addition & 1 deletion SPID/include/DeathDistribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace DeathDistribution

/// <summary>
/// Performs Death Distribution on a given NPC.
///
///
/// NPC passed to this method must be Dead in order to be processed.
/// </summary>
/// <param name=""></param>
Expand Down
4 changes: 2 additions & 2 deletions SPID/include/Distribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ namespace Distribute
void Distribute(NPCData& npcData, const PCLevelMult::Input& input, Forms::DistributionSet& forms, bool allowOverwrites, DistributedForms* accumulatedForms = nullptr);

/// <summary>
/// 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.
/// </summary>
/// <param name="npcData">General information about NPC that is being processed.</param>
Expand Down
2 changes: 1 addition & 1 deletion SPID/include/DistributeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
9 changes: 5 additions & 4 deletions SPID/include/OutfitManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Outfits

/// <summary>
/// Sets given outfit as default outfit for the actor.
///
///
/// This method also makes sure to properly remove previously distributed outfit.
/// </summary>
/// <param name="Actor">Target Actor for whom the outfit will be set.</param>
Expand All @@ -18,7 +18,7 @@ namespace Outfits

/// <summary>
/// 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.
/// </summary>
void UseOriginalOutfit(RE::Actor*);
Expand All @@ -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
{
Expand Down Expand Up @@ -67,7 +68,7 @@ struct fmt::formatter<Outfits::Manager::OutfitReplacement>
{
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");
Expand Down
2 changes: 1 addition & 1 deletion SPID/src/DeathDistribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions SPID/src/Distribute.cpp
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -105,13 +105,13 @@ namespace Distribute
accumulatedForms);

if (!for_first_form<RE::BGSOutfit>(
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<RE::BGSOutfit>(
npcData, forms.sleepOutfits, input, [&](auto* a_outfit) {
if (npc->sleepOutfit != a_outfit) {
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions SPID/src/DistributeManager.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "DistributeManager.h"
#include "OutfitManager.h"
#include "DeathDistribution.h"
#include "Distribute.h"
#include "DistributePCLevelMult.h"
#include "OutfitManager.h"

namespace Distribute
{
Expand Down Expand Up @@ -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()) {
Expand Down
30 changes: 15 additions & 15 deletions SPID/src/OutfitManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ namespace Outfits
namespace Data
{
constexpr std::uint32_t recordType = 'OTFT';
template<typename T>

template <typename T>
bool Load(SKSE::SerializationInterface* interface, T*& output)
{
RE::FormID id = 0;
Expand All @@ -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;
}
Expand All @@ -70,7 +70,7 @@ namespace Outfits
if (const auto form = RE::TESForm::LookupByID<T>(id); form) {
output = form;
return true;
}
}

return false;
}
Expand Down Expand Up @@ -177,16 +177,16 @@ namespace Outfits
{
logger::info("{:*^30}", "LOADING");

auto* manager = Manager::GetSingleton();
auto* manager = Manager::GetSingleton();

std::unordered_map<RE::Actor*, OutfitReplacement> 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)) {
Expand All @@ -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);
Expand All @@ -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;
}
}

Expand Down

0 comments on commit 50858bd

Please sign in to comment.