Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion soh/soh/Enhancements/customequipment.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <initializer_list>
#include <spdlog/spdlog.h>
#include "src/overlays/actors/ovl_En_Elf/z_en_elf.h"
#include "objects/object_link_boy/object_link_boy.h"
#include "objects/object_link_child/object_link_child.h"
Expand All @@ -24,7 +25,7 @@ static const char* ResolveCustomChain(std::initializer_list<const char*> paths)
for (auto path : paths) {
if (path != nullptr) {
fallback = path;
if (ResourceMgr_FileExists(path)) {
if (ResourceGetIsCustomByName(path) || ResourceMgr_FileExists(path)) {
return path;
}
}
Expand Down Expand Up @@ -113,13 +114,15 @@ static void RefreshCustomEquipment() {
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) {
SPDLOG_DEBUG("CustomEquip: skip patch (null arg) res={} gfx={} d1={} d2={}", resource, gfx, dlist1, dlist2);
return;
}

const bool altAssetsRuntime = ResourceMgr_IsAltAssetsEnabled();

if (!altAssetsRuntime) {
// Alt assets are off; ensure any prior patches using these names are reverted.
SPDLOG_DEBUG("CustomEquip: unpatch (alt assets off) res={}", resource);
ResourceMgr_UnpatchGfxByName(resource, dlist1);
ResourceMgr_UnpatchGfxByName(resource, dlist2);
if (dlist3 != NULL) {
Expand All @@ -131,10 +134,13 @@ void PatchOrUnpatch(const char* resource, const char* gfx, const char* dlist1, c
}

if (!ResourceGetIsCustomByName(gfx)) {
SPDLOG_DEBUG("CustomEquip: skip patch (gfx not custom) gfx={}", gfx);
return;
}

if (alternateDL == NULL || ResourceGetIsCustomByName(alternateDL) || ResourceMgr_FileExists(alternateDL)) {
SPDLOG_DEBUG("CustomEquip: patch res={} gfx={} d1={} d2={} d3={} alt={}", resource, gfx, dlist1, dlist2,
dlist3 != NULL ? dlist3 : "null", alternateDL != NULL ? alternateDL : "null");
ResourceMgr_PatchCustomGfxByName(resource, dlist1, 0, gsSPDisplayListOTRFilePath(gfx));
if (dlist3 == NULL) {
ResourceMgr_PatchCustomGfxByName(resource, dlist2, 1, gsSPEndDisplayList());
Expand All @@ -144,6 +150,8 @@ void PatchOrUnpatch(const char* resource, const char* gfx, const char* dlist1, c
if (dlist3 != NULL) {
ResourceMgr_PatchCustomGfxByName(resource, dlist3, 2, gsSPEndDisplayList());
}
} else {
SPDLOG_DEBUG("CustomEquip: skip patch (alternate missing) alt={}", alternateDL);
}
}

Expand Down
Loading