summaryrefslogtreecommitdiff
path: root/ZAPD/ZFile.cpp
diff options
context:
space:
mode:
authorNicholas Estelami <NEstelami@users.noreply.github.com>2023-05-30 22:07:11 -0400
committerGitHub <noreply@github.com>2023-05-30 22:07:11 -0400
commitbd87285d719e738a8baee8f11d4d6ffce0ab24a0 (patch)
tree1e4956187985e860261c364eca86d9bd0710e19c /ZAPD/ZFile.cpp
parent55bb75eaa6ebf95858931e1557ed90105a150d80 (diff)
Some cleanup and refactoring (#295)
* Cleaned up Main and improved documentation * Moved ZRoom::GetDeclarationSizeFromNeighbor into ZFile * Fixed compile issue
Diffstat (limited to 'ZAPD/ZFile.cpp')
-rw-r--r--ZAPD/ZFile.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/ZAPD/ZFile.cpp b/ZAPD/ZFile.cpp
index 5087a24..8501509 100644
--- a/ZAPD/ZFile.cpp
+++ b/ZAPD/ZFile.cpp
@@ -272,7 +272,7 @@ void ZFile::ParseXML(tinyxml2::XMLElement* reader, const std::string& filename)
ZResource* nRes = nodeMap[nodeName](this);
if (mode == ZFileMode::Extract || mode == ZFileMode::ExternalFile)
- nRes->ExtractFromXML(child, rawDataIndex);
+ nRes->ExtractWithXML(child, rawDataIndex);
switch (nRes->GetResourceType())
{
@@ -772,6 +772,21 @@ bool ZFile::HasDeclaration(offset_t address)
return declarations.find(address) != declarations.end();
}
+
+size_t ZFile::GetDeclarationSizeFromNeighbor(uint32_t declarationAddress)
+{
+ auto currentDecl = declarations.find(declarationAddress);
+ if (currentDecl == declarations.end())
+ return 0;
+
+ auto nextDecl = currentDecl;
+ std::advance(nextDecl, 1);
+ if (nextDecl == declarations.end())
+ return GetRawData().size() - currentDecl->first;
+
+ return nextDecl->first - currentDecl->first;
+}
+
void ZFile::GenerateSourceFiles()
{
std::string sourceOutput;
@@ -887,13 +902,9 @@ std::string ZFile::GetExternalFileHeaderInclude() const
{
fs::path outputFolderPath = externalFile->GetSourceOutputFolderPath();
if (outputFolderPath == this->GetSourceOutputFolderPath())
- {
outputFolderPath = externalFile->outName.stem();
- }
else
- {
outputFolderPath /= externalFile->outName.stem();
- }
externalFilesIncludes +=
StringHelper::Sprintf("#include \"%s.h\"\n", outputFolderPath.string().c_str());