Skip to content

Commit

Permalink
minor inconsequential stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
adya committed Jul 19, 2024
1 parent ac65d98 commit 042789c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 13 additions & 0 deletions SPID/include/OutfitManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,26 @@ namespace Outfits
public:
static void Register();

/// <summary>
/// Checks whether the actor can technically wear a given outfit.
/// Actor can wear an outfit when all of its components are compatible with actor's race.
///
/// This method doesn't validate any other logic.
/// </summary>
/// <param name="Actor">Target Actor to be tested</param>
/// <param name="Outfit">An outfit that needs to be equipped</param>
/// <returns>True if the actor can wear the outfit, false otherwise</returns>
bool CanEquipOutfit(const RE::Actor*, RE::BGSOutfit*);

/// <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>
/// <param name="Outfit">A new outfit to set as the default.</param>
/// <param name="allowOverwrites">If true, the outfit will be set even if the actor already has a distributed outfit.</param>
/// <returns>True if the outfit was successfully set, false otherwise.</returns>
bool SetDefaultOutfit(RE::Actor*, RE::BGSOutfit*, bool allowOverwrites);

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions SPID/src/OutfitManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ namespace Outfits
return RE::BSEventNotifyControl::kContinue;
}

bool CanEquipOutfit(const RE::Actor* actor, RE::BGSOutfit* outfit)
bool Manager::CanEquipOutfit(const RE::Actor* actor, RE::BGSOutfit* outfit)
{
const auto race = actor->GetRace();
for (const auto& item : outfit->outfitItems) {
Expand All @@ -155,7 +155,7 @@ namespace Outfits
auto defaultOutfit = npc->defaultOutfit;

if (!allowOverwrites && replacements.find(actor->formID) != replacements.end()) {
return true;
return true; // return true to indicate that some outfit was already set for this actor, and with overwrite disabled we won't be able to set any outfit.
}

if (!CanEquipOutfit(actor, outfit)) {
Expand All @@ -165,7 +165,7 @@ namespace Outfits
return false;
}

actor->SetDefaultOutfit(outfit, false); // Having true here causes infinite loading. It seems that it works either way.
actor->SetDefaultOutfit(outfit, false); // Having true here causes infinite loading. It seems that equipping works either way, so we are good :)

if (auto previous = replacements.find(actor->formID); previous != replacements.end()) {
previous->second.distributed = outfit;
Expand Down

0 comments on commit 042789c

Please sign in to comment.