diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp index a02a658877..077732809b 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp @@ -2707,6 +2707,7 @@ void RegisterCosmeticHooks() { [](s16 sceneNum) { CosmeticsEditor_AutoRandomizeAll(); }); COND_HOOK(OnGameFrameUpdate, true, CosmeticsUpdateTick); + COND_HOOK(OnAssetAltChange, true, []() { ApplyOrResetCustomGfxPatches(true); }); } void RegisterCosmeticWidgets() { diff --git a/soh/soh/Enhancements/customequipment.cpp b/soh/soh/Enhancements/customequipment.cpp index 1ce4c79048..06e6453802 100644 --- a/soh/soh/Enhancements/customequipment.cpp +++ b/soh/soh/Enhancements/customequipment.cpp @@ -121,6 +121,8 @@ static bool IsDummyPlayer(const Player* player) { return player != nullptr && player->actor.update == DummyPlayer_Update; } +static bool sPrevAltAssetsEnabled = false; + void PatchOrUnpatch(const char* resource, const char* gfx, const char* dlist1, const char* dlist2, const char* dlist3, const char* alternateDL) { if (resource == NULL || gfx == NULL || dlist1 == NULL || dlist2 == NULL) { @@ -128,6 +130,7 @@ void PatchOrUnpatch(const char* resource, const char* gfx, const char* dlist1, c } const bool altAssetsRuntime = ResourceMgr_IsAltAssetsEnabled(); + const bool altAssetsChanged = (altAssetsRuntime != sPrevAltAssetsEnabled); if (!altAssetsRuntime) { // Alt assets are off; ensure any prior patches using these names are reverted. @@ -136,11 +139,16 @@ void PatchOrUnpatch(const char* resource, const char* gfx, const char* dlist1, c if (dlist3 != NULL) { ResourceMgr_UnpatchGfxByName(resource, dlist3); } - // Drop any cached version of the resource so it reloads clean (unpatched) next use. - ResourceMgr_UnloadResource(resource); + if (altAssetsChanged) { + ResourceMgr_UnloadResource(resource); + } return; } + if (altAssetsChanged) { + ResourceMgr_UnloadResource(resource); + } + if (!ResourceGetIsCustomByName(gfx)) { return; } @@ -510,4 +518,6 @@ void UpdatePatchCustomEquipmentDlists() { } ApplyCommonEquipmentPatches(); + + sPrevAltAssetsEnabled = ResourceMgr_IsAltAssetsEnabled(); }