From 4d051c0fa036d245027a211bc7fd6a4afdce207f Mon Sep 17 00:00:00 2001 From: Anghelo Carvajal Date: Mon, 13 Sep 2021 11:29:46 -0300 Subject: ZRoom cleaning 3 (#140) * Remove redundant scene member * altheaders clean * it is broken and I don't know why * fix VTXs * Fix the stuff I broke in SetRoomList * Add RoomAltHeader and SceneAltHeader * fix syotes again and set the size of each ZRoomCommand * Add SCENE_CMD_UNK_09 todo * Nuke HintSystem * run format * Remove `canHaveInner` from ZRoom since the HintSystem doesn't exists anymore * Remove sourceOutput member from ZResource * Update docs * run format * Add non 64-bits aligned textures warning * remove unused json library * Update SCENE_CMD_UNK_09 * Fix merge issues * run format * Clean up actorlist output * Fix merge conflicts * format * Fix actorlist extraction * Unify AltHeader * fix merge conflicts * Run formatter * minor style changes * fix using wrong symbols for extracted vtxs from overlays * format * fix makefile stuff * fix merge issue --- ZAPD/ZFile.cpp | 51 ++++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 23 deletions(-) (limited to 'ZAPD/ZFile.cpp') diff --git a/ZAPD/ZFile.cpp b/ZAPD/ZFile.cpp index 7d461b8..3709771 100644 --- a/ZAPD/ZFile.cpp +++ b/ZAPD/ZFile.cpp @@ -276,8 +276,10 @@ void ZFile::ExtractResources() if (!Directory::Exists(GetSourceOutputFolderPath().string())) Directory::CreateDirectory(GetSourceOutputFolderPath().string()); - for (ZResource* res : resources) - res->PreGenSourceFiles(); + for (size_t i = 0; i < resources.size(); i++) + resources[i]->ParseRawDataLate(); + for (size_t i = 0; i < resources.size(); i++) + resources[i]->DeclareReferencesLate(name); if (Globals::Instance->genSourceFile) GenerateSourceFiles(Globals::Instance->outputPath); @@ -375,12 +377,8 @@ Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment a size_t size, std::string varType, std::string varName, size_t arrayItemCnt, std::string body) { - assert(GETSEGNUM(address) == 0); - AddDeclarationDebugChecks(address); - - declarations[address] = - new Declaration(alignment, size, varType, varName, true, arrayItemCnt, body); - return declarations[address]; + return AddDeclarationArray(address, alignment, DeclarationPadding::None, size, varType, varName, + arrayItemCnt, body); } Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, @@ -395,18 +393,6 @@ Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment a return declarations[address]; } -Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, - size_t size, std::string varType, std::string varName, - size_t arrayItemCnt, std::string body, bool isExternal) -{ - assert(GETSEGNUM(address) == 0); - AddDeclarationDebugChecks(address); - - declarations[address] = - new Declaration(alignment, size, varType, varName, true, arrayItemCnt, body, isExternal); - return declarations[address]; -} - Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment alignment, DeclarationPadding padding, size_t size, std::string varType, std::string varName, @@ -415,9 +401,28 @@ Declaration* ZFile::AddDeclarationArray(uint32_t address, DeclarationAlignment a assert(GETSEGNUM(address) == 0); AddDeclarationDebugChecks(address); - declarations[address] = - new Declaration(alignment, padding, size, varType, varName, true, arrayItemCnt, body); - return declarations[address]; + Declaration* decl = GetDeclaration(address); + if (decl == nullptr) + { + decl = + new Declaration(alignment, padding, size, varType, varName, true, arrayItemCnt, body); + declarations[address] = decl; + } + else + { + if (decl->isPlaceholder) + decl->varName = varName; + decl->alignment = alignment; + decl->padding = padding; + decl->size = size; + decl->varType = varType; + decl->isArray = true; + decl->arrayItemCnt = arrayItemCnt; + if (body != "" && decl->text == "") + decl->text = body; + } + + return decl; } Declaration* ZFile::AddDeclarationPlaceholder(uint32_t address) -- cgit v1.2.3