summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett Cox <garrettjcox@gmail.com>2024-01-14 02:53:34 +0000
committerlouist103 <35883445+louist103@users.noreply.github.com>2025-03-29 13:50:21 -0400
commitffb2d89f1d7163065a449a00335f50b1243b7919 (patch)
tree56b58aeaf5355f1f5a044a70bc511d436f99c378
parente6bd2bb679b2e4f2260c1b1b40a6ac28de30b7b3 (diff)
Fix issue with dlists referencing offsets outside of their own file (#5)
-rw-r--r--OTRExporter/DisplayListExporter.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/OTRExporter/DisplayListExporter.cpp b/OTRExporter/DisplayListExporter.cpp
index 889aca0..f096352 100644
--- a/OTRExporter/DisplayListExporter.cpp
+++ b/OTRExporter/DisplayListExporter.cpp
@@ -477,9 +477,24 @@ void OTRExporter_DisplayList::Save(ZResource* res, const fs::path& outPath, Bina
}
else
{
- word0 = 0;
- word1 = 0;
- spdlog::error(StringHelper::Sprintf("dListDecl == nullptr! Addr = {:08X}", GETSEGOFFSET(data)));
+ // If we can't find the display list in this file, try looking in other files based on the segment number
+ uint32_t seg = data & 0xFFFFFFFF;
+ std::string resourceName = "";
+ bool foundDecl = Globals::Instance->GetSegmentedPtrName(seg, dList->parent, "", resourceName, res->parent->workerID);
+ if (foundDecl) {
+ ZFile* assocFile = Globals::Instance->GetSegment(GETSEGNUM(seg), res->parent->workerID);
+ std::string assocFileName = assocFile->GetName();
+ std::string fName = GetPathToRes(assocFile->resources[0], resourceName.c_str());
+
+ uint64_t hash = CRC64(fName.c_str());
+
+ word0 = hash >> 32;
+ word1 = hash & 0xFFFFFFFF;
+ } else {
+ word0 = 0;
+ word1 = 0;
+ spdlog::error(StringHelper::Sprintf("dListDecl == nullptr! Addr = {:08X}", GETSEGOFFSET(data)));
+ }
}
for (size_t i = 0; i < dList->otherDLists.size(); i++)