diff options
| author | Nicholas Estelami <NEstelami@users.noreply.github.com> | 2023-07-20 19:34:07 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-20 19:34:07 -0400 |
| commit | cb03424254152e4c96d236125ef925f9333e90f4 (patch) | |
| tree | a070f59cbfd122f5034260469fa71a1f09b5bae9 | |
| parent | b62d38046dbc6618b5eb433a0a29560e02bf43a9 (diff) | |
Updated to use clang-format-14 (#297)
| -rw-r--r-- | .clang-format | 2 | ||||
| -rw-r--r-- | ExporterTest/Makefile | 2 | ||||
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | ZAPD/CrashHandler.cpp | 2 | ||||
| -rw-r--r-- | ZAPD/Declaration.cpp | 30 | ||||
| -rw-r--r-- | ZAPD/Declaration.h | 122 | ||||
| -rw-r--r-- | ZAPD/GameConfig.h | 3 | ||||
| -rw-r--r-- | ZAPD/Main.cpp | 4 | ||||
| -rw-r--r-- | ZAPD/OutputFormatter.h | 2 | ||||
| -rw-r--r-- | ZAPD/ZCollision.cpp | 25 | ||||
| -rw-r--r-- | ZAPD/ZDisplayList.cpp | 9 | ||||
| -rw-r--r-- | ZAPD/ZFile.cpp | 11 | ||||
| -rw-r--r-- | ZAPD/ZPath.cpp | 8 | ||||
| -rw-r--r-- | ZAPD/ZResource.h | 4 | ||||
| -rw-r--r-- | ZAPD/ZTexture.cpp | 28 | ||||
| -rw-r--r-- | ZAPD/ZTexture.h | 4 | ||||
| -rw-r--r-- | ZAPD/ZWaterbox.h | 34 | ||||
| -rw-r--r-- | ZAPDUtils/Makefile | 2 | ||||
| -rw-r--r-- | ZAPDUtils/Utils/BitConverter.h | 20 | ||||
| -rw-r--r-- | ZAPDUtils/Utils/StringHelper.h | 3 |
20 files changed, 165 insertions, 152 deletions
diff --git a/.clang-format b/.clang-format index 784e734..5ba1c4a 100644 --- a/.clang-format +++ b/.clang-format @@ -66,7 +66,7 @@ PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Left ReflowComments: true -SortIncludes: true +SortIncludes: false SpaceAfterCStyleCast: false SpaceBeforeAssignmentOperators: true SpaceBeforeParens: ControlStatements diff --git a/ExporterTest/Makefile b/ExporterTest/Makefile index 42033b7..98e0475 100644 --- a/ExporterTest/Makefile +++ b/ExporterTest/Makefile @@ -17,7 +17,7 @@ clean: rm -rf build $(LIB) format: - clang-format-11 -i $(CPP_FILES) $(H_FILES) + clang-format-14 -i $(CPP_FILES) $(H_FILES) .PHONY: all clean format @@ -106,7 +106,7 @@ clean: rebuild: clean all format: - clang-format-11 -i $(ZAPD_CPP_FILES) $(ZAPD_H_FILES) + clang-format-14 -i $(ZAPD_CPP_FILES) $(ZAPD_H_FILES) $(MAKE) -C ZAPDUtils format $(MAKE) -C ExporterTest format diff --git a/ZAPD/CrashHandler.cpp b/ZAPD/CrashHandler.cpp index 506e410..7ddec5a 100644 --- a/ZAPD/CrashHandler.cpp +++ b/ZAPD/CrashHandler.cpp @@ -8,9 +8,9 @@ #endif #include <array> +#include <cstdint> #include <cstdio> #include <cstdlib> -#include <cstdint> #include <ctime> #if HAS_POSIX == 1 diff --git a/ZAPD/Declaration.cpp b/ZAPD/Declaration.cpp index 1da29f4..3086380 100644 --- a/ZAPD/Declaration.cpp +++ b/ZAPD/Declaration.cpp @@ -13,7 +13,8 @@ Declaration::Declaration(offset_t nAddress, DeclarationAlignment nAlignment, siz } Declaration* Declaration::Create(offset_t declAddr, DeclarationAlignment declAlign, size_t declSize, - const std::string& declType, const std::string& declName, const std::string& declBody) + const std::string& declType, const std::string& declName, + const std::string& declBody) { Declaration* decl = new Declaration(declAddr, declAlign, declSize, declBody); @@ -25,13 +26,12 @@ Declaration* Declaration::Create(offset_t declAddr, DeclarationAlignment declAli } Declaration* Declaration::CreateArray(offset_t declAddr, DeclarationAlignment declAlign, - size_t declSize, const std::string& declType, const std::string& declName, - const std::string& declBody, size_t declArrayItemCnt, - bool isDeclExternal) + size_t declSize, const std::string& declType, + const std::string& declName, const std::string& declBody, + size_t declArrayItemCnt, bool isDeclExternal) { Declaration* decl = new Declaration(declAddr, declAlign, declSize, declBody); - decl->declName = declName; decl->declType = declType; decl->arrayItemCnt = declArrayItemCnt; @@ -42,9 +42,9 @@ Declaration* Declaration::CreateArray(offset_t declAddr, DeclarationAlignment de } Declaration* Declaration::CreateArray(offset_t declAddr, DeclarationAlignment declAlign, - size_t declSize, const std::string& declType, const std::string& declName, - const std::string& declBody, const std::string& declArrayItemCntStr, - bool isDeclExternal) + size_t declSize, const std::string& declType, + const std::string& declName, const std::string& declBody, + const std::string& declArrayItemCntStr, bool isDeclExternal) { Declaration* decl = new Declaration(declAddr, declAlign, declSize, declBody); @@ -57,9 +57,9 @@ Declaration* Declaration::CreateArray(offset_t declAddr, DeclarationAlignment de return decl; } -Declaration* Declaration::CreateInclude(offset_t declAddr, const std::string& includePath, size_t declSize, - const std::string& declType, const std::string& declName, - const std::string& defines) +Declaration* Declaration::CreateInclude(offset_t declAddr, const std::string& includePath, + size_t declSize, const std::string& declType, + const std::string& declName, const std::string& defines) { Declaration* decl = new Declaration(declAddr, DeclarationAlignment::Align4, declSize, ""); decl->includePath = includePath; @@ -67,14 +67,12 @@ Declaration* Declaration::CreateInclude(offset_t declAddr, const std::string& in decl->declName = declName; decl->defines = defines; - return decl; } Declaration* Declaration::CreatePlaceholder(offset_t declAddr, const std::string& declName) { - Declaration* decl = - new Declaration(declAddr, DeclarationAlignment::Align4, 0, ""); + Declaration* decl = new Declaration(declAddr, DeclarationAlignment::Align4, 0, ""); decl->declName = declName; decl->isPlaceholder = true; @@ -117,8 +115,8 @@ std::string Declaration::GetNormalDeclarationStr() const output += StringHelper::Sprintf("%s %s[%s];\n", declType.c_str(), declName.c_str(), arrayItemCntStr.c_str()); else - output += StringHelper::Sprintf("%s %s[%i] = {\n", declType.c_str(), declName.c_str(), - arrayItemCnt); + output += StringHelper::Sprintf("%s %s[%i] = {\n", declType.c_str(), + declName.c_str(), arrayItemCnt); } else { diff --git a/ZAPD/Declaration.h b/ZAPD/Declaration.h index f5af671..d079cb8 100644 --- a/ZAPD/Declaration.h +++ b/ZAPD/Declaration.h @@ -1,8 +1,8 @@ #pragma once +#include <cstdint> #include <string> #include <vector> -#include <cstdint> // TODO: should we drop the `_t` suffix because of UNIX compliance? typedef uint32_t segptr_t; @@ -24,15 +24,16 @@ enum class StaticConfig }; /// <summary> -/// A declaration is contains the C contents of a symbol for a file. -/// It contains at a minimum the address where the symbol would be in the binary file, alignment settings, the size of the binary data, and the C code that makes it up. -/// Optionally it can also contain comments. +/// A declaration is contains the C contents of a symbol for a file. +/// It contains at a minimum the address where the symbol would be in the binary file, alignment +/// settings, the size of the binary data, and the C code that makes it up. Optionally it can also +/// contain comments. /// </summary> class Declaration { public: // Where in the binary file (segment) will this C code end up being? - offset_t address = 0; + offset_t address = 0; // How is this C code aligned? DeclarationAlignment alignment = DeclarationAlignment::Align4; @@ -50,12 +51,13 @@ public: // In "int j = 7;", "7" would be text. std::string declBody = ""; - // #define's to be included in the header - std::string defines = ""; + // #define's to be included in the header + std::string defines = ""; std::string includePath = ""; - // Is this declaration in an external file? (ie. a gameplay_keep reference being found in another file that wishes to use its data) + // Is this declaration in an external file? (ie. a gameplay_keep reference being found in + // another file that wishes to use its data) bool isExternal = false; bool isArray = false; @@ -71,16 +73,16 @@ public: std::vector<segptr_t> references; - // If true, this declaration represents data inside the file which we do not understand it's purpose for. - // It will be outputted as just a byte array. + // If true, this declaration represents data inside the file which we do not understand it's + // purpose for. It will be outputted as just a byte array. bool isUnaccounted = false; // Is this declaration a placeholder that will be replaced later? bool isPlaceholder = false; - // Does this declaration come straight from the XML? - // If false, this means that the declaration was created by ZAPD when it was parsing the resources. + // If false, this means that the declaration was created by ZAPD when it was parsing the + // resources. bool declaredInXml = false; StaticConfig staticConf = StaticConfig::Global; @@ -88,78 +90,82 @@ public: /// <summary> /// Creates a regular declaration. /// </summary> - /// <param name="declAddr">The address inside a binary file this declaration will be in when compiled.</param> - /// <param name="declAlign">The alignment of this declaration in the compiled binary file.</param> - /// <param name="declSize">The size of this declaration when it is compiled to binary data.</param> - /// <param name="declType">The C variable type this declaration will be declared as.</param> - /// <param name="declName">The C variable name this declaration will be declared as.</param> - /// <param name="declBody">The contents of the C variable declaration.</param> - /// <returns></returns> + /// <param name="declAddr">The address inside a binary file this declaration will be in when + /// compiled.</param> <param name="declAlign">The alignment of this declaration in the compiled + /// binary file.</param> <param name="declSize">The size of this declaration when it is compiled + /// to binary data.</param> <param name="declType">The C variable type this declaration will be + /// declared as.</param> <param name="declName">The C variable name this declaration will be + /// declared as.</param> <param name="declBody">The contents of the C variable + /// declaration.</param> <returns></returns> static Declaration* Create(offset_t declAddr, DeclarationAlignment declAlign, size_t declSize, - const std::string& declType, const std::string& declName, const std::string& declBody); + const std::string& declType, const std::string& declName, + const std::string& declBody); /// <summary> /// Creates an array declaration. /// </summary> - /// <param name="declAddr">The address inside a binary file this declaration will be in when compiled.</param> - /// <param name="declAlign">The alignment of this declaration in the compiled binary file.</param> - /// <param name="declSize">The size of this declaration when it is compiled to binary data.</param> - /// <param name="declType">The C variable type this declaration will be declared as.</param> - /// <param name="declName">The C variable name this declaration will be declared as.</param> - /// <param name="declBody">The contents of the C variable declaration.</param> - /// <param name="declArrayItemCnt">The number of items in the array.</param> - /// <param name="isDeclExternal">(Optional) Is this declaration from another segment?</param> - /// <returns></returns> + /// <param name="declAddr">The address inside a binary file this declaration will be in when + /// compiled.</param> <param name="declAlign">The alignment of this declaration in the compiled + /// binary file.</param> <param name="declSize">The size of this declaration when it is compiled + /// to binary data.</param> <param name="declType">The C variable type this declaration will be + /// declared as.</param> <param name="declName">The C variable name this declaration will be + /// declared as.</param> <param name="declBody">The contents of the C variable + /// declaration.</param> <param name="declArrayItemCnt">The number of items in the + /// array.</param> <param name="isDeclExternal">(Optional) Is this declaration from another + /// segment?</param> <returns></returns> static Declaration* CreateArray(offset_t declAddr, DeclarationAlignment declAlign, - size_t declSize, const std::string& declType, const std::string& declName, - const std::string& declBody, size_t declArrayItemCnt = 0, - bool isDeclExternal = false); + size_t declSize, const std::string& declType, + const std::string& declName, const std::string& declBody, + size_t declArrayItemCnt = 0, bool isDeclExternal = false); /// <summary> /// Creates an array declaration who's size in the C code uses a custom string. /// </summary> - /// <param name="declAddr">The address inside a binary file this declaration will be in when compiled.</param> - /// <param name="declAlign">The alignment of this declaration in the compiled binary file.</param> - /// <param name="declSize">The size of this declaration when it is compiled to binary data.</param> - /// <param name="declType">The C variable type this declaration will be declared as.</param> - /// <param name="declName">The C variable name this declaration will be declared as.</param> - /// <param name="declBody">The contents of the C variable declaration.</param> - /// <param name="declArrayItemCntStr">The string to be put in the C array's size inbetween the brackets.</param> - /// <param name="isDeclExternal">(Optional) Is this declaration from another segment?</param> - /// <returns></returns> + /// <param name="declAddr">The address inside a binary file this declaration will be in when + /// compiled.</param> <param name="declAlign">The alignment of this declaration in the compiled + /// binary file.</param> <param name="declSize">The size of this declaration when it is compiled + /// to binary data.</param> <param name="declType">The C variable type this declaration will be + /// declared as.</param> <param name="declName">The C variable name this declaration will be + /// declared as.</param> <param name="declBody">The contents of the C variable + /// declaration.</param> <param name="declArrayItemCntStr">The string to be put in the C array's + /// size inbetween the brackets.</param> <param name="isDeclExternal">(Optional) Is this + /// declaration from another segment?</param> <returns></returns> static Declaration* CreateArray(offset_t declAddr, DeclarationAlignment declAlign, - size_t declSize, const std::string& declType, const std::string& declName, - const std::string& declBody, const std::string& declArrayItemCntStr, + size_t declSize, const std::string& declType, + const std::string& declName, const std::string& declBody, + const std::string& declArrayItemCntStr, bool isDeclExternal = false); /// <summary> /// Creates a declaration who's body uses a #include to include another file /// </summary> - /// <param name="declAddr">The address inside a binary file this declaration will be in when compiled.</param> - /// <param name="includePath">The path to the file this declaration will be #including.</param> - /// <param name="declSize">The size of this declaration when it is compiled to binary data.</param> - /// <param name="declType">The C variable type this declaration will be declared as.</param> - /// <param name="declName">The C variable name this declaration will be declared as.</param> - /// <param name="defines">(Optional) Any #define's we want to have outputted by this declaration.</param> - /// <returns></returns> - static Declaration* CreateInclude(offset_t declAddr, const std::string& includePath, size_t declSize, - const std::string& declType, const std::string& declName, - const std::string& defines = ""); + /// <param name="declAddr">The address inside a binary file this declaration will be in when + /// compiled.</param> <param name="includePath">The path to the file this declaration will be + /// #including.</param> <param name="declSize">The size of this declaration when it is compiled + /// to binary data.</param> <param name="declType">The C variable type this declaration will be + /// declared as.</param> <param name="declName">The C variable name this declaration will be + /// declared as.</param> <param name="defines">(Optional) Any #define's we want to have + /// outputted by this declaration.</param> <returns></returns> + static Declaration* CreateInclude(offset_t declAddr, const std::string& includePath, + size_t declSize, const std::string& declType, + const std::string& declName, const std::string& defines = ""); /// <summary> /// Creates a placeholder declaration to be replaced later. /// </summary> - /// <param name="declAddr">The address inside a binary file this declaration will be in when compiled.</param> - /// <param name="declName">The C variable name this declaration will be declared as.</param> - /// <returns></returns> + /// <param name="declAddr">The address inside a binary file this declaration will be in when + /// compiled.</param> <param name="declName">The C variable name this declaration will be + /// declared as.</param> <returns></returns> static Declaration* CreatePlaceholder(offset_t declAddr, const std::string& declName); bool IsStatic() const; - // Returns the declaration as C code as it would be in the code file when the body contains the needed data + // Returns the declaration as C code as it would be in the code file when the body contains the + // needed data std::string GetNormalDeclarationStr() const; - // Returns the declaration as C code as it would be in the code file when the body #include's another file + // Returns the declaration as C code as it would be in the code file when the body #include's + // another file std::string GetExternalDeclarationStr() const; // Generates the extern for this item to be placed in header files. diff --git a/ZAPD/GameConfig.h b/ZAPD/GameConfig.h index 25b94cb..d650c6d 100644 --- a/ZAPD/GameConfig.h +++ b/ZAPD/GameConfig.h @@ -37,7 +37,8 @@ public: // ZBackground uint32_t bgScreenWidth = 320, bgScreenHeight = 240; - bool useScreenWidthHeightConstants = true; // If true, ZBackground's will be declared with SCREEN_WIDTH * SCREEN_HEIGHT in the C file + bool useScreenWidthHeightConstants = true; // If true, ZBackground's will be declared with + // SCREEN_WIDTH * SCREEN_HEIGHT in the C file // ExternalFile fs::path externalXmlFolder; diff --git a/ZAPD/Main.cpp b/ZAPD/Main.cpp index 28b280f..d92a279 100644 --- a/ZAPD/Main.cpp +++ b/ZAPD/Main.cpp @@ -9,8 +9,8 @@ #include "ZFile.h" #include "ZTexture.h" -#include "CrashHandler.h" #include <functional> +#include "CrashHandler.h" #include <string> #include <string_view> @@ -37,7 +37,6 @@ void Arg_EnableGCCCompat(int& i, char* argv[]); void Arg_ForceStatic(int& i, char* argv[]); void Arg_ForceUnaccountedStatic(int& i, char* argv[]); - int main(int argc, char* argv[]); bool Parse(const fs::path& xmlFilePath, const fs::path& basePath, const fs::path& outPath, @@ -270,7 +269,6 @@ void ParseArgs(int& argc, char* argv[]) } } - ZFileMode ParseFileMode(const std::string& buildMode, ExporterSet* exporterSet) { ZFileMode fileMode = ZFileMode::Invalid; diff --git a/ZAPD/OutputFormatter.h b/ZAPD/OutputFormatter.h index 290a8dc..ec56b65 100644 --- a/ZAPD/OutputFormatter.h +++ b/ZAPD/OutputFormatter.h @@ -1,9 +1,9 @@ #pragma once +#include <cstdint> #include <map> #include <string> #include <vector> -#include <cstdint> class OutputFormatter { diff --git a/ZAPD/ZCollision.cpp b/ZAPD/ZCollision.cpp index 71835e7..8c19316 100644 --- a/ZAPD/ZCollision.cpp +++ b/ZAPD/ZCollision.cpp @@ -123,7 +123,8 @@ void ZCollisionHeader::ParseRawData() upperCameraBoundary = rawDataIndex; } - // Sharp Ocarina places the CamDataEntries above the list so we need to calculate the number of cameras differently. + // Sharp Ocarina places the CamDataEntries above the list so we need to calculate the number + // of cameras differently. if (upperCameraBoundary < camDataSegmentOffset) { offset_t offset = camDataSegmentOffset; @@ -138,7 +139,8 @@ void ZCollisionHeader::ParseRawData() new CameraDataList(parent, name, rawData, camDataSegmentOffset, upperCameraBoundary); } - for (int32_t i = 0; i < numWaterBoxes; i++) { + for (int32_t i = 0; i < numWaterBoxes; i++) + { ZWaterbox waterbox(parent); waterbox.SetRawDataIndex(waterBoxSegmentOffset + @@ -240,7 +242,8 @@ std::string ZCollisionHeader::GetBodySourceCode() const Globals::Instance->GetSegmentedPtrName(vtxAddress, parent, "Vec3s", vtxName); if (numVerts > 0) - declaration += StringHelper::Sprintf("\tARRAY_COUNT(%s), %s,\n", vtxName.c_str(), vtxName.c_str()); + declaration += + StringHelper::Sprintf("\tARRAY_COUNT(%s), %s,\n", vtxName.c_str(), vtxName.c_str()); else declaration += StringHelper::Sprintf("\t%i, %s,\n", numVerts, vtxName.c_str()); @@ -248,7 +251,8 @@ std::string ZCollisionHeader::GetBodySourceCode() const Globals::Instance->GetSegmentedPtrName(polyAddress, parent, "CollisionPoly", polyName); if (numPolygons > 0) - declaration += StringHelper::Sprintf("\tARRAY_COUNT(%s), %s,\n", polyName.c_str(), polyName.c_str()); + declaration += + StringHelper::Sprintf("\tARRAY_COUNT(%s), %s,\n", polyName.c_str(), polyName.c_str()); else declaration += StringHelper::Sprintf("\t%i, %s,\n", numPolygons, polyName.c_str()); @@ -264,7 +268,8 @@ std::string ZCollisionHeader::GetBodySourceCode() const Globals::Instance->GetSegmentedPtrName(waterBoxAddress, parent, "WaterBox", waterBoxName); if (numWaterBoxes > 0) - declaration += StringHelper::Sprintf("\tARRAY_COUNT(%s), %s\n", waterBoxName.c_str(), waterBoxName.c_str()); + declaration += StringHelper::Sprintf("\tARRAY_COUNT(%s), %s\n", waterBoxName.c_str(), + waterBoxName.c_str()); else declaration += StringHelper::Sprintf("\t%i, %s\n", numWaterBoxes, waterBoxName.c_str()); @@ -328,9 +333,10 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix, cameraPosDataSeg > GETSEGOFFSET(entry.cameraPosDataSeg)) cameraPosDataSeg = GETSEGOFFSET(entry.cameraPosDataSeg); } - else + else { - // Sharp Ocarina will place the cam data after the list as opposed to the original maps which have it before. + // Sharp Ocarina will place the cam data after the list as opposed to the original maps + // which have it before. isSharpOcarina = true; cameraPosDataSeg = rawDataIndex + (numElements * 0x8); if (cameraPosDataSegEnd < GETSEGOFFSET(entry.cameraPosDataSeg)) @@ -349,8 +355,7 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix, if (entries[i].cameraPosDataSeg != 0) { uint32_t index = - (GETSEGOFFSET(entries[i].cameraPosDataSeg) - cameraPosDataOffset) / - 0x6; + (GETSEGOFFSET(entries[i].cameraPosDataSeg) - cameraPosDataOffset) / 0x6; snprintf(camSegLine, 2048, "&%sCamPosData[%i]", prefix.c_str(), index); } else @@ -363,7 +368,7 @@ CameraDataList::CameraDataList(ZFile* parent, const std::string& prefix, if (i < entries.size() - 1) declaration += "\n"; } - + parent->AddDeclarationArray( rawDataIndex, DeclarationAlignment::Align4, entries.size() * 8, "CamData", StringHelper::Sprintf("%sCamDataList", prefix.c_str(), rawDataIndex), entries.size(), diff --git a/ZAPD/ZDisplayList.cpp b/ZAPD/ZDisplayList.cpp index 3d34370..98c4d0e 100644 --- a/ZAPD/ZDisplayList.cpp +++ b/ZAPD/ZDisplayList.cpp @@ -1645,8 +1645,10 @@ static int32_t GfxdCallback_Vtx(uint32_t seg, int32_t count) bool keyAlreadyOccupied = self->vertices.find(vtxOffset) != self->vertices.end(); - // In some cases a vtxList already exists at vtxOffset. Only override the existing list if the new one is bigger. - if (!keyAlreadyOccupied || (keyAlreadyOccupied && vtxList.size() > self->vertices[vtxOffset].size())) + // In some cases a vtxList already exists at vtxOffset. Only override the existing list + // if the new one is bigger. + if (!keyAlreadyOccupied || + (keyAlreadyOccupied && vtxList.size() > self->vertices[vtxOffset].size())) self->vertices[vtxOffset] = vtxList; } } @@ -1894,7 +1896,8 @@ void ZDisplayList::DeclareReferences(const std::string& prefix) vtxName = StringHelper::Sprintf("%sVtx_%06X", prefix.c_str(), vtxKeys[i]); auto filepath = Globals::Instance->outputPath / vtxName; - std::string incStr = StringHelper::Sprintf("%s.%s.inc", filepath.string().c_str(), "vtx"); + std::string incStr = + StringHelper::Sprintf("%s.%s.inc", filepath.string().c_str(), "vtx"); Declaration* vtxDecl = parent->AddDeclarationIncludeArray( vtxKeys[i], incStr, item.size() * 16, "Vtx", vtxName, item.size()); diff --git a/ZAPD/ZFile.cpp b/ZAPD/ZFile.cpp index 8501509..0b2a4d6 100644 --- a/ZAPD/ZFile.cpp +++ b/ZAPD/ZFile.cpp @@ -513,8 +513,8 @@ Declaration* ZFile::AddDeclarationArray(offset_t address, DeclarationAlignment a Declaration* decl = GetDeclaration(address); if (decl == nullptr) { - decl = Declaration::CreateArray(address, alignment, size, varType, varName, - body, arrayItemCntStr); + decl = Declaration::CreateArray(address, alignment, size, varType, varName, body, + arrayItemCntStr); declarations[address] = decl; } @@ -772,7 +772,6 @@ bool ZFile::HasDeclaration(offset_t address) return declarations.find(address) != declarations.end(); } - size_t ZFile::GetDeclarationSizeFromNeighbor(uint32_t declarationAddress) { auto currentDecl = declarations.find(declarationAddress); @@ -876,8 +875,8 @@ void ZFile::GenerateSourceHeaderFiles() std::string ZFile::GetHeaderInclude() const { - std::string headers = StringHelper::Sprintf("#include \"%s.h\"\n", - (outName.parent_path() / outName.stem()).string().c_str()); + std::string headers = StringHelper::Sprintf( + "#include \"%s.h\"\n", (outName.parent_path() / outName.stem()).string().c_str()); return headers; } @@ -1153,7 +1152,7 @@ void ZFile::ProcessDeclarationText(Declaration* decl) std::string ZFile::ProcessExterns() { std::string output = ""; - bool hadDefines = true; // Previous declaration included defines. + bool hadDefines = true; // Previous declaration included defines. for (const auto& item : declarations) { diff --git a/ZAPD/ZPath.cpp b/ZAPD/ZPath.cpp index 7a014cf..cb82956 100644 --- a/ZAPD/ZPath.cpp +++ b/ZAPD/ZPath.cpp @@ -6,8 +6,8 @@ #include "WarningHandler.h" #include "ZFile.h" -REGISTER_ZFILENODE(Path, ZPath); // Old name that is being kept for backwards compatability -REGISTER_ZFILENODE(PathList, ZPath); // New name that may be used in future XMLs +REGISTER_ZFILENODE(Path, ZPath); // Old name that is being kept for backwards compatability +REGISTER_ZFILENODE(PathList, ZPath); // New name that may be used in future XMLs ZPath::ZPath(ZFile* nParent) : ZResource(nParent) { @@ -188,8 +188,8 @@ std::string PathwayEntry::GetBodySourceCode() const else { if (numPoints > 0) - declaration += - StringHelper::Sprintf("ARRAY_COUNT(%s), %s", listName.c_str(), listName.c_str()); + declaration += + StringHelper::Sprintf("ARRAY_COUNT(%s), %s", listName.c_str(), listName.c_str()); else declaration += StringHelper::Sprintf("%i, %s", numPoints, listName.c_str()); } diff --git a/ZAPD/ZResource.h b/ZAPD/ZResource.h index 171dcdc..9754013 100644 --- a/ZAPD/ZResource.h +++ b/ZAPD/ZResource.h @@ -80,12 +80,12 @@ public: ZResource(ZFile* nParent); virtual ~ZResource() = default; - /// <summary> /// Extracts/Parsees data from binary file using an XML to provide the needed metadata. /// </summary> /// <param name="reader">XML Node we wish to parse from.</param> - /// <param name="nRawDataIndex">The offset within the binary file we are going to parse from as indicated by the "Offset" parameter in the XML.</param> + /// <param name="nRawDataIndex">The offset within the binary file we are going to parse from as + /// indicated by the "Offset" parameter in the XML.</param> virtual void ExtractWithXML(tinyxml2::XMLElement* reader, offset_t nRawDataIndex); /// <summary> diff --git a/ZAPD/ZTexture.cpp b/ZAPD/ZTexture.cpp index fe54489..0ecda1a 100644 --- a/ZAPD/ZTexture.cpp +++ b/ZAPD/ZTexture.cpp @@ -227,8 +227,8 @@ void ZTexture::ConvertN64ToBitmap_RGBA16() uint8_t b = (data & 0x003E) >> 1; uint8_t alpha = data & 0x01; - textureData.SetRGBPixel(y, x, (r << 3) | (r >> 2), (g << 3) | (g >> 2), (b << 3) | (b >> 2), - alpha * 255); + textureData.SetRGBPixel(y, x, (r << 3) | (r >> 2), (g << 3) | (g >> 2), + (b << 3) | (b >> 2), alpha * 255); } } } @@ -310,7 +310,7 @@ void ZTexture::ConvertN64ToBitmap_GrayscaleAlpha4() data = parentRawData.at(pos) & 0x0F; uint8_t grayscale = data & 0b1110; - grayscale = (grayscale << 4) | (grayscale << 1) | (grayscale >> 2); + grayscale = (grayscale << 4) | (grayscale << 1) | (grayscale >> 2); uint8_t alpha = (data & 0x01) ? 255 : 0; textureData.SetGrayscalePixel(y, x + i, grayscale, alpha); @@ -570,8 +570,8 @@ void ZTexture::ConvertBitmapToN64_GrayscaleAlpha8() size_t pos = ((y * width) + x) * 1; RGBAPixel pixel = textureData.GetPixel(y, x); - uint8_t r = (pixel.r >> 4) &0xF; - uint8_t a = (pixel.a >> 4) &0xF; + uint8_t r = (pixel.r >> 4) & 0xF; + uint8_t a = (pixel.a >> 4) & 0xF; textureDataRaw[pos] = (r << 4) | a; } @@ -777,8 +777,8 @@ Declaration* ZTexture::DeclareVar(const std::string& prefix, auto filepath = Globals::Instance->outputPath / fs::path(auxOutName).stem(); if (dWordAligned) - incStr = - StringHelper::Sprintf("%s.%s.inc.c", filepath.string().c_str(), GetExternalExtension().c_str()); + incStr = StringHelper::Sprintf("%s.%s.inc.c", filepath.string().c_str(), + GetExternalExtension().c_str()); else incStr = StringHelper::Sprintf("%s.u32.%s.inc.c", filepath.string().c_str(), GetExternalExtension().c_str()); @@ -792,10 +792,12 @@ Declaration* ZTexture::DeclareVar(const std::string& prefix, if (poolEntry != Globals::Instance->cfg.texturePool.end()) { if (dWordAligned) - incStr = StringHelper::Sprintf("%s.%s.inc.c", poolEntry->second.path.string().c_str(), - GetExternalExtension().c_str()); + incStr = + StringHelper::Sprintf("%s.%s.inc.c", poolEntry->second.path.string().c_str(), + GetExternalExtension().c_str()); else - incStr = StringHelper::Sprintf("%s.u32.%s.inc.c", poolEntry->second.path.string().c_str(), + incStr = StringHelper::Sprintf("%s.u32.%s.inc.c", + poolEntry->second.path.string().c_str(), GetExternalExtension().c_str()); } } @@ -811,9 +813,9 @@ Declaration* ZTexture::DeclareVar(const std::string& prefix, } else { - decl = - parent->AddDeclarationIncludeArray(rawDataIndex, incStr, GetRawDataSize(), - GetSourceTypeName(), auxName, GetRawDataSize() / texSizeDivisor); + decl = parent->AddDeclarationIncludeArray(rawDataIndex, incStr, GetRawDataSize(), + GetSourceTypeName(), auxName, + GetRawDataSize() / texSizeDivisor); } decl->staticConf = staticConf; return decl; diff --git a/ZAPD/ZTexture.h b/ZAPD/ZTexture.h index cf85edf..1461ff9 100644 --- a/ZAPD/ZTexture.h +++ b/ZAPD/ZTexture.h @@ -97,7 +97,7 @@ public: /// </summary> /// <returns></returns> float GetPixelMultiplyer() const; - + TextureType GetTextureType() const; /// <summary> @@ -112,7 +112,7 @@ public: /// </summary> /// <returns></returns> bool IsColorIndexed() const; - + void SetTlut(ZTexture* nTlut); bool HasTlut() const; void ParseRawDataLate() override; diff --git a/ZAPD/ZWaterbox.h b/ZAPD/ZWaterbox.h index e901e80..e190b26 100644 --- a/ZAPD/ZWaterbox.h +++ b/ZAPD/ZWaterbox.h @@ -5,26 +5,26 @@ class ZWaterbox : public ZResource { - public: - int16_t xMin; - int16_t ySurface; - int16_t zMin; - int16_t xLength; - int16_t zLength; - int32_t properties; +public: + int16_t xMin; + int16_t ySurface; + int16_t zMin; + int16_t xLength; + int16_t zLength; + int32_t properties; - ZWaterbox(ZFile* nParent); - ~ZWaterbox(); + ZWaterbox(ZFile* nParent); + ~ZWaterbox(); - void ParseRawData() override; - void DeclareReferences(const std::string& prefix) override; - std::string GetBodySourceCode() const override; - std::string GetDefaultName(const std::string& prefix) const override; + void ParseRawData() override; + void DeclareReferences(const std::string& prefix) override; + std::string GetBodySourceCode() const override; + std::string GetDefaultName(const std::string& prefix) const override; - std::string GetSourceTypeName() const override; - ZResourceType GetResourceType() const override; + std::string GetSourceTypeName() const override; + ZResourceType GetResourceType() const override; - bool DoesSupportArray() const override; + bool DoesSupportArray() const override; - size_t GetRawDataSize() const override; + size_t GetRawDataSize() const override; }; diff --git a/ZAPDUtils/Makefile b/ZAPDUtils/Makefile index e8941ed..c0f818b 100644 --- a/ZAPDUtils/Makefile +++ b/ZAPDUtils/Makefile @@ -17,7 +17,7 @@ clean: rm -rf build $(LIB) format: - clang-format-11 -i $(CPP_FILES) $(H_FILES) + clang-format-14 -i $(CPP_FILES) $(H_FILES) .PHONY: all clean format diff --git a/ZAPDUtils/Utils/BitConverter.h b/ZAPDUtils/Utils/BitConverter.h index 646fa12..aa41b5b 100644 --- a/ZAPDUtils/Utils/BitConverter.h +++ b/ZAPDUtils/Utils/BitConverter.h @@ -76,7 +76,7 @@ public: fprintf(stderr, "\t Trying to read at offset: 0x%zX\n", offset); } return ((uint32_t)data.at(offset + 0) << 24) + ((uint32_t)data.at(offset + 1) << 16) + - ((uint32_t)data.at(offset + 2) << 8) + (uint32_t)data.at(offset + 3); + ((uint32_t)data.at(offset + 2) << 8) + (uint32_t)data.at(offset + 3); } static inline uint32_t ToUInt32BE(const std::vector<uint8_t>& data, size_t offset) @@ -89,7 +89,7 @@ public: fprintf(stderr, "\t Trying to read at offset: 0x%zX\n", offset); } return ((uint32_t)data.at(offset + 0) << 24) + ((uint32_t)data.at(offset + 1) << 16) + - ((uint32_t)data.at(offset + 2) << 8) + (uint32_t)data.at(offset + 3); + ((uint32_t)data.at(offset + 2) << 8) + (uint32_t)data.at(offset + 3); } static inline int64_t ToInt64BE(const std::vector<uint8_t>& data, size_t offset) @@ -102,9 +102,9 @@ public: fprintf(stderr, "\t Trying to read at offset: 0x%zX\n", offset); } return ((uint64_t)data.at(offset + 0) << 56) + ((uint64_t)data.at(offset + 1) << 48) + - ((uint64_t)data.at(offset + 2) << 40) + ((uint64_t)data.at(offset + 3) << 32) + - ((uint64_t)data.at(offset + 4) << 24) + ((uint64_t)data.at(offset + 5) << 16) + - ((uint64_t)data.at(offset + 6) << 8) + ((uint64_t)data.at(offset + 7)); + ((uint64_t)data.at(offset + 2) << 40) + ((uint64_t)data.at(offset + 3) << 32) + + ((uint64_t)data.at(offset + 4) << 24) + ((uint64_t)data.at(offset + 5) << 16) + + ((uint64_t)data.at(offset + 6) << 8) + ((uint64_t)data.at(offset + 7)); } static inline uint64_t ToUInt64BE(const std::vector<uint8_t>& data, size_t offset) @@ -117,9 +117,9 @@ public: fprintf(stderr, "\t Trying to read at offset: 0x%zX\n", offset); } return ((uint64_t)data.at(offset + 0) << 56) + ((uint64_t)data.at(offset + 1) << 48) + - ((uint64_t)data.at(offset + 2) << 40) + ((uint64_t)data.at(offset + 3) << 32) + - ((uint64_t)data.at(offset + 4) << 24) + ((uint64_t)data.at(offset + 5) << 16) + - ((uint64_t)data.at(offset + 6) << 8) + ((uint64_t)data.at(offset + 7)); + ((uint64_t)data.at(offset + 2) << 40) + ((uint64_t)data.at(offset + 3) << 32) + + ((uint64_t)data.at(offset + 4) << 24) + ((uint64_t)data.at(offset + 5) << 16) + + ((uint64_t)data.at(offset + 6) << 8) + ((uint64_t)data.at(offset + 7)); } static inline float ToFloatBE(const std::vector<uint8_t>& data, size_t offset) @@ -133,8 +133,8 @@ public: } float value; uint32_t floatData = ((uint32_t)data.at(offset + 0) << 24) + - ((uint32_t)data.at(offset + 1) << 16) + - ((uint32_t)data.at(offset + 2) << 8) + (uint32_t)data.at(offset + 3); + ((uint32_t)data.at(offset + 1) << 16) + + ((uint32_t)data.at(offset + 2) << 8) + (uint32_t)data.at(offset + 3); static_assert(sizeof(uint32_t) == sizeof(float), "expected 32-bit float"); std::memcpy(&value, &floatData, sizeof(value)); return value; diff --git a/ZAPDUtils/Utils/StringHelper.h b/ZAPDUtils/Utils/StringHelper.h index 1420095..c4e012e 100644 --- a/ZAPDUtils/Utils/StringHelper.h +++ b/ZAPDUtils/Utils/StringHelper.h @@ -170,7 +170,8 @@ public: if (skipSP) { // Print it anyway if the next character is lowercase, e.g. "gameplay_keep_...". - if (!isupper(ptr[1])) { + if (!isupper(ptr[1])) + { out.push_back(toupper(ch)); } if ((ch = *++ptr) == '\0') |
