Fix Ganondorf boss battle ending (MQ only) (#2072)

This commit is contained in:
Amaro Martínez 2022-12-06 19:24:09 -05:00 committed by GitHub
parent 7f4a19461c
commit 52b896271c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 19 deletions

View File

@ -707,19 +707,29 @@ extern "C" char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize)
return result; return result;
} }
extern "C" void ResourceMgr_LoadFile(const char* resName) { std::string GetName(const char* path) {
OTRGlobals::Instance->context->GetResourceManager()->LoadResource(resName);
}
std::shared_ptr<Ship::Resource> ResourceMgr_LoadResource(const char* path) {
std::string Path = path; std::string Path = path;
if (ResourceMgr_IsGameMasterQuest()) { if (IsGameMasterQuest()) {
size_t pos = 0; size_t pos = 0;
if ((pos = Path.find("/nonmq/", 0)) != std::string::npos) { if ((pos = Path.find("/nonmq/", 0)) != std::string::npos) {
Path.replace(pos, 7, "/mq/"); 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<Ship::Resource> ResourceMgr_LoadResource(const char* path) {
return OTRGlobals::Instance->context->GetResourceManager()->LoadResource(ResourceMgr_GetName(path));
} }
extern "C" char* ResourceMgr_LoadFileRaw(const char* resName) { 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) else if (res->ResType == Ship::ResourceType::Array)
return (char*)(std::static_pointer_cast<Ship::Array>(res))->vertices.data(); return (char*)(std::static_pointer_cast<Ship::Array>(res))->vertices.data();
else { else {
std::string Path = filePath; return ResourceMgr_LoadTexByName(ResourceMgr_GetName(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());
} }
} }

View File

@ -35,6 +35,7 @@ private:
}; };
uint32_t IsGameMasterQuest(); uint32_t IsGameMasterQuest();
std::string GetName(const char* path);
#endif #endif
#ifndef __cplusplus #ifndef __cplusplus
@ -57,6 +58,7 @@ uint32_t ResourceMgr_GetNumGameVersions();
uint32_t ResourceMgr_GetGameVersion(int index); uint32_t ResourceMgr_GetGameVersion(int index);
void ResourceMgr_CacheDirectory(const char* resName); void ResourceMgr_CacheDirectory(const char* resName);
char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize); char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize);
const char* ResourceMgr_GetName(const char* path);
void ResourceMgr_LoadFile(const char* resName); void ResourceMgr_LoadFile(const char* resName);
char* ResourceMgr_LoadFileFromDisk(const char* filePath); char* ResourceMgr_LoadFileFromDisk(const char* filePath);
char* ResourceMgr_LoadJPEG(char* data, int dataSize); char* ResourceMgr_LoadJPEG(char* data, int dataSize);

View File

@ -1197,8 +1197,8 @@ void BossGanon_SetupTowerCutscene(BossGanon* this, PlayState* play) {
void BossGanon_ShatterWindows(u8 windowShatterState) { void BossGanon_ShatterWindows(u8 windowShatterState) {
s16 i; s16 i;
u8* tex1 = ResourceMgr_LoadTexByName(SEGMENTED_TO_VIRTUAL(ganon_boss_sceneTex_006C18)); u8* tex1 = ResourceMgr_LoadTexByName(SEGMENTED_TO_VIRTUAL(ResourceMgr_GetName(ganon_boss_sceneTex_006C18)));
u8* tex2 = ResourceMgr_LoadTexByName(SEGMENTED_TO_VIRTUAL(ganon_boss_sceneTex_007418)); u8* tex2 = ResourceMgr_LoadTexByName(SEGMENTED_TO_VIRTUAL(ResourceMgr_GetName(ganon_boss_sceneTex_007418)));
u8* templateTex = ResourceMgr_LoadTexByName(SEGMENTED_TO_VIRTUAL(gGanondorfWindowShatterTemplateTex)); u8* templateTex = ResourceMgr_LoadTexByName(SEGMENTED_TO_VIRTUAL(gGanondorfWindowShatterTemplateTex));
for (i = 0; i < 2048; i++) { for (i = 0; i < 2048; i++) {
@ -3819,8 +3819,8 @@ void BossGanon_Draw(Actor* thisx, PlayState* play) {
// Invalidate textures if they have changed // Invalidate textures if they have changed
if (this->windowShatterState != GDF_WINDOW_SHATTER_OFF) { if (this->windowShatterState != GDF_WINDOW_SHATTER_OFF) {
gSPInvalidateTexCache(POLY_OPA_DISP++, ganon_boss_sceneTex_006C18); gSPInvalidateTexCache(POLY_OPA_DISP++, ResourceMgr_GetName(ganon_boss_sceneTex_006C18));
gSPInvalidateTexCache(POLY_OPA_DISP++, ganon_boss_sceneTex_007418); gSPInvalidateTexCache(POLY_OPA_DISP++, ResourceMgr_GetName(ganon_boss_sceneTex_007418));
} }
func_80093D18(play->state.gfxCtx); func_80093D18(play->state.gfxCtx);