Skip to content

Commit

Permalink
Quick fix for loading older saves.
Browse files Browse the repository at this point in the history
  • Loading branch information
adya committed Jan 11, 2025
1 parent 781d637 commit 675168a
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions SPID/src/OutfitManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,23 @@ namespace Outfits
}

if (!details::Load(interface, distributed, id)) {
failedDistributedOutfitFormID = id;
#ifndef NDEBUG
logger::warn("Failed to load Outfit Replacement record: Unknown distributed outfit [{:08X}].", id);
#endif
return false;
if (!id) {
return false;
}
failedDistributedOutfitFormID = id;
}

bool isDeathOutfit = false;
// For earlier version we assume that all distributed outfits on currently dead actors are death outfits.
if (auto loadedActor = RE::TESForm::LookupByID<RE::Actor>(loadedActorFormID); loadedActor) {
auto npc = loadedActor->GetActorBase();
if (npc && npc->defaultOutfit) {
if (npc) {
// Revert NPC's outfit back to original since we no longer need to track original defaultOutfit since we won't change it.
if (npc->defaultOutfit == distributed) {
// Note this also handles the case when distributed outfit got corrupted (which will make defaultOutfit to be NULL).
if (!distributed || npc->defaultOutfit == distributed) {
npc->defaultOutfit = original;
}
}
Expand Down Expand Up @@ -369,7 +372,9 @@ namespace Outfits
auto initialOutfit = npc->defaultOutfit;
func(npc, a_buf);
if (initialOutfit && initialOutfit != npc->defaultOutfit) {
logger::info("{} loaded outfit {}, originally it was {}", *npc, *npc->defaultOutfit, *initialOutfit);
#ifndef NDEBUG
//logger::info("{} loaded outfit {}, originally it was {}", *npc, *npc->defaultOutfit, *initialOutfit);
#endif
Manager::GetSingleton()->initialOutfits.try_emplace(npc->formID, initialOutfit);
// TODO: Use these to track whether external sources changed the outfit
}
Expand Down Expand Up @@ -491,17 +496,17 @@ namespace Outfits
stl::write_vfunc<RE::Character, Load3D>();
logger::info("Outfit Manager: Installed Load3D hook.");

stl::write_vfunc<RE::TESNPC, LoadGame>();
logger::info("Outfit Manager: Installed LoadGame hook.");
//stl::write_vfunc<RE::TESNPC, LoadGame>();
//logger::info("Outfit Manager: Installed LoadGame hook.");

stl::write_vfunc<RE::Character, Resurrect>();
logger::info("Outfit Manager: Installed Resurrect hook.");

stl::write_thunk_call<ResetReference>();
logger::info("Outfit Manager: Installed ResetReference hook.");

stl::write_thunk_call<SetOutfitActor>();
logger::info("Outfit Manager: Installed SetOutfit hook.");
//stl::write_thunk_call<SetOutfitActor>();
//logger::info("Outfit Manager: Installed SetOutfit hook.");
}
break;
case SKSE::MessagingInterface::kPreLoadGame:
Expand Down

0 comments on commit 675168a

Please sign in to comment.