diff options
| author | Reppan <72985260+Jepvid@users.noreply.github.com> | 2026-04-20 19:18:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-20 17:18:08 +0000 |
| commit | bf37645d723254abc9eade79f6f4dc2d4b4b1c80 (patch) | |
| tree | c973cc34375ec0fe7aa8cbff557d5fa651736141 | |
| parent | 3b65eaa4ef7c24611e2884210191c4519d494db9 (diff) | |
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.
| -rw-r--r-- | soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp | 1 | ||||
| -rw-r--r-- | 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 a02a65887..077732809 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 1ce4c7904..06e645380 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(); } |
