Skip to content

Commit

Permalink
Implemented SetOutfit
Browse files Browse the repository at this point in the history
OutfitManager's SetOutfit hook now directly replaces original implementation.
  • Loading branch information
adya committed Jan 19, 2025
1 parent dfcc11f commit 1e46566
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions SPID/src/OutfitManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,8 @@ namespace Outfits
/// thus eligible for a fresh distribution.
struct ResetReference
{
static inline constexpr REL::Relocation relocation = { RELOCATION_ID(21556, 22038), OFFSET(0x4B, 0x4B) };
static inline constexpr REL::ID relocation = RELOCATION_ID(21556, 22038);
static inline constexpr std::size_t offset = OFFSET(0x4B, 0x4B);

static bool thunk(std::int64_t a1, std::int64_t a2, RE::TESObjectREFR* refr, std::int64_t a4, std::int64_t a5, std::int64_t a6, int a7, int* a8)
{
Expand Down Expand Up @@ -486,9 +487,40 @@ namespace Outfits
static inline constexpr REL::ID relocation = RELOCATION_ID(0, 54784);
static inline constexpr std::size_t offset = OFFSET(0, 0x47D5);

static bool thunk(int a1, int a2, RE::Actor* actor, RE::BGSOutfit* outfit, bool forceUpdate)
static bool thunk(RE::BSScript::Internal::VirtualMachine* vm, RE::VMStackID stackID, RE::Actor* actor, RE::BGSOutfit* outfit, bool isSleepOutfit)
{
return Manager::GetSingleton()->ProcessSetOutfitActor(actor, outfit, [&] { return func(a1, a2, actor, outfit, forceUpdate); });
if (!outfit) {
using PapyrusLog = void(RE::TESObjectREFR*, const char*, RE::BSScript::Internal::VirtualMachine*, RE::VMStackID, RE::BSScript::ErrorLogger::Severity);
REL::Relocation<PapyrusLog> writeLog{ RELOCATION_ID(0, 0x53824) }; // TODO: Find SE relocation
writeLog(actor, "Cannot set sleep or default outfit to None", vm, stackID, RE::BSScript::ErrorLogger::Severity::kError);
return;
}

auto npc = actor->GetActorBase();

if (isSleepOutfit) {
if (npc->sleepOutfit == outfit) {
return;
}
actor->RemoveOutfitItems(npc->sleepOutfit);
npc->SetSleepOutfit(outfit);
} else {

// TODO: Write what was needed here :)
if (npc->defaultOutfit == outfit) {
return;
}
actor->RemoveOutfitItems(npc->defaultOutfit);
npc->SetDefaultOutfit(outfit);
}

actor->InitInventoryIfRequired();
if ((actor->formFlags & RE::TESForm::RecordFlags::kDisabled) == 0) {
actor->AddWornOutfit(outfit, true);
}


return Manager::GetSingleton()->ProcessSetOutfitActor(actor, outfit, [&] { return func(vm, stackID, actor, outfit, isSleepOutfit); });
}

static inline void post_hook()
Expand Down

0 comments on commit 1e46566

Please sign in to comment.