diff --git a/src/Components/Modules/AssetInterfaces/ImenuDef_t.cpp b/src/Components/Modules/AssetInterfaces/ImenuDef_t.cpp index 6ba6c80a..6a64b529 100644 --- a/src/Components/Modules/AssetInterfaces/ImenuDef_t.cpp +++ b/src/Components/Modules/AssetInterfaces/ImenuDef_t.cpp @@ -61,6 +61,10 @@ namespace Assets AssertSize(Game::ExpressionSupportingData, 24); Utils::Stream* buffer = builder->getBuffer(); +#ifdef WRITE_LOGS + buffer->enterStruct("ExpressionSupportingData"); +#endif + buffer->align(Utils::Stream::ALIGN_4); Game::ExpressionSupportingData *dest = buffer->dest(); @@ -131,13 +135,21 @@ namespace Assets } } } +#ifdef WRITE_LOGS + buffer->leaveStruct(); +#endif } void ImenuDef_t::save_Statement_s(Game::Statement_s* asset, Components::ZoneBuilder::Zone* builder) { AssertSize(Game::Statement_s, 24); + AssertSize(Game::expressionEntry, 12); Utils::Stream* buffer = builder->getBuffer(); +#ifdef WRITE_LOGS + buffer->enterStruct("Statement_s"); +#endif + // Write header data Game::Statement_s *dest = buffer->dest(); buffer->save(asset); @@ -145,6 +157,9 @@ namespace Assets // Write statement entries if (asset->entries) { +#ifdef WRITE_LOGS + buffer->enterStruct("statement entries"); +#endif buffer->align(Utils::Stream::ALIGN_4); // Write entries @@ -154,6 +169,9 @@ namespace Assets // Loop through entries for (int i = 0; i < asset->numEntries; ++i) { +#ifdef WRITE_LOGS + buffer->enterStruct("entry"); +#endif if (asset->entries[i].type) { switch (asset->entries[i].data.operand.dataType) @@ -183,13 +201,23 @@ namespace Assets break; } } +#ifdef WRITE_LOGS + buffer->leaveStruct(); +#endif } +#ifdef WRITE_LOGS + buffer->leaveStruct(); +#endif } + if (asset->supportingData) { this->save_ExpressionSupportingData(asset->supportingData, builder); Utils::Stream::ClearPointer(&dest->supportingData); } +#ifdef WRITE_LOGS + buffer->leaveStruct(); +#endif } void ImenuDef_t::save_MenuEventHandlerSet(Game::MenuEventHandlerSet* asset, Components::ZoneBuilder::Zone* builder) @@ -197,6 +225,10 @@ namespace Assets AssertSize(Game::MenuEventHandlerSet, 8); Utils::Stream* buffer = builder->getBuffer(); +#ifdef WRITE_LOGS + buffer->enterStruct("MenuEventHandlerSet"); +#endif + // Write header data Game::MenuEventHandlerSet *destset = buffer->dest(); buffer->save(asset); @@ -215,6 +247,9 @@ namespace Assets if (asset->eventHandlers[i]) { buffer->align(Utils::Stream::ALIGN_4); +#ifdef WRITE_LOGS + buffer->enterStruct("MenuEventHandler"); +#endif // Write menu event handler Game::MenuEventHandler *dest = buffer->dest(); @@ -302,11 +337,17 @@ namespace Assets } break; } +#ifdef WRITE_LOGS + buffer->leaveStruct(); +#endif } } Utils::Stream::ClearPointer(&destset->eventHandlers); } +#ifdef WRITE_LOGS + buffer->leaveStruct(); +#endif } void ImenuDef_t::save_ItemKeyHandler(Game::ItemKeyHandler* asset, Components::ZoneBuilder::Zone* builder) @@ -314,6 +355,10 @@ namespace Assets AssertSize(Game::ItemKeyHandler, 12); Utils::Stream* buffer = builder->getBuffer(); +#ifdef WRITE_LOGS + buffer->enterStruct("ItemKeyHandler"); +#endif + while (asset) { // Write header @@ -337,6 +382,9 @@ namespace Assets // Next key handler asset = asset->next; } +#ifdef WRITE_LOGS + buffer->leaveStruct(); +#endif } #define EVENTHANDLERSET(__indice) \ @@ -364,6 +412,10 @@ namespace Assets Utils::Stream* buffer = builder->getBuffer(); +#ifdef WRITE_LOGS + buffer->enterStruct("itemDefData_t"); +#endif + // feeder if (type == 6) { @@ -445,6 +497,10 @@ namespace Assets } Utils::Stream::ClearPointer(&dest->typeData.data); + +#ifdef WRITE_LOGS + buffer->leaveStruct(); +#endif } void ImenuDef_t::save_itemDef_s(Game::itemDef_s *asset, Components::ZoneBuilder::Zone* builder) @@ -454,6 +510,15 @@ namespace Assets Utils::Stream* buffer = builder->getBuffer(); Game::itemDef_s* dest = buffer->dest(); +#ifdef WRITE_LOGS + if (asset->window.name) + buffer->enterStruct(Utils::String::VA("itemDef_s: name = '%s'", asset->window.name)); + else if (asset->window.background) + buffer->enterStruct(Utils::String::VA("itemDef_s: bg = '%s'", asset->window.background->info.name)); + else + buffer->enterStruct("itemDef_s"); +#endif + buffer->save(asset); // window data @@ -482,6 +547,7 @@ namespace Assets buffer->saveString(asset->dvar); Utils::Stream::ClearPointer(&dest->dvar); } + if (asset->dvarTest) { buffer->saveString(asset->dvarTest); @@ -502,6 +568,7 @@ namespace Assets buffer->saveString(asset->enableDvar); Utils::Stream::ClearPointer(&dest->enableDvar); } + if (asset->localVar) { buffer->saveString(asset->localVar); @@ -524,6 +591,9 @@ namespace Assets if (asset->floatExpressions) { buffer->align(Utils::Stream::ALIGN_4); +#ifdef WRITE_LOGS + buffer->enterStruct("floatExpressions"); +#endif Game::ItemFloatExpression* destExp = buffer->dest(); buffer->saveArray(asset->floatExpressions, asset->floatExpressionCount); @@ -532,10 +602,14 @@ namespace Assets { buffer->align(Utils::Stream::ALIGN_4); this->save_Statement_s(asset->floatExpressions[i].expression, builder); - Utils::Stream::ClearPointer(&destExp->expression); + Utils::Stream::ClearPointer(&destExp[i].expression); } Utils::Stream::ClearPointer(&dest->floatExpressions); + +#ifdef WRITE_LOGS + buffer->leaveStruct(); +#endif } // Statements @@ -543,16 +617,23 @@ namespace Assets STATEMENT(disabledExp); STATEMENT(textExp); STATEMENT(materialExp); + +#ifdef WRITE_LOGS + buffer->leaveStruct(); +#endif } void ImenuDef_t::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) { AssertSize(Game::menuDef_t, 400); +#ifdef WRITE_LOGS + buffer->enterStruct("ImenuDef_t"); +#endif + Utils::Stream* buffer = builder->getBuffer(); Game::menuDef_t* asset = header.menu; Game::menuDef_t* dest = buffer->dest(); - buffer->save(asset); buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL); @@ -627,6 +708,9 @@ namespace Assets } } } +#ifdef WRITE_LOGS + buffer->leaveStruct(); +#endif buffer->popBlock(); } diff --git a/src/Utils/Stream.cpp b/src/Utils/Stream.cpp index 2cda0998..92049f59 100644 --- a/src/Utils/Stream.cpp +++ b/src/Utils/Stream.cpp @@ -289,8 +289,8 @@ namespace Utils } #ifdef WRITE_LOGS - std::string data = fmt::sprintf("%*s%d\n", this->structLevel, "", size); - if (stream == Game::XFILE_BLOCK_RUNTIME) data = fmt::sprintf("%*s(%d)\n", this->structLevel, "", size); + std::string data = Utils::String::VA("%*s%d\n", this->structLevel, "", size); + if (stream == Game::XFILE_BLOCK_RUNTIME) data = Utils::String::VA("%*s(%d)\n", this->structLevel, "", size); Utils::IO::WriteFile("userraw/logs/zb_writes.log", data, true); #endif } @@ -379,7 +379,7 @@ namespace Utils { if (this->structLevel >= 0) { - Utils::IO::WriteFile("userraw/logs/zb_writes.log", fmt::sprintf("%*s%s\n", this->structLevel++, "", structName), true); + Utils::IO::WriteFile("userraw/logs/zb_writes.log", Utils::String::VA("%*s%s\n", this->structLevel++, "", structName), true); } } @@ -391,7 +391,7 @@ namespace Utils return; } - Utils::IO::WriteFile("userraw/logs/zb_writes.log", fmt::sprintf("%*s-----\n", this->structLevel, ""), true); + Utils::IO::WriteFile("userraw/logs/zb_writes.log", Utils::String::VA("%*s-----\n", this->structLevel, ""), true); } #endif }