mirror of
https://github.com/HarbourMasters/Shipwright
synced 2026-05-22 22:44:40 -04:00
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:
@@ -2707,6 +2707,7 @@ void RegisterCosmeticHooks() {
|
||||
[](s16 sceneNum) { CosmeticsEditor_AutoRandomizeAll(); });
|
||||
|
||||
COND_HOOK(OnGameFrameUpdate, true, CosmeticsUpdateTick);
|
||||
COND_HOOK(OnAssetAltChange, true, []() { ApplyOrResetCustomGfxPatches(true); });
|
||||
}
|
||||
|
||||
void RegisterCosmeticWidgets() {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user