From 0f031ad34d8d8ad70d5ca157c98a2cca36739092 Mon Sep 17 00:00:00 2001 From: cadmic Date: Wed, 19 Jun 2024 11:05:01 -0700 Subject: [PATCH] Add ZAPD hack to deal with extracted/VERSION/ in include paths --- tools/ZAPD/ZAPD/ZFile.cpp | 12 ++++++++++++ tools/ZAPD/ZAPDUtils/Utils/StringHelper.h | 15 +++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/tools/ZAPD/ZAPD/ZFile.cpp b/tools/ZAPD/ZAPD/ZFile.cpp index 0b2a4d631c..656ef6aa69 100644 --- a/tools/ZAPD/ZAPD/ZFile.cpp +++ b/tools/ZAPD/ZAPD/ZFile.cpp @@ -585,6 +585,12 @@ Declaration* ZFile::AddDeclarationIncludeArray(offset_t address, std::string& in includePath = "assets/" + StringHelper::Split(includePath, "assets/extracted/")[1]; if (StringHelper::StartsWith(includePath, "assets/custom/")) includePath = "assets/" + StringHelper::Split(includePath, "assets/custom/")[1]; + // Hack for OOT: don't prefix include paths with extracted/VERSION/ + if (StringHelper::StartsWith(includePath, "extracted/")) { + std::vector parts = StringHelper::Split(includePath, "/"); + parts.erase(parts.begin(), parts.begin() + 2); + includePath = StringHelper::Join(parts, "/"); + } Declaration* decl = GetDeclaration(address); if (decl == nullptr) @@ -621,6 +627,12 @@ Declaration* ZFile::AddDeclarationIncludeArray(offset_t address, std::string& in includePath = "assets/" + StringHelper::Split(includePath, "assets/extracted/")[1]; if (StringHelper::StartsWith(includePath, "assets/custom/")) includePath = "assets/" + StringHelper::Split(includePath, "assets/custom/")[1]; + // Hack for OOT: don't prefix include paths with extracted/VERSION/ + if (StringHelper::StartsWith(includePath, "extracted/")) { + std::vector parts = StringHelper::Split(includePath, "/"); + parts.erase(parts.begin(), parts.begin() + 2); + includePath = StringHelper::Join(parts, "/"); + } Declaration* decl = GetDeclaration(address); if (decl == nullptr) diff --git a/tools/ZAPD/ZAPDUtils/Utils/StringHelper.h b/tools/ZAPD/ZAPDUtils/Utils/StringHelper.h index c4e012eb06..942d0bcc9e 100644 --- a/tools/ZAPD/ZAPDUtils/Utils/StringHelper.h +++ b/tools/ZAPD/ZAPDUtils/Utils/StringHelper.h @@ -30,6 +30,21 @@ public: return result; } + static std::string Join(const std::vector parts, const std::string& delimiter) + { + std::string result; + + for (size_t i = 0; i < parts.size(); i++) + { + result += parts[i]; + + if (i != parts.size() - 1) + result += delimiter; + } + + return result; + } + static std::string Strip(std::string s, const std::string& delimiter) { size_t pos = 0;