From 4fa3dc84f3f90b3b49cc8f9cc3336cd23dcf3738 Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Thu, 18 Jan 2024 02:34:47 +0000 Subject: Fix some textures (#8) --- OTRExporter/DisplayListExporter.cpp | 40 +++++++++++++++++++++++++------------ 1 file 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; -- cgit v1.2.3