Skip to content

Commit

Permalink
Fix issue with dlists referencing offsets outside of their own file
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettjoecox committed Jan 14, 2024
1 parent f23ccf7 commit 51a2334
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions OTRExporter/DisplayListExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,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++)
Expand Down

0 comments on commit 51a2334

Please sign in to comment.