diff options
| author | Garrett Cox <garrettjcox@gmail.com> | 2024-01-18 02:34:47 +0000 |
|---|---|---|
| committer | louist103 <35883445+louist103@users.noreply.github.com> | 2025-03-29 13:50:21 -0400 |
| commit | 4fa3dc84f3f90b3b49cc8f9cc3336cd23dcf3738 (patch) | |
| tree | d71057dc6cc768db287b216c553e5e9148e350a0 | |
| parent | 0f763ec8dcbb82fd8fd1bafb39db76f42c2b2626 (diff) | |
Fix some textures (#8)
| -rw-r--r-- | OTRExporter/DisplayListExporter.cpp | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/OTRExporter/DisplayListExporter.cpp b/OTRExporter/DisplayListExporter.cpp index efead06..0e5a647 100644 --- a/OTRExporter/DisplayListExporter.cpp +++ b/OTRExporter/DisplayListExporter.cpp @@ -745,9 +745,6 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina } else { - std::string texName = ""; - bool foundDecl = Globals::Instance->GetSegmentedPtrName(seg, dList->parent, "", texName, res->parent->workerID); - int32_t __ = (data & 0x00FF000000000000) >> 48; int32_t www = (data & 0x00000FFF00000000) >> 32; @@ -763,18 +760,35 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina writer->Write(word0); writer->Write(word1); - if (foundDecl) - { - ZFile* assocFile = Globals::Instance->GetSegment(GETSEGNUM(seg), res->parent->workerID); - std::string assocFileName = assocFile->GetName(); - std::string fName = ""; + bool foundDecl = false; + std::string resourcePath = ""; - if (GETSEGNUM(seg) == SEGMENT_SCENE || GETSEGNUM(seg) == SEGMENT_ROOM) - fName = GetPathToRes(res, texName.c_str()); - else - fName = GetPathToRes(assocFile->resources[0], texName.c_str()); + // First check current file + if (res->parent->segment == GETSEGNUM(seg)) { + uint32_t segmentOffset = GETSEGOFFSET(seg); + Declaration* resourceDecl = dList->parent->GetDeclaration(segmentOffset); - uint64_t hash = CRC64(fName.c_str()); + if (resourceDecl != nullptr) + { + foundDecl = true; + resourcePath = OTRExporter_DisplayList::GetPathToRes(res, resourceDecl->declName); + } + } + + // Then check in global resources + if (!foundDecl) { + foundDecl = Globals::Instance->GetSegmentedPtrName(seg, dList->parent, "", resourcePath, res->parent->workerID); + + if (foundDecl) { + ZFile* assocFile = Globals::Instance->GetSegment(GETSEGNUM(seg), res->parent->workerID); + std::string assocFileName = assocFile->GetName(); + resourcePath = GetPathToRes(assocFile->resources[0], resourcePath); + } + } + + if (foundDecl) + { + uint64_t hash = CRC64(resourcePath.c_str()); word0 = hash >> 32; word1 = hash & 0xFFFFFFFF; |
