From bf37645d723254abc9eade79f6f4dc2d4b4b1c80 Mon Sep 17 00:00:00 2001 From: Reppan <72985260+Jepvid@users.noreply.github.com> Date: Mon, 20 Apr 2026 19:18:08 +0200 Subject: [PATCH] Fix mirror shield color editor (#6542) Oversight on my end that customequipment.cpp unloaded and reloaded assets abit to aggressive. Adds a guard to make sure to only unload if custom asset is used and to not unload then reload vanilla asset. Have tested it with fados customequipment and confirmed that mirrorshield is working as intended. --- soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp | 1 + soh/soh/Enhancements/customequipment.cpp | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) 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(); }