Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with dlists referencing offsets outside of their own file #5

Merged
merged 1 commit into from
Jan 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look good but could you add a comment explaining its purpose? Something like // If we can't find the display list in this file, try looking in other files based on the segment number

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