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.
This commit is contained in:
Reppan
2026-04-20 19:18:08 +02:00
committed by GitHub
parent 3b65eaa4ef
commit bf37645d72
2 changed files with 13 additions and 2 deletions
@@ -2707,6 +2707,7 @@ void RegisterCosmeticHooks() {
[](s16 sceneNum) { CosmeticsEditor_AutoRandomizeAll(); });
COND_HOOK(OnGameFrameUpdate, true, CosmeticsUpdateTick);
COND_HOOK(OnAssetAltChange, true, []() { ApplyOrResetCustomGfxPatches(true); });
}
void RegisterCosmeticWidgets() {
+12 -2
View File
@@ -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();
}