From f9ca6c7efbf4e965e2f2d9096c97ee8e5d7e0b0f Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Sun, 14 Jan 2024 05:07:56 +0000 Subject: Fix for dlist referencing vtx outside of their own file (#6) --- OTRExporter/DisplayListExporter.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/OTRExporter/DisplayListExporter.cpp b/OTRExporter/DisplayListExporter.cpp index f096352..efead06 100644 --- a/OTRExporter/DisplayListExporter.cpp +++ b/OTRExporter/DisplayListExporter.cpp @@ -815,6 +815,22 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina int32_t aa = (data & 0x000000FF00000000ULL) >> 32; int32_t nn = (data & 0x000FF00000000000ULL) >> 44; + bool isSegmentedPtr = false; + std::string fName = ""; + + // If we can't find the display list in this file, try looking in other files based on the segment number + if (vtxDecl == nullptr) { + uint32_t seg = data & 0xFFFFFFFF; + std::string resourceName = ""; + isSegmentedPtr = Globals::Instance->GetSegmentedPtrName(seg, dList->parent, "", resourceName, res->parent->workerID); + + if (isSegmentedPtr) { + ZFile* assocFile = Globals::Instance->GetSegment(GETSEGNUM(seg), res->parent->workerID); + std::string assocFileName = assocFile->GetName(); + fName = GetPathToRes(assocFile->resources[0], resourceName.c_str()); + vtxDecl = assocFile->GetDeclarationRanged(segOffset); + } + } if (vtxDecl != nullptr && vtxDecl->declName != "Gfx") { @@ -830,7 +846,9 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina writer->Write(word0); writer->Write(word1); - std::string fName = OTRExporter_DisplayList::GetPathToRes(res, vtxDecl->declName); + if (!isSegmentedPtr) { + fName = OTRExporter_DisplayList::GetPathToRes(res, vtxDecl->declName); + } uint64_t hash = CRC64(fName.c_str()); -- cgit v1.2.3