diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index bccc00e71..42cae1a26 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -707,19 +707,29 @@ extern "C" char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize) return result; } -extern "C" void ResourceMgr_LoadFile(const char* resName) { - OTRGlobals::Instance->context->GetResourceManager()->LoadResource(resName); -} - -std::shared_ptr ResourceMgr_LoadResource(const char* path) { +std::string GetName(const char* path) { std::string Path = path; - if (ResourceMgr_IsGameMasterQuest()) { + if (IsGameMasterQuest()) { size_t pos = 0; if ((pos = Path.find("/nonmq/", 0)) != std::string::npos) { Path.replace(pos, 7, "/mq/"); } } - return OTRGlobals::Instance->context->GetResourceManager()->LoadResource(Path.c_str()); + return Path; +} + +extern "C" const char* ResourceMgr_GetName(const char* path) { + auto s = new std::string(GetName(path)); + const char* name = s->c_str(); + return name; +} + +extern "C" void ResourceMgr_LoadFile(const char* resName) { + OTRGlobals::Instance->context->GetResourceManager()->LoadResource(resName); +} + +std::shared_ptr ResourceMgr_LoadResource(const char* path) { + return OTRGlobals::Instance->context->GetResourceManager()->LoadResource(ResourceMgr_GetName(path)); } extern "C" char* ResourceMgr_LoadFileRaw(const char* resName) { @@ -794,14 +804,7 @@ extern "C" char* ResourceMgr_LoadTexOrDListByName(const char* filePath) { else if (res->ResType == Ship::ResourceType::Array) return (char*)(std::static_pointer_cast(res))->vertices.data(); else { - std::string Path = filePath; - if (ResourceMgr_IsGameMasterQuest()) { - size_t pos = 0; - if ((pos = Path.find("/nonmq/", 0)) != std::string::npos) { - Path.replace(pos, 7, "/mq/"); - } - } - return ResourceMgr_LoadTexByName(Path.c_str()); + return ResourceMgr_LoadTexByName(ResourceMgr_GetName(filePath)); } } diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 549332785..4e1a848ab 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -35,6 +35,7 @@ private: }; uint32_t IsGameMasterQuest(); +std::string GetName(const char* path); #endif #ifndef __cplusplus @@ -57,6 +58,7 @@ uint32_t ResourceMgr_GetNumGameVersions(); uint32_t ResourceMgr_GetGameVersion(int index); void ResourceMgr_CacheDirectory(const char* resName); char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize); +const char* ResourceMgr_GetName(const char* path); void ResourceMgr_LoadFile(const char* resName); char* ResourceMgr_LoadFileFromDisk(const char* filePath); char* ResourceMgr_LoadJPEG(char* data, int dataSize); diff --git a/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c b/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c index 7083bf672..9fdf348c8 100644 --- a/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c +++ b/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c @@ -1197,8 +1197,8 @@ void BossGanon_SetupTowerCutscene(BossGanon* this, PlayState* play) { void BossGanon_ShatterWindows(u8 windowShatterState) { s16 i; - u8* tex1 = ResourceMgr_LoadTexByName(SEGMENTED_TO_VIRTUAL(ganon_boss_sceneTex_006C18)); - u8* tex2 = ResourceMgr_LoadTexByName(SEGMENTED_TO_VIRTUAL(ganon_boss_sceneTex_007418)); + u8* tex1 = ResourceMgr_LoadTexByName(SEGMENTED_TO_VIRTUAL(ResourceMgr_GetName(ganon_boss_sceneTex_006C18))); + u8* tex2 = ResourceMgr_LoadTexByName(SEGMENTED_TO_VIRTUAL(ResourceMgr_GetName(ganon_boss_sceneTex_007418))); u8* templateTex = ResourceMgr_LoadTexByName(SEGMENTED_TO_VIRTUAL(gGanondorfWindowShatterTemplateTex)); for (i = 0; i < 2048; i++) { @@ -3819,8 +3819,8 @@ void BossGanon_Draw(Actor* thisx, PlayState* play) { // Invalidate textures if they have changed if (this->windowShatterState != GDF_WINDOW_SHATTER_OFF) { - gSPInvalidateTexCache(POLY_OPA_DISP++, ganon_boss_sceneTex_006C18); - gSPInvalidateTexCache(POLY_OPA_DISP++, ganon_boss_sceneTex_007418); + gSPInvalidateTexCache(POLY_OPA_DISP++, ResourceMgr_GetName(ganon_boss_sceneTex_006C18)); + gSPInvalidateTexCache(POLY_OPA_DISP++, ResourceMgr_GetName(ganon_boss_sceneTex_007418)); } func_80093D18(play->state.gfxCtx);