From 64bd89dc46a913f1c54a2a03844f3b1d6634abc1 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Fri, 25 Jul 2025 17:52:10 +0100 Subject: [PATCH 01/35] refactor: get rid of unnecessary AssetDumper wrapper class --- .../Game/IW3/AssetDumpers/AssetDumperXModel.cpp | 15 --------------- .../Game/IW3/AssetDumpers/AssetDumperXModel.h | 14 -------------- src/ObjWriting/Game/IW3/ObjWriterIW3.cpp | 2 +- .../Game/IW4/AssetDumpers/AssetDumperXModel.cpp | 15 --------------- .../Game/IW4/AssetDumpers/AssetDumperXModel.h | 14 -------------- src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 2 +- .../Game/IW5/AssetDumpers/AssetDumperXModel.cpp | 15 --------------- .../Game/IW5/AssetDumpers/AssetDumperXModel.h | 14 -------------- src/ObjWriting/Game/IW5/ObjWriterIW5.cpp | 2 +- .../Game/T5/AssetDumpers/AssetDumperXModel.cpp | 15 --------------- .../Game/T5/AssetDumpers/AssetDumperXModel.h | 14 -------------- src/ObjWriting/Game/T5/ObjWriterT5.cpp | 2 +- .../Game/T6/AssetDumpers/AssetDumperXModel.cpp | 15 --------------- .../Game/T6/AssetDumpers/AssetDumperXModel.h | 14 -------------- src/ObjWriting/Game/T6/ObjWriterT6.cpp | 2 +- src/ObjWriting/XModel/XModelDumper.cpp.template | 12 +++++++----- src/ObjWriting/XModel/XModelDumper.h.template | 11 ++++++++--- 17 files changed, 20 insertions(+), 158 deletions(-) delete mode 100644 src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperXModel.cpp delete mode 100644 src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperXModel.h delete mode 100644 src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperXModel.cpp delete mode 100644 src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperXModel.h delete mode 100644 src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperXModel.cpp delete mode 100644 src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperXModel.h delete mode 100644 src/ObjWriting/Game/T5/AssetDumpers/AssetDumperXModel.cpp delete mode 100644 src/ObjWriting/Game/T5/AssetDumpers/AssetDumperXModel.h delete mode 100644 src/ObjWriting/Game/T6/AssetDumpers/AssetDumperXModel.cpp delete mode 100644 src/ObjWriting/Game/T6/AssetDumpers/AssetDumperXModel.h diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperXModel.cpp b/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperXModel.cpp deleted file mode 100644 index 1491047c..00000000 --- a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperXModel.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "AssetDumperXModel.h" - -#include "Game/IW3/XModel/XModelDumperIW3.h" - -using namespace IW3; - -bool AssetDumperXModel::ShouldDump(XAssetInfo* asset) -{ - return !asset->m_name.empty() && asset->m_name[0] != ','; -} - -void AssetDumperXModel::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - DumpXModel(context, asset); -} diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperXModel.h b/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperXModel.h deleted file mode 100644 index e8aa5df8..00000000 --- a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperXModel.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/IW3/IW3.h" - -namespace IW3 -{ - class AssetDumperXModel final : public AbstractAssetDumper - { - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace IW3 diff --git a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp index 55da3a17..a878c2d3 100644 --- a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp +++ b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp @@ -7,8 +7,8 @@ #include "AssetDumpers/AssetDumperRawFile.h" #include "AssetDumpers/AssetDumperStringTable.h" #include "AssetDumpers/AssetDumperWeapon.h" -#include "AssetDumpers/AssetDumperXModel.h" #include "Game/IW3/GameAssetPoolIW3.h" +#include "Game/IW3/XModel/XModelDumperIW3.h" #include "Material/DumperMaterialIW3.h" #include "ObjWriting.h" diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperXModel.cpp b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperXModel.cpp deleted file mode 100644 index a82ddbd8..00000000 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperXModel.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "AssetDumperXModel.h" - -#include "Game/IW4/XModel/XModelDumperIW4.h" - -using namespace IW4; - -bool AssetDumperXModel::ShouldDump(XAssetInfo* asset) -{ - return !asset->m_name.empty() && asset->m_name[0] != ','; -} - -void AssetDumperXModel::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - DumpXModel(context, asset); -} diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperXModel.h b/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperXModel.h deleted file mode 100644 index 84be5262..00000000 --- a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperXModel.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/IW4/IW4.h" - -namespace IW4 -{ - class AssetDumperXModel final : public AbstractAssetDumper - { - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace IW4 diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 0516a4af..30a0dc9e 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -20,8 +20,8 @@ #include "AssetDumpers/AssetDumperVehicle.h" #include "AssetDumpers/AssetDumperVertexShader.h" #include "AssetDumpers/AssetDumperWeapon.h" -#include "AssetDumpers/AssetDumperXModel.h" #include "Game/IW4/GameAssetPoolIW4.h" +#include "Game/IW4/XModel/XModelDumperIW4.h" #include "Material/DumperMaterialIW4.h" #include "ObjWriting.h" diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperXModel.cpp b/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperXModel.cpp deleted file mode 100644 index bd882e41..00000000 --- a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperXModel.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "AssetDumperXModel.h" - -#include "Game/IW5/XModel/XModelDumperIW5.h" - -using namespace IW5; - -bool AssetDumperXModel::ShouldDump(XAssetInfo* asset) -{ - return !asset->m_name.empty() && asset->m_name[0] != ','; -} - -void AssetDumperXModel::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - DumpXModel(context, asset); -} diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperXModel.h b/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperXModel.h deleted file mode 100644 index 28880a59..00000000 --- a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperXModel.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/IW5/IW5.h" - -namespace IW5 -{ - class AssetDumperXModel final : public AbstractAssetDumper - { - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace IW5 diff --git a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp index 09a16378..8e239829 100644 --- a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp +++ b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp @@ -12,8 +12,8 @@ #include "AssetDumpers/AssetDumperStringTable.h" #include "AssetDumpers/AssetDumperWeapon.h" #include "AssetDumpers/AssetDumperWeaponAttachment.h" -#include "AssetDumpers/AssetDumperXModel.h" #include "Game/IW5/GameAssetPoolIW5.h" +#include "Game/IW5/XModel/XModelDumperIW5.h" #include "Material/DumperMaterialIW5.h" #include "ObjWriting.h" diff --git a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperXModel.cpp b/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperXModel.cpp deleted file mode 100644 index 8eb958bb..00000000 --- a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperXModel.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "AssetDumperXModel.h" - -#include "Game/T5/XModel/XModelDumperT5.h" - -using namespace T5; - -bool AssetDumperXModel::ShouldDump(XAssetInfo* asset) -{ - return !asset->m_name.empty() && asset->m_name[0] != ','; -} - -void AssetDumperXModel::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - DumpXModel(context, asset); -} diff --git a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperXModel.h b/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperXModel.h deleted file mode 100644 index 08a1a274..00000000 --- a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperXModel.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/T5/T5.h" - -namespace T5 -{ - class AssetDumperXModel final : public AbstractAssetDumper - { - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace T5 diff --git a/src/ObjWriting/Game/T5/ObjWriterT5.cpp b/src/ObjWriting/Game/T5/ObjWriterT5.cpp index ce6dab53..4eafde5a 100644 --- a/src/ObjWriting/Game/T5/ObjWriterT5.cpp +++ b/src/ObjWriting/Game/T5/ObjWriterT5.cpp @@ -8,8 +8,8 @@ #include "AssetDumpers/AssetDumperSndBank.h" #include "AssetDumpers/AssetDumperStringTable.h" #include "AssetDumpers/AssetDumperWeapon.h" -#include "AssetDumpers/AssetDumperXModel.h" #include "Game/T5/GameAssetPoolT5.h" +#include "Game/T5/XModel/XModelDumperT5.h" #include "Material/DumperMaterialT5.h" #include "ObjWriting.h" diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperXModel.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperXModel.cpp deleted file mode 100644 index 24dc56dc..00000000 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperXModel.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "AssetDumperXModel.h" - -#include "Game/T6/XModel/XModelDumperT6.h" - -using namespace T6; - -bool AssetDumperXModel::ShouldDump(XAssetInfo* asset) -{ - return !asset->m_name.empty() && asset->m_name[0] != ','; -} - -void AssetDumperXModel::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - DumpXModel(context, asset); -} diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperXModel.h b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperXModel.h deleted file mode 100644 index 75218729..00000000 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperXModel.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/T6/T6.h" - -namespace T6 -{ - class AssetDumperXModel final : public AbstractAssetDumper - { - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace T6 diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 971462b8..03f1737b 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -20,10 +20,10 @@ #include "AssetDumpers/AssetDumperWeaponAttachment.h" #include "AssetDumpers/AssetDumperWeaponAttachmentUnique.h" #include "AssetDumpers/AssetDumperWeaponCamo.h" -#include "AssetDumpers/AssetDumperXModel.h" #include "AssetDumpers/AssetDumperZBarrier.h" #include "FontIcon/DumperFontIconT6.h" #include "Game/T6/GameAssetPoolT6.h" +#include "Game/T6/XModel/XModelDumperT6.h" #include "Material/DumperMaterialT6.h" #include "ObjWriting.h" diff --git a/src/ObjWriting/XModel/XModelDumper.cpp.template b/src/ObjWriting/XModel/XModelDumper.cpp.template index 812e4c31..f8fcb3ab 100644 --- a/src/ObjWriting/XModel/XModelDumper.cpp.template +++ b/src/ObjWriting/XModel/XModelDumper.cpp.template @@ -839,11 +839,13 @@ namespace } } // namespace -namespace GAME +bool AssetDumperXModel::ShouldDump(XAssetInfo* asset) +{ + return !asset->m_name.empty() && asset->m_name[0] != ','; +} + +void AssetDumperXModel::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { - void DumpXModel(AssetDumpingContext& context, XAssetInfo* asset) - { DumpXModelJson(context, asset); DumpXModelSurfs(context, asset); - } -} // namespace GAME +} diff --git a/src/ObjWriting/XModel/XModelDumper.h.template b/src/ObjWriting/XModel/XModelDumper.h.template index 5c4cecb2..0a758303 100644 --- a/src/ObjWriting/XModel/XModelDumper.h.template +++ b/src/ObjWriting/XModel/XModelDumper.h.template @@ -10,10 +10,15 @@ #pragma once -#include "Dumping/AssetDumpingContext.h" +#include "Dumping/AbstractAssetDumper.h" #include GAME_HEADER namespace GAME { - void DumpXModel(AssetDumpingContext& context, XAssetInfo* asset); -} + class AssetDumperXModel final : public AbstractAssetDumper + { + protected: + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + }; +} // namespace GAME From 39fe9965d1166d2ff91ca53b348df771d3deabe5 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Fri, 25 Jul 2025 21:23:49 +0100 Subject: [PATCH 02/35] refactor: move iw3,iw4,iw5,t5 dumpers into seperate folders --- .../AssetDumperGfxImage.cpp | 0 .../AssetDumperGfxImage.h | 0 .../AssetDumperLocalizeEntry.cpp | 0 .../AssetDumperLocalizeEntry.h | 0 .../AssetDumperMapEnts.cpp | 0 .../AssetDumperMapEnts.h | 0 src/ObjWriting/Game/IW3/ObjWriterIW3.cpp | 14 +++--- .../AssetDumperRawFile.cpp | 0 .../AssetDumperRawFile.h | 0 .../AssetDumperLoadedSound.cpp | 0 .../AssetDumperLoadedSound.h | 0 .../AssetDumperStringTable.cpp | 0 .../AssetDumperStringTable.h | 0 .../AssetDumperWeapon.cpp | 0 .../AssetDumperWeapon.h | 0 .../AssetDumperGfxImage.cpp | 0 .../AssetDumperGfxImage.h | 0 .../AssetDumperLeaderboardDef.cpp | 0 .../AssetDumperLeaderboardDef.h | 0 .../AssetDumperGfxLightDef.cpp | 0 .../AssetDumperGfxLightDef.h | 0 .../AssetDumperLocalizeEntry.cpp | 0 .../AssetDumperLocalizeEntry.h | 0 .../AssetDumperAddonMapEnts.cpp | 0 .../AssetDumperAddonMapEnts.h | 0 .../AssetDumperMenuDef.cpp | 0 .../AssetDumperMenuDef.h | 0 .../AssetDumperMenuList.cpp | 0 .../AssetDumperMenuList.h | 0 src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 40 ++++++++--------- .../AssetDumperPhysCollmap.cpp | 0 .../AssetDumperPhysCollmap.h | 0 .../AssetDumperPhysPreset.cpp | 0 .../AssetDumperPhysPreset.h | 0 .../AssetDumperRawFile.cpp | 0 .../AssetDumperRawFile.h | 0 .../AssetDumperPixelShader.cpp | 0 .../AssetDumperPixelShader.h | 0 .../AssetDumperVertexShader.cpp | 0 .../AssetDumperVertexShader.h | 0 .../AssetDumperLoadedSound.cpp | 0 .../AssetDumperLoadedSound.h | 0 .../AssetDumperSndCurve.cpp | 0 .../AssetDumperSndCurve.h | 0 .../AssetDumperStringTable.cpp | 0 .../AssetDumperStringTable.h | 0 .../AssetDumperStructuredDataDefSet.cpp | 0 .../AssetDumperStructuredDataDefSet.h | 0 .../AssetDumperTechniqueSet.cpp | 0 .../AssetDumperTechniqueSet.h | 0 .../AssetDumperTracer.cpp | 0 .../AssetDumperTracer.h | 0 .../AssetDumperVehicle.cpp | 0 .../AssetDumperVehicle.h | 0 .../AssetDumperWeapon.cpp | 0 .../AssetDumperWeapon.h | 0 .../AssetDumperGfxImage.cpp | 0 .../AssetDumperGfxImage.h | 0 .../AssetDumperLeaderboardDef.cpp | 0 .../AssetDumperLeaderboardDef.h | 0 .../AssetDumperLocalizeEntry.cpp | 0 .../AssetDumperLocalizeEntry.h | 0 .../AssetDumperAddonMapEnts.cpp | 0 .../AssetDumperAddonMapEnts.h | 0 .../AssetDumperMenuDef.cpp | 0 .../AssetDumperMenuDef.h | 0 .../AssetDumperMenuList.cpp | 0 .../AssetDumperMenuList.h | 0 src/ObjWriting/Game/IW5/ObjWriterIW5.cpp | 24 +++++------ .../AssetDumperRawFile.cpp | 0 .../AssetDumperRawFile.h | 0 .../AssetDumperScriptFile.cpp | 0 .../AssetDumperScriptFile.h | 0 .../AssetDumperLoadedSound.cpp | 0 .../AssetDumperLoadedSound.h | 0 .../AssetDumperStringTable.cpp | 0 .../AssetDumperStringTable.h | 0 .../AssetDumperWeapon.cpp | 0 .../AssetDumperWeapon.h | 0 .../AssetDumperWeaponAttachment.cpp | 0 .../AssetDumperWeaponAttachment.h | 0 .../AssetDumperGfxImage.cpp | 0 .../AssetDumperGfxImage.h | 0 .../AssetDumperLocalizeEntry.cpp | 0 .../AssetDumperLocalizeEntry.h | 0 src/ObjWriting/Game/T5/ObjWriterT5.cpp | 16 +++---- .../AssetDumperPhysConstraints.cpp | 0 .../AssetDumperPhysConstraints.h | 0 .../AssetDumperPhysPreset.cpp | 0 .../AssetDumperPhysPreset.h | 0 .../AssetDumperRawFile.cpp | 0 .../AssetDumperRawFile.h | 0 .../AssetDumperSndBank.cpp | 0 .../AssetDumperSndBank.h | 0 .../AssetDumperStringTable.cpp | 0 .../AssetDumperStringTable.h | 0 .../AssetDumperWeapon.cpp | 0 .../AssetDumperWeapon.h | 0 .../AssetDumperGfxImage.cpp | 0 .../AssetDumperGfxImage.h | 0 .../AssetDumperLeaderboardDef.cpp | 0 .../AssetDumperLeaderboardDef.h | 0 .../AssetDumperLocalizeEntry.cpp | 0 .../AssetDumperLocalizeEntry.h | 0 .../AssetDumperMapEnts.cpp | 0 .../AssetDumperMapEnts.h | 0 src/ObjWriting/Game/T6/ObjWriterT6.cpp | 43 ++++++++++--------- .../AssetDumperPhysConstraints.cpp | 0 .../AssetDumperPhysConstraints.h | 0 .../AssetDumperPhysPreset.cpp | 0 .../AssetDumperPhysPreset.h | 0 .../{AssetDumpers => Qdb}/AssetDumperQdb.cpp | 0 .../T6/{AssetDumpers => Qdb}/AssetDumperQdb.h | 0 .../AssetDumperRawFile.cpp | 0 .../AssetDumperRawFile.h | 0 .../AssetDumperScriptParseTree.cpp | 0 .../AssetDumperScriptParseTree.h | 0 .../AssetDumperSlug.cpp | 0 .../{AssetDumpers => Slug}/AssetDumperSlug.h | 0 .../AssetDumperSndBank.cpp | 0 .../AssetDumperSndBank.h | 0 .../AssetDumperSndDriverGlobals.cpp | 0 .../AssetDumperSndDriverGlobals.h | 0 .../AssetDumperStringTable.cpp | 0 .../AssetDumperStringTable.h | 0 .../AssetDumperTechniqueSet.cpp | 0 .../AssetDumperTechniqueSet.h | 0 .../AssetDumperTracer.cpp | 0 .../AssetDumperTracer.h | 0 .../AssetDumperVehicle.cpp | 0 .../AssetDumperVehicle.h | 0 .../AssetDumperWeapon.cpp | 0 .../AssetDumperWeapon.h | 0 .../AssetDumperWeaponAttachment.cpp | 0 .../AssetDumperWeaponAttachment.h | 0 .../AssetDumperWeaponAttachmentUnique.cpp | 0 .../AssetDumperWeaponAttachmentUnique.h | 0 .../AssetDumperWeaponCamo.cpp | 2 +- .../AssetDumperWeaponCamo.h | 0 .../JsonWeaponCamoWriter.cpp | 0 .../JsonWeaponCamoWriter.h | 0 .../AssetDumperZBarrier.cpp | 0 .../AssetDumperZBarrier.h | 0 143 files changed, 70 insertions(+), 69 deletions(-) rename src/ObjWriting/Game/IW3/{AssetDumpers => Image}/AssetDumperGfxImage.cpp (100%) rename src/ObjWriting/Game/IW3/{AssetDumpers => Image}/AssetDumperGfxImage.h (100%) rename src/ObjWriting/Game/IW3/{AssetDumpers => Localize}/AssetDumperLocalizeEntry.cpp (100%) rename src/ObjWriting/Game/IW3/{AssetDumpers => Localize}/AssetDumperLocalizeEntry.h (100%) rename src/ObjWriting/Game/IW3/{AssetDumpers => Maps}/AssetDumperMapEnts.cpp (100%) rename src/ObjWriting/Game/IW3/{AssetDumpers => Maps}/AssetDumperMapEnts.h (100%) rename src/ObjWriting/Game/IW3/{AssetDumpers => RawFile}/AssetDumperRawFile.cpp (100%) rename src/ObjWriting/Game/IW3/{AssetDumpers => RawFile}/AssetDumperRawFile.h (100%) rename src/ObjWriting/Game/IW3/{AssetDumpers => Sound}/AssetDumperLoadedSound.cpp (100%) rename src/ObjWriting/Game/IW3/{AssetDumpers => Sound}/AssetDumperLoadedSound.h (100%) rename src/ObjWriting/Game/IW3/{AssetDumpers => StringTable}/AssetDumperStringTable.cpp (100%) rename src/ObjWriting/Game/IW3/{AssetDumpers => StringTable}/AssetDumperStringTable.h (100%) rename src/ObjWriting/Game/IW3/{AssetDumpers => Weapon}/AssetDumperWeapon.cpp (100%) rename src/ObjWriting/Game/IW3/{AssetDumpers => Weapon}/AssetDumperWeapon.h (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Image}/AssetDumperGfxImage.cpp (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Image}/AssetDumperGfxImage.h (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Leaderboard}/AssetDumperLeaderboardDef.cpp (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Leaderboard}/AssetDumperLeaderboardDef.h (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => LightDef}/AssetDumperGfxLightDef.cpp (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => LightDef}/AssetDumperGfxLightDef.h (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Localize}/AssetDumperLocalizeEntry.cpp (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Localize}/AssetDumperLocalizeEntry.h (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Maps}/AssetDumperAddonMapEnts.cpp (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Maps}/AssetDumperAddonMapEnts.h (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Menu}/AssetDumperMenuDef.cpp (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Menu}/AssetDumperMenuDef.h (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Menu}/AssetDumperMenuList.cpp (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Menu}/AssetDumperMenuList.h (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => PhysCollmap}/AssetDumperPhysCollmap.cpp (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => PhysCollmap}/AssetDumperPhysCollmap.h (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => PhysPreset}/AssetDumperPhysPreset.cpp (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => PhysPreset}/AssetDumperPhysPreset.h (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => RawFile}/AssetDumperRawFile.cpp (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => RawFile}/AssetDumperRawFile.h (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Shader}/AssetDumperPixelShader.cpp (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Shader}/AssetDumperPixelShader.h (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Shader}/AssetDumperVertexShader.cpp (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Shader}/AssetDumperVertexShader.h (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Sound}/AssetDumperLoadedSound.cpp (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Sound}/AssetDumperLoadedSound.h (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Sound}/AssetDumperSndCurve.cpp (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Sound}/AssetDumperSndCurve.h (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => StringTable}/AssetDumperStringTable.cpp (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => StringTable}/AssetDumperStringTable.h (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => StructuredDataDef}/AssetDumperStructuredDataDefSet.cpp (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => StructuredDataDef}/AssetDumperStructuredDataDefSet.h (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Techset}/AssetDumperTechniqueSet.cpp (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Techset}/AssetDumperTechniqueSet.h (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Tracer}/AssetDumperTracer.cpp (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Tracer}/AssetDumperTracer.h (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Vehicle}/AssetDumperVehicle.cpp (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Vehicle}/AssetDumperVehicle.h (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Weapon}/AssetDumperWeapon.cpp (100%) rename src/ObjWriting/Game/IW4/{AssetDumpers => Weapon}/AssetDumperWeapon.h (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => Image}/AssetDumperGfxImage.cpp (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => Image}/AssetDumperGfxImage.h (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => Leaderboard}/AssetDumperLeaderboardDef.cpp (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => Leaderboard}/AssetDumperLeaderboardDef.h (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => Localize}/AssetDumperLocalizeEntry.cpp (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => Localize}/AssetDumperLocalizeEntry.h (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => Maps}/AssetDumperAddonMapEnts.cpp (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => Maps}/AssetDumperAddonMapEnts.h (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => Menu}/AssetDumperMenuDef.cpp (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => Menu}/AssetDumperMenuDef.h (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => Menu}/AssetDumperMenuList.cpp (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => Menu}/AssetDumperMenuList.h (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => RawFile}/AssetDumperRawFile.cpp (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => RawFile}/AssetDumperRawFile.h (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => Script}/AssetDumperScriptFile.cpp (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => Script}/AssetDumperScriptFile.h (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => Sound}/AssetDumperLoadedSound.cpp (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => Sound}/AssetDumperLoadedSound.h (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => StringTable}/AssetDumperStringTable.cpp (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => StringTable}/AssetDumperStringTable.h (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => Weapon}/AssetDumperWeapon.cpp (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => Weapon}/AssetDumperWeapon.h (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => Weapon}/AssetDumperWeaponAttachment.cpp (100%) rename src/ObjWriting/Game/IW5/{AssetDumpers => Weapon}/AssetDumperWeaponAttachment.h (100%) rename src/ObjWriting/Game/T5/{AssetDumpers => Image}/AssetDumperGfxImage.cpp (100%) rename src/ObjWriting/Game/T5/{AssetDumpers => Image}/AssetDumperGfxImage.h (100%) rename src/ObjWriting/Game/T5/{AssetDumpers => Localize}/AssetDumperLocalizeEntry.cpp (100%) rename src/ObjWriting/Game/T5/{AssetDumpers => Localize}/AssetDumperLocalizeEntry.h (100%) rename src/ObjWriting/Game/T5/{AssetDumpers => PhysConstraints}/AssetDumperPhysConstraints.cpp (100%) rename src/ObjWriting/Game/T5/{AssetDumpers => PhysConstraints}/AssetDumperPhysConstraints.h (100%) rename src/ObjWriting/Game/T5/{AssetDumpers => PhysPreset}/AssetDumperPhysPreset.cpp (100%) rename src/ObjWriting/Game/T5/{AssetDumpers => PhysPreset}/AssetDumperPhysPreset.h (100%) rename src/ObjWriting/Game/T5/{AssetDumpers => RawFile}/AssetDumperRawFile.cpp (100%) rename src/ObjWriting/Game/T5/{AssetDumpers => RawFile}/AssetDumperRawFile.h (100%) rename src/ObjWriting/Game/T5/{AssetDumpers => Sound}/AssetDumperSndBank.cpp (100%) rename src/ObjWriting/Game/T5/{AssetDumpers => Sound}/AssetDumperSndBank.h (100%) rename src/ObjWriting/Game/T5/{AssetDumpers => StringTable}/AssetDumperStringTable.cpp (100%) rename src/ObjWriting/Game/T5/{AssetDumpers => StringTable}/AssetDumperStringTable.h (100%) rename src/ObjWriting/Game/T5/{AssetDumpers => Weapon}/AssetDumperWeapon.cpp (100%) rename src/ObjWriting/Game/T5/{AssetDumpers => Weapon}/AssetDumperWeapon.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Image}/AssetDumperGfxImage.cpp (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Image}/AssetDumperGfxImage.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Leaderboard}/AssetDumperLeaderboardDef.cpp (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Leaderboard}/AssetDumperLeaderboardDef.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Localize}/AssetDumperLocalizeEntry.cpp (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Localize}/AssetDumperLocalizeEntry.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Maps}/AssetDumperMapEnts.cpp (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Maps}/AssetDumperMapEnts.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => PhysConstraints}/AssetDumperPhysConstraints.cpp (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => PhysConstraints}/AssetDumperPhysConstraints.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => PhysPreset}/AssetDumperPhysPreset.cpp (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => PhysPreset}/AssetDumperPhysPreset.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Qdb}/AssetDumperQdb.cpp (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Qdb}/AssetDumperQdb.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => RawFile}/AssetDumperRawFile.cpp (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => RawFile}/AssetDumperRawFile.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Script}/AssetDumperScriptParseTree.cpp (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Script}/AssetDumperScriptParseTree.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Slug}/AssetDumperSlug.cpp (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Slug}/AssetDumperSlug.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Sound}/AssetDumperSndBank.cpp (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Sound}/AssetDumperSndBank.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Sound}/AssetDumperSndDriverGlobals.cpp (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Sound}/AssetDumperSndDriverGlobals.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => StringTable}/AssetDumperStringTable.cpp (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => StringTable}/AssetDumperStringTable.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Techset}/AssetDumperTechniqueSet.cpp (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Techset}/AssetDumperTechniqueSet.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Tracer}/AssetDumperTracer.cpp (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Tracer}/AssetDumperTracer.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Vehicle}/AssetDumperVehicle.cpp (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Vehicle}/AssetDumperVehicle.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Weapon}/AssetDumperWeapon.cpp (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Weapon}/AssetDumperWeapon.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Weapon}/AssetDumperWeaponAttachment.cpp (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Weapon}/AssetDumperWeaponAttachment.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Weapon}/AssetDumperWeaponAttachmentUnique.cpp (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Weapon}/AssetDumperWeaponAttachmentUnique.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => Weapon}/AssetDumperWeaponCamo.cpp (90%) rename src/ObjWriting/Game/T6/{AssetDumpers => Weapon}/AssetDumperWeaponCamo.h (100%) rename src/ObjWriting/Game/T6/{WeaponCamo => Weapon}/JsonWeaponCamoWriter.cpp (100%) rename src/ObjWriting/Game/T6/{WeaponCamo => Weapon}/JsonWeaponCamoWriter.h (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => ZBarrier}/AssetDumperZBarrier.cpp (100%) rename src/ObjWriting/Game/T6/{AssetDumpers => ZBarrier}/AssetDumperZBarrier.h (100%) diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperGfxImage.cpp b/src/ObjWriting/Game/IW3/Image/AssetDumperGfxImage.cpp similarity index 100% rename from src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperGfxImage.cpp rename to src/ObjWriting/Game/IW3/Image/AssetDumperGfxImage.cpp diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperGfxImage.h b/src/ObjWriting/Game/IW3/Image/AssetDumperGfxImage.h similarity index 100% rename from src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperGfxImage.h rename to src/ObjWriting/Game/IW3/Image/AssetDumperGfxImage.h diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperLocalizeEntry.cpp b/src/ObjWriting/Game/IW3/Localize/AssetDumperLocalizeEntry.cpp similarity index 100% rename from src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperLocalizeEntry.cpp rename to src/ObjWriting/Game/IW3/Localize/AssetDumperLocalizeEntry.cpp diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperLocalizeEntry.h b/src/ObjWriting/Game/IW3/Localize/AssetDumperLocalizeEntry.h similarity index 100% rename from src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperLocalizeEntry.h rename to src/ObjWriting/Game/IW3/Localize/AssetDumperLocalizeEntry.h diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperMapEnts.cpp b/src/ObjWriting/Game/IW3/Maps/AssetDumperMapEnts.cpp similarity index 100% rename from src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperMapEnts.cpp rename to src/ObjWriting/Game/IW3/Maps/AssetDumperMapEnts.cpp diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperMapEnts.h b/src/ObjWriting/Game/IW3/Maps/AssetDumperMapEnts.h similarity index 100% rename from src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperMapEnts.h rename to src/ObjWriting/Game/IW3/Maps/AssetDumperMapEnts.h diff --git a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp index a878c2d3..b2a605df 100644 --- a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp +++ b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp @@ -1,16 +1,16 @@ #include "ObjWriterIW3.h" -#include "AssetDumpers/AssetDumperGfxImage.h" -#include "AssetDumpers/AssetDumperLoadedSound.h" -#include "AssetDumpers/AssetDumperLocalizeEntry.h" -#include "AssetDumpers/AssetDumperMapEnts.h" -#include "AssetDumpers/AssetDumperRawFile.h" -#include "AssetDumpers/AssetDumperStringTable.h" -#include "AssetDumpers/AssetDumperWeapon.h" #include "Game/IW3/GameAssetPoolIW3.h" #include "Game/IW3/XModel/XModelDumperIW3.h" +#include "Image/AssetDumperGfxImage.h" +#include "Localize/AssetDumperLocalizeEntry.h" +#include "Maps/AssetDumperMapEnts.h" #include "Material/DumperMaterialIW3.h" #include "ObjWriting.h" +#include "RawFile/AssetDumperRawFile.h" +#include "Sound/AssetDumperLoadedSound.h" +#include "StringTable/AssetDumperStringTable.h" +#include "Weapon/AssetDumperWeapon.h" using namespace IW3; diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperRawFile.cpp b/src/ObjWriting/Game/IW3/RawFile/AssetDumperRawFile.cpp similarity index 100% rename from src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperRawFile.cpp rename to src/ObjWriting/Game/IW3/RawFile/AssetDumperRawFile.cpp diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperRawFile.h b/src/ObjWriting/Game/IW3/RawFile/AssetDumperRawFile.h similarity index 100% rename from src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperRawFile.h rename to src/ObjWriting/Game/IW3/RawFile/AssetDumperRawFile.h diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperLoadedSound.cpp b/src/ObjWriting/Game/IW3/Sound/AssetDumperLoadedSound.cpp similarity index 100% rename from src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperLoadedSound.cpp rename to src/ObjWriting/Game/IW3/Sound/AssetDumperLoadedSound.cpp diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperLoadedSound.h b/src/ObjWriting/Game/IW3/Sound/AssetDumperLoadedSound.h similarity index 100% rename from src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperLoadedSound.h rename to src/ObjWriting/Game/IW3/Sound/AssetDumperLoadedSound.h diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperStringTable.cpp b/src/ObjWriting/Game/IW3/StringTable/AssetDumperStringTable.cpp similarity index 100% rename from src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperStringTable.cpp rename to src/ObjWriting/Game/IW3/StringTable/AssetDumperStringTable.cpp diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperStringTable.h b/src/ObjWriting/Game/IW3/StringTable/AssetDumperStringTable.h similarity index 100% rename from src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperStringTable.h rename to src/ObjWriting/Game/IW3/StringTable/AssetDumperStringTable.h diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperWeapon.cpp b/src/ObjWriting/Game/IW3/Weapon/AssetDumperWeapon.cpp similarity index 100% rename from src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperWeapon.cpp rename to src/ObjWriting/Game/IW3/Weapon/AssetDumperWeapon.cpp diff --git a/src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperWeapon.h b/src/ObjWriting/Game/IW3/Weapon/AssetDumperWeapon.h similarity index 100% rename from src/ObjWriting/Game/IW3/AssetDumpers/AssetDumperWeapon.h rename to src/ObjWriting/Game/IW3/Weapon/AssetDumperWeapon.h diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperGfxImage.cpp b/src/ObjWriting/Game/IW4/Image/AssetDumperGfxImage.cpp similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperGfxImage.cpp rename to src/ObjWriting/Game/IW4/Image/AssetDumperGfxImage.cpp diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperGfxImage.h b/src/ObjWriting/Game/IW4/Image/AssetDumperGfxImage.h similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperGfxImage.h rename to src/ObjWriting/Game/IW4/Image/AssetDumperGfxImage.h diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLeaderboardDef.cpp b/src/ObjWriting/Game/IW4/Leaderboard/AssetDumperLeaderboardDef.cpp similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLeaderboardDef.cpp rename to src/ObjWriting/Game/IW4/Leaderboard/AssetDumperLeaderboardDef.cpp diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLeaderboardDef.h b/src/ObjWriting/Game/IW4/Leaderboard/AssetDumperLeaderboardDef.h similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLeaderboardDef.h rename to src/ObjWriting/Game/IW4/Leaderboard/AssetDumperLeaderboardDef.h diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperGfxLightDef.cpp b/src/ObjWriting/Game/IW4/LightDef/AssetDumperGfxLightDef.cpp similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperGfxLightDef.cpp rename to src/ObjWriting/Game/IW4/LightDef/AssetDumperGfxLightDef.cpp diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperGfxLightDef.h b/src/ObjWriting/Game/IW4/LightDef/AssetDumperGfxLightDef.h similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperGfxLightDef.h rename to src/ObjWriting/Game/IW4/LightDef/AssetDumperGfxLightDef.h diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLocalizeEntry.cpp b/src/ObjWriting/Game/IW4/Localize/AssetDumperLocalizeEntry.cpp similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLocalizeEntry.cpp rename to src/ObjWriting/Game/IW4/Localize/AssetDumperLocalizeEntry.cpp diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLocalizeEntry.h b/src/ObjWriting/Game/IW4/Localize/AssetDumperLocalizeEntry.h similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLocalizeEntry.h rename to src/ObjWriting/Game/IW4/Localize/AssetDumperLocalizeEntry.h diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperAddonMapEnts.cpp b/src/ObjWriting/Game/IW4/Maps/AssetDumperAddonMapEnts.cpp similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperAddonMapEnts.cpp rename to src/ObjWriting/Game/IW4/Maps/AssetDumperAddonMapEnts.cpp diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperAddonMapEnts.h b/src/ObjWriting/Game/IW4/Maps/AssetDumperAddonMapEnts.h similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperAddonMapEnts.h rename to src/ObjWriting/Game/IW4/Maps/AssetDumperAddonMapEnts.h diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperMenuDef.cpp b/src/ObjWriting/Game/IW4/Menu/AssetDumperMenuDef.cpp similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperMenuDef.cpp rename to src/ObjWriting/Game/IW4/Menu/AssetDumperMenuDef.cpp diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperMenuDef.h b/src/ObjWriting/Game/IW4/Menu/AssetDumperMenuDef.h similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperMenuDef.h rename to src/ObjWriting/Game/IW4/Menu/AssetDumperMenuDef.h diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperMenuList.cpp b/src/ObjWriting/Game/IW4/Menu/AssetDumperMenuList.cpp similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperMenuList.cpp rename to src/ObjWriting/Game/IW4/Menu/AssetDumperMenuList.cpp diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperMenuList.h b/src/ObjWriting/Game/IW4/Menu/AssetDumperMenuList.h similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperMenuList.h rename to src/ObjWriting/Game/IW4/Menu/AssetDumperMenuList.h diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 30a0dc9e..84065df7 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -1,29 +1,29 @@ #include "ObjWriterIW4.h" -#include "AssetDumpers/AssetDumperAddonMapEnts.h" -#include "AssetDumpers/AssetDumperGfxImage.h" -#include "AssetDumpers/AssetDumperGfxLightDef.h" -#include "AssetDumpers/AssetDumperLeaderboardDef.h" -#include "AssetDumpers/AssetDumperLoadedSound.h" -#include "AssetDumpers/AssetDumperLocalizeEntry.h" -#include "AssetDumpers/AssetDumperMenuDef.h" -#include "AssetDumpers/AssetDumperMenuList.h" -#include "AssetDumpers/AssetDumperPhysCollmap.h" -#include "AssetDumpers/AssetDumperPhysPreset.h" -#include "AssetDumpers/AssetDumperPixelShader.h" -#include "AssetDumpers/AssetDumperRawFile.h" -#include "AssetDumpers/AssetDumperSndCurve.h" -#include "AssetDumpers/AssetDumperStringTable.h" -#include "AssetDumpers/AssetDumperStructuredDataDefSet.h" -#include "AssetDumpers/AssetDumperTechniqueSet.h" -#include "AssetDumpers/AssetDumperTracer.h" -#include "AssetDumpers/AssetDumperVehicle.h" -#include "AssetDumpers/AssetDumperVertexShader.h" -#include "AssetDumpers/AssetDumperWeapon.h" #include "Game/IW4/GameAssetPoolIW4.h" #include "Game/IW4/XModel/XModelDumperIW4.h" +#include "Image/AssetDumperGfxImage.h" +#include "Leaderboard/AssetDumperLeaderboardDef.h" +#include "LightDef/AssetDumperGfxLightDef.h" +#include "Localize/AssetDumperLocalizeEntry.h" +#include "Maps/AssetDumperAddonMapEnts.h" #include "Material/DumperMaterialIW4.h" +#include "Menu/AssetDumperMenuDef.h" +#include "Menu/AssetDumperMenuList.h" #include "ObjWriting.h" +#include "PhysCollmap/AssetDumperPhysCollmap.h" +#include "PhysPreset/AssetDumperPhysPreset.h" +#include "RawFile/AssetDumperRawFile.h" +#include "Shader/AssetDumperPixelShader.h" +#include "Shader/AssetDumperVertexShader.h" +#include "Sound/AssetDumperLoadedSound.h" +#include "Sound/AssetDumperSndCurve.h" +#include "StringTable/AssetDumperStringTable.h" +#include "StructuredDataDef/AssetDumperStructuredDataDefSet.h" +#include "Techset/AssetDumperTechniqueSet.h" +#include "Tracer/AssetDumperTracer.h" +#include "Vehicle/AssetDumperVehicle.h" +#include "Weapon/AssetDumperWeapon.h" using namespace IW4; diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperPhysCollmap.cpp b/src/ObjWriting/Game/IW4/PhysCollmap/AssetDumperPhysCollmap.cpp similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperPhysCollmap.cpp rename to src/ObjWriting/Game/IW4/PhysCollmap/AssetDumperPhysCollmap.cpp diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperPhysCollmap.h b/src/ObjWriting/Game/IW4/PhysCollmap/AssetDumperPhysCollmap.h similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperPhysCollmap.h rename to src/ObjWriting/Game/IW4/PhysCollmap/AssetDumperPhysCollmap.h diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperPhysPreset.cpp b/src/ObjWriting/Game/IW4/PhysPreset/AssetDumperPhysPreset.cpp similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperPhysPreset.cpp rename to src/ObjWriting/Game/IW4/PhysPreset/AssetDumperPhysPreset.cpp diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperPhysPreset.h b/src/ObjWriting/Game/IW4/PhysPreset/AssetDumperPhysPreset.h similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperPhysPreset.h rename to src/ObjWriting/Game/IW4/PhysPreset/AssetDumperPhysPreset.h diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperRawFile.cpp b/src/ObjWriting/Game/IW4/RawFile/AssetDumperRawFile.cpp similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperRawFile.cpp rename to src/ObjWriting/Game/IW4/RawFile/AssetDumperRawFile.cpp diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperRawFile.h b/src/ObjWriting/Game/IW4/RawFile/AssetDumperRawFile.h similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperRawFile.h rename to src/ObjWriting/Game/IW4/RawFile/AssetDumperRawFile.h diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperPixelShader.cpp b/src/ObjWriting/Game/IW4/Shader/AssetDumperPixelShader.cpp similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperPixelShader.cpp rename to src/ObjWriting/Game/IW4/Shader/AssetDumperPixelShader.cpp diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperPixelShader.h b/src/ObjWriting/Game/IW4/Shader/AssetDumperPixelShader.h similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperPixelShader.h rename to src/ObjWriting/Game/IW4/Shader/AssetDumperPixelShader.h diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperVertexShader.cpp b/src/ObjWriting/Game/IW4/Shader/AssetDumperVertexShader.cpp similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperVertexShader.cpp rename to src/ObjWriting/Game/IW4/Shader/AssetDumperVertexShader.cpp diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperVertexShader.h b/src/ObjWriting/Game/IW4/Shader/AssetDumperVertexShader.h similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperVertexShader.h rename to src/ObjWriting/Game/IW4/Shader/AssetDumperVertexShader.h diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLoadedSound.cpp b/src/ObjWriting/Game/IW4/Sound/AssetDumperLoadedSound.cpp similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLoadedSound.cpp rename to src/ObjWriting/Game/IW4/Sound/AssetDumperLoadedSound.cpp diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLoadedSound.h b/src/ObjWriting/Game/IW4/Sound/AssetDumperLoadedSound.h similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperLoadedSound.h rename to src/ObjWriting/Game/IW4/Sound/AssetDumperLoadedSound.h diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperSndCurve.cpp b/src/ObjWriting/Game/IW4/Sound/AssetDumperSndCurve.cpp similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperSndCurve.cpp rename to src/ObjWriting/Game/IW4/Sound/AssetDumperSndCurve.cpp diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperSndCurve.h b/src/ObjWriting/Game/IW4/Sound/AssetDumperSndCurve.h similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperSndCurve.h rename to src/ObjWriting/Game/IW4/Sound/AssetDumperSndCurve.h diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperStringTable.cpp b/src/ObjWriting/Game/IW4/StringTable/AssetDumperStringTable.cpp similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperStringTable.cpp rename to src/ObjWriting/Game/IW4/StringTable/AssetDumperStringTable.cpp diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperStringTable.h b/src/ObjWriting/Game/IW4/StringTable/AssetDumperStringTable.h similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperStringTable.h rename to src/ObjWriting/Game/IW4/StringTable/AssetDumperStringTable.h diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperStructuredDataDefSet.cpp b/src/ObjWriting/Game/IW4/StructuredDataDef/AssetDumperStructuredDataDefSet.cpp similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperStructuredDataDefSet.cpp rename to src/ObjWriting/Game/IW4/StructuredDataDef/AssetDumperStructuredDataDefSet.cpp diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperStructuredDataDefSet.h b/src/ObjWriting/Game/IW4/StructuredDataDef/AssetDumperStructuredDataDefSet.h similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperStructuredDataDefSet.h rename to src/ObjWriting/Game/IW4/StructuredDataDef/AssetDumperStructuredDataDefSet.h diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperTechniqueSet.cpp b/src/ObjWriting/Game/IW4/Techset/AssetDumperTechniqueSet.cpp similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperTechniqueSet.cpp rename to src/ObjWriting/Game/IW4/Techset/AssetDumperTechniqueSet.cpp diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperTechniqueSet.h b/src/ObjWriting/Game/IW4/Techset/AssetDumperTechniqueSet.h similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperTechniqueSet.h rename to src/ObjWriting/Game/IW4/Techset/AssetDumperTechniqueSet.h diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperTracer.cpp b/src/ObjWriting/Game/IW4/Tracer/AssetDumperTracer.cpp similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperTracer.cpp rename to src/ObjWriting/Game/IW4/Tracer/AssetDumperTracer.cpp diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperTracer.h b/src/ObjWriting/Game/IW4/Tracer/AssetDumperTracer.h similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperTracer.h rename to src/ObjWriting/Game/IW4/Tracer/AssetDumperTracer.h diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperVehicle.cpp b/src/ObjWriting/Game/IW4/Vehicle/AssetDumperVehicle.cpp similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperVehicle.cpp rename to src/ObjWriting/Game/IW4/Vehicle/AssetDumperVehicle.cpp diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperVehicle.h b/src/ObjWriting/Game/IW4/Vehicle/AssetDumperVehicle.h similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperVehicle.h rename to src/ObjWriting/Game/IW4/Vehicle/AssetDumperVehicle.h diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperWeapon.cpp b/src/ObjWriting/Game/IW4/Weapon/AssetDumperWeapon.cpp similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperWeapon.cpp rename to src/ObjWriting/Game/IW4/Weapon/AssetDumperWeapon.cpp diff --git a/src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperWeapon.h b/src/ObjWriting/Game/IW4/Weapon/AssetDumperWeapon.h similarity index 100% rename from src/ObjWriting/Game/IW4/AssetDumpers/AssetDumperWeapon.h rename to src/ObjWriting/Game/IW4/Weapon/AssetDumperWeapon.h diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperGfxImage.cpp b/src/ObjWriting/Game/IW5/Image/AssetDumperGfxImage.cpp similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperGfxImage.cpp rename to src/ObjWriting/Game/IW5/Image/AssetDumperGfxImage.cpp diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperGfxImage.h b/src/ObjWriting/Game/IW5/Image/AssetDumperGfxImage.h similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperGfxImage.h rename to src/ObjWriting/Game/IW5/Image/AssetDumperGfxImage.h diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperLeaderboardDef.cpp b/src/ObjWriting/Game/IW5/Leaderboard/AssetDumperLeaderboardDef.cpp similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperLeaderboardDef.cpp rename to src/ObjWriting/Game/IW5/Leaderboard/AssetDumperLeaderboardDef.cpp diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperLeaderboardDef.h b/src/ObjWriting/Game/IW5/Leaderboard/AssetDumperLeaderboardDef.h similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperLeaderboardDef.h rename to src/ObjWriting/Game/IW5/Leaderboard/AssetDumperLeaderboardDef.h diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperLocalizeEntry.cpp b/src/ObjWriting/Game/IW5/Localize/AssetDumperLocalizeEntry.cpp similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperLocalizeEntry.cpp rename to src/ObjWriting/Game/IW5/Localize/AssetDumperLocalizeEntry.cpp diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperLocalizeEntry.h b/src/ObjWriting/Game/IW5/Localize/AssetDumperLocalizeEntry.h similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperLocalizeEntry.h rename to src/ObjWriting/Game/IW5/Localize/AssetDumperLocalizeEntry.h diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperAddonMapEnts.cpp b/src/ObjWriting/Game/IW5/Maps/AssetDumperAddonMapEnts.cpp similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperAddonMapEnts.cpp rename to src/ObjWriting/Game/IW5/Maps/AssetDumperAddonMapEnts.cpp diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperAddonMapEnts.h b/src/ObjWriting/Game/IW5/Maps/AssetDumperAddonMapEnts.h similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperAddonMapEnts.h rename to src/ObjWriting/Game/IW5/Maps/AssetDumperAddonMapEnts.h diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperMenuDef.cpp b/src/ObjWriting/Game/IW5/Menu/AssetDumperMenuDef.cpp similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperMenuDef.cpp rename to src/ObjWriting/Game/IW5/Menu/AssetDumperMenuDef.cpp diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperMenuDef.h b/src/ObjWriting/Game/IW5/Menu/AssetDumperMenuDef.h similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperMenuDef.h rename to src/ObjWriting/Game/IW5/Menu/AssetDumperMenuDef.h diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperMenuList.cpp b/src/ObjWriting/Game/IW5/Menu/AssetDumperMenuList.cpp similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperMenuList.cpp rename to src/ObjWriting/Game/IW5/Menu/AssetDumperMenuList.cpp diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperMenuList.h b/src/ObjWriting/Game/IW5/Menu/AssetDumperMenuList.h similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperMenuList.h rename to src/ObjWriting/Game/IW5/Menu/AssetDumperMenuList.h diff --git a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp index 8e239829..46a3b354 100644 --- a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp +++ b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp @@ -1,21 +1,21 @@ #include "ObjWriterIW5.h" -#include "AssetDumpers/AssetDumperAddonMapEnts.h" -#include "AssetDumpers/AssetDumperGfxImage.h" -#include "AssetDumpers/AssetDumperLeaderboardDef.h" -#include "AssetDumpers/AssetDumperLoadedSound.h" -#include "AssetDumpers/AssetDumperLocalizeEntry.h" -#include "AssetDumpers/AssetDumperMenuDef.h" -#include "AssetDumpers/AssetDumperMenuList.h" -#include "AssetDumpers/AssetDumperRawFile.h" -#include "AssetDumpers/AssetDumperScriptFile.h" -#include "AssetDumpers/AssetDumperStringTable.h" -#include "AssetDumpers/AssetDumperWeapon.h" -#include "AssetDumpers/AssetDumperWeaponAttachment.h" #include "Game/IW5/GameAssetPoolIW5.h" #include "Game/IW5/XModel/XModelDumperIW5.h" +#include "Image/AssetDumperGfxImage.h" +#include "Leaderboard/AssetDumperLeaderboardDef.h" +#include "Localize/AssetDumperLocalizeEntry.h" +#include "Maps/AssetDumperAddonMapEnts.h" #include "Material/DumperMaterialIW5.h" +#include "Menu/AssetDumperMenuDef.h" +#include "Menu/AssetDumperMenuList.h" #include "ObjWriting.h" +#include "RawFile/AssetDumperRawFile.h" +#include "Script/AssetDumperScriptFile.h" +#include "Sound/AssetDumperLoadedSound.h" +#include "StringTable/AssetDumperStringTable.h" +#include "Weapon/AssetDumperWeapon.h" +#include "Weapon/AssetDumperWeaponAttachment.h" using namespace IW5; diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperRawFile.cpp b/src/ObjWriting/Game/IW5/RawFile/AssetDumperRawFile.cpp similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperRawFile.cpp rename to src/ObjWriting/Game/IW5/RawFile/AssetDumperRawFile.cpp diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperRawFile.h b/src/ObjWriting/Game/IW5/RawFile/AssetDumperRawFile.h similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperRawFile.h rename to src/ObjWriting/Game/IW5/RawFile/AssetDumperRawFile.h diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperScriptFile.cpp b/src/ObjWriting/Game/IW5/Script/AssetDumperScriptFile.cpp similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperScriptFile.cpp rename to src/ObjWriting/Game/IW5/Script/AssetDumperScriptFile.cpp diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperScriptFile.h b/src/ObjWriting/Game/IW5/Script/AssetDumperScriptFile.h similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperScriptFile.h rename to src/ObjWriting/Game/IW5/Script/AssetDumperScriptFile.h diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperLoadedSound.cpp b/src/ObjWriting/Game/IW5/Sound/AssetDumperLoadedSound.cpp similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperLoadedSound.cpp rename to src/ObjWriting/Game/IW5/Sound/AssetDumperLoadedSound.cpp diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperLoadedSound.h b/src/ObjWriting/Game/IW5/Sound/AssetDumperLoadedSound.h similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperLoadedSound.h rename to src/ObjWriting/Game/IW5/Sound/AssetDumperLoadedSound.h diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperStringTable.cpp b/src/ObjWriting/Game/IW5/StringTable/AssetDumperStringTable.cpp similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperStringTable.cpp rename to src/ObjWriting/Game/IW5/StringTable/AssetDumperStringTable.cpp diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperStringTable.h b/src/ObjWriting/Game/IW5/StringTable/AssetDumperStringTable.h similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperStringTable.h rename to src/ObjWriting/Game/IW5/StringTable/AssetDumperStringTable.h diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperWeapon.cpp b/src/ObjWriting/Game/IW5/Weapon/AssetDumperWeapon.cpp similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperWeapon.cpp rename to src/ObjWriting/Game/IW5/Weapon/AssetDumperWeapon.cpp diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperWeapon.h b/src/ObjWriting/Game/IW5/Weapon/AssetDumperWeapon.h similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperWeapon.h rename to src/ObjWriting/Game/IW5/Weapon/AssetDumperWeapon.h diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperWeaponAttachment.cpp b/src/ObjWriting/Game/IW5/Weapon/AssetDumperWeaponAttachment.cpp similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperWeaponAttachment.cpp rename to src/ObjWriting/Game/IW5/Weapon/AssetDumperWeaponAttachment.cpp diff --git a/src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperWeaponAttachment.h b/src/ObjWriting/Game/IW5/Weapon/AssetDumperWeaponAttachment.h similarity index 100% rename from src/ObjWriting/Game/IW5/AssetDumpers/AssetDumperWeaponAttachment.h rename to src/ObjWriting/Game/IW5/Weapon/AssetDumperWeaponAttachment.h diff --git a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperGfxImage.cpp b/src/ObjWriting/Game/T5/Image/AssetDumperGfxImage.cpp similarity index 100% rename from src/ObjWriting/Game/T5/AssetDumpers/AssetDumperGfxImage.cpp rename to src/ObjWriting/Game/T5/Image/AssetDumperGfxImage.cpp diff --git a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperGfxImage.h b/src/ObjWriting/Game/T5/Image/AssetDumperGfxImage.h similarity index 100% rename from src/ObjWriting/Game/T5/AssetDumpers/AssetDumperGfxImage.h rename to src/ObjWriting/Game/T5/Image/AssetDumperGfxImage.h diff --git a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperLocalizeEntry.cpp b/src/ObjWriting/Game/T5/Localize/AssetDumperLocalizeEntry.cpp similarity index 100% rename from src/ObjWriting/Game/T5/AssetDumpers/AssetDumperLocalizeEntry.cpp rename to src/ObjWriting/Game/T5/Localize/AssetDumperLocalizeEntry.cpp diff --git a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperLocalizeEntry.h b/src/ObjWriting/Game/T5/Localize/AssetDumperLocalizeEntry.h similarity index 100% rename from src/ObjWriting/Game/T5/AssetDumpers/AssetDumperLocalizeEntry.h rename to src/ObjWriting/Game/T5/Localize/AssetDumperLocalizeEntry.h diff --git a/src/ObjWriting/Game/T5/ObjWriterT5.cpp b/src/ObjWriting/Game/T5/ObjWriterT5.cpp index 4eafde5a..e37bc427 100644 --- a/src/ObjWriting/Game/T5/ObjWriterT5.cpp +++ b/src/ObjWriting/Game/T5/ObjWriterT5.cpp @@ -1,17 +1,17 @@ #include "ObjWriterT5.h" -#include "AssetDumpers/AssetDumperGfxImage.h" -#include "AssetDumpers/AssetDumperLocalizeEntry.h" -#include "AssetDumpers/AssetDumperPhysConstraints.h" -#include "AssetDumpers/AssetDumperPhysPreset.h" -#include "AssetDumpers/AssetDumperRawFile.h" -#include "AssetDumpers/AssetDumperSndBank.h" -#include "AssetDumpers/AssetDumperStringTable.h" -#include "AssetDumpers/AssetDumperWeapon.h" #include "Game/T5/GameAssetPoolT5.h" #include "Game/T5/XModel/XModelDumperT5.h" +#include "Image/AssetDumperGfxImage.h" +#include "Localize/AssetDumperLocalizeEntry.h" #include "Material/DumperMaterialT5.h" #include "ObjWriting.h" +#include "PhysConstraints/AssetDumperPhysConstraints.h" +#include "PhysPreset/AssetDumperPhysPreset.h" +#include "RawFile/AssetDumperRawFile.h" +#include "Sound/AssetDumperSndBank.h" +#include "StringTable/AssetDumperStringTable.h" +#include "Weapon/AssetDumperWeapon.h" using namespace T5; diff --git a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperPhysConstraints.cpp b/src/ObjWriting/Game/T5/PhysConstraints/AssetDumperPhysConstraints.cpp similarity index 100% rename from src/ObjWriting/Game/T5/AssetDumpers/AssetDumperPhysConstraints.cpp rename to src/ObjWriting/Game/T5/PhysConstraints/AssetDumperPhysConstraints.cpp diff --git a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperPhysConstraints.h b/src/ObjWriting/Game/T5/PhysConstraints/AssetDumperPhysConstraints.h similarity index 100% rename from src/ObjWriting/Game/T5/AssetDumpers/AssetDumperPhysConstraints.h rename to src/ObjWriting/Game/T5/PhysConstraints/AssetDumperPhysConstraints.h diff --git a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperPhysPreset.cpp b/src/ObjWriting/Game/T5/PhysPreset/AssetDumperPhysPreset.cpp similarity index 100% rename from src/ObjWriting/Game/T5/AssetDumpers/AssetDumperPhysPreset.cpp rename to src/ObjWriting/Game/T5/PhysPreset/AssetDumperPhysPreset.cpp diff --git a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperPhysPreset.h b/src/ObjWriting/Game/T5/PhysPreset/AssetDumperPhysPreset.h similarity index 100% rename from src/ObjWriting/Game/T5/AssetDumpers/AssetDumperPhysPreset.h rename to src/ObjWriting/Game/T5/PhysPreset/AssetDumperPhysPreset.h diff --git a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperRawFile.cpp b/src/ObjWriting/Game/T5/RawFile/AssetDumperRawFile.cpp similarity index 100% rename from src/ObjWriting/Game/T5/AssetDumpers/AssetDumperRawFile.cpp rename to src/ObjWriting/Game/T5/RawFile/AssetDumperRawFile.cpp diff --git a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperRawFile.h b/src/ObjWriting/Game/T5/RawFile/AssetDumperRawFile.h similarity index 100% rename from src/ObjWriting/Game/T5/AssetDumpers/AssetDumperRawFile.h rename to src/ObjWriting/Game/T5/RawFile/AssetDumperRawFile.h diff --git a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperSndBank.cpp b/src/ObjWriting/Game/T5/Sound/AssetDumperSndBank.cpp similarity index 100% rename from src/ObjWriting/Game/T5/AssetDumpers/AssetDumperSndBank.cpp rename to src/ObjWriting/Game/T5/Sound/AssetDumperSndBank.cpp diff --git a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperSndBank.h b/src/ObjWriting/Game/T5/Sound/AssetDumperSndBank.h similarity index 100% rename from src/ObjWriting/Game/T5/AssetDumpers/AssetDumperSndBank.h rename to src/ObjWriting/Game/T5/Sound/AssetDumperSndBank.h diff --git a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperStringTable.cpp b/src/ObjWriting/Game/T5/StringTable/AssetDumperStringTable.cpp similarity index 100% rename from src/ObjWriting/Game/T5/AssetDumpers/AssetDumperStringTable.cpp rename to src/ObjWriting/Game/T5/StringTable/AssetDumperStringTable.cpp diff --git a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperStringTable.h b/src/ObjWriting/Game/T5/StringTable/AssetDumperStringTable.h similarity index 100% rename from src/ObjWriting/Game/T5/AssetDumpers/AssetDumperStringTable.h rename to src/ObjWriting/Game/T5/StringTable/AssetDumperStringTable.h diff --git a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperWeapon.cpp b/src/ObjWriting/Game/T5/Weapon/AssetDumperWeapon.cpp similarity index 100% rename from src/ObjWriting/Game/T5/AssetDumpers/AssetDumperWeapon.cpp rename to src/ObjWriting/Game/T5/Weapon/AssetDumperWeapon.cpp diff --git a/src/ObjWriting/Game/T5/AssetDumpers/AssetDumperWeapon.h b/src/ObjWriting/Game/T5/Weapon/AssetDumperWeapon.h similarity index 100% rename from src/ObjWriting/Game/T5/AssetDumpers/AssetDumperWeapon.h rename to src/ObjWriting/Game/T5/Weapon/AssetDumperWeapon.h diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperGfxImage.cpp b/src/ObjWriting/Game/T6/Image/AssetDumperGfxImage.cpp similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperGfxImage.cpp rename to src/ObjWriting/Game/T6/Image/AssetDumperGfxImage.cpp diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperGfxImage.h b/src/ObjWriting/Game/T6/Image/AssetDumperGfxImage.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperGfxImage.h rename to src/ObjWriting/Game/T6/Image/AssetDumperGfxImage.h diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperLeaderboardDef.cpp b/src/ObjWriting/Game/T6/Leaderboard/AssetDumperLeaderboardDef.cpp similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperLeaderboardDef.cpp rename to src/ObjWriting/Game/T6/Leaderboard/AssetDumperLeaderboardDef.cpp diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperLeaderboardDef.h b/src/ObjWriting/Game/T6/Leaderboard/AssetDumperLeaderboardDef.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperLeaderboardDef.h rename to src/ObjWriting/Game/T6/Leaderboard/AssetDumperLeaderboardDef.h diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperLocalizeEntry.cpp b/src/ObjWriting/Game/T6/Localize/AssetDumperLocalizeEntry.cpp similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperLocalizeEntry.cpp rename to src/ObjWriting/Game/T6/Localize/AssetDumperLocalizeEntry.cpp diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperLocalizeEntry.h b/src/ObjWriting/Game/T6/Localize/AssetDumperLocalizeEntry.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperLocalizeEntry.h rename to src/ObjWriting/Game/T6/Localize/AssetDumperLocalizeEntry.h diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperMapEnts.cpp b/src/ObjWriting/Game/T6/Maps/AssetDumperMapEnts.cpp similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperMapEnts.cpp rename to src/ObjWriting/Game/T6/Maps/AssetDumperMapEnts.cpp diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperMapEnts.h b/src/ObjWriting/Game/T6/Maps/AssetDumperMapEnts.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperMapEnts.h rename to src/ObjWriting/Game/T6/Maps/AssetDumperMapEnts.h diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 03f1737b..48d3dd34 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -1,31 +1,32 @@ #include "ObjWriterT6.h" -#include "AssetDumpers/AssetDumperGfxImage.h" -#include "AssetDumpers/AssetDumperLeaderboardDef.h" -#include "AssetDumpers/AssetDumperLocalizeEntry.h" -#include "AssetDumpers/AssetDumperMapEnts.h" -#include "AssetDumpers/AssetDumperPhysConstraints.h" -#include "AssetDumpers/AssetDumperPhysPreset.h" -#include "AssetDumpers/AssetDumperQdb.h" -#include "AssetDumpers/AssetDumperRawFile.h" -#include "AssetDumpers/AssetDumperScriptParseTree.h" -#include "AssetDumpers/AssetDumperSlug.h" -#include "AssetDumpers/AssetDumperSndBank.h" -#include "AssetDumpers/AssetDumperSndDriverGlobals.h" -#include "AssetDumpers/AssetDumperStringTable.h" -#include "AssetDumpers/AssetDumperTechniqueSet.h" -#include "AssetDumpers/AssetDumperTracer.h" -#include "AssetDumpers/AssetDumperVehicle.h" -#include "AssetDumpers/AssetDumperWeapon.h" -#include "AssetDumpers/AssetDumperWeaponAttachment.h" -#include "AssetDumpers/AssetDumperWeaponAttachmentUnique.h" -#include "AssetDumpers/AssetDumperWeaponCamo.h" -#include "AssetDumpers/AssetDumperZBarrier.h" #include "FontIcon/DumperFontIconT6.h" #include "Game/T6/GameAssetPoolT6.h" #include "Game/T6/XModel/XModelDumperT6.h" +#include "Image/AssetDumperGfxImage.h" +#include "Leaderboard/AssetDumperLeaderboardDef.h" +#include "Localize/AssetDumperLocalizeEntry.h" +#include "Maps/AssetDumperMapEnts.h" #include "Material/DumperMaterialT6.h" #include "ObjWriting.h" +#include "PhysConstraints/AssetDumperPhysConstraints.h" +#include "PhysPreset/AssetDumperPhysPreset.h" +#include "Qdb/AssetDumperQdb.h" +#include "RawFile/AssetDumperRawFile.h" +#include "Script/AssetDumperScriptParseTree.h" +#include "Slug/AssetDumperSlug.h" +#include "Sound/AssetDumperSndBank.h" +#include "Sound/AssetDumperSndDriverGlobals.h" +#include "StringTable/AssetDumperStringTable.h" +#include "Techset/AssetDumperTechniqueSet.h" +#include "Tracer/AssetDumperTracer.h" +#include "Vehicle/AssetDumperVehicle.h" +#include "Weapon/AssetDumperWeapon.h" +#include "Weapon/AssetDumperWeaponAttachment.h" +#include "Weapon/AssetDumperWeaponAttachmentUnique.h" +#include "Weapon/AssetDumperWeaponCamo.h" +#include "ZBarrier/AssetDumperZBarrier.h" + using namespace T6; diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysConstraints.cpp b/src/ObjWriting/Game/T6/PhysConstraints/AssetDumperPhysConstraints.cpp similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysConstraints.cpp rename to src/ObjWriting/Game/T6/PhysConstraints/AssetDumperPhysConstraints.cpp diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysConstraints.h b/src/ObjWriting/Game/T6/PhysConstraints/AssetDumperPhysConstraints.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysConstraints.h rename to src/ObjWriting/Game/T6/PhysConstraints/AssetDumperPhysConstraints.h diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.cpp b/src/ObjWriting/Game/T6/PhysPreset/AssetDumperPhysPreset.cpp similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.cpp rename to src/ObjWriting/Game/T6/PhysPreset/AssetDumperPhysPreset.cpp diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.h b/src/ObjWriting/Game/T6/PhysPreset/AssetDumperPhysPreset.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperPhysPreset.h rename to src/ObjWriting/Game/T6/PhysPreset/AssetDumperPhysPreset.h diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperQdb.cpp b/src/ObjWriting/Game/T6/Qdb/AssetDumperQdb.cpp similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperQdb.cpp rename to src/ObjWriting/Game/T6/Qdb/AssetDumperQdb.cpp diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperQdb.h b/src/ObjWriting/Game/T6/Qdb/AssetDumperQdb.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperQdb.h rename to src/ObjWriting/Game/T6/Qdb/AssetDumperQdb.h diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperRawFile.cpp b/src/ObjWriting/Game/T6/RawFile/AssetDumperRawFile.cpp similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperRawFile.cpp rename to src/ObjWriting/Game/T6/RawFile/AssetDumperRawFile.cpp diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperRawFile.h b/src/ObjWriting/Game/T6/RawFile/AssetDumperRawFile.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperRawFile.h rename to src/ObjWriting/Game/T6/RawFile/AssetDumperRawFile.h diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperScriptParseTree.cpp b/src/ObjWriting/Game/T6/Script/AssetDumperScriptParseTree.cpp similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperScriptParseTree.cpp rename to src/ObjWriting/Game/T6/Script/AssetDumperScriptParseTree.cpp diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperScriptParseTree.h b/src/ObjWriting/Game/T6/Script/AssetDumperScriptParseTree.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperScriptParseTree.h rename to src/ObjWriting/Game/T6/Script/AssetDumperScriptParseTree.h diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSlug.cpp b/src/ObjWriting/Game/T6/Slug/AssetDumperSlug.cpp similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSlug.cpp rename to src/ObjWriting/Game/T6/Slug/AssetDumperSlug.cpp diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSlug.h b/src/ObjWriting/Game/T6/Slug/AssetDumperSlug.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSlug.h rename to src/ObjWriting/Game/T6/Slug/AssetDumperSlug.h diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp b/src/ObjWriting/Game/T6/Sound/AssetDumperSndBank.cpp similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp rename to src/ObjWriting/Game/T6/Sound/AssetDumperSndBank.cpp diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.h b/src/ObjWriting/Game/T6/Sound/AssetDumperSndBank.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.h rename to src/ObjWriting/Game/T6/Sound/AssetDumperSndBank.h diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndDriverGlobals.cpp b/src/ObjWriting/Game/T6/Sound/AssetDumperSndDriverGlobals.cpp similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndDriverGlobals.cpp rename to src/ObjWriting/Game/T6/Sound/AssetDumperSndDriverGlobals.cpp diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndDriverGlobals.h b/src/ObjWriting/Game/T6/Sound/AssetDumperSndDriverGlobals.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndDriverGlobals.h rename to src/ObjWriting/Game/T6/Sound/AssetDumperSndDriverGlobals.h diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperStringTable.cpp b/src/ObjWriting/Game/T6/StringTable/AssetDumperStringTable.cpp similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperStringTable.cpp rename to src/ObjWriting/Game/T6/StringTable/AssetDumperStringTable.cpp diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperStringTable.h b/src/ObjWriting/Game/T6/StringTable/AssetDumperStringTable.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperStringTable.h rename to src/ObjWriting/Game/T6/StringTable/AssetDumperStringTable.h diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTechniqueSet.cpp b/src/ObjWriting/Game/T6/Techset/AssetDumperTechniqueSet.cpp similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTechniqueSet.cpp rename to src/ObjWriting/Game/T6/Techset/AssetDumperTechniqueSet.cpp diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTechniqueSet.h b/src/ObjWriting/Game/T6/Techset/AssetDumperTechniqueSet.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTechniqueSet.h rename to src/ObjWriting/Game/T6/Techset/AssetDumperTechniqueSet.h diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.cpp b/src/ObjWriting/Game/T6/Tracer/AssetDumperTracer.cpp similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.cpp rename to src/ObjWriting/Game/T6/Tracer/AssetDumperTracer.cpp diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.h b/src/ObjWriting/Game/T6/Tracer/AssetDumperTracer.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperTracer.h rename to src/ObjWriting/Game/T6/Tracer/AssetDumperTracer.h diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperVehicle.cpp b/src/ObjWriting/Game/T6/Vehicle/AssetDumperVehicle.cpp similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperVehicle.cpp rename to src/ObjWriting/Game/T6/Vehicle/AssetDumperVehicle.cpp diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperVehicle.h b/src/ObjWriting/Game/T6/Vehicle/AssetDumperVehicle.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperVehicle.h rename to src/ObjWriting/Game/T6/Vehicle/AssetDumperVehicle.h diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp b/src/ObjWriting/Game/T6/Weapon/AssetDumperWeapon.cpp similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp rename to src/ObjWriting/Game/T6/Weapon/AssetDumperWeapon.cpp diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.h b/src/ObjWriting/Game/T6/Weapon/AssetDumperWeapon.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.h rename to src/ObjWriting/Game/T6/Weapon/AssetDumperWeapon.h diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeaponAttachment.cpp b/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachment.cpp similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeaponAttachment.cpp rename to src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachment.cpp diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeaponAttachment.h b/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachment.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeaponAttachment.h rename to src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachment.h diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeaponAttachmentUnique.cpp b/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachmentUnique.cpp similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeaponAttachmentUnique.cpp rename to src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachmentUnique.cpp diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeaponAttachmentUnique.h b/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachmentUnique.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeaponAttachmentUnique.h rename to src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachmentUnique.h diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeaponCamo.cpp b/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponCamo.cpp similarity index 90% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeaponCamo.cpp rename to src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponCamo.cpp index 4631e962..4e485235 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeaponCamo.cpp +++ b/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponCamo.cpp @@ -1,6 +1,6 @@ #include "AssetDumperWeaponCamo.h" -#include "Game/T6/WeaponCamo/JsonWeaponCamoWriter.h" +#include "JsonWeaponCamoWriter.h" #include diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeaponCamo.h b/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponCamo.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeaponCamo.h rename to src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponCamo.h diff --git a/src/ObjWriting/Game/T6/WeaponCamo/JsonWeaponCamoWriter.cpp b/src/ObjWriting/Game/T6/Weapon/JsonWeaponCamoWriter.cpp similarity index 100% rename from src/ObjWriting/Game/T6/WeaponCamo/JsonWeaponCamoWriter.cpp rename to src/ObjWriting/Game/T6/Weapon/JsonWeaponCamoWriter.cpp diff --git a/src/ObjWriting/Game/T6/WeaponCamo/JsonWeaponCamoWriter.h b/src/ObjWriting/Game/T6/Weapon/JsonWeaponCamoWriter.h similarity index 100% rename from src/ObjWriting/Game/T6/WeaponCamo/JsonWeaponCamoWriter.h rename to src/ObjWriting/Game/T6/Weapon/JsonWeaponCamoWriter.h diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.cpp b/src/ObjWriting/Game/T6/ZBarrier/AssetDumperZBarrier.cpp similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.cpp rename to src/ObjWriting/Game/T6/ZBarrier/AssetDumperZBarrier.cpp diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.h b/src/ObjWriting/Game/T6/ZBarrier/AssetDumperZBarrier.h similarity index 100% rename from src/ObjWriting/Game/T6/AssetDumpers/AssetDumperZBarrier.h rename to src/ObjWriting/Game/T6/ZBarrier/AssetDumperZBarrier.h From ce1f0d23c92fb3f42dafdb76939beeb4f92524bb Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Fri, 25 Jul 2025 22:33:40 +0100 Subject: [PATCH 03/35] refactor: merge leaderboard dumpers into a single file --- .../Leaderboard/LeaderboardCommon.cpp | 11 ++++++ src/ObjCommon/Leaderboard/LeaderboardCommon.h | 8 +++++ .../IW4/Leaderboard/LoaderLeaderboardIW4.cpp | 3 +- .../Leaderboard/AssetDumperLeaderboardDef.cpp | 28 --------------- .../Leaderboard/AssetDumperLeaderboardDef.h | 16 --------- .../T6/Leaderboard/JsonLeaderboardDefWriter.h | 11 ------ ...Writer.cpp => LeaderboardJsonDumperT6.cpp} | 34 +++++++++++++------ .../T6/Leaderboard/LeaderboardJsonDumperT6.h | 14 ++++++++ src/ObjWriting/Game/T6/ObjWriterT6.cpp | 5 ++- 9 files changed, 61 insertions(+), 69 deletions(-) create mode 100644 src/ObjCommon/Leaderboard/LeaderboardCommon.cpp create mode 100644 src/ObjCommon/Leaderboard/LeaderboardCommon.h delete mode 100644 src/ObjWriting/Game/T6/Leaderboard/AssetDumperLeaderboardDef.cpp delete mode 100644 src/ObjWriting/Game/T6/Leaderboard/AssetDumperLeaderboardDef.h delete mode 100644 src/ObjWriting/Game/T6/Leaderboard/JsonLeaderboardDefWriter.h rename src/ObjWriting/Game/T6/Leaderboard/{JsonLeaderboardDefWriter.cpp => LeaderboardJsonDumperT6.cpp} (77%) create mode 100644 src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.h diff --git a/src/ObjCommon/Leaderboard/LeaderboardCommon.cpp b/src/ObjCommon/Leaderboard/LeaderboardCommon.cpp new file mode 100644 index 00000000..d3286f36 --- /dev/null +++ b/src/ObjCommon/Leaderboard/LeaderboardCommon.cpp @@ -0,0 +1,11 @@ +#include "LeaderboardCommon.h" + +#include + +namespace leaderboard +{ + std::string GetJsonFileNameForAsset(const std::string& assetName) + { + return std::format("leaderboards/{}.json", assetName); + } +} // namespace leaderboard diff --git a/src/ObjCommon/Leaderboard/LeaderboardCommon.h b/src/ObjCommon/Leaderboard/LeaderboardCommon.h new file mode 100644 index 00000000..ab6958b1 --- /dev/null +++ b/src/ObjCommon/Leaderboard/LeaderboardCommon.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace leaderboard +{ + std::string GetJsonFileNameForAsset(const std::string& assetName); +} diff --git a/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.cpp b/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.cpp index 550472dc..60f4418e 100644 --- a/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.cpp +++ b/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.cpp @@ -2,6 +2,7 @@ #include "Game/IW4/IW4.h" #include "JsonLeaderboardDefLoader.h" +#include "Leaderboard/LeaderboardCommon.h" #include #include @@ -22,7 +23,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto file = m_search_path.Open(std::format("leaderboards/{}.json", assetName)); + const auto file = m_search_path.Open(leaderboard::GetJsonFileNameForAsset(assetName)); if (!file.IsOpen()) return AssetCreationResult::NoAction(); diff --git a/src/ObjWriting/Game/T6/Leaderboard/AssetDumperLeaderboardDef.cpp b/src/ObjWriting/Game/T6/Leaderboard/AssetDumperLeaderboardDef.cpp deleted file mode 100644 index 2d83e5bd..00000000 --- a/src/ObjWriting/Game/T6/Leaderboard/AssetDumperLeaderboardDef.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "AssetDumperLeaderboardDef.h" - -#include "Game/T6/Leaderboard/JsonLeaderboardDefWriter.h" - -#include -#include - -using namespace T6; - -std::string AssetDumperLeaderboardDef::GetFileNameForAsset(const std::string& assetName) -{ - return std::format("leaderboards/{}.json", assetName); -} - -bool AssetDumperLeaderboardDef::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperLeaderboardDef::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset->m_name)); - - if (!assetFile) - return; - - DumpLeaderboardDefAsJson(*assetFile, asset->Asset()); -} diff --git a/src/ObjWriting/Game/T6/Leaderboard/AssetDumperLeaderboardDef.h b/src/ObjWriting/Game/T6/Leaderboard/AssetDumperLeaderboardDef.h deleted file mode 100644 index 057d4252..00000000 --- a/src/ObjWriting/Game/T6/Leaderboard/AssetDumperLeaderboardDef.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/T6/T6.h" - -namespace T6 -{ - class AssetDumperLeaderboardDef final : public AbstractAssetDumper - { - static std::string GetFileNameForAsset(const std::string& assetName); - - protected: - _NODISCARD bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace T6 diff --git a/src/ObjWriting/Game/T6/Leaderboard/JsonLeaderboardDefWriter.h b/src/ObjWriting/Game/T6/Leaderboard/JsonLeaderboardDefWriter.h deleted file mode 100644 index cdc31389..00000000 --- a/src/ObjWriting/Game/T6/Leaderboard/JsonLeaderboardDefWriter.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "Dumping/AssetDumpingContext.h" -#include "Game/T6/T6.h" - -#include - -namespace T6 -{ - void DumpLeaderboardDefAsJson(std::ostream& stream, const LeaderboardDef* leaderboardDef); -} // namespace T6 diff --git a/src/ObjWriting/Game/T6/Leaderboard/JsonLeaderboardDefWriter.cpp b/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.cpp similarity index 77% rename from src/ObjWriting/Game/T6/Leaderboard/JsonLeaderboardDefWriter.cpp rename to src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.cpp index a559881f..5e468579 100644 --- a/src/ObjWriting/Game/T6/Leaderboard/JsonLeaderboardDefWriter.cpp +++ b/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.cpp @@ -1,28 +1,32 @@ -#include "JsonLeaderboardDefWriter.h" +#include "LeaderboardJsonDumperT6.h" #include "Game/T6/CommonT6.h" #include "Game/T6/Leaderboard/JsonLeaderboardDef.h" +#include "Leaderboard/LeaderboardCommon.h" +#include #include #include +#include using namespace nlohmann; using namespace T6; +using namespace ::leaderboard; namespace { - class JsonDumper + class Dumper { public: - explicit JsonDumper(std::ostream& stream) + explicit Dumper(std::ostream& stream) : m_stream(stream) { } - void Dump(const LeaderboardDef* leaderboardDef) const + void Dump(const LeaderboardDef& leaderboardDef) const { JsonLeaderboardDef jsonLeaderboardDef; - CreateJsonLeaderboardDef(jsonLeaderboardDef, *leaderboardDef); + CreateJsonLeaderboardDef(jsonLeaderboardDef, leaderboardDef); json jRoot = jsonLeaderboardDef; @@ -94,11 +98,21 @@ namespace }; } // namespace -namespace T6 +namespace T6::leaderboard { - void DumpLeaderboardDefAsJson(std::ostream& stream, const LeaderboardDef* leaderboardDef) + bool JsonDumper::ShouldDump(XAssetInfo* asset) { - JsonDumper dumper(stream); - dumper.Dump(leaderboardDef); + return true; } -} // namespace T6 + + void JsonDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAsset(asset->m_name)); + + if (!assetFile) + return; + + Dumper dumper(*assetFile); + dumper.Dump(*asset->Asset()); + } +} // namespace T6::leaderboard diff --git a/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.h b/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.h new file mode 100644 index 00000000..85d18061 --- /dev/null +++ b/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.h @@ -0,0 +1,14 @@ +#pragma once + +#include "Dumping/AbstractAssetDumper.h" +#include "Game/T6/T6.h" + +namespace T6::leaderboard +{ + class JsonDumper final : public AbstractAssetDumper + { + protected: + [[nodiscard]] bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + }; +} // namespace T6::leaderboard diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 48d3dd34..21c45d73 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -4,7 +4,7 @@ #include "Game/T6/GameAssetPoolT6.h" #include "Game/T6/XModel/XModelDumperT6.h" #include "Image/AssetDumperGfxImage.h" -#include "Leaderboard/AssetDumperLeaderboardDef.h" +#include "Leaderboard/LeaderboardJsonDumperT6.h" #include "Localize/AssetDumperLocalizeEntry.h" #include "Maps/AssetDumperMapEnts.h" #include "Material/DumperMaterialT6.h" @@ -27,7 +27,6 @@ #include "Weapon/AssetDumperWeaponCamo.h" #include "ZBarrier/AssetDumperZBarrier.h" - using namespace T6; bool ObjWriter::DumpZone(AssetDumpingContext& context) const @@ -72,7 +71,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file, ASSET_TYPE_RAWFILE) DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE) - DUMP_ASSET_POOL(AssetDumperLeaderboardDef, m_leaderboard, ASSET_TYPE_LEADERBOARD) + DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD) // DUMP_ASSET_POOL(AssetDumperXGlobals, m_xglobals, ASSET_TYPE_XGLOBALS) // DUMP_ASSET_POOL(AssetDumperDDLRoot, m_ddl, ASSET_TYPE_DDL) // DUMP_ASSET_POOL(AssetDumperGlasses, m_glasses, ASSET_TYPE_GLASSES) From dbec702075b76d97c880dfb895972305f7a50345 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Sun, 27 Jul 2025 23:13:26 +0100 Subject: [PATCH 04/35] refactor: use IAssetDumper interface on implementations directly --- .../Game/T6/FontIcon/DumperFontIconCsvT6.h | 9 ---- .../Game/T6/FontIcon/DumperFontIconJsonT6.h | 9 ---- .../Game/T6/FontIcon/DumperFontIconT6.cpp | 22 ---------- ...tIconCsvT6.cpp => FontIconCsvDumperT6.cpp} | 25 ++++++----- ...mperFontIconT6.h => FontIconCsvDumperT6.h} | 6 +-- .../Game/T6/FontIcon/FontIconDumperT6.cpp | 20 +++++++++ .../Game/T6/FontIcon/FontIconDumperT6.h | 9 ++++ ...conJsonT6.cpp => FontIconJsonDumperT6.cpp} | 17 ++++--- .../Game/T6/FontIcon/FontIconJsonDumperT6.h | 14 ++++++ src/ObjWriting/Game/T6/ObjWriterT6.cpp | 10 ++++- ...6Test.cpp => FontIconJsonDumperT6Test.cpp} | 44 ++++++++++--------- .../Game/T6/Material/DumperMaterialT6Test.cpp | 1 - 12 files changed, 103 insertions(+), 83 deletions(-) delete mode 100644 src/ObjWriting/Game/T6/FontIcon/DumperFontIconCsvT6.h delete mode 100644 src/ObjWriting/Game/T6/FontIcon/DumperFontIconJsonT6.h delete mode 100644 src/ObjWriting/Game/T6/FontIcon/DumperFontIconT6.cpp rename src/ObjWriting/Game/T6/FontIcon/{DumperFontIconCsvT6.cpp => FontIconCsvDumperT6.cpp} (88%) rename src/ObjWriting/Game/T6/FontIcon/{DumperFontIconT6.h => FontIconCsvDumperT6.h} (69%) create mode 100644 src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.cpp create mode 100644 src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.h rename src/ObjWriting/Game/T6/FontIcon/{DumperFontIconJsonT6.cpp => FontIconJsonDumperT6.cpp} (88%) create mode 100644 src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.h rename test/ObjWritingTests/Game/T6/FontIcon/{DumperFontIconJsonT6Test.cpp => FontIconJsonDumperT6Test.cpp} (77%) diff --git a/src/ObjWriting/Game/T6/FontIcon/DumperFontIconCsvT6.h b/src/ObjWriting/Game/T6/FontIcon/DumperFontIconCsvT6.h deleted file mode 100644 index bbdc5649..00000000 --- a/src/ObjWriting/Game/T6/FontIcon/DumperFontIconCsvT6.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/T6/T6.h" - -namespace T6 -{ - void DumpFontIconAsCsv(const AssetDumpingContext& context, const FontIcon& fontIcon); -} diff --git a/src/ObjWriting/Game/T6/FontIcon/DumperFontIconJsonT6.h b/src/ObjWriting/Game/T6/FontIcon/DumperFontIconJsonT6.h deleted file mode 100644 index 7603e35d..00000000 --- a/src/ObjWriting/Game/T6/FontIcon/DumperFontIconJsonT6.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/T6/T6.h" - -namespace T6 -{ - void DumpFontIconAsJson(const AssetDumpingContext& context, const FontIcon& fontIcon); -} diff --git a/src/ObjWriting/Game/T6/FontIcon/DumperFontIconT6.cpp b/src/ObjWriting/Game/T6/FontIcon/DumperFontIconT6.cpp deleted file mode 100644 index 91dc5946..00000000 --- a/src/ObjWriting/Game/T6/FontIcon/DumperFontIconT6.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "DumperFontIconT6.h" - -#include "DumperFontIconCsvT6.h" -#include "DumperFontIconJsonT6.h" - -using namespace T6; - -// #define DUMP_FONT_ICON_AS_CSV 1 - -bool AssetDumperFontIcon::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperFontIcon::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ -#ifdef DUMP_FONT_ICON_AS_CSV - DumpFontIconAsCsv(context, *asset->Asset()); -#else - DumpFontIconAsJson(context, *asset->Asset()); -#endif -} diff --git a/src/ObjWriting/Game/T6/FontIcon/DumperFontIconCsvT6.cpp b/src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.cpp similarity index 88% rename from src/ObjWriting/Game/T6/FontIcon/DumperFontIconCsvT6.cpp rename to src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.cpp index a6b199ae..c8974ff1 100644 --- a/src/ObjWriting/Game/T6/FontIcon/DumperFontIconCsvT6.cpp +++ b/src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.cpp @@ -1,4 +1,4 @@ -#include "DumperFontIconCsvT6.h" +#include "FontIconCsvDumperT6.h" #include "Csv/CsvStream.h" #include "Game/T6/CommonT6.h" @@ -52,15 +52,15 @@ namespace } } - class DumperFontIconCsv + class Dumper { public: - explicit DumperFontIconCsv(std::ostream& stream) + explicit Dumper(std::ostream& stream) : m_csv(stream) { } - void DumpFontIcon(const FontIcon& fontIcon) + void Dump(const FontIcon& fontIcon) { WriteFontIconEntries(fontIcon); m_csv.NextRow(); @@ -131,16 +131,21 @@ namespace }; } // namespace -namespace T6 +namespace T6::font_icon { - void DumpFontIconAsCsv(const AssetDumpingContext& context, const FontIcon& fontIcon) + bool CsvDumper::ShouldDump(XAssetInfo* asset) { - const auto assetFile = context.OpenAssetFile(fontIcon.name); + return true; + } + + void CsvDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto assetFile = context.OpenAssetFile(asset->m_name); if (!assetFile) return; - DumperFontIconCsv dumperFontIconCsv(*assetFile); - dumperFontIconCsv.DumpFontIcon(fontIcon); + Dumper dumper(*assetFile); + dumper.Dump(*asset->Asset()); } -} // namespace T6 +} // namespace T6::font_icon diff --git a/src/ObjWriting/Game/T6/FontIcon/DumperFontIconT6.h b/src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.h similarity index 69% rename from src/ObjWriting/Game/T6/FontIcon/DumperFontIconT6.h rename to src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.h index 0581829f..7483dddf 100644 --- a/src/ObjWriting/Game/T6/FontIcon/DumperFontIconT6.h +++ b/src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6 +namespace T6::font_icon { - class AssetDumperFontIcon final : public AbstractAssetDumper + class CsvDumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6 +} // namespace T6::font_icon diff --git a/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.cpp b/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.cpp new file mode 100644 index 00000000..a3ec3322 --- /dev/null +++ b/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.cpp @@ -0,0 +1,20 @@ +#include "FontIconDumperT6.h" + +#include "FontIconCsvDumperT6.h" +#include "FontIconJsonDumperT6.h" + +using namespace T6; + +// #define DUMP_FONT_ICON_AS_CSV 1 + +namespace T6::font_icon +{ + std::unique_ptr> CreateDumper() + { +#ifdef DUMP_FONT_ICON_AS_CSV + return std::make_unique(); +#else + return std::make_unique(); +#endif + } +} // namespace T6::font_icon diff --git a/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.h b/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.h new file mode 100644 index 00000000..a9e06e13 --- /dev/null +++ b/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.h @@ -0,0 +1,9 @@ +#pragma once + +#include "Dumping/AbstractAssetDumper.h" +#include "Game/T6/T6.h" + +namespace T6::font_icon +{ + std::unique_ptr> CreateDumper(); +} // namespace T6::font_icon diff --git a/src/ObjWriting/Game/T6/FontIcon/DumperFontIconJsonT6.cpp b/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.cpp similarity index 88% rename from src/ObjWriting/Game/T6/FontIcon/DumperFontIconJsonT6.cpp rename to src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.cpp index f532ebe3..cd3078f5 100644 --- a/src/ObjWriting/Game/T6/FontIcon/DumperFontIconJsonT6.cpp +++ b/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.cpp @@ -1,4 +1,4 @@ -#include "DumperFontIconJsonT6.h" +#include "FontIconJsonDumperT6.h" #include "Game/T6/CommonT6.h" #include "Game/T6/FontIcon/FontIconCommonT6.h" @@ -76,15 +76,20 @@ namespace } } // namespace -namespace T6 +namespace T6::font_icon { - void DumpFontIconAsJson(const AssetDumpingContext& context, const FontIcon& fontIcon) + bool JsonDumper::ShouldDump(XAssetInfo* asset) { - const auto assetFile = context.OpenAssetFile(font_icon::GetJsonFileNameForAssetName(fontIcon.name)); + return true; + } + + void JsonDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto assetFile = context.OpenAssetFile(font_icon::GetJsonFileNameForAssetName(asset->m_name)); if (!assetFile) return; - DumpFontIcon(*assetFile, fontIcon); + DumpFontIcon(*assetFile, *asset->Asset()); } -} // namespace T6 +} // namespace T6::font_icon diff --git a/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.h b/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.h new file mode 100644 index 00000000..ade8bf33 --- /dev/null +++ b/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.h @@ -0,0 +1,14 @@ +#pragma once + +#include "Dumping/AbstractAssetDumper.h" +#include "Game/T6/T6.h" + +namespace T6::font_icon +{ + class JsonDumper final : public AbstractAssetDumper + { + protected: + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + }; +} // namespace T6::font_icon diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 21c45d73..37313290 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -1,6 +1,6 @@ #include "ObjWriterT6.h" -#include "FontIcon/DumperFontIconT6.h" +#include "FontIcon/FontIconDumperT6.h" #include "Game/T6/GameAssetPoolT6.h" #include "Game/T6/XModel/XModelDumperT6.h" #include "Image/AssetDumperGfxImage.h" @@ -37,6 +37,12 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const dumperType dumper; \ dumper.DumpPool(context, assetPools->poolName.get()); \ } +#define DUMP_ASSET_POOL_WITH_FACTORY(createDumper, poolName, assetType) \ + if (assetPools->poolName && ObjWriting::ShouldHandleAssetType(assetType)) \ + { \ + const auto dumper = createDumper; \ + dumper->DumpPool(context, assetPools->poolName.get()); \ + } const auto* assetPools = dynamic_cast(context.m_zone.m_pools.get()); @@ -58,7 +64,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD) // DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF) // DUMP_ASSET_POOL(AssetDumperFont, m_font, ASSET_TYPE_FONT) - DUMP_ASSET_POOL(AssetDumperFontIcon, m_font_icon, ASSET_TYPE_FONTICON) + DUMP_ASSET_POOL_WITH_FACTORY(font_icon::CreateDumper(), m_font_icon, ASSET_TYPE_FONTICON) // DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST) // DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU) DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) diff --git a/test/ObjWritingTests/Game/T6/FontIcon/DumperFontIconJsonT6Test.cpp b/test/ObjWritingTests/Game/T6/FontIcon/FontIconJsonDumperT6Test.cpp similarity index 77% rename from test/ObjWritingTests/Game/T6/FontIcon/DumperFontIconJsonT6Test.cpp rename to test/ObjWritingTests/Game/T6/FontIcon/FontIconJsonDumperT6Test.cpp index c8837e7b..04bf8440 100644 --- a/test/ObjWritingTests/Game/T6/FontIcon/DumperFontIconJsonT6Test.cpp +++ b/test/ObjWritingTests/Game/T6/FontIcon/FontIconJsonDumperT6Test.cpp @@ -1,4 +1,4 @@ -#include "Game/T6/FontIcon/DumperFontIconJsonT6.h" +#include "Game/T6/FontIcon/FontIconJsonDumperT6.h" #include "Asset/AssetRegistration.h" #include "Game/T6/CommonT6.h" @@ -27,14 +27,15 @@ namespace return material; } - void GivenFontIcon(const std::string& name, FontIcon& fontIcon, MemoryManager& memory) + void GivenFontIcon(const std::string& name, AssetPool& pool, MemoryManager& memory) { - fontIcon.name = memory.Dup(name.c_str()); + auto* fontIcon = memory.Alloc(); + fontIcon->name = memory.Dup(name.c_str()); - fontIcon.numEntries = 3; - fontIcon.fontIconEntry = memory.Alloc(fontIcon.numEntries); + fontIcon->numEntries = 3; + fontIcon->fontIconEntry = memory.Alloc(fontIcon->numEntries); - auto& entry0 = fontIcon.fontIconEntry[0]; + auto& entry0 = fontIcon->fontIconEntry[0]; entry0.fontIconName.string = "XenonButtondpadAll"; entry0.fontIconName.hash = Common::Com_HashString(entry0.fontIconName.string); entry0.fontIconMaterialHandle = GivenMaterial("xenonbutton_dpad_all", memory); @@ -42,7 +43,7 @@ namespace entry0.xScale = 1.0f; entry0.yScale = 1.0f; - auto& entry1 = fontIcon.fontIconEntry[1]; + auto& entry1 = fontIcon->fontIconEntry[1]; entry1.fontIconName.string = "XenonButtonLStickAnimatedD"; entry1.fontIconName.hash = Common::Com_HashString(entry1.fontIconName.string); entry1.fontIconMaterialHandle = GivenMaterial("ui_button_xenon_lstick_anim_d", memory); @@ -50,7 +51,7 @@ namespace entry1.xScale = 1.5f; entry1.yScale = 1.5f; - auto& entry2 = fontIcon.fontIconEntry[2]; + auto& entry2 = fontIcon->fontIconEntry[2]; entry2.fontIconName.string = "XenonButtonStickAnimatedL"; entry2.fontIconName.hash = Common::Com_HashString(entry2.fontIconName.string); entry2.fontIconMaterialHandle = GivenMaterial("xenonbutton_ls", memory); @@ -58,32 +59,34 @@ namespace entry2.xScale = 1.0f; entry2.yScale = 1.0f; - fontIcon.numAliasEntries = 6; - fontIcon.fontIconAlias = memory.Alloc(fontIcon.numAliasEntries); + fontIcon->numAliasEntries = 6; + fontIcon->fontIconAlias = memory.Alloc(fontIcon->numAliasEntries); - auto& alias0 = fontIcon.fontIconAlias[0]; + auto& alias0 = fontIcon->fontIconAlias[0]; alias0.aliasHash = Common::Com_HashString("BUTTON_LUI_DPAD_ALL"); alias0.buttonHash = entry0.fontIconName.hash; - auto& alias1 = fontIcon.fontIconAlias[1]; + auto& alias1 = fontIcon->fontIconAlias[1]; alias1.aliasHash = static_cast(0xCE7211DA); alias1.buttonHash = entry1.fontIconName.hash; - auto& alias2 = fontIcon.fontIconAlias[2]; + auto& alias2 = fontIcon->fontIconAlias[2]; alias2.aliasHash = Common::Com_HashString("BUTTON_MOVE"); alias2.buttonHash = entry2.fontIconName.hash; - auto& alias3 = fontIcon.fontIconAlias[3]; + auto& alias3 = fontIcon->fontIconAlias[3]; alias3.aliasHash = Common::Com_HashString("BUTTON_EMBLEM_MOVE"); alias3.buttonHash = entry2.fontIconName.hash; - auto& alias4 = fontIcon.fontIconAlias[4]; + auto& alias4 = fontIcon->fontIconAlias[4]; alias4.aliasHash = Common::Com_HashString("BUTTON_LUI_LEFT_STICK_UP"); alias4.buttonHash = entry2.fontIconName.hash; - auto& alias5 = fontIcon.fontIconAlias[5]; + auto& alias5 = fontIcon->fontIconAlias[5]; alias5.aliasHash = Common::Com_HashString("BUTTON_MOVESTICK"); alias5.buttonHash = entry2.fontIconName.hash; + + pool.AddAsset(std::make_unique>(ASSET_TYPE_FONTICON, name, fontIcon)); } TEST_CASE("DumperFontIconJson(T6): Can dump font icon", "[t6][font-icon][assetdumper]") @@ -145,12 +148,11 @@ namespace MockOutputPath mockOutput; AssetDumpingContext context(zone, "", mockOutput, mockObjPath); - AssetPoolDynamic materialPool(0); + AssetPoolDynamic fontIconPool(0); + GivenFontIcon("fonticon/test.csv", fontIconPool, memory); - FontIcon asset; - GivenFontIcon("fonticon/test.csv", asset, memory); - - DumpFontIconAsJson(context, asset); + font_icon::JsonDumper dumper; + dumper.DumpPool(context, &fontIconPool); const auto* file = mockOutput.GetMockedFile("fonticon/test.json"); REQUIRE(file); diff --git a/test/ObjWritingTests/Game/T6/Material/DumperMaterialT6Test.cpp b/test/ObjWritingTests/Game/T6/Material/DumperMaterialT6Test.cpp index 30c83ec1..2586760d 100644 --- a/test/ObjWritingTests/Game/T6/Material/DumperMaterialT6Test.cpp +++ b/test/ObjWritingTests/Game/T6/Material/DumperMaterialT6Test.cpp @@ -470,7 +470,6 @@ namespace AssetDumpingContext context(zone, "", mockOutput, mockObjPath); AssetPoolDynamic materialPool(0); - GivenMaterial("wpc/metal_ac_duct", materialPool, memory); AssetDumperMaterial dumper; From 5fefdef0a6c8a3d197a3c07e1c05e1c440009b3d Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Mon, 28 Jul 2025 19:48:36 +0100 Subject: [PATCH 05/35] refactor: merge leaderboard dumpers for iw4,iw5 --- .../Leaderboard/AssetDumperLeaderboardDef.cpp | 24 -------------- .../Leaderboard/AssetDumperLeaderboardDef.h | 14 -------- .../Leaderboard/JsonLeaderboardDefWriter.h | 11 ------- ...riter.cpp => LeaderboardJsonDumperIW4.cpp} | 32 ++++++++++++------ .../Leaderboard/LeaderboardJsonDumperIW4.h | 14 ++++++++ src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 4 +-- .../Leaderboard/AssetDumperLeaderboardDef.cpp | 24 -------------- .../Leaderboard/AssetDumperLeaderboardDef.h | 14 -------- .../Leaderboard/JsonLeaderboardDefWriter.h | 11 ------- ...riter.cpp => LeaderboardJsonDumperIW5.cpp} | 33 +++++++++++++------ .../Leaderboard/LeaderboardJsonDumperIW5.h | 14 ++++++++ src/ObjWriting/Game/IW5/ObjWriterIW5.cpp | 4 +-- .../Leaderboard/LeaderboardJsonDumperT6.cpp | 1 - 13 files changed, 77 insertions(+), 123 deletions(-) delete mode 100644 src/ObjWriting/Game/IW4/Leaderboard/AssetDumperLeaderboardDef.cpp delete mode 100644 src/ObjWriting/Game/IW4/Leaderboard/AssetDumperLeaderboardDef.h delete mode 100644 src/ObjWriting/Game/IW4/Leaderboard/JsonLeaderboardDefWriter.h rename src/ObjWriting/Game/IW4/Leaderboard/{JsonLeaderboardDefWriter.cpp => LeaderboardJsonDumperIW4.cpp} (72%) create mode 100644 src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.h delete mode 100644 src/ObjWriting/Game/IW5/Leaderboard/AssetDumperLeaderboardDef.cpp delete mode 100644 src/ObjWriting/Game/IW5/Leaderboard/AssetDumperLeaderboardDef.h delete mode 100644 src/ObjWriting/Game/IW5/Leaderboard/JsonLeaderboardDefWriter.h rename src/ObjWriting/Game/IW5/Leaderboard/{JsonLeaderboardDefWriter.cpp => LeaderboardJsonDumperIW5.cpp} (76%) create mode 100644 src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.h diff --git a/src/ObjWriting/Game/IW4/Leaderboard/AssetDumperLeaderboardDef.cpp b/src/ObjWriting/Game/IW4/Leaderboard/AssetDumperLeaderboardDef.cpp deleted file mode 100644 index a761b471..00000000 --- a/src/ObjWriting/Game/IW4/Leaderboard/AssetDumperLeaderboardDef.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "AssetDumperLeaderboardDef.h" - -#include "Game/IW4/Leaderboard/JsonLeaderboardDefWriter.h" - -#include -#include - -using namespace IW4; - -bool AssetDumperLeaderboardDef::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperLeaderboardDef::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto assetName = asset->m_name; - const auto assetFile = context.OpenAssetFile(std::format("leaderboards/{}.json", assetName)); - - if (!assetFile) - return; - - DumpLeaderboardDefAsJson(*assetFile, asset->Asset()); -} diff --git a/src/ObjWriting/Game/IW4/Leaderboard/AssetDumperLeaderboardDef.h b/src/ObjWriting/Game/IW4/Leaderboard/AssetDumperLeaderboardDef.h deleted file mode 100644 index c8a344bf..00000000 --- a/src/ObjWriting/Game/IW4/Leaderboard/AssetDumperLeaderboardDef.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/IW4/IW4.h" - -namespace IW4 -{ - class AssetDumperLeaderboardDef final : public AbstractAssetDumper - { - protected: - _NODISCARD bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace IW4 diff --git a/src/ObjWriting/Game/IW4/Leaderboard/JsonLeaderboardDefWriter.h b/src/ObjWriting/Game/IW4/Leaderboard/JsonLeaderboardDefWriter.h deleted file mode 100644 index a1b4546d..00000000 --- a/src/ObjWriting/Game/IW4/Leaderboard/JsonLeaderboardDefWriter.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "Dumping/AssetDumpingContext.h" -#include "Game/IW4/IW4.h" - -#include - -namespace IW4 -{ - void DumpLeaderboardDefAsJson(std::ostream& stream, const LeaderboardDef* leaderboardDef); -} // namespace IW4 diff --git a/src/ObjWriting/Game/IW4/Leaderboard/JsonLeaderboardDefWriter.cpp b/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.cpp similarity index 72% rename from src/ObjWriting/Game/IW4/Leaderboard/JsonLeaderboardDefWriter.cpp rename to src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.cpp index fe6628bf..363335bd 100644 --- a/src/ObjWriting/Game/IW4/Leaderboard/JsonLeaderboardDefWriter.cpp +++ b/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.cpp @@ -1,28 +1,30 @@ -#include "JsonLeaderboardDefWriter.h" +#include "LeaderboardJsonDumperIW4.h" #include "Game/IW4/CommonIW4.h" #include "Game/IW4/Leaderboard/JsonLeaderboardDef.h" +#include "Leaderboard/LeaderboardCommon.h" #include #include using namespace nlohmann; using namespace IW4; +using namespace ::leaderboard; namespace { - class JsonDumper + class Dumper { public: - explicit JsonDumper(std::ostream& stream) + explicit Dumper(std::ostream& stream) : m_stream(stream) { } - void Dump(const LeaderboardDef* leaderboardDef) const + void Dump(const LeaderboardDef& leaderboardDef) const { JsonLeaderboardDef jsonLeaderboardDef; - CreateJsonLeaderboardDef(jsonLeaderboardDef, *leaderboardDef); + CreateJsonLeaderboardDef(jsonLeaderboardDef, leaderboardDef); json jRoot = jsonLeaderboardDef; @@ -74,11 +76,21 @@ namespace }; } // namespace -namespace IW4 +namespace IW4::leaderboard { - void DumpLeaderboardDefAsJson(std::ostream& stream, const LeaderboardDef* leaderboardDef) + bool JsonDumper::ShouldDump(XAssetInfo* asset) { - JsonDumper dumper(stream); - dumper.Dump(leaderboardDef); + return true; } -} // namespace IW4 + + void JsonDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAsset(asset->m_name)); + + if (!assetFile) + return; + + Dumper dumper(*assetFile); + dumper.Dump(*asset->Asset()); + } +} // namespace IW4::leaderboard diff --git a/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.h b/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.h new file mode 100644 index 00000000..eb7f7183 --- /dev/null +++ b/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.h @@ -0,0 +1,14 @@ +#pragma once + +#include "Dumping/AbstractAssetDumper.h" +#include "Game/IW4/IW4.h" + +namespace IW4::leaderboard +{ + class JsonDumper final : public AbstractAssetDumper + { + protected: + [[nodiscard]] bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + }; +} // namespace IW4::leaderboard diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 84065df7..1be58651 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -3,7 +3,7 @@ #include "Game/IW4/GameAssetPoolIW4.h" #include "Game/IW4/XModel/XModelDumperIW4.h" #include "Image/AssetDumperGfxImage.h" -#include "Leaderboard/AssetDumperLeaderboardDef.h" +#include "Leaderboard/LeaderboardJsonDumperIW4.h" #include "LightDef/AssetDumperGfxLightDef.h" #include "Localize/AssetDumperLocalizeEntry.h" #include "Maps/AssetDumperAddonMapEnts.h" @@ -68,7 +68,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file, ASSET_TYPE_RAWFILE) DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE) - DUMP_ASSET_POOL(AssetDumperLeaderboardDef, m_leaderboard, ASSET_TYPE_LEADERBOARD) + DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD) DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF) DUMP_ASSET_POOL(AssetDumperTracer, m_tracer, ASSET_TYPE_TRACER) DUMP_ASSET_POOL(AssetDumperVehicle, m_vehicle, ASSET_TYPE_VEHICLE) diff --git a/src/ObjWriting/Game/IW5/Leaderboard/AssetDumperLeaderboardDef.cpp b/src/ObjWriting/Game/IW5/Leaderboard/AssetDumperLeaderboardDef.cpp deleted file mode 100644 index 9b1804f2..00000000 --- a/src/ObjWriting/Game/IW5/Leaderboard/AssetDumperLeaderboardDef.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "AssetDumperLeaderboardDef.h" - -#include "Game/IW5/Leaderboard/JsonLeaderboardDefWriter.h" - -#include -#include - -using namespace IW5; - -bool AssetDumperLeaderboardDef::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperLeaderboardDef::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto assetName = asset->m_name; - const auto assetFile = context.OpenAssetFile(std::format("leaderboards/{}.json", assetName)); - - if (!assetFile) - return; - - DumpLeaderboardDefAsJson(*assetFile, asset->Asset()); -} diff --git a/src/ObjWriting/Game/IW5/Leaderboard/AssetDumperLeaderboardDef.h b/src/ObjWriting/Game/IW5/Leaderboard/AssetDumperLeaderboardDef.h deleted file mode 100644 index 934ad940..00000000 --- a/src/ObjWriting/Game/IW5/Leaderboard/AssetDumperLeaderboardDef.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/IW5/IW5.h" - -namespace IW5 -{ - class AssetDumperLeaderboardDef final : public AbstractAssetDumper - { - protected: - _NODISCARD bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace IW5 diff --git a/src/ObjWriting/Game/IW5/Leaderboard/JsonLeaderboardDefWriter.h b/src/ObjWriting/Game/IW5/Leaderboard/JsonLeaderboardDefWriter.h deleted file mode 100644 index b992e6b2..00000000 --- a/src/ObjWriting/Game/IW5/Leaderboard/JsonLeaderboardDefWriter.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "Dumping/AssetDumpingContext.h" -#include "Game/IW5/IW5.h" - -#include - -namespace IW5 -{ - void DumpLeaderboardDefAsJson(std::ostream& stream, const LeaderboardDef* leaderboardDef); -} // namespace IW5 diff --git a/src/ObjWriting/Game/IW5/Leaderboard/JsonLeaderboardDefWriter.cpp b/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.cpp similarity index 76% rename from src/ObjWriting/Game/IW5/Leaderboard/JsonLeaderboardDefWriter.cpp rename to src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.cpp index ef365d79..ced74ca0 100644 --- a/src/ObjWriting/Game/IW5/Leaderboard/JsonLeaderboardDefWriter.cpp +++ b/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.cpp @@ -1,28 +1,31 @@ -#include "JsonLeaderboardDefWriter.h" +#include "LeaderboardJsonDumperIW5.h" #include "Game/IW5/CommonIW5.h" #include "Game/IW5/Leaderboard/JsonLeaderboardDef.h" +#include "Leaderboard/LeaderboardCommon.h" #include #include +#include using namespace nlohmann; using namespace IW5; +using namespace ::leaderboard; namespace { - class JsonDumper + class Dumper { public: - explicit JsonDumper(std::ostream& stream) + explicit Dumper(std::ostream& stream) : m_stream(stream) { } - void Dump(const LeaderboardDef* leaderboardDef) const + void Dump(const LeaderboardDef& leaderboardDef) const { JsonLeaderboardDef jsonLeaderboardDef; - CreateJsonLeaderboardDef(jsonLeaderboardDef, *leaderboardDef); + CreateJsonLeaderboardDef(jsonLeaderboardDef, leaderboardDef); json jRoot = jsonLeaderboardDef; @@ -90,11 +93,21 @@ namespace }; } // namespace -namespace IW5 +namespace IW5::leaderboard { - void DumpLeaderboardDefAsJson(std::ostream& stream, const LeaderboardDef* leaderboardDef) + bool JsonDumper::ShouldDump(XAssetInfo* asset) { - JsonDumper dumper(stream); - dumper.Dump(leaderboardDef); + return true; } -} // namespace IW5 + + void JsonDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAsset(asset->m_name)); + + if (!assetFile) + return; + + Dumper dumper(*assetFile); + dumper.Dump(*asset->Asset()); + } +} // namespace IW5::leaderboard diff --git a/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.h b/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.h new file mode 100644 index 00000000..88b32415 --- /dev/null +++ b/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.h @@ -0,0 +1,14 @@ +#pragma once + +#include "Dumping/AbstractAssetDumper.h" +#include "Game/IW5/IW5.h" + +namespace IW5::leaderboard +{ + class JsonDumper final : public AbstractAssetDumper + { + protected: + [[nodiscard]] bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + }; +} // namespace IW5::leaderboard diff --git a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp index 46a3b354..2a9599c9 100644 --- a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp +++ b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp @@ -3,7 +3,7 @@ #include "Game/IW5/GameAssetPoolIW5.h" #include "Game/IW5/XModel/XModelDumperIW5.h" #include "Image/AssetDumperGfxImage.h" -#include "Leaderboard/AssetDumperLeaderboardDef.h" +#include "Leaderboard/LeaderboardJsonDumperIW5.h" #include "Localize/AssetDumperLocalizeEntry.h" #include "Maps/AssetDumperAddonMapEnts.h" #include "Material/DumperMaterialIW5.h" @@ -64,7 +64,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file, ASSET_TYPE_RAWFILE) DUMP_ASSET_POOL(AssetDumperScriptFile, m_script_file, ASSET_TYPE_SCRIPTFILE) DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE) - DUMP_ASSET_POOL(AssetDumperLeaderboardDef, m_leaderboard, ASSET_TYPE_LEADERBOARD) + DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD) // DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF) // DUMP_ASSET_POOL(AssetDumperTracerDef, m_tracer, ASSET_TYPE_TRACER) // DUMP_ASSET_POOL(AssetDumperVehicleDef, m_vehicle, ASSET_TYPE_VEHICLE) diff --git a/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.cpp b/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.cpp index 5e468579..9947924d 100644 --- a/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.cpp @@ -4,7 +4,6 @@ #include "Game/T6/Leaderboard/JsonLeaderboardDef.h" #include "Leaderboard/LeaderboardCommon.h" -#include #include #include #include From 9a6f0c89192fa4bf2a629ccf4ce9db81413b2f0b Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Mon, 28 Jul 2025 21:51:12 +0100 Subject: [PATCH 06/35] refactor: restructure light def dumper --- src/ObjCommon/LightDef/LightDefCommon.cpp | 11 ++++++ src/ObjCommon/LightDef/LightDefCommon.h | 8 +++++ ...rLightDefIW4.cpp => LightDefLoaderIW4.cpp} | 12 +++---- ...oaderLightDefIW4.h => LightDefLoaderIW4.h} | 0 src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp | 2 +- .../IW4/LightDef/AssetDumperGfxLightDef.cpp | 36 ------------------- .../Game/IW4/LightDef/LightDefDumperIW4.cpp | 33 +++++++++++++++++ ...umperGfxLightDef.h => LightDefDumperIW4.h} | 6 ++-- src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 4 +-- 9 files changed, 62 insertions(+), 50 deletions(-) create mode 100644 src/ObjCommon/LightDef/LightDefCommon.cpp create mode 100644 src/ObjCommon/LightDef/LightDefCommon.h rename src/ObjLoading/Game/IW4/LightDef/{LoaderLightDefIW4.cpp => LightDefLoaderIW4.cpp} (91%) rename src/ObjLoading/Game/IW4/LightDef/{LoaderLightDefIW4.h => LightDefLoaderIW4.h} (100%) delete mode 100644 src/ObjWriting/Game/IW4/LightDef/AssetDumperGfxLightDef.cpp create mode 100644 src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.cpp rename src/ObjWriting/Game/IW4/LightDef/{AssetDumperGfxLightDef.h => LightDefDumperIW4.h} (63%) diff --git a/src/ObjCommon/LightDef/LightDefCommon.cpp b/src/ObjCommon/LightDef/LightDefCommon.cpp new file mode 100644 index 00000000..b43af370 --- /dev/null +++ b/src/ObjCommon/LightDef/LightDefCommon.cpp @@ -0,0 +1,11 @@ +#include "LightDefCommon.h" + +#include + +namespace light_def +{ + std::string GetFileNameForAsset(const std::string& assetName) + { + return std::format("lights/{}", assetName); + } +} // namespace light_def diff --git a/src/ObjCommon/LightDef/LightDefCommon.h b/src/ObjCommon/LightDef/LightDefCommon.h new file mode 100644 index 00000000..22002431 --- /dev/null +++ b/src/ObjCommon/LightDef/LightDefCommon.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace light_def +{ + std::string GetFileNameForAsset(const std::string& assetName); +} diff --git a/src/ObjLoading/Game/IW4/LightDef/LoaderLightDefIW4.cpp b/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.cpp similarity index 91% rename from src/ObjLoading/Game/IW4/LightDef/LoaderLightDefIW4.cpp rename to src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.cpp index 0563554e..abf4bf0b 100644 --- a/src/ObjLoading/Game/IW4/LightDef/LoaderLightDefIW4.cpp +++ b/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.cpp @@ -1,12 +1,15 @@ -#include "LoaderLightDefIW4.h" +#include "LightDefLoaderIW4.h" #include "Game/IW4/IW4.h" +#include "LightDef/LightDefCommon.h" #include #include #include + using namespace IW4; +using namespace ::light_def; namespace { @@ -23,7 +26,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto filename = GetAssetFilename(assetName); + const auto filename = GetFileNameForAsset(assetName); const auto file = m_search_path.Open(filename); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -61,11 +64,6 @@ namespace } private: - std::string GetAssetFilename(const std::string& assetName) - { - return std::format("lights/{}", assetName); - } - MemoryManager& m_memory; ISearchPath& m_search_path; }; diff --git a/src/ObjLoading/Game/IW4/LightDef/LoaderLightDefIW4.h b/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.h similarity index 100% rename from src/ObjLoading/Game/IW4/LightDef/LoaderLightDefIW4.h rename to src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.h diff --git a/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp b/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp index f90d1afd..1fc97241 100644 --- a/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp +++ b/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp @@ -5,7 +5,7 @@ #include "Game/IW4/IW4.h" #include "Game/IW4/XModel/LoaderXModelIW4.h" #include "Leaderboard/LoaderLeaderboardIW4.h" -#include "LightDef/LoaderLightDefIW4.h" +#include "LightDef/LightDefLoaderIW4.h" #include "Localize/LoaderLocalizeIW4.h" #include "Material/LoaderMaterialIW4.h" #include "Menu/LoaderMenuListIW4.h" diff --git a/src/ObjWriting/Game/IW4/LightDef/AssetDumperGfxLightDef.cpp b/src/ObjWriting/Game/IW4/LightDef/AssetDumperGfxLightDef.cpp deleted file mode 100644 index af05c62d..00000000 --- a/src/ObjWriting/Game/IW4/LightDef/AssetDumperGfxLightDef.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "AssetDumperGfxLightDef.h" - -#include - -using namespace IW4; - -std::string AssetDumperGfxLightDef::GetAssetFilename(const std::string& assetName) -{ - std::ostringstream ss; - - ss << "lights/" << assetName; - - return ss.str(); -} - -bool AssetDumperGfxLightDef::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperGfxLightDef::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* lightDef = asset->Asset(); - const auto assetFile = context.OpenAssetFile(GetAssetFilename(asset->m_name)); - - if (!assetFile || lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr) - return; - - auto& stream = *assetFile; - - const auto* imageName = lightDef->attenuation.image->name; - if (imageName[0] == ',') - imageName = &imageName[1]; - - stream << lightDef->attenuation.samplerState << imageName << static_cast(lightDef->lmapLookupStart); -} diff --git a/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.cpp b/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.cpp new file mode 100644 index 00000000..549da3d1 --- /dev/null +++ b/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.cpp @@ -0,0 +1,33 @@ +#include "LightDefDumperIW4.h" + +#include "LightDef/LightDefCommon.h" + +#include + +using namespace IW4; +using namespace ::light_def; + +namespace IW4::light_def +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* lightDef = asset->Asset(); + const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset->m_name)); + + if (!assetFile || lightDef->attenuation.image == nullptr || lightDef->attenuation.image->name == nullptr) + return; + + auto& stream = *assetFile; + + const auto* imageName = lightDef->attenuation.image->name; + if (imageName[0] == ',') + imageName = &imageName[1]; + + stream << lightDef->attenuation.samplerState << imageName << static_cast(lightDef->lmapLookupStart); + } +} // namespace IW4::light_def diff --git a/src/ObjWriting/Game/IW4/LightDef/AssetDumperGfxLightDef.h b/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.h similarity index 63% rename from src/ObjWriting/Game/IW4/LightDef/AssetDumperGfxLightDef.h rename to src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.h index 275712ef..9b8003c9 100644 --- a/src/ObjWriting/Game/IW4/LightDef/AssetDumperGfxLightDef.h +++ b/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.h @@ -3,12 +3,10 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4 +namespace IW4::light_def { - class AssetDumperGfxLightDef final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { - static std::string GetAssetFilename(const std::string& assetName); - protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 1be58651..40a370b6 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -4,7 +4,7 @@ #include "Game/IW4/XModel/XModelDumperIW4.h" #include "Image/AssetDumperGfxImage.h" #include "Leaderboard/LeaderboardJsonDumperIW4.h" -#include "LightDef/AssetDumperGfxLightDef.h" +#include "LightDef/LightDefDumperIW4.h" #include "Localize/AssetDumperLocalizeEntry.h" #include "Maps/AssetDumperAddonMapEnts.h" #include "Material/DumperMaterialIW4.h" @@ -57,7 +57,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS) // DUMP_ASSET_POOL(AssetDumperFxWorld, m_fx_world, ASSET_TYPE_FXWORLD) // DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD) - DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF) + DUMP_ASSET_POOL(light_def::Dumper, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF) // DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT) DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST) DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU) From 22dbf5726906bfc5479feb58f8d875b796d84aa9 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Mon, 28 Jul 2025 23:15:45 +0100 Subject: [PATCH 07/35] refactor: restructure image dumper --- src/ObjCommon/Image/ImageCommon.cpp | 15 ++++ src/ObjCommon/Image/ImageCommon.h | 8 ++ ...tDumperGfxImage.cpp => ImageDumperIW3.cpp} | 74 +++++++++---------- ...AssetDumperGfxImage.h => ImageDumperIW3.h} | 15 ++-- src/ObjWriting/Game/IW3/ObjWriterIW3.cpp | 4 +- ...tDumperGfxImage.cpp => ImageDumperIW4.cpp} | 73 +++++++++--------- ...AssetDumperGfxImage.h => ImageDumperIW4.h} | 15 ++-- src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 4 +- ...tDumperGfxImage.cpp => ImageDumperIW5.cpp} | 74 +++++++++---------- ...AssetDumperGfxImage.h => ImageDumperIW5.h} | 15 ++-- src/ObjWriting/Game/IW5/ObjWriterIW5.cpp | 4 +- ...etDumperGfxImage.cpp => ImageDumperT5.cpp} | 73 +++++++++--------- ...{AssetDumperGfxImage.h => ImageDumperT5.h} | 15 ++-- src/ObjWriting/Game/T5/ObjWriterT5.cpp | 4 +- ...etDumperGfxImage.cpp => ImageDumperT6.cpp} | 73 +++++++++--------- ...{AssetDumperGfxImage.h => ImageDumperT6.h} | 15 ++-- src/ObjWriting/Game/T6/ObjWriterT6.cpp | 4 +- 17 files changed, 245 insertions(+), 240 deletions(-) create mode 100644 src/ObjCommon/Image/ImageCommon.cpp create mode 100644 src/ObjCommon/Image/ImageCommon.h rename src/ObjWriting/Game/IW3/Image/{AssetDumperGfxImage.cpp => ImageDumperIW3.cpp} (59%) rename src/ObjWriting/Game/IW3/Image/{AssetDumperGfxImage.h => ImageDumperIW3.h} (61%) rename src/ObjWriting/Game/IW4/Image/{AssetDumperGfxImage.cpp => ImageDumperIW4.cpp} (59%) rename src/ObjWriting/Game/IW4/Image/{AssetDumperGfxImage.h => ImageDumperIW4.h} (61%) rename src/ObjWriting/Game/IW5/Image/{AssetDumperGfxImage.cpp => ImageDumperIW5.cpp} (59%) rename src/ObjWriting/Game/IW5/Image/{AssetDumperGfxImage.h => ImageDumperIW5.h} (61%) rename src/ObjWriting/Game/T5/Image/{AssetDumperGfxImage.cpp => ImageDumperT5.cpp} (58%) rename src/ObjWriting/Game/T5/Image/{AssetDumperGfxImage.h => ImageDumperT5.h} (62%) rename src/ObjWriting/Game/T6/Image/{AssetDumperGfxImage.cpp => ImageDumperT6.cpp} (64%) rename src/ObjWriting/Game/T6/Image/{AssetDumperGfxImage.h => ImageDumperT6.h} (63%) diff --git a/src/ObjCommon/Image/ImageCommon.cpp b/src/ObjCommon/Image/ImageCommon.cpp new file mode 100644 index 00000000..8a605bd7 --- /dev/null +++ b/src/ObjCommon/Image/ImageCommon.cpp @@ -0,0 +1,15 @@ +#include "ImageCommon.h" + +#include +#include + +namespace image +{ + std::string GetFileNameForAsset(std::string assetName, const std::string& extension) + { + std::string cleanAssetName(std::move(assetName)); + std::ranges::replace(cleanAssetName, '*', '_'); + + return std::format("images/{}{}", cleanAssetName, extension); + } +} // namespace image diff --git a/src/ObjCommon/Image/ImageCommon.h b/src/ObjCommon/Image/ImageCommon.h new file mode 100644 index 00000000..1a18b70e --- /dev/null +++ b/src/ObjCommon/Image/ImageCommon.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace image +{ + std::string GetFileNameForAsset(std::string assetName, const std::string& extension); +} diff --git a/src/ObjWriting/Game/IW3/Image/AssetDumperGfxImage.cpp b/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.cpp similarity index 59% rename from src/ObjWriting/Game/IW3/Image/AssetDumperGfxImage.cpp rename to src/ObjWriting/Game/IW3/Image/ImageDumperIW3.cpp index 5f76f1c4..0e8c9873 100644 --- a/src/ObjWriting/Game/IW3/Image/AssetDumperGfxImage.cpp +++ b/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.cpp @@ -1,7 +1,8 @@ -#include "AssetDumperGfxImage.h" +#include "ImageDumperIW3.h" #include "Image/DdsWriter.h" #include "Image/Dx9TextureLoader.h" +#include "Image/ImageCommon.h" #include "Image/IwiLoader.h" #include "Image/IwiTypes.h" #include "Image/IwiWriter6.h" @@ -13,7 +14,9 @@ #include #include + using namespace IW3; +using namespace ::image; namespace { @@ -58,48 +61,43 @@ namespace } } // namespace -AssetDumperGfxImage::AssetDumperGfxImage() +namespace IW3::image { - switch (ObjWriting::Configuration.ImageOutputFormat) + Dumper::Dumper() { - case ObjWriting::Configuration_t::ImageOutputFormat_e::DDS: - m_writer = std::make_unique(); - break; - case ObjWriting::Configuration_t::ImageOutputFormat_e::IWI: - m_writer = std::make_unique(); - break; - default: - assert(false); - m_writer = nullptr; - break; + switch (ObjWriting::Configuration.ImageOutputFormat) + { + case ObjWriting::Configuration_t::ImageOutputFormat_e::DDS: + m_writer = std::make_unique(); + break; + case ObjWriting::Configuration_t::ImageOutputFormat_e::IWI: + m_writer = std::make_unique(); + break; + default: + assert(false); + m_writer = nullptr; + break; + } } -} -bool AssetDumperGfxImage::ShouldDump(XAssetInfo* asset) -{ - return true; -} + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } -std::string AssetDumperGfxImage::GetAssetFileName(const XAssetInfo& asset) const -{ - auto cleanAssetName = asset.m_name; - std::ranges::replace(cleanAssetName, '*', '_'); + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* image = asset->Asset(); + const auto texture = LoadImageData(context.m_obj_search_path, *image); + if (!texture) + return; - return std::format("images/{}{}", cleanAssetName, m_writer->GetFileExtension()); -} + const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset->m_name, m_writer->GetFileExtension())); -void AssetDumperGfxImage::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* image = asset->Asset(); - const auto texture = LoadImageData(context.m_obj_search_path, *image); - if (!texture) - return; + if (!assetFile) + return; - const auto assetFile = context.OpenAssetFile(GetAssetFileName(*asset)); - - if (!assetFile) - return; - - auto& stream = *assetFile; - m_writer->DumpImage(stream, texture.get()); -} + auto& stream = *assetFile; + m_writer->DumpImage(stream, texture.get()); + } +} // namespace IW3::image diff --git a/src/ObjWriting/Game/IW3/Image/AssetDumperGfxImage.h b/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.h similarity index 61% rename from src/ObjWriting/Game/IW3/Image/AssetDumperGfxImage.h rename to src/ObjWriting/Game/IW3/Image/ImageDumperIW3.h index 009a7e57..24a22efa 100644 --- a/src/ObjWriting/Game/IW3/Image/AssetDumperGfxImage.h +++ b/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.h @@ -6,19 +6,18 @@ #include -namespace IW3 +namespace IW3::image { - class AssetDumperGfxImage final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { - std::unique_ptr m_writer; - - [[nodiscard]] std::string GetAssetFileName(const XAssetInfo& asset) const; + public: + Dumper(); protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - public: - AssetDumperGfxImage(); + private: + std::unique_ptr m_writer; }; -} // namespace IW3 +} // namespace IW3::image diff --git a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp index b2a605df..cec9c088 100644 --- a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp +++ b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp @@ -2,7 +2,7 @@ #include "Game/IW3/GameAssetPoolIW3.h" #include "Game/IW3/XModel/XModelDumperIW3.h" -#include "Image/AssetDumperGfxImage.h" +#include "Image/ImageDumperIW3.h" #include "Localize/AssetDumperLocalizeEntry.h" #include "Maps/AssetDumperMapEnts.h" #include "Material/DumperMaterialIW3.h" @@ -30,7 +30,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) DUMP_ASSET_POOL(AssetDumperMaterial, m_material, ASSET_TYPE_MATERIAL) // DUMP_ASSET_POOL(AssetDumperMaterialTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) - DUMP_ASSET_POOL(AssetDumperGfxImage, m_image, ASSET_TYPE_IMAGE) + DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) // DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND) // DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE) DUMP_ASSET_POOL(AssetDumperLoadedSound, m_loaded_sound, ASSET_TYPE_LOADED_SOUND) diff --git a/src/ObjWriting/Game/IW4/Image/AssetDumperGfxImage.cpp b/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.cpp similarity index 59% rename from src/ObjWriting/Game/IW4/Image/AssetDumperGfxImage.cpp rename to src/ObjWriting/Game/IW4/Image/ImageDumperIW4.cpp index 4490e520..ad2bf5c9 100644 --- a/src/ObjWriting/Game/IW4/Image/AssetDumperGfxImage.cpp +++ b/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.cpp @@ -1,7 +1,8 @@ -#include "AssetDumperGfxImage.h" +#include "ImageDumperIW4.h" #include "Image/DdsWriter.h" #include "Image/Dx9TextureLoader.h" +#include "Image/ImageCommon.h" #include "Image/IwiLoader.h" #include "Image/IwiWriter8.h" #include "ObjWriting.h" @@ -11,6 +12,7 @@ #include using namespace IW4; +using namespace ::image; namespace { @@ -55,48 +57,43 @@ namespace } } // namespace -AssetDumperGfxImage::AssetDumperGfxImage() +namespace IW4::image { - switch (ObjWriting::Configuration.ImageOutputFormat) + Dumper::Dumper() { - case ObjWriting::Configuration_t::ImageOutputFormat_e::DDS: - m_writer = std::make_unique(); - break; - case ObjWriting::Configuration_t::ImageOutputFormat_e::IWI: - m_writer = std::make_unique(); - break; - default: - assert(false); - m_writer = nullptr; - break; + switch (ObjWriting::Configuration.ImageOutputFormat) + { + case ObjWriting::Configuration_t::ImageOutputFormat_e::DDS: + m_writer = std::make_unique(); + break; + case ObjWriting::Configuration_t::ImageOutputFormat_e::IWI: + m_writer = std::make_unique(); + break; + default: + assert(false); + m_writer = nullptr; + break; + } } -} -bool AssetDumperGfxImage::ShouldDump(XAssetInfo* asset) -{ - return true; -} + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } -std::string AssetDumperGfxImage::GetAssetFileName(const XAssetInfo& asset) const -{ - auto cleanAssetName = asset.m_name; - std::ranges::replace(cleanAssetName, '*', '_'); + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* image = asset->Asset(); + const auto texture = LoadImageData(context.m_obj_search_path, *image); + if (!texture) + return; - return std::format("images/{}{}", cleanAssetName, m_writer->GetFileExtension()); -} + const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset->m_name, m_writer->GetFileExtension())); -void AssetDumperGfxImage::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* image = asset->Asset(); - const auto texture = LoadImageData(context.m_obj_search_path, *image); - if (!texture) - return; + if (!assetFile) + return; - const auto assetFile = context.OpenAssetFile(GetAssetFileName(*asset)); - - if (!assetFile) - return; - - auto& stream = *assetFile; - m_writer->DumpImage(stream, texture.get()); -} + auto& stream = *assetFile; + m_writer->DumpImage(stream, texture.get()); + } +} // namespace IW4::image diff --git a/src/ObjWriting/Game/IW4/Image/AssetDumperGfxImage.h b/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.h similarity index 61% rename from src/ObjWriting/Game/IW4/Image/AssetDumperGfxImage.h rename to src/ObjWriting/Game/IW4/Image/ImageDumperIW4.h index bcbee6ec..ee9910f4 100644 --- a/src/ObjWriting/Game/IW4/Image/AssetDumperGfxImage.h +++ b/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.h @@ -6,19 +6,18 @@ #include -namespace IW4 +namespace IW4::image { - class AssetDumperGfxImage final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { - std::unique_ptr m_writer; - - [[nodiscard]] std::string GetAssetFileName(const XAssetInfo& asset) const; + public: + Dumper(); protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - public: - AssetDumperGfxImage(); + private: + std::unique_ptr m_writer; }; -} // namespace IW4 +} // namespace IW4::image diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 40a370b6..4a32c507 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -2,7 +2,7 @@ #include "Game/IW4/GameAssetPoolIW4.h" #include "Game/IW4/XModel/XModelDumperIW4.h" -#include "Image/AssetDumperGfxImage.h" +#include "Image/ImageDumperIW4.h" #include "Leaderboard/LeaderboardJsonDumperIW4.h" #include "LightDef/LightDefDumperIW4.h" #include "Localize/AssetDumperLocalizeEntry.h" @@ -46,7 +46,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(AssetDumperPixelShader, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER) DUMP_ASSET_POOL(AssetDumperVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER) DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) - DUMP_ASSET_POOL(AssetDumperGfxImage, m_image, ASSET_TYPE_IMAGE) + DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) // DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND) DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE) DUMP_ASSET_POOL(AssetDumperLoadedSound, m_loaded_sound, ASSET_TYPE_LOADED_SOUND) diff --git a/src/ObjWriting/Game/IW5/Image/AssetDumperGfxImage.cpp b/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.cpp similarity index 59% rename from src/ObjWriting/Game/IW5/Image/AssetDumperGfxImage.cpp rename to src/ObjWriting/Game/IW5/Image/ImageDumperIW5.cpp index 82d3cca1..5bc59c92 100644 --- a/src/ObjWriting/Game/IW5/Image/AssetDumperGfxImage.cpp +++ b/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.cpp @@ -1,7 +1,8 @@ -#include "AssetDumperGfxImage.h" +#include "ImageDumperIW5.h" #include "Image/DdsWriter.h" #include "Image/Dx9TextureLoader.h" +#include "Image/ImageCommon.h" #include "Image/IwiLoader.h" #include "Image/IwiWriter8.h" #include "ObjWriting.h" @@ -10,7 +11,9 @@ #include #include + using namespace IW5; +using namespace ::image; namespace { @@ -56,48 +59,43 @@ namespace } } // namespace -AssetDumperGfxImage::AssetDumperGfxImage() +namespace IW5::image { - switch (ObjWriting::Configuration.ImageOutputFormat) + Dumper::Dumper() { - case ObjWriting::Configuration_t::ImageOutputFormat_e::DDS: - m_writer = std::make_unique(); - break; - case ObjWriting::Configuration_t::ImageOutputFormat_e::IWI: - m_writer = std::make_unique(); - break; - default: - assert(false); - m_writer = nullptr; - break; + switch (ObjWriting::Configuration.ImageOutputFormat) + { + case ObjWriting::Configuration_t::ImageOutputFormat_e::DDS: + m_writer = std::make_unique(); + break; + case ObjWriting::Configuration_t::ImageOutputFormat_e::IWI: + m_writer = std::make_unique(); + break; + default: + assert(false); + m_writer = nullptr; + break; + } } -} -bool AssetDumperGfxImage::ShouldDump(XAssetInfo* asset) -{ - return true; -} + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } -std::string AssetDumperGfxImage::GetAssetFileName(const XAssetInfo& asset) const -{ - auto cleanAssetName = asset.m_name; - std::ranges::replace(cleanAssetName, '*', '_'); + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* image = asset->Asset(); + const auto texture = LoadImageData(context.m_obj_search_path, *image); + if (!texture) + return; - return std::format("images/{}{}", cleanAssetName, m_writer->GetFileExtension()); -} + const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset->m_name, m_writer->GetFileExtension())); -void AssetDumperGfxImage::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* image = asset->Asset(); - const auto texture = LoadImageData(context.m_obj_search_path, *image); - if (!texture) - return; + if (!assetFile) + return; - const auto assetFile = context.OpenAssetFile(GetAssetFileName(*asset)); - - if (!assetFile) - return; - - auto& stream = *assetFile; - m_writer->DumpImage(stream, texture.get()); -} + auto& stream = *assetFile; + m_writer->DumpImage(stream, texture.get()); + } +} // namespace IW5::image diff --git a/src/ObjWriting/Game/IW5/Image/AssetDumperGfxImage.h b/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.h similarity index 61% rename from src/ObjWriting/Game/IW5/Image/AssetDumperGfxImage.h rename to src/ObjWriting/Game/IW5/Image/ImageDumperIW5.h index fac3f66b..ff6edf39 100644 --- a/src/ObjWriting/Game/IW5/Image/AssetDumperGfxImage.h +++ b/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.h @@ -6,19 +6,18 @@ #include -namespace IW5 +namespace IW5::image { - class AssetDumperGfxImage final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { - std::unique_ptr m_writer; - - [[nodiscard]] std::string GetAssetFileName(const XAssetInfo& asset) const; + public: + Dumper(); protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - public: - AssetDumperGfxImage(); + private: + std::unique_ptr m_writer; }; -} // namespace IW5 +} // namespace IW5::image diff --git a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp index 2a9599c9..7a10547f 100644 --- a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp +++ b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp @@ -2,7 +2,7 @@ #include "Game/IW5/GameAssetPoolIW5.h" #include "Game/IW5/XModel/XModelDumperIW5.h" -#include "Image/AssetDumperGfxImage.h" +#include "Image/ImageDumperIW5.h" #include "Leaderboard/LeaderboardJsonDumperIW5.h" #include "Localize/AssetDumperLocalizeEntry.h" #include "Maps/AssetDumperAddonMapEnts.h" @@ -39,7 +39,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperMaterialVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER) // DUMP_ASSET_POOL(AssetDumperMaterialVertexDeclaration, m_material_vertex_decl, ASSET_TYPE_VERTEXDECL) // DUMP_ASSET_POOL(AssetDumperMaterialTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) - DUMP_ASSET_POOL(AssetDumperGfxImage, m_image, ASSET_TYPE_IMAGE) + DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) // DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND) // DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE) DUMP_ASSET_POOL(AssetDumperLoadedSound, m_loaded_sound, ASSET_TYPE_LOADED_SOUND) diff --git a/src/ObjWriting/Game/T5/Image/AssetDumperGfxImage.cpp b/src/ObjWriting/Game/T5/Image/ImageDumperT5.cpp similarity index 58% rename from src/ObjWriting/Game/T5/Image/AssetDumperGfxImage.cpp rename to src/ObjWriting/Game/T5/Image/ImageDumperT5.cpp index 6bb99fcf..a0ba1d0a 100644 --- a/src/ObjWriting/Game/T5/Image/AssetDumperGfxImage.cpp +++ b/src/ObjWriting/Game/T5/Image/ImageDumperT5.cpp @@ -1,7 +1,8 @@ -#include "AssetDumperGfxImage.h" +#include "ImageDumperT5.h" #include "Image/DdsWriter.h" #include "Image/Dx9TextureLoader.h" +#include "Image/ImageCommon.h" #include "Image/IwiLoader.h" #include "Image/IwiWriter13.h" #include "ObjWriting.h" @@ -11,6 +12,7 @@ #include using namespace T5; +using namespace ::image; namespace { @@ -55,48 +57,43 @@ namespace } } // namespace -AssetDumperGfxImage::AssetDumperGfxImage() +namespace T5::image { - switch (ObjWriting::Configuration.ImageOutputFormat) + Dumper::Dumper() { - case ObjWriting::Configuration_t::ImageOutputFormat_e::DDS: - m_writer = std::make_unique(); - break; - case ObjWriting::Configuration_t::ImageOutputFormat_e::IWI: - m_writer = std::make_unique(); - break; - default: - assert(false); - m_writer = nullptr; - break; + switch (ObjWriting::Configuration.ImageOutputFormat) + { + case ObjWriting::Configuration_t::ImageOutputFormat_e::DDS: + m_writer = std::make_unique(); + break; + case ObjWriting::Configuration_t::ImageOutputFormat_e::IWI: + m_writer = std::make_unique(); + break; + default: + assert(false); + m_writer = nullptr; + break; + } } -} -bool AssetDumperGfxImage::ShouldDump(XAssetInfo* asset) -{ - return true; -} + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } -std::string AssetDumperGfxImage::GetAssetFileName(const XAssetInfo& asset) const -{ - auto cleanAssetName = asset.m_name; - std::ranges::replace(cleanAssetName, '*', '_'); + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* image = asset->Asset(); + const auto texture = LoadImageData(context.m_obj_search_path, *image); + if (!texture) + return; - return std::format("images/{}{}", cleanAssetName, m_writer->GetFileExtension()); -} + const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset->m_name, m_writer->GetFileExtension())); -void AssetDumperGfxImage::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* image = asset->Asset(); - const auto texture = LoadImageData(context.m_obj_search_path, *image); - if (!texture) - return; + if (!assetFile) + return; - const auto assetFile = context.OpenAssetFile(GetAssetFileName(*asset)); - - if (!assetFile) - return; - - auto& stream = *assetFile; - m_writer->DumpImage(stream, texture.get()); -} + auto& stream = *assetFile; + m_writer->DumpImage(stream, texture.get()); + } +} // namespace T5::image diff --git a/src/ObjWriting/Game/T5/Image/AssetDumperGfxImage.h b/src/ObjWriting/Game/T5/Image/ImageDumperT5.h similarity index 62% rename from src/ObjWriting/Game/T5/Image/AssetDumperGfxImage.h rename to src/ObjWriting/Game/T5/Image/ImageDumperT5.h index b9f89b36..82581dde 100644 --- a/src/ObjWriting/Game/T5/Image/AssetDumperGfxImage.h +++ b/src/ObjWriting/Game/T5/Image/ImageDumperT5.h @@ -6,19 +6,18 @@ #include -namespace T5 +namespace T5::image { - class AssetDumperGfxImage final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { - std::unique_ptr m_writer; - - [[nodiscard]] std::string GetAssetFileName(const XAssetInfo& asset) const; + public: + Dumper(); protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - public: - AssetDumperGfxImage(); + private: + std::unique_ptr m_writer; }; -} // namespace T5 +} // namespace T5::image diff --git a/src/ObjWriting/Game/T5/ObjWriterT5.cpp b/src/ObjWriting/Game/T5/ObjWriterT5.cpp index e37bc427..7dd14410 100644 --- a/src/ObjWriting/Game/T5/ObjWriterT5.cpp +++ b/src/ObjWriting/Game/T5/ObjWriterT5.cpp @@ -2,7 +2,7 @@ #include "Game/T5/GameAssetPoolT5.h" #include "Game/T5/XModel/XModelDumperT5.h" -#include "Image/AssetDumperGfxImage.h" +#include "Image/ImageDumperT5.h" #include "Localize/AssetDumperLocalizeEntry.h" #include "Material/DumperMaterialT5.h" #include "ObjWriting.h" @@ -33,7 +33,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) DUMP_ASSET_POOL(AssetDumperMaterial, m_material, ASSET_TYPE_MATERIAL) // DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) - DUMP_ASSET_POOL(AssetDumperGfxImage, m_image, ASSET_TYPE_IMAGE) + DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) // DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank, ASSET_TYPE_SOUND) // DUMP_ASSET_POOL(AssetDumperSndPatch, m_sound_patch, ASSET_TYPE_SOUND_PATCH) // DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_PVS) diff --git a/src/ObjWriting/Game/T6/Image/AssetDumperGfxImage.cpp b/src/ObjWriting/Game/T6/Image/ImageDumperT6.cpp similarity index 64% rename from src/ObjWriting/Game/T6/Image/AssetDumperGfxImage.cpp rename to src/ObjWriting/Game/T6/Image/ImageDumperT6.cpp index f529cca1..d492a848 100644 --- a/src/ObjWriting/Game/T6/Image/AssetDumperGfxImage.cpp +++ b/src/ObjWriting/Game/T6/Image/ImageDumperT6.cpp @@ -1,7 +1,8 @@ -#include "AssetDumperGfxImage.h" +#include "ImageDumperT6.h" #include "Image/DdsWriter.h" #include "Image/Dx12TextureLoader.h" +#include "Image/ImageCommon.h" #include "Image/IwiLoader.h" #include "Image/IwiWriter27.h" #include "ObjContainer/IPak/IPak.h" @@ -12,6 +13,7 @@ #include using namespace T6; +using namespace ::image; namespace { @@ -73,48 +75,43 @@ namespace } } // namespace -AssetDumperGfxImage::AssetDumperGfxImage() +namespace T6::image { - switch (ObjWriting::Configuration.ImageOutputFormat) + Dumper::Dumper() { - case ObjWriting::Configuration_t::ImageOutputFormat_e::DDS: - m_writer = std::make_unique(); - break; - case ObjWriting::Configuration_t::ImageOutputFormat_e::IWI: - m_writer = std::make_unique(); - break; - default: - assert(false); - m_writer = nullptr; - break; + switch (ObjWriting::Configuration.ImageOutputFormat) + { + case ObjWriting::Configuration_t::ImageOutputFormat_e::DDS: + m_writer = std::make_unique(); + break; + case ObjWriting::Configuration_t::ImageOutputFormat_e::IWI: + m_writer = std::make_unique(); + break; + default: + assert(false); + m_writer = nullptr; + break; + } } -} -bool AssetDumperGfxImage::ShouldDump(XAssetInfo* asset) -{ - return true; -} + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } -std::string AssetDumperGfxImage::GetAssetFileName(const XAssetInfo& asset) const -{ - auto cleanAssetName = asset.m_name; - std::ranges::replace(cleanAssetName, '*', '_'); + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* image = asset->Asset(); + const auto texture = LoadImageData(context.m_obj_search_path, *image); + if (!texture) + return; - return std::format("images/{}{}", cleanAssetName, m_writer->GetFileExtension()); -} + const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset->m_name, m_writer->GetFileExtension())); -void AssetDumperGfxImage::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* image = asset->Asset(); - const auto texture = LoadImageData(context.m_obj_search_path, *image); - if (!texture) - return; + if (!assetFile) + return; - const auto assetFile = context.OpenAssetFile(GetAssetFileName(*asset)); - - if (!assetFile) - return; - - auto& stream = *assetFile; - m_writer->DumpImage(stream, texture.get()); -} + auto& stream = *assetFile; + m_writer->DumpImage(stream, texture.get()); + } +} // namespace T6::image diff --git a/src/ObjWriting/Game/T6/Image/AssetDumperGfxImage.h b/src/ObjWriting/Game/T6/Image/ImageDumperT6.h similarity index 63% rename from src/ObjWriting/Game/T6/Image/AssetDumperGfxImage.h rename to src/ObjWriting/Game/T6/Image/ImageDumperT6.h index 401aae5e..4b0c2599 100644 --- a/src/ObjWriting/Game/T6/Image/AssetDumperGfxImage.h +++ b/src/ObjWriting/Game/T6/Image/ImageDumperT6.h @@ -6,19 +6,18 @@ #include -namespace T6 +namespace T6::image { - class AssetDumperGfxImage final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { - std::unique_ptr m_writer; - - std::string GetAssetFileName(const XAssetInfo& asset) const; + public: + Dumper(); protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - public: - AssetDumperGfxImage(); + private: + std::unique_ptr m_writer; }; -} // namespace T6 +} // namespace T6::image diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 37313290..4a33c00d 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -3,7 +3,7 @@ #include "FontIcon/FontIconDumperT6.h" #include "Game/T6/GameAssetPoolT6.h" #include "Game/T6/XModel/XModelDumperT6.h" -#include "Image/AssetDumperGfxImage.h" +#include "Image/ImageDumperT6.h" #include "Leaderboard/LeaderboardJsonDumperT6.h" #include "Localize/AssetDumperLocalizeEntry.h" #include "Maps/AssetDumperMapEnts.h" @@ -53,7 +53,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) DUMP_ASSET_POOL(AssetDumperMaterial, m_material, ASSET_TYPE_MATERIAL) DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) - DUMP_ASSET_POOL(AssetDumperGfxImage, m_image, ASSET_TYPE_IMAGE) + DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank, ASSET_TYPE_SOUND) // DUMP_ASSET_POOL(AssetDumperSndPatch, m_sound_patch, ASSET_TYPE_SOUND_PATCH) // DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_PVS) From 934ba7f95aead292440ff07894780cf98856f6c7 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Tue, 29 Jul 2025 20:44:24 +0100 Subject: [PATCH 08/35] refactor: streamline localize dumper --- .../IW3/Localize/AssetDumperLocalizeEntry.cpp | 41 ----------------- .../Game/IW3/Localize/LocalizeDumperIW3.cpp | 44 +++++++++++++++++++ ...perLocalizeEntry.h => LocalizeDumperIW3.h} | 6 +-- src/ObjWriting/Game/IW3/ObjWriterIW3.cpp | 4 +- .../IW4/Localize/AssetDumperLocalizeEntry.cpp | 41 ----------------- .../Game/IW4/Localize/LocalizeDumperIW4.cpp | 44 +++++++++++++++++++ ...perLocalizeEntry.h => LocalizeDumperIW4.h} | 6 +-- src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 4 +- .../IW5/Localize/AssetDumperLocalizeEntry.cpp | 41 ----------------- .../Game/IW5/Localize/LocalizeDumperIW5.cpp | 44 +++++++++++++++++++ ...perLocalizeEntry.h => LocalizeDumperIW5.h} | 6 +-- src/ObjWriting/Game/IW5/ObjWriterIW5.cpp | 4 +- .../T5/Localize/AssetDumperLocalizeEntry.cpp | 41 ----------------- .../Game/T5/Localize/LocalizeDumperT5.cpp | 44 +++++++++++++++++++ ...mperLocalizeEntry.h => LocalizeDumperT5.h} | 6 +-- src/ObjWriting/Game/T5/ObjWriterT5.cpp | 4 +- .../T6/Localize/AssetDumperLocalizeEntry.cpp | 41 ----------------- .../Game/T6/Localize/LocalizeDumperT6.cpp | 44 +++++++++++++++++++ ...mperLocalizeEntry.h => LocalizeDumperT6.h} | 6 +-- src/ObjWriting/Game/T6/ObjWriterT6.cpp | 4 +- 20 files changed, 245 insertions(+), 230 deletions(-) delete mode 100644 src/ObjWriting/Game/IW3/Localize/AssetDumperLocalizeEntry.cpp create mode 100644 src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.cpp rename src/ObjWriting/Game/IW3/Localize/{AssetDumperLocalizeEntry.h => LocalizeDumperIW3.h} (64%) delete mode 100644 src/ObjWriting/Game/IW4/Localize/AssetDumperLocalizeEntry.cpp create mode 100644 src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.cpp rename src/ObjWriting/Game/IW4/Localize/{AssetDumperLocalizeEntry.h => LocalizeDumperIW4.h} (64%) delete mode 100644 src/ObjWriting/Game/IW5/Localize/AssetDumperLocalizeEntry.cpp create mode 100644 src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.cpp rename src/ObjWriting/Game/IW5/Localize/{AssetDumperLocalizeEntry.h => LocalizeDumperIW5.h} (64%) delete mode 100644 src/ObjWriting/Game/T5/Localize/AssetDumperLocalizeEntry.cpp create mode 100644 src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.cpp rename src/ObjWriting/Game/T5/Localize/{AssetDumperLocalizeEntry.h => LocalizeDumperT5.h} (64%) delete mode 100644 src/ObjWriting/Game/T6/Localize/AssetDumperLocalizeEntry.cpp create mode 100644 src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.cpp rename src/ObjWriting/Game/T6/Localize/{AssetDumperLocalizeEntry.h => LocalizeDumperT6.h} (64%) diff --git a/src/ObjWriting/Game/IW3/Localize/AssetDumperLocalizeEntry.cpp b/src/ObjWriting/Game/IW3/Localize/AssetDumperLocalizeEntry.cpp deleted file mode 100644 index d95a03b7..00000000 --- a/src/ObjWriting/Game/IW3/Localize/AssetDumperLocalizeEntry.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "AssetDumperLocalizeEntry.h" - -#include "Dumping/Localize/StringFileDumper.h" -#include "Localize/LocalizeCommon.h" - -#include -#include - -using namespace IW3; - -void AssetDumperLocalizeEntry::DumpPool(AssetDumpingContext& context, AssetPool* pool) -{ - if (pool->m_asset_lookup.empty()) - return; - - const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language); - const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name)); - - if (assetFile) - { - StringFileDumper stringFileDumper(context.m_zone, *assetFile); - - stringFileDumper.SetLanguageName(language); - - // Magic string. Original string files do have this config file. The purpose of the config file is unknown though. - stringFileDumper.SetConfigFile(R"(C:/trees/cod3/cod3/bin/StringEd.cfg)"); - - stringFileDumper.SetNotes(""); - - for (auto* localizeEntry : *pool) - { - stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value); - } - - stringFileDumper.Finalize(); - } - else - { - std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name); - } -} diff --git a/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.cpp b/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.cpp new file mode 100644 index 00000000..e01f32d7 --- /dev/null +++ b/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.cpp @@ -0,0 +1,44 @@ +#include "LocalizeDumperIW3.h" + +#include "Dumping/Localize/StringFileDumper.h" +#include "Localize/LocalizeCommon.h" + +#include +#include + +using namespace IW3; + +namespace IW3::localize +{ + void Dumper::DumpPool(AssetDumpingContext& context, AssetPool* pool) + { + if (pool->m_asset_lookup.empty()) + return; + + const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language); + const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name)); + + if (assetFile) + { + StringFileDumper stringFileDumper(context.m_zone, *assetFile); + + stringFileDumper.SetLanguageName(language); + + // Magic string. Original string files do have this config file. The purpose of the config file is unknown though. + stringFileDumper.SetConfigFile(R"(C:/trees/cod3/cod3/bin/StringEd.cfg)"); + + stringFileDumper.SetNotes(""); + + for (auto* localizeEntry : *pool) + { + stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value); + } + + stringFileDumper.Finalize(); + } + else + { + std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name); + } + } +} // namespace IW3::localize diff --git a/src/ObjWriting/Game/IW3/Localize/AssetDumperLocalizeEntry.h b/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.h similarity index 64% rename from src/ObjWriting/Game/IW3/Localize/AssetDumperLocalizeEntry.h rename to src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.h index 02d18955..aebdd9aa 100644 --- a/src/ObjWriting/Game/IW3/Localize/AssetDumperLocalizeEntry.h +++ b/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.h @@ -3,11 +3,11 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW3/IW3.h" -namespace IW3 +namespace IW3::localize { - class AssetDumperLocalizeEntry final : public IAssetDumper + class Dumper final : public IAssetDumper { public: void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; }; -} // namespace IW3 +} // namespace IW3::localize diff --git a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp index cec9c088..4f9b11b7 100644 --- a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp +++ b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp @@ -3,7 +3,7 @@ #include "Game/IW3/GameAssetPoolIW3.h" #include "Game/IW3/XModel/XModelDumperIW3.h" #include "Image/ImageDumperIW3.h" -#include "Localize/AssetDumperLocalizeEntry.h" +#include "Localize/LocalizeDumperIW3.h" #include "Maps/AssetDumperMapEnts.h" #include "Material/DumperMaterialIW3.h" #include "ObjWriting.h" @@ -44,7 +44,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT) // DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST) // DUMP_ASSET_POOL(AssetDumpermenuDef_t, m_menu_def, ASSET_TYPE_MENU) - DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) + DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) // DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON) // DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) diff --git a/src/ObjWriting/Game/IW4/Localize/AssetDumperLocalizeEntry.cpp b/src/ObjWriting/Game/IW4/Localize/AssetDumperLocalizeEntry.cpp deleted file mode 100644 index ef1799ac..00000000 --- a/src/ObjWriting/Game/IW4/Localize/AssetDumperLocalizeEntry.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "AssetDumperLocalizeEntry.h" - -#include "Dumping/Localize/StringFileDumper.h" -#include "Localize/LocalizeCommon.h" - -#include -#include - -using namespace IW4; - -void AssetDumperLocalizeEntry::DumpPool(AssetDumpingContext& context, AssetPool* pool) -{ - if (pool->m_asset_lookup.empty()) - return; - - const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language); - const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name)); - - if (assetFile) - { - StringFileDumper stringFileDumper(context.m_zone, *assetFile); - - stringFileDumper.SetLanguageName(language); - - // Magic string. Original string files do have this config file. The purpose of the config file is unknown though. - stringFileDumper.SetConfigFile(R"(C:/trees/cod3/cod3/bin/StringEd.cfg)"); - - stringFileDumper.SetNotes(""); - - for (auto* localizeEntry : *pool) - { - stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value); - } - - stringFileDumper.Finalize(); - } - else - { - std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name); - } -} diff --git a/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.cpp b/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.cpp new file mode 100644 index 00000000..3efb30ea --- /dev/null +++ b/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.cpp @@ -0,0 +1,44 @@ +#include "LocalizeDumperIW4.h" + +#include "Dumping/Localize/StringFileDumper.h" +#include "Localize/LocalizeCommon.h" + +#include +#include + +using namespace IW4; + +namespace IW4::localize +{ + void Dumper::DumpPool(AssetDumpingContext& context, AssetPool* pool) + { + if (pool->m_asset_lookup.empty()) + return; + + const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language); + const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name)); + + if (assetFile) + { + StringFileDumper stringFileDumper(context.m_zone, *assetFile); + + stringFileDumper.SetLanguageName(language); + + // Magic string. Original string files do have this config file. The purpose of the config file is unknown though. + stringFileDumper.SetConfigFile(R"(C:/trees/cod3/cod3/bin/StringEd.cfg)"); + + stringFileDumper.SetNotes(""); + + for (auto* localizeEntry : *pool) + { + stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value); + } + + stringFileDumper.Finalize(); + } + else + { + std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name); + } + } +} // namespace IW4::localize diff --git a/src/ObjWriting/Game/IW4/Localize/AssetDumperLocalizeEntry.h b/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.h similarity index 64% rename from src/ObjWriting/Game/IW4/Localize/AssetDumperLocalizeEntry.h rename to src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.h index cc1e07f2..f7435a5b 100644 --- a/src/ObjWriting/Game/IW4/Localize/AssetDumperLocalizeEntry.h +++ b/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.h @@ -3,11 +3,11 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4 +namespace IW4::localize { - class AssetDumperLocalizeEntry final : public IAssetDumper + class Dumper final : public IAssetDumper { public: void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; }; -} // namespace IW4 +} // namespace IW4::localize diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 4a32c507..13ae2541 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -5,7 +5,7 @@ #include "Image/ImageDumperIW4.h" #include "Leaderboard/LeaderboardJsonDumperIW4.h" #include "LightDef/LightDefDumperIW4.h" -#include "Localize/AssetDumperLocalizeEntry.h" +#include "Localize/LocalizeDumperIW4.h" #include "Maps/AssetDumperAddonMapEnts.h" #include "Material/DumperMaterialIW4.h" #include "Menu/AssetDumperMenuDef.h" @@ -61,7 +61,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT) DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST) DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU) - DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) + DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON) // DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) diff --git a/src/ObjWriting/Game/IW5/Localize/AssetDumperLocalizeEntry.cpp b/src/ObjWriting/Game/IW5/Localize/AssetDumperLocalizeEntry.cpp deleted file mode 100644 index 600e41b8..00000000 --- a/src/ObjWriting/Game/IW5/Localize/AssetDumperLocalizeEntry.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "AssetDumperLocalizeEntry.h" - -#include "Dumping/Localize/StringFileDumper.h" -#include "Localize/LocalizeCommon.h" - -#include -#include - -using namespace IW5; - -void AssetDumperLocalizeEntry::DumpPool(AssetDumpingContext& context, AssetPool* pool) -{ - if (pool->m_asset_lookup.empty()) - return; - - const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language); - const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name)); - - if (assetFile) - { - StringFileDumper stringFileDumper(context.m_zone, *assetFile); - - stringFileDumper.SetLanguageName(language); - - // Magic string. Original string files do have this config file. The purpose of the config file is unknown though. - stringFileDumper.SetConfigFile(R"(C:/trees/cod3/cod3/bin/StringEd.cfg)"); - - stringFileDumper.SetNotes(""); - - for (auto* localizeEntry : *pool) - { - stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value); - } - - stringFileDumper.Finalize(); - } - else - { - std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name); - } -} diff --git a/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.cpp b/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.cpp new file mode 100644 index 00000000..f29817a2 --- /dev/null +++ b/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.cpp @@ -0,0 +1,44 @@ +#include "LocalizeDumperIW5.h" + +#include "Dumping/Localize/StringFileDumper.h" +#include "Localize/LocalizeCommon.h" + +#include +#include + +using namespace IW5; + +namespace IW5::localize +{ + void Dumper::DumpPool(AssetDumpingContext& context, AssetPool* pool) + { + if (pool->m_asset_lookup.empty()) + return; + + const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language); + const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name)); + + if (assetFile) + { + StringFileDumper stringFileDumper(context.m_zone, *assetFile); + + stringFileDumper.SetLanguageName(language); + + // Magic string. Original string files do have this config file. The purpose of the config file is unknown though. + stringFileDumper.SetConfigFile(R"(C:/trees/cod3/cod3/bin/StringEd.cfg)"); + + stringFileDumper.SetNotes(""); + + for (auto* localizeEntry : *pool) + { + stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value); + } + + stringFileDumper.Finalize(); + } + else + { + std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name); + } + } +} // namespace IW5::localize diff --git a/src/ObjWriting/Game/IW5/Localize/AssetDumperLocalizeEntry.h b/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.h similarity index 64% rename from src/ObjWriting/Game/IW5/Localize/AssetDumperLocalizeEntry.h rename to src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.h index 151dcd73..91cfdee3 100644 --- a/src/ObjWriting/Game/IW5/Localize/AssetDumperLocalizeEntry.h +++ b/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.h @@ -3,11 +3,11 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW5/IW5.h" -namespace IW5 +namespace IW5::localize { - class AssetDumperLocalizeEntry final : public IAssetDumper + class Dumper final : public IAssetDumper { public: void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; }; -} // namespace IW5 +} // namespace IW5::localize diff --git a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp index 7a10547f..ee374cc4 100644 --- a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp +++ b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp @@ -4,7 +4,7 @@ #include "Game/IW5/XModel/XModelDumperIW5.h" #include "Image/ImageDumperIW5.h" #include "Leaderboard/LeaderboardJsonDumperIW5.h" -#include "Localize/AssetDumperLocalizeEntry.h" +#include "Localize/LocalizeDumperIW5.h" #include "Maps/AssetDumperAddonMapEnts.h" #include "Material/DumperMaterialIW5.h" #include "Menu/AssetDumperMenuDef.h" @@ -55,7 +55,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT) DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST) DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU) - DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) + DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) DUMP_ASSET_POOL(AssetDumperWeaponAttachment, m_attachment, ASSET_TYPE_ATTACHMENT) DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON) // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) diff --git a/src/ObjWriting/Game/T5/Localize/AssetDumperLocalizeEntry.cpp b/src/ObjWriting/Game/T5/Localize/AssetDumperLocalizeEntry.cpp deleted file mode 100644 index 0377f5cf..00000000 --- a/src/ObjWriting/Game/T5/Localize/AssetDumperLocalizeEntry.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "AssetDumperLocalizeEntry.h" - -#include "Dumping/Localize/StringFileDumper.h" -#include "Localize/LocalizeCommon.h" - -#include -#include - -using namespace T5; - -void AssetDumperLocalizeEntry::DumpPool(AssetDumpingContext& context, AssetPool* pool) -{ - if (pool->m_asset_lookup.empty()) - return; - - const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language); - const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name)); - - if (assetFile) - { - StringFileDumper stringFileDumper(context.m_zone, *assetFile); - - stringFileDumper.SetLanguageName(language); - - // Magic string. Original string files do have this config file. The purpose of the config file is unknown though. - stringFileDumper.SetConfigFile(R"(C:/projects/cod/t5/bin/StringEd.cfg)"); - - stringFileDumper.SetNotes(""); - - for (auto* localizeEntry : *pool) - { - stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value); - } - - stringFileDumper.Finalize(); - } - else - { - std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name); - } -} diff --git a/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.cpp b/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.cpp new file mode 100644 index 00000000..5da3d791 --- /dev/null +++ b/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.cpp @@ -0,0 +1,44 @@ +#include "LocalizeDumperT5.h" + +#include "Dumping/Localize/StringFileDumper.h" +#include "Localize/LocalizeCommon.h" + +#include +#include + +using namespace T5; + +namespace T5::localize +{ + void Dumper::DumpPool(AssetDumpingContext& context, AssetPool* pool) + { + if (pool->m_asset_lookup.empty()) + return; + + const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language); + const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name)); + + if (assetFile) + { + StringFileDumper stringFileDumper(context.m_zone, *assetFile); + + stringFileDumper.SetLanguageName(language); + + // Magic string. Original string files do have this config file. The purpose of the config file is unknown though. + stringFileDumper.SetConfigFile(R"(C:/projects/cod/t5/bin/StringEd.cfg)"); + + stringFileDumper.SetNotes(""); + + for (auto* localizeEntry : *pool) + { + stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value); + } + + stringFileDumper.Finalize(); + } + else + { + std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name); + } + } +} // namespace T5::localize diff --git a/src/ObjWriting/Game/T5/Localize/AssetDumperLocalizeEntry.h b/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.h similarity index 64% rename from src/ObjWriting/Game/T5/Localize/AssetDumperLocalizeEntry.h rename to src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.h index e4aec7e8..e317d37d 100644 --- a/src/ObjWriting/Game/T5/Localize/AssetDumperLocalizeEntry.h +++ b/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.h @@ -3,11 +3,11 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T5/T5.h" -namespace T5 +namespace T5::localize { - class AssetDumperLocalizeEntry final : public IAssetDumper + class Dumper final : public IAssetDumper { public: void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; }; -} // namespace T5 +} // namespace T5::localize diff --git a/src/ObjWriting/Game/T5/ObjWriterT5.cpp b/src/ObjWriting/Game/T5/ObjWriterT5.cpp index 7dd14410..7528ea67 100644 --- a/src/ObjWriting/Game/T5/ObjWriterT5.cpp +++ b/src/ObjWriting/Game/T5/ObjWriterT5.cpp @@ -3,7 +3,7 @@ #include "Game/T5/GameAssetPoolT5.h" #include "Game/T5/XModel/XModelDumperT5.h" #include "Image/ImageDumperT5.h" -#include "Localize/AssetDumperLocalizeEntry.h" +#include "Localize/LocalizeDumperT5.h" #include "Material/DumperMaterialT5.h" #include "ObjWriting.h" #include "PhysConstraints/AssetDumperPhysConstraints.h" @@ -46,7 +46,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperFont, m_font, ASSET_TYPE_FONT) // DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST) // DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU) - DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) + DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) // DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON) // DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) diff --git a/src/ObjWriting/Game/T6/Localize/AssetDumperLocalizeEntry.cpp b/src/ObjWriting/Game/T6/Localize/AssetDumperLocalizeEntry.cpp deleted file mode 100644 index e9ebf735..00000000 --- a/src/ObjWriting/Game/T6/Localize/AssetDumperLocalizeEntry.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "AssetDumperLocalizeEntry.h" - -#include "Dumping/Localize/StringFileDumper.h" -#include "Localize/LocalizeCommon.h" - -#include -#include - -using namespace T6; - -void AssetDumperLocalizeEntry::DumpPool(AssetDumpingContext& context, AssetPool* pool) -{ - if (pool->m_asset_lookup.empty()) - return; - - const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language); - const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name)); - - if (assetFile) - { - StringFileDumper stringFileDumper(context.m_zone, *assetFile); - - stringFileDumper.SetLanguageName(language); - - // Magic string. Original string files do have this config file. The purpose of the config file is unknown though. - stringFileDumper.SetConfigFile(R"(C:/projects/cod/t6/bin/StringEd.cfg)"); - - stringFileDumper.SetNotes(""); - - for (auto* localizeEntry : *pool) - { - stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value); - } - - stringFileDumper.Finalize(); - } - else - { - std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name); - } -} diff --git a/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.cpp b/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.cpp new file mode 100644 index 00000000..b989f9e2 --- /dev/null +++ b/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.cpp @@ -0,0 +1,44 @@ +#include "LocalizeDumperT6.h" + +#include "Dumping/Localize/StringFileDumper.h" +#include "Localize/LocalizeCommon.h" + +#include +#include + +using namespace T6; + +namespace T6::localize +{ + void Dumper::DumpPool(AssetDumpingContext& context, AssetPool* pool) + { + if (pool->m_asset_lookup.empty()) + return; + + const auto language = LocalizeCommon::GetNameOfLanguage(context.m_zone.m_language); + const auto assetFile = context.OpenAssetFile(std::format("{}/localizedstrings/{}.str", language, context.m_zone.m_name)); + + if (assetFile) + { + StringFileDumper stringFileDumper(context.m_zone, *assetFile); + + stringFileDumper.SetLanguageName(language); + + // Magic string. Original string files do have this config file. The purpose of the config file is unknown though. + stringFileDumper.SetConfigFile(R"(C:/projects/cod/t6/bin/StringEd.cfg)"); + + stringFileDumper.SetNotes(""); + + for (auto* localizeEntry : *pool) + { + stringFileDumper.WriteLocalizeEntry(localizeEntry->m_name, localizeEntry->Asset()->value); + } + + stringFileDumper.Finalize(); + } + else + { + std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name); + } + } +} // namespace T6::localize diff --git a/src/ObjWriting/Game/T6/Localize/AssetDumperLocalizeEntry.h b/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.h similarity index 64% rename from src/ObjWriting/Game/T6/Localize/AssetDumperLocalizeEntry.h rename to src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.h index d85de9ac..f0591f38 100644 --- a/src/ObjWriting/Game/T6/Localize/AssetDumperLocalizeEntry.h +++ b/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.h @@ -3,11 +3,11 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6 +namespace T6::localize { - class AssetDumperLocalizeEntry final : public IAssetDumper + class Dumper final : public IAssetDumper { public: void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; }; -} // namespace T6 +} // namespace T6::localize diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 4a33c00d..97f4143d 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -5,7 +5,7 @@ #include "Game/T6/XModel/XModelDumperT6.h" #include "Image/ImageDumperT6.h" #include "Leaderboard/LeaderboardJsonDumperT6.h" -#include "Localize/AssetDumperLocalizeEntry.h" +#include "Localize/LocalizeDumperT6.h" #include "Maps/AssetDumperMapEnts.h" #include "Material/DumperMaterialT6.h" #include "ObjWriting.h" @@ -67,7 +67,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL_WITH_FACTORY(font_icon::CreateDumper(), m_font_icon, ASSET_TYPE_FONTICON) // DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST) // DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU) - DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) + DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON) DUMP_ASSET_POOL(AssetDumperWeaponAttachment, m_attachment, ASSET_TYPE_ATTACHMENT) DUMP_ASSET_POOL(AssetDumperWeaponAttachmentUnique, m_attachment_unique, ASSET_TYPE_ATTACHMENT_UNIQUE) From 9885a4ce938604c4299af4be857d5aa09b8f409a Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Tue, 29 Jul 2025 22:51:56 +0100 Subject: [PATCH 09/35] refactor: streamline map assets dumper --- .../Game/IW3/Maps/AssetDumperMapEnts.cpp | 20 -------------- .../Game/IW3/Maps/MapEntsDumperIW3.cpp | 23 ++++++++++++++++ ...ssetDumperMapEnts.h => MapEntsDumperIW3.h} | 6 ++--- src/ObjWriting/Game/IW3/ObjWriterIW3.cpp | 4 +-- .../Game/IW4/Maps/AddonMapEntsDumperIW4.cpp | 27 +++++++++++++++++++ ...AddonMapEnts.h => AddonMapEntsDumperIW4.h} | 6 ++--- .../Game/IW4/Maps/AssetDumperAddonMapEnts.cpp | 24 ----------------- src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 4 +-- .../Game/IW5/Maps/AddonMapEntsDumperIW5.cpp | 26 ++++++++++++++++++ ...AddonMapEnts.h => AddonMapEntsDumperIW5.h} | 6 ++--- .../Game/IW5/Maps/AssetDumperAddonMapEnts.cpp | 23 ---------------- src/ObjWriting/Game/IW5/ObjWriterIW5.cpp | 4 +-- .../Game/T6/Maps/AssetDumperMapEnts.cpp | 23 ---------------- .../Game/T6/Maps/MapEntsDumperT6.cpp | 26 ++++++++++++++++++ ...AssetDumperMapEnts.h => MapEntsDumperT6.h} | 6 ++--- src/ObjWriting/Game/T6/ObjWriterT6.cpp | 4 +-- 16 files changed, 122 insertions(+), 110 deletions(-) delete mode 100644 src/ObjWriting/Game/IW3/Maps/AssetDumperMapEnts.cpp create mode 100644 src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.cpp rename src/ObjWriting/Game/IW3/Maps/{AssetDumperMapEnts.h => MapEntsDumperIW3.h} (69%) create mode 100644 src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.cpp rename src/ObjWriting/Game/IW4/Maps/{AssetDumperAddonMapEnts.h => AddonMapEntsDumperIW4.h} (67%) delete mode 100644 src/ObjWriting/Game/IW4/Maps/AssetDumperAddonMapEnts.cpp create mode 100644 src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.cpp rename src/ObjWriting/Game/IW5/Maps/{AssetDumperAddonMapEnts.h => AddonMapEntsDumperIW5.h} (67%) delete mode 100644 src/ObjWriting/Game/IW5/Maps/AssetDumperAddonMapEnts.cpp delete mode 100644 src/ObjWriting/Game/T6/Maps/AssetDumperMapEnts.cpp create mode 100644 src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.cpp rename src/ObjWriting/Game/T6/Maps/{AssetDumperMapEnts.h => MapEntsDumperT6.h} (70%) diff --git a/src/ObjWriting/Game/IW3/Maps/AssetDumperMapEnts.cpp b/src/ObjWriting/Game/IW3/Maps/AssetDumperMapEnts.cpp deleted file mode 100644 index 9e9cd441..00000000 --- a/src/ObjWriting/Game/IW3/Maps/AssetDumperMapEnts.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "AssetDumperMapEnts.h" - -using namespace IW3; - -bool AssetDumperMapEnts::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperMapEnts::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* mapEnts = asset->Asset(); - const auto assetFile = context.OpenAssetFile(asset->m_name + ".ents"); - - if (!assetFile) - return; - - auto& stream = *assetFile; - stream.write(mapEnts->entityString, mapEnts->numEntityChars); -} diff --git a/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.cpp b/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.cpp new file mode 100644 index 00000000..abe0e937 --- /dev/null +++ b/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.cpp @@ -0,0 +1,23 @@ +#include "MapEntsDumperIW3.h" + +using namespace IW3; + +namespace IW3::map_ents +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* mapEnts = asset->Asset(); + const auto assetFile = context.OpenAssetFile(asset->m_name + ".ents"); + + if (!assetFile) + return; + + auto& stream = *assetFile; + stream.write(mapEnts->entityString, mapEnts->numEntityChars); + } +} // namespace IW3::map_ents diff --git a/src/ObjWriting/Game/IW3/Maps/AssetDumperMapEnts.h b/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.h similarity index 69% rename from src/ObjWriting/Game/IW3/Maps/AssetDumperMapEnts.h rename to src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.h index c769bec0..55518202 100644 --- a/src/ObjWriting/Game/IW3/Maps/AssetDumperMapEnts.h +++ b/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW3/IW3.h" -namespace IW3 +namespace IW3::map_ents { - class AssetDumperMapEnts final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW3 +} // namespace IW3::map_ents diff --git a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp index 4f9b11b7..9149fc70 100644 --- a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp +++ b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp @@ -4,7 +4,7 @@ #include "Game/IW3/XModel/XModelDumperIW3.h" #include "Image/ImageDumperIW3.h" #include "Localize/LocalizeDumperIW3.h" -#include "Maps/AssetDumperMapEnts.h" +#include "Maps/MapEntsDumperIW3.h" #include "Material/DumperMaterialIW3.h" #include "ObjWriting.h" #include "RawFile/AssetDumperRawFile.h" @@ -38,7 +38,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD) // DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP) // DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP) - DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS) + DUMP_ASSET_POOL(map_ents::Dumper, m_map_ents, ASSET_TYPE_MAP_ENTS) // DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD) // DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF) // DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT) diff --git a/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.cpp b/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.cpp new file mode 100644 index 00000000..7f708cc0 --- /dev/null +++ b/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.cpp @@ -0,0 +1,27 @@ +#define NOMINMAX +#include "AddonMapEntsDumperIW4.h" + +#include + +using namespace IW4; + +namespace IW4::addon_map_ents +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* addonMapEnts = asset->Asset(); + const auto assetFile = context.OpenAssetFile(asset->m_name); + + if (!assetFile) + return; + + auto& stream = *assetFile; + + stream.write(addonMapEnts->entityString, std::max(addonMapEnts->numEntityChars - 1, 0)); + } +} // namespace IW4::addon_map_ents diff --git a/src/ObjWriting/Game/IW4/Maps/AssetDumperAddonMapEnts.h b/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.h similarity index 67% rename from src/ObjWriting/Game/IW4/Maps/AssetDumperAddonMapEnts.h rename to src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.h index 8a5ad601..a4691a78 100644 --- a/src/ObjWriting/Game/IW4/Maps/AssetDumperAddonMapEnts.h +++ b/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4 +namespace IW4::addon_map_ents { - class AssetDumperAddonMapEnts final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4 +} // namespace IW4::addon_map_ents diff --git a/src/ObjWriting/Game/IW4/Maps/AssetDumperAddonMapEnts.cpp b/src/ObjWriting/Game/IW4/Maps/AssetDumperAddonMapEnts.cpp deleted file mode 100644 index 58c745c5..00000000 --- a/src/ObjWriting/Game/IW4/Maps/AssetDumperAddonMapEnts.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#define NOMINMAX -#include "AssetDumperAddonMapEnts.h" - -#include - -using namespace IW4; - -bool AssetDumperAddonMapEnts::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperAddonMapEnts::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* addonMapEnts = asset->Asset(); - const auto assetFile = context.OpenAssetFile(asset->m_name); - - if (!assetFile) - return; - - auto& stream = *assetFile; - - stream.write(addonMapEnts->entityString, std::max(addonMapEnts->numEntityChars - 1, 0)); -} diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 13ae2541..417ec52b 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -6,7 +6,7 @@ #include "Leaderboard/LeaderboardJsonDumperIW4.h" #include "LightDef/LightDefDumperIW4.h" #include "Localize/LocalizeDumperIW4.h" -#include "Maps/AssetDumperAddonMapEnts.h" +#include "Maps/AddonMapEntsDumperIW4.h" #include "Material/DumperMaterialIW4.h" #include "Menu/AssetDumperMenuDef.h" #include "Menu/AssetDumperMenuList.h" @@ -72,7 +72,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF) DUMP_ASSET_POOL(AssetDumperTracer, m_tracer, ASSET_TYPE_TRACER) DUMP_ASSET_POOL(AssetDumperVehicle, m_vehicle, ASSET_TYPE_VEHICLE) - DUMP_ASSET_POOL(AssetDumperAddonMapEnts, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS) + DUMP_ASSET_POOL(addon_map_ents::Dumper, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS) return true; diff --git a/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.cpp b/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.cpp new file mode 100644 index 00000000..5c2cc0c4 --- /dev/null +++ b/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.cpp @@ -0,0 +1,26 @@ +#define NOMINMAX +#include "AddonMapEntsDumperIW5.h" + +#include + +using namespace IW5; + +namespace IW5::addon_map_ents +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* addonMapEnts = asset->Asset(); + const auto assetFile = context.OpenAssetFile(asset->m_name); + + if (!assetFile) + return; + + auto& stream = *assetFile; + stream.write(addonMapEnts->entityString, std::max(addonMapEnts->numEntityChars - 1, 0)); + } +} // namespace IW5::addon_map_ents diff --git a/src/ObjWriting/Game/IW5/Maps/AssetDumperAddonMapEnts.h b/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.h similarity index 67% rename from src/ObjWriting/Game/IW5/Maps/AssetDumperAddonMapEnts.h rename to src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.h index 9e5ec39d..928fc8e1 100644 --- a/src/ObjWriting/Game/IW5/Maps/AssetDumperAddonMapEnts.h +++ b/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW5/IW5.h" -namespace IW5 +namespace IW5::addon_map_ents { - class AssetDumperAddonMapEnts final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW5 +} // namespace IW5::addon_map_ents diff --git a/src/ObjWriting/Game/IW5/Maps/AssetDumperAddonMapEnts.cpp b/src/ObjWriting/Game/IW5/Maps/AssetDumperAddonMapEnts.cpp deleted file mode 100644 index 547881cf..00000000 --- a/src/ObjWriting/Game/IW5/Maps/AssetDumperAddonMapEnts.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#define NOMINMAX -#include "AssetDumperAddonMapEnts.h" - -#include - -using namespace IW5; - -bool AssetDumperAddonMapEnts::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperAddonMapEnts::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* addonMapEnts = asset->Asset(); - const auto assetFile = context.OpenAssetFile(asset->m_name); - - if (!assetFile) - return; - - auto& stream = *assetFile; - stream.write(addonMapEnts->entityString, std::max(addonMapEnts->numEntityChars - 1, 0)); -} diff --git a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp index ee374cc4..b08d609f 100644 --- a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp +++ b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp @@ -5,7 +5,7 @@ #include "Image/ImageDumperIW5.h" #include "Leaderboard/LeaderboardJsonDumperIW5.h" #include "Localize/LocalizeDumperIW5.h" -#include "Maps/AssetDumperAddonMapEnts.h" +#include "Maps/AddonMapEntsDumperIW5.h" #include "Material/DumperMaterialIW5.h" #include "Menu/AssetDumperMenuDef.h" #include "Menu/AssetDumperMenuList.h" @@ -68,7 +68,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF) // DUMP_ASSET_POOL(AssetDumperTracerDef, m_tracer, ASSET_TYPE_TRACER) // DUMP_ASSET_POOL(AssetDumperVehicleDef, m_vehicle, ASSET_TYPE_VEHICLE) - DUMP_ASSET_POOL(AssetDumperAddonMapEnts, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS) + DUMP_ASSET_POOL(addon_map_ents::Dumper, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS) return true; diff --git a/src/ObjWriting/Game/T6/Maps/AssetDumperMapEnts.cpp b/src/ObjWriting/Game/T6/Maps/AssetDumperMapEnts.cpp deleted file mode 100644 index cd4a8165..00000000 --- a/src/ObjWriting/Game/T6/Maps/AssetDumperMapEnts.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "AssetDumperMapEnts.h" - -#include - -using namespace T6; - -bool AssetDumperMapEnts::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperMapEnts::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* mapEnts = asset->Asset(); - - const auto mapEntsFile = context.OpenAssetFile(std::format("{}.ents", mapEnts->name)); - - if (!mapEntsFile) - return; - - auto& stream = *mapEntsFile; - stream.write(mapEnts->entityString, mapEnts->numEntityChars - 1); -} diff --git a/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.cpp b/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.cpp new file mode 100644 index 00000000..7dce7a29 --- /dev/null +++ b/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.cpp @@ -0,0 +1,26 @@ +#include "MapEntsDumperT6.h" + +#include + +using namespace T6; + +namespace T6::map_ents +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* mapEnts = asset->Asset(); + + const auto mapEntsFile = context.OpenAssetFile(std::format("{}.ents", mapEnts->name)); + + if (!mapEntsFile) + return; + + auto& stream = *mapEntsFile; + stream.write(mapEnts->entityString, mapEnts->numEntityChars - 1); + } +} // namespace T6::map_ents diff --git a/src/ObjWriting/Game/T6/Maps/AssetDumperMapEnts.h b/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.h similarity index 70% rename from src/ObjWriting/Game/T6/Maps/AssetDumperMapEnts.h rename to src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.h index 98b0301a..9fc7a6b8 100644 --- a/src/ObjWriting/Game/T6/Maps/AssetDumperMapEnts.h +++ b/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6 +namespace T6::map_ents { - class AssetDumperMapEnts final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6 +} // namespace T6::map_ents diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 97f4143d..54dc5056 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -6,7 +6,7 @@ #include "Image/ImageDumperT6.h" #include "Leaderboard/LeaderboardJsonDumperT6.h" #include "Localize/LocalizeDumperT6.h" -#include "Maps/AssetDumperMapEnts.h" +#include "Maps/MapEntsDumperT6.h" #include "Material/DumperMaterialT6.h" #include "ObjWriting.h" #include "PhysConstraints/AssetDumperPhysConstraints.h" @@ -60,7 +60,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD) // DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP) // DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP) - DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS) + DUMP_ASSET_POOL(map_ents::Dumper, m_map_ents, ASSET_TYPE_MAP_ENTS) // DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD) // DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF) // DUMP_ASSET_POOL(AssetDumperFont, m_font, ASSET_TYPE_FONT) From 0dfa57446c059e39693f4e20644eca85bf9d56d6 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Tue, 29 Jul 2025 23:37:41 +0100 Subject: [PATCH 10/35] refactor: streamline material dumping --- .../Game/IW3/Material/DumperMaterialIW3.cpp | 30 ----------- .../Game/IW3/Material/DumperMaterialIW3.h | 17 ------ src/ObjWriting/Game/IW3/ObjWriterIW3.cpp | 4 +- .../Material/DecompilingMaterialDumperIW4.h | 10 ---- .../Game/IW4/Material/DumperMaterialIW4.cpp | 38 -------------- ...4.cpp => MaterialDecompilingDumperIW4.cpp} | 20 ++++--- ...alIW4.h => MaterialDecompilingDumperIW4.h} | 9 ++-- src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 8 ++- .../Game/IW5/Material/DumperMaterialIW5.cpp | 31 ----------- .../Game/IW5/Material/DumperMaterialIW5.h | 17 ------ src/ObjWriting/Game/IW5/ObjWriterIW5.cpp | 4 +- .../Game/T5/Material/DumperMaterialT5.cpp | 35 ------------- .../Game/T5/Material/DumperMaterialT5.h | 17 ------ src/ObjWriting/Game/T5/ObjWriterT5.cpp | 4 +- .../Game/T6/Material/DumperMaterialT6.cpp | 36 ------------- .../Game/T6/Material/DumperMaterialT6.h | 17 ------ src/ObjWriting/Game/T6/ObjWriterT6.cpp | 4 +- .../Material/JsonMaterialWriter.h.template | 20 ------- ...mplate => MaterialJsonDumper.cpp.template} | 52 +++++++++++++++---- .../Material/MaterialJsonDumper.h.template | 27 ++++++++++ test/ObjWritingTests.lua | 1 + ...lIW3Test.cpp => MaterialJsonDumperIW3.cpp} | 4 +- ...lIW4Test.cpp => MaterialJsonDumperIW4.cpp} | 4 +- ...lIW5Test.cpp => MaterialJsonDumperIW5.cpp} | 4 +- ...ialT5Test.cpp => MaterialJsonDumperT5.cpp} | 4 +- ...6Test.cpp => MaterialJsonDumperT6Test.cpp} | 4 +- 26 files changed, 111 insertions(+), 310 deletions(-) delete mode 100644 src/ObjWriting/Game/IW3/Material/DumperMaterialIW3.cpp delete mode 100644 src/ObjWriting/Game/IW3/Material/DumperMaterialIW3.h delete mode 100644 src/ObjWriting/Game/IW4/Material/DecompilingMaterialDumperIW4.h delete mode 100644 src/ObjWriting/Game/IW4/Material/DumperMaterialIW4.cpp rename src/ObjWriting/Game/IW4/Material/{DecompilingMaterialDumperIW4.cpp => MaterialDecompilingDumperIW4.cpp} (99%) rename src/ObjWriting/Game/IW4/Material/{DumperMaterialIW4.h => MaterialDecompilingDumperIW4.h} (55%) delete mode 100644 src/ObjWriting/Game/IW5/Material/DumperMaterialIW5.cpp delete mode 100644 src/ObjWriting/Game/IW5/Material/DumperMaterialIW5.h delete mode 100644 src/ObjWriting/Game/T5/Material/DumperMaterialT5.cpp delete mode 100644 src/ObjWriting/Game/T5/Material/DumperMaterialT5.h delete mode 100644 src/ObjWriting/Game/T6/Material/DumperMaterialT6.cpp delete mode 100644 src/ObjWriting/Game/T6/Material/DumperMaterialT6.h delete mode 100644 src/ObjWriting/Material/JsonMaterialWriter.h.template rename src/ObjWriting/Material/{JsonMaterialWriter.cpp.template => MaterialJsonDumper.cpp.template} (90%) create mode 100644 src/ObjWriting/Material/MaterialJsonDumper.h.template rename test/ObjWritingTests/Game/IW3/Material/{DumperMaterialIW3Test.cpp => MaterialJsonDumperIW3.cpp} (99%) rename test/ObjWritingTests/Game/IW4/Material/{DumperMaterialIW4Test.cpp => MaterialJsonDumperIW4.cpp} (99%) rename test/ObjWritingTests/Game/IW5/Material/{DumperMaterialIW5Test.cpp => MaterialJsonDumperIW5.cpp} (99%) rename test/ObjWritingTests/Game/T5/Material/{DumperMaterialT5Test.cpp => MaterialJsonDumperT5.cpp} (99%) rename test/ObjWritingTests/Game/T6/Material/{DumperMaterialT6Test.cpp => MaterialJsonDumperT6Test.cpp} (99%) diff --git a/src/ObjWriting/Game/IW3/Material/DumperMaterialIW3.cpp b/src/ObjWriting/Game/IW3/Material/DumperMaterialIW3.cpp deleted file mode 100644 index bb3a87a8..00000000 --- a/src/ObjWriting/Game/IW3/Material/DumperMaterialIW3.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "DumperMaterialIW3.h" - -#include "Game/IW3/Material/JsonMaterialWriterIW3.h" -#include "Game/IW3/Material/MaterialConstantZoneStateIW3.h" -#include "Material/MaterialCommon.h" - -using namespace IW3; - -void AssetDumperMaterial::DumpPool(AssetDumpingContext& context, AssetPool* pool) -{ - auto* materialConstantState = context.GetZoneAssetDumperState(); - materialConstantState->ExtractNamesFromZone(); - - AbstractAssetDumper::DumpPool(context, pool); -} - -bool AssetDumperMaterial::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperMaterial::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto assetFile = context.OpenAssetFile(material::GetFileNameForAssetName(asset->m_name)); - - if (!assetFile) - return; - - DumpMaterialAsJson(*assetFile, *asset->Asset(), context); -} diff --git a/src/ObjWriting/Game/IW3/Material/DumperMaterialIW3.h b/src/ObjWriting/Game/IW3/Material/DumperMaterialIW3.h deleted file mode 100644 index 8438f6af..00000000 --- a/src/ObjWriting/Game/IW3/Material/DumperMaterialIW3.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/IW3/IW3.h" - -namespace IW3 -{ - class AssetDumperMaterial final : public AbstractAssetDumper - { - public: - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; - - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace IW3 diff --git a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp index 9149fc70..5aa9db1d 100644 --- a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp +++ b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp @@ -1,11 +1,11 @@ #include "ObjWriterIW3.h" #include "Game/IW3/GameAssetPoolIW3.h" +#include "Game/IW3/Material/MaterialJsonDumperIW3.h" #include "Game/IW3/XModel/XModelDumperIW3.h" #include "Image/ImageDumperIW3.h" #include "Localize/LocalizeDumperIW3.h" #include "Maps/MapEntsDumperIW3.h" -#include "Material/DumperMaterialIW3.h" #include "ObjWriting.h" #include "RawFile/AssetDumperRawFile.h" #include "Sound/AssetDumperLoadedSound.h" @@ -28,7 +28,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset, ASSET_TYPE_PHYSPRESET) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) - DUMP_ASSET_POOL(AssetDumperMaterial, m_material, ASSET_TYPE_MATERIAL) + DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) // DUMP_ASSET_POOL(AssetDumperMaterialTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) // DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND) diff --git a/src/ObjWriting/Game/IW4/Material/DecompilingMaterialDumperIW4.h b/src/ObjWriting/Game/IW4/Material/DecompilingMaterialDumperIW4.h deleted file mode 100644 index c6792591..00000000 --- a/src/ObjWriting/Game/IW4/Material/DecompilingMaterialDumperIW4.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include "Dumping/AssetDumpingContext.h" -#include "Game/IW4/IW4.h" -#include "Obj/Gdt/GdtStream.h" - -namespace IW4 -{ - void DecompileMaterialToGdt(GdtOutputStream& out, const Material& material, AssetDumpingContext& context); -} // namespace IW4 diff --git a/src/ObjWriting/Game/IW4/Material/DumperMaterialIW4.cpp b/src/ObjWriting/Game/IW4/Material/DumperMaterialIW4.cpp deleted file mode 100644 index 9d10c301..00000000 --- a/src/ObjWriting/Game/IW4/Material/DumperMaterialIW4.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "DumperMaterialIW4.h" - -#include "DecompilingMaterialDumperIW4.h" -#include "Game/IW4/Material/JsonMaterialWriterIW4.h" -#include "Game/IW4/Material/MaterialConstantZoneStateIW4.h" -#include "Material/MaterialCommon.h" - -using namespace IW4; - -void AssetDumperMaterial::DumpPool(AssetDumpingContext& context, AssetPool* pool) -{ - auto* materialConstantState = context.GetZoneAssetDumperState(); - materialConstantState->ExtractNamesFromZone(); - - AbstractAssetDumper::DumpPool(context, pool); -} - -bool AssetDumperMaterial::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperMaterial::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ -#ifdef EXPERIMENTAL_MATERIAL_COMPILATION - if (context.m_gdt) - { - DecompileMaterialToGdt(*context.m_gdt, *asset->Asset(), context); - } -#else - const auto assetFile = context.OpenAssetFile(material::GetFileNameForAssetName(asset->m_name)); - - if (!assetFile) - return; - - DumpMaterialAsJson(*assetFile, *asset->Asset(), context); -#endif -} diff --git a/src/ObjWriting/Game/IW4/Material/DecompilingMaterialDumperIW4.cpp b/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.cpp similarity index 99% rename from src/ObjWriting/Game/IW4/Material/DecompilingMaterialDumperIW4.cpp rename to src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.cpp index e6a5443d..21ca149e 100644 --- a/src/ObjWriting/Game/IW4/Material/DecompilingMaterialDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.cpp @@ -1,4 +1,4 @@ -#include "DecompilingMaterialDumperIW4.h" +#include "MaterialDecompilingDumperIW4.h" #include "Game/IW4/MaterialConstantsIW4.h" #include "Game/IW4/ObjConstantsIW4.h" @@ -1108,11 +1108,19 @@ namespace }; } // namespace -namespace IW4 +namespace IW4::material { - void DecompileMaterialToGdt(GdtOutputStream& out, const Material& material, AssetDumpingContext& context) + bool DecompilingGdtDumper::ShouldDump(XAssetInfo* asset) { - MaterialGdtDumper dumper(material); - out.WriteEntry(dumper.CreateGdtEntry()); + return true; } -} // namespace IW4 + + void DecompilingGdtDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + if (!context.m_gdt) + return; + + MaterialGdtDumper dumper(*asset->Asset()); + context.m_gdt->WriteEntry(dumper.CreateGdtEntry()); + } +} // namespace IW4::material diff --git a/src/ObjWriting/Game/IW4/Material/DumperMaterialIW4.h b/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.h similarity index 55% rename from src/ObjWriting/Game/IW4/Material/DumperMaterialIW4.h rename to src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.h index 1d3447f3..dd192116 100644 --- a/src/ObjWriting/Game/IW4/Material/DumperMaterialIW4.h +++ b/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.h @@ -3,15 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4 +namespace IW4::material { - class AssetDumperMaterial final : public AbstractAssetDumper + class DecompilingGdtDumper final : public AbstractAssetDumper { - public: - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; - protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4 +} // namespace IW4::material diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 417ec52b..d14504d6 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -1,13 +1,14 @@ #include "ObjWriterIW4.h" #include "Game/IW4/GameAssetPoolIW4.h" +#include "Game/IW4/Material/MaterialJsonDumperIW4.h" #include "Game/IW4/XModel/XModelDumperIW4.h" #include "Image/ImageDumperIW4.h" #include "Leaderboard/LeaderboardJsonDumperIW4.h" #include "LightDef/LightDefDumperIW4.h" #include "Localize/LocalizeDumperIW4.h" #include "Maps/AddonMapEntsDumperIW4.h" -#include "Material/DumperMaterialIW4.h" +#include "Material/MaterialDecompilingDumperIW4.h" #include "Menu/AssetDumperMenuDef.h" #include "Menu/AssetDumperMenuList.h" #include "ObjWriting.h" @@ -42,7 +43,10 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(AssetDumperPhysCollmap, m_phys_collmap, ASSET_TYPE_PHYSCOLLMAP) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) - DUMP_ASSET_POOL(AssetDumperMaterial, m_material, ASSET_TYPE_MATERIAL) + DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) +#ifdef EXPERIMENTAL_MATERIAL_COMPILATION + DUMP_ASSET_POOL(material::DecompilingGdtDumper, m_material, ASSET_TYPE_MATERIAL) +#endif DUMP_ASSET_POOL(AssetDumperPixelShader, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER) DUMP_ASSET_POOL(AssetDumperVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER) DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) diff --git a/src/ObjWriting/Game/IW5/Material/DumperMaterialIW5.cpp b/src/ObjWriting/Game/IW5/Material/DumperMaterialIW5.cpp deleted file mode 100644 index b8e705cb..00000000 --- a/src/ObjWriting/Game/IW5/Material/DumperMaterialIW5.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "DumperMaterialIW5.h" - -#include "Game/IW5/Material/JsonMaterialWriterIW5.h" -#include "Game/IW5/Material/MaterialConstantZoneStateIW5.h" -#include "Material/MaterialCommon.h" - -using namespace IW5; - -void AssetDumperMaterial::DumpPool(AssetDumpingContext& context, AssetPool* pool) -{ - auto* materialConstantState = context.GetZoneAssetDumperState(); - materialConstantState->ExtractNamesFromZone(); - - AbstractAssetDumper::DumpPool(context, pool); -} - -bool AssetDumperMaterial::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperMaterial::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto assetFile = context.OpenAssetFile(material::GetFileNameForAssetName(asset->m_name)); - - if (!assetFile) - return; - - const auto* material = asset->Asset(); - DumpMaterialAsJson(*assetFile, *material, context); -} diff --git a/src/ObjWriting/Game/IW5/Material/DumperMaterialIW5.h b/src/ObjWriting/Game/IW5/Material/DumperMaterialIW5.h deleted file mode 100644 index 12e57790..00000000 --- a/src/ObjWriting/Game/IW5/Material/DumperMaterialIW5.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/IW5/IW5.h" - -namespace IW5 -{ - class AssetDumperMaterial final : public AbstractAssetDumper - { - public: - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; - - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace IW5 diff --git a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp index b08d609f..2e735cb7 100644 --- a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp +++ b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp @@ -1,12 +1,12 @@ #include "ObjWriterIW5.h" #include "Game/IW5/GameAssetPoolIW5.h" +#include "Game/IW5/Material/MaterialJsonDumperIW5.h" #include "Game/IW5/XModel/XModelDumperIW5.h" #include "Image/ImageDumperIW5.h" #include "Leaderboard/LeaderboardJsonDumperIW5.h" #include "Localize/LocalizeDumperIW5.h" #include "Maps/AddonMapEntsDumperIW5.h" -#include "Material/DumperMaterialIW5.h" #include "Menu/AssetDumperMenuDef.h" #include "Menu/AssetDumperMenuList.h" #include "ObjWriting.h" @@ -34,7 +34,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) // DUMP_ASSET_POOL(AssetDumperXModelSurfs, m_xmodel_surfs, ASSET_TYPE_XMODEL_SURFS) DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) - DUMP_ASSET_POOL(AssetDumperMaterial, m_material, ASSET_TYPE_MATERIAL) + DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) // DUMP_ASSET_POOL(AssetDumperMaterialPixelShader, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER) // DUMP_ASSET_POOL(AssetDumperMaterialVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER) // DUMP_ASSET_POOL(AssetDumperMaterialVertexDeclaration, m_material_vertex_decl, ASSET_TYPE_VERTEXDECL) diff --git a/src/ObjWriting/Game/T5/Material/DumperMaterialT5.cpp b/src/ObjWriting/Game/T5/Material/DumperMaterialT5.cpp deleted file mode 100644 index dcc6feb8..00000000 --- a/src/ObjWriting/Game/T5/Material/DumperMaterialT5.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "DumperMaterialT5.h" - -#include "Game/T5/Material/JsonMaterialWriterT5.h" -#include "Game/T5/Material/MaterialConstantZoneStateT5.h" -#include "Material/MaterialCommon.h" - -#include - -using namespace T5; - -void AssetDumperMaterial::DumpPool(AssetDumpingContext& context, AssetPool* pool) -{ - auto* materialConstantState = context.GetZoneAssetDumperState(); - materialConstantState->ExtractNamesFromZone(); - - AbstractAssetDumper::DumpPool(context, pool); -} - -bool AssetDumperMaterial::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperMaterial::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto assetFile = context.OpenAssetFile(material::GetFileNameForAssetName(asset->m_name)); - - if (!assetFile) - return; - - const auto* material = asset->Asset(); - assert(material->info.gameFlags < 0x400); - assert(material->maxStreamedMips == 0); - DumpMaterialAsJson(*assetFile, *material, context); -} diff --git a/src/ObjWriting/Game/T5/Material/DumperMaterialT5.h b/src/ObjWriting/Game/T5/Material/DumperMaterialT5.h deleted file mode 100644 index bb13565c..00000000 --- a/src/ObjWriting/Game/T5/Material/DumperMaterialT5.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/T5/T5.h" - -namespace T5 -{ - class AssetDumperMaterial final : public AbstractAssetDumper - { - public: - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; - - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace T5 diff --git a/src/ObjWriting/Game/T5/ObjWriterT5.cpp b/src/ObjWriting/Game/T5/ObjWriterT5.cpp index 7528ea67..1660e0d1 100644 --- a/src/ObjWriting/Game/T5/ObjWriterT5.cpp +++ b/src/ObjWriting/Game/T5/ObjWriterT5.cpp @@ -1,10 +1,10 @@ #include "ObjWriterT5.h" #include "Game/T5/GameAssetPoolT5.h" +#include "Game/T5/Material/MaterialJsonDumperT5.h" #include "Game/T5/XModel/XModelDumperT5.h" #include "Image/ImageDumperT5.h" #include "Localize/LocalizeDumperT5.h" -#include "Material/DumperMaterialT5.h" #include "ObjWriting.h" #include "PhysConstraints/AssetDumperPhysConstraints.h" #include "PhysPreset/AssetDumperPhysPreset.h" @@ -31,7 +31,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperDestructibleDef, m_destructible_def, ASSET_TYPE_DESTRUCTIBLEDEF) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) - DUMP_ASSET_POOL(AssetDumperMaterial, m_material, ASSET_TYPE_MATERIAL) + DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) // DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) // DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank, ASSET_TYPE_SOUND) diff --git a/src/ObjWriting/Game/T6/Material/DumperMaterialT6.cpp b/src/ObjWriting/Game/T6/Material/DumperMaterialT6.cpp deleted file mode 100644 index 56e11e97..00000000 --- a/src/ObjWriting/Game/T6/Material/DumperMaterialT6.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "DumperMaterialT6.h" - -#include "Game/T6/Material/JsonMaterialWriterT6.h" -#include "Game/T6/Material/MaterialConstantZoneStateT6.h" -#include "Material/MaterialCommon.h" - -#include - -using namespace T6; - -void AssetDumperMaterial::DumpPool(AssetDumpingContext& context, AssetPool* pool) -{ - auto* materialConstantState = context.GetZoneAssetDumperState(); - materialConstantState->ExtractNamesFromZone(); - - AbstractAssetDumper::DumpPool(context, pool); -} - -bool AssetDumperMaterial::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperMaterial::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto assetFile = context.OpenAssetFile(material::GetFileNameForAssetName(asset->m_name)); - - if (!assetFile) - return; - - const auto* material = asset->Asset(); - assert(material->info.gameFlags < 0x8000); - assert(material->info.hashIndex == 0); - assert(material->probeMipBits == 0); - DumpMaterialAsJson(*assetFile, *material, context); -} diff --git a/src/ObjWriting/Game/T6/Material/DumperMaterialT6.h b/src/ObjWriting/Game/T6/Material/DumperMaterialT6.h deleted file mode 100644 index 99de31e7..00000000 --- a/src/ObjWriting/Game/T6/Material/DumperMaterialT6.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/T6/T6.h" - -namespace T6 -{ - class AssetDumperMaterial final : public AbstractAssetDumper - { - public: - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; - - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace T6 diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 54dc5056..c32e8ac0 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -2,12 +2,12 @@ #include "FontIcon/FontIconDumperT6.h" #include "Game/T6/GameAssetPoolT6.h" +#include "Game/T6/Material/MaterialJsonDumperT6.h" #include "Game/T6/XModel/XModelDumperT6.h" #include "Image/ImageDumperT6.h" #include "Leaderboard/LeaderboardJsonDumperT6.h" #include "Localize/LocalizeDumperT6.h" #include "Maps/MapEntsDumperT6.h" -#include "Material/DumperMaterialT6.h" #include "ObjWriting.h" #include "PhysConstraints/AssetDumperPhysConstraints.h" #include "PhysPreset/AssetDumperPhysPreset.h" @@ -51,7 +51,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperDestructibleDef, m_destructible_def, ASSET_TYPE_DESTRUCTIBLEDEF) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) - DUMP_ASSET_POOL(AssetDumperMaterial, m_material, ASSET_TYPE_MATERIAL) + DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank, ASSET_TYPE_SOUND) diff --git a/src/ObjWriting/Material/JsonMaterialWriter.h.template b/src/ObjWriting/Material/JsonMaterialWriter.h.template deleted file mode 100644 index 277c5420..00000000 --- a/src/ObjWriting/Material/JsonMaterialWriter.h.template +++ /dev/null @@ -1,20 +0,0 @@ -#options GAME (IW3, IW4, IW5, T5, T6) - -#filename "Game/" + GAME + "/Material/JsonMaterialWriter" + GAME + ".h" - -// This file was templated. -// See JsonMaterialWriter.h.template. -// Do not modify, changes will be lost. - -#pragma once - -#include "Dumping/AssetDumpingContext.h" -#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\"" -#include GAME_HEADER - -#include - -namespace GAME -{ - void DumpMaterialAsJson(std::ostream& stream, const Material& material, AssetDumpingContext& context); -} // namespace GAME diff --git a/src/ObjWriting/Material/JsonMaterialWriter.cpp.template b/src/ObjWriting/Material/MaterialJsonDumper.cpp.template similarity index 90% rename from src/ObjWriting/Material/JsonMaterialWriter.cpp.template rename to src/ObjWriting/Material/MaterialJsonDumper.cpp.template index 4cce4829..817788f0 100644 --- a/src/ObjWriting/Material/JsonMaterialWriter.cpp.template +++ b/src/ObjWriting/Material/MaterialJsonDumper.cpp.template @@ -1,6 +1,6 @@ #options GAME (IW3, IW4, IW5, T5, T6) -#filename "Game/" + GAME + "/Material/JsonMaterialWriter" + GAME + ".cpp" +#filename "Game/" + GAME + "/Material/MaterialJsonDumper" + GAME + ".cpp" #if GAME == "IW3" #define FEATURE_IW3 @@ -24,16 +24,17 @@ #endif // This file was templated. -// See JsonMaterialWriter.cpp.template. +// See MaterialJsonDumper.cpp.template. // Do not modify, changes will be lost. -#set WRITER_HEADER "\"JsonMaterialWriter" + GAME + ".h\"" +#set WRITER_HEADER "\"MaterialJsonDumper" + GAME + ".h\"" #include WRITER_HEADER #ifdef HAS_WATER #include "Base64.h" #endif +#include "Material/MaterialCommon.h" #set COMMON_HEADER "\"Game/" + GAME + "/Common" + GAME + ".h\"" #include COMMON_HEADER #set JSON_HEADER "\"Game/" + GAME + "/Material/JsonMaterial" + GAME + ".h\"" @@ -41,18 +42,20 @@ #set CONSTANTS_HEADER "\"Game/" + GAME + "/Material/MaterialConstantZoneState" + GAME + ".h\"" #include CONSTANTS_HEADER +#include #include #include using namespace nlohmann; using namespace GAME; +using namespace ::material; namespace { - class JsonDumper + class JsonDumperImpl { public: - JsonDumper(AssetDumpingContext& context, std::ostream& stream) + JsonDumperImpl(AssetDumpingContext& context, std::ostream& stream) : m_stream(stream), m_material_constants(*context.GetZoneAssetDumperState()) { @@ -355,11 +358,40 @@ namespace }; } // namespace -namespace GAME +namespace GAME::material { - void DumpMaterialAsJson(std::ostream& stream, const Material& material, AssetDumpingContext& context) + void JsonDumper::DumpPool(AssetDumpingContext& context, AssetPool* pool) { - const JsonDumper dumper(context, stream); - dumper.Dump(material); + auto* materialConstantState = context.GetZoneAssetDumperState(); + materialConstantState->ExtractNamesFromZone(); + + AbstractAssetDumper::DumpPool(context, pool); } -} // namespace GAME + + bool JsonDumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void JsonDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name)); + + if (!assetFile) + return; + + const auto* material = asset->Asset(); +#if defined(FEATURE_T5) + assert(material->info.gameFlags < 0x400); + assert(material->maxStreamedMips == 0); +#elif defined(FEATURE_T6) + assert(material->info.gameFlags < 0x8000); + assert(material->info.hashIndex == 0); + assert(material->probeMipBits == 0); +#endif + + JsonDumperImpl dumper(context, *assetFile); + dumper.Dump(*material); + } +} // namespace T6::leaderboard + diff --git a/src/ObjWriting/Material/MaterialJsonDumper.h.template b/src/ObjWriting/Material/MaterialJsonDumper.h.template new file mode 100644 index 00000000..a9677b77 --- /dev/null +++ b/src/ObjWriting/Material/MaterialJsonDumper.h.template @@ -0,0 +1,27 @@ +#options GAME(IW3, IW4, IW5, T5, T6) + +#filename "Game/" + GAME + "/Material/MaterialJsonDumper" + GAME + ".h" + +// This file was templated. +// See MaterialJsonDumper.h.template. +// Do not modify, changes will be lost. + +#pragma once + +#include "Dumping/AbstractAssetDumper.h" +#include "Dumping/AssetDumpingContext.h" +#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\"" +#include GAME_HEADER + +namespace GAME::material +{ + class JsonDumper final : public AbstractAssetDumper + { + public: + void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; + + protected: + [[nodiscard]] bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + }; +} // namespace GAME::material diff --git a/test/ObjWritingTests.lua b/test/ObjWritingTests.lua index 8afcba6c..cda98707 100644 --- a/test/ObjWritingTests.lua +++ b/test/ObjWritingTests.lua @@ -3,6 +3,7 @@ ObjWritingTests = {} function ObjWritingTests:include(includes) if includes:handle(self:name()) then includedirs { + "%{wks.location}/src/ObjWriting", path.join(TestFolder(), "ObjWritingTests") } end diff --git a/test/ObjWritingTests/Game/IW3/Material/DumperMaterialIW3Test.cpp b/test/ObjWritingTests/Game/IW3/Material/MaterialJsonDumperIW3.cpp similarity index 99% rename from test/ObjWritingTests/Game/IW3/Material/DumperMaterialIW3Test.cpp rename to test/ObjWritingTests/Game/IW3/Material/MaterialJsonDumperIW3.cpp index 077cbe13..e09856ba 100644 --- a/test/ObjWritingTests/Game/IW3/Material/DumperMaterialIW3Test.cpp +++ b/test/ObjWritingTests/Game/IW3/Material/MaterialJsonDumperIW3.cpp @@ -1,4 +1,4 @@ -#include "Game/IW3/Material/DumperMaterialIW3.h" +#include "Game/IW3/Material/MaterialJsonDumperIW3.h" #include "Asset/AssetRegistration.h" #include "Game/IW3/CommonIW3.h" @@ -562,7 +562,7 @@ namespace GivenMaterial("wc/ch_plasterwall_long", materialPool, memory); - AssetDumperMaterial dumper; + material::JsonDumper dumper; dumper.DumpPool(context, &materialPool); const auto* file = mockOutput.GetMockedFile("materials/wc/ch_plasterwall_long.json"); diff --git a/test/ObjWritingTests/Game/IW4/Material/DumperMaterialIW4Test.cpp b/test/ObjWritingTests/Game/IW4/Material/MaterialJsonDumperIW4.cpp similarity index 99% rename from test/ObjWritingTests/Game/IW4/Material/DumperMaterialIW4Test.cpp rename to test/ObjWritingTests/Game/IW4/Material/MaterialJsonDumperIW4.cpp index 39b264a7..c2268aff 100644 --- a/test/ObjWritingTests/Game/IW4/Material/DumperMaterialIW4Test.cpp +++ b/test/ObjWritingTests/Game/IW4/Material/MaterialJsonDumperIW4.cpp @@ -1,4 +1,4 @@ -#include "Game/IW4/Material/DumperMaterialIW4.h" +#include "Game/IW4/Material/MaterialJsonDumperIW4.h" #include "Asset/AssetRegistration.h" #include "Game/IW4/CommonIW4.h" @@ -543,7 +543,7 @@ namespace GivenMaterial("mc/ch_rubble01", materialPool, memory); - AssetDumperMaterial dumper; + material::JsonDumper dumper; dumper.DumpPool(context, &materialPool); const auto* file = mockOutput.GetMockedFile("materials/mc/ch_rubble01.json"); diff --git a/test/ObjWritingTests/Game/IW5/Material/DumperMaterialIW5Test.cpp b/test/ObjWritingTests/Game/IW5/Material/MaterialJsonDumperIW5.cpp similarity index 99% rename from test/ObjWritingTests/Game/IW5/Material/DumperMaterialIW5Test.cpp rename to test/ObjWritingTests/Game/IW5/Material/MaterialJsonDumperIW5.cpp index f8c15582..a40a1e2e 100644 --- a/test/ObjWritingTests/Game/IW5/Material/DumperMaterialIW5Test.cpp +++ b/test/ObjWritingTests/Game/IW5/Material/MaterialJsonDumperIW5.cpp @@ -1,4 +1,4 @@ -#include "Game/IW5/Material/DumperMaterialIW5.h" +#include "Game/IW5/Material/MaterialJsonDumperIW5.h" #include "Asset/AssetRegistration.h" #include "Game/IW5/CommonIW5.h" @@ -596,7 +596,7 @@ namespace GivenMaterial("wc/me_metal_rust_02", materialPool, memory); - AssetDumperMaterial dumper; + material::JsonDumper dumper; dumper.DumpPool(context, &materialPool); const auto* file = mockOutput.GetMockedFile("materials/wc/me_metal_rust_02.json"); diff --git a/test/ObjWritingTests/Game/T5/Material/DumperMaterialT5Test.cpp b/test/ObjWritingTests/Game/T5/Material/MaterialJsonDumperT5.cpp similarity index 99% rename from test/ObjWritingTests/Game/T5/Material/DumperMaterialT5Test.cpp rename to test/ObjWritingTests/Game/T5/Material/MaterialJsonDumperT5.cpp index 4cc56013..aa5d230b 100644 --- a/test/ObjWritingTests/Game/T5/Material/DumperMaterialT5Test.cpp +++ b/test/ObjWritingTests/Game/T5/Material/MaterialJsonDumperT5.cpp @@ -1,4 +1,4 @@ -#include "Game/T5/Material/DumperMaterialT5.h" +#include "Game/T5/Material/MaterialJsonDumperT5.h" #include "Asset/AssetRegistration.h" #include "Game/T5/CommonT5.h" @@ -625,7 +625,7 @@ namespace GivenMaterial("mc/ch_rubble01", materialPool, memory); - AssetDumperMaterial dumper; + material::JsonDumper dumper; dumper.DumpPool(context, &materialPool); const auto* file = mockOutput.GetMockedFile("materials/mc/ch_rubble01.json"); diff --git a/test/ObjWritingTests/Game/T6/Material/DumperMaterialT6Test.cpp b/test/ObjWritingTests/Game/T6/Material/MaterialJsonDumperT6Test.cpp similarity index 99% rename from test/ObjWritingTests/Game/T6/Material/DumperMaterialT6Test.cpp rename to test/ObjWritingTests/Game/T6/Material/MaterialJsonDumperT6Test.cpp index 2586760d..db8dc42a 100644 --- a/test/ObjWritingTests/Game/T6/Material/DumperMaterialT6Test.cpp +++ b/test/ObjWritingTests/Game/T6/Material/MaterialJsonDumperT6Test.cpp @@ -1,4 +1,4 @@ -#include "Game/T6/Material/DumperMaterialT6.h" +#include "Game/T6/Material/MaterialJsonDumperT6.h" #include "Asset/AssetRegistration.h" #include "Game/T6/CommonT6.h" @@ -472,7 +472,7 @@ namespace AssetPoolDynamic materialPool(0); GivenMaterial("wpc/metal_ac_duct", materialPool, memory); - AssetDumperMaterial dumper; + material::JsonDumper dumper; dumper.DumpPool(context, &materialPool); const auto* file = mockOutput.GetMockedFile("materials/wpc/metal_ac_duct.json"); From d4ab0c43140369f7a8a5dfeeae6e44ed2e30de30 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Wed, 30 Jul 2025 18:25:01 +0100 Subject: [PATCH 11/35] refactor: streamline phys constraints dumping --- .../PhysConstraints/PhysConstraintsCommon.cpp | 11 +++ .../PhysConstraints/PhysConstraintsCommon.h | 8 ++ .../RawLoaderPhysConstraintsT6.cpp | 3 +- src/ObjWriting/Game/T5/ObjWriterT5.cpp | 1 - .../AssetDumperPhysConstraints.cpp | 0 .../AssetDumperPhysConstraints.h | 0 src/ObjWriting/Game/T6/ObjWriterT6.cpp | 4 +- .../AssetDumperPhysConstraints.cpp | 88 ------------------ .../PhysConstraintsInfoStringDumperT6.cpp | 93 +++++++++++++++++++ ....h => PhysConstraintsInfoStringDumperT6.h} | 8 +- 10 files changed, 119 insertions(+), 97 deletions(-) create mode 100644 src/ObjCommon/PhysConstraints/PhysConstraintsCommon.cpp create mode 100644 src/ObjCommon/PhysConstraints/PhysConstraintsCommon.h delete mode 100644 src/ObjWriting/Game/T5/PhysConstraints/AssetDumperPhysConstraints.cpp delete mode 100644 src/ObjWriting/Game/T5/PhysConstraints/AssetDumperPhysConstraints.h delete mode 100644 src/ObjWriting/Game/T6/PhysConstraints/AssetDumperPhysConstraints.cpp create mode 100644 src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.cpp rename src/ObjWriting/Game/T6/PhysConstraints/{AssetDumperPhysConstraints.h => PhysConstraintsInfoStringDumperT6.h} (60%) diff --git a/src/ObjCommon/PhysConstraints/PhysConstraintsCommon.cpp b/src/ObjCommon/PhysConstraints/PhysConstraintsCommon.cpp new file mode 100644 index 00000000..222a2615 --- /dev/null +++ b/src/ObjCommon/PhysConstraints/PhysConstraintsCommon.cpp @@ -0,0 +1,11 @@ +#include "PhysConstraintsCommon.h" + +#include + +namespace phys_constraints +{ + std::string GetFileNameForAssetName(const std::string& assetName) + { + return std::format("physconstraints/{}", assetName); + } +} // namespace phys_constraints diff --git a/src/ObjCommon/PhysConstraints/PhysConstraintsCommon.h b/src/ObjCommon/PhysConstraints/PhysConstraintsCommon.h new file mode 100644 index 00000000..90ccfb1c --- /dev/null +++ b/src/ObjCommon/PhysConstraints/PhysConstraintsCommon.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace phys_constraints +{ + std::string GetFileNameForAssetName(const std::string& assetName); +} diff --git a/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.cpp b/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.cpp index 607a3c82..0555c180 100644 --- a/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.cpp +++ b/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.cpp @@ -4,6 +4,7 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" #include "InfoStringLoaderPhysConstraintsT6.h" +#include "PhysConstraints/PhysConstraintsCommon.h" #include #include @@ -24,7 +25,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = std::format("physconstraints/{}", assetName); + const auto fileName = phys_constraints::GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); diff --git a/src/ObjWriting/Game/T5/ObjWriterT5.cpp b/src/ObjWriting/Game/T5/ObjWriterT5.cpp index 1660e0d1..b12857e8 100644 --- a/src/ObjWriting/Game/T5/ObjWriterT5.cpp +++ b/src/ObjWriting/Game/T5/ObjWriterT5.cpp @@ -6,7 +6,6 @@ #include "Image/ImageDumperT5.h" #include "Localize/LocalizeDumperT5.h" #include "ObjWriting.h" -#include "PhysConstraints/AssetDumperPhysConstraints.h" #include "PhysPreset/AssetDumperPhysPreset.h" #include "RawFile/AssetDumperRawFile.h" #include "Sound/AssetDumperSndBank.h" diff --git a/src/ObjWriting/Game/T5/PhysConstraints/AssetDumperPhysConstraints.cpp b/src/ObjWriting/Game/T5/PhysConstraints/AssetDumperPhysConstraints.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/src/ObjWriting/Game/T5/PhysConstraints/AssetDumperPhysConstraints.h b/src/ObjWriting/Game/T5/PhysConstraints/AssetDumperPhysConstraints.h deleted file mode 100644 index e69de29b..00000000 diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index c32e8ac0..3aeaf091 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -9,7 +9,7 @@ #include "Localize/LocalizeDumperT6.h" #include "Maps/MapEntsDumperT6.h" #include "ObjWriting.h" -#include "PhysConstraints/AssetDumperPhysConstraints.h" +#include "PhysConstraints/PhysConstraintsInfoStringDumperT6.h" #include "PhysPreset/AssetDumperPhysPreset.h" #include "Qdb/AssetDumperQdb.h" #include "RawFile/AssetDumperRawFile.h" @@ -47,7 +47,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const const auto* assetPools = dynamic_cast(context.m_zone.m_pools.get()); DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset, ASSET_TYPE_PHYSPRESET) - DUMP_ASSET_POOL(AssetDumperPhysConstraints, m_phys_constraints, ASSET_TYPE_PHYSCONSTRAINTS) + DUMP_ASSET_POOL(phys_constraints::InfoStringDumper, m_phys_constraints, ASSET_TYPE_PHYSCONSTRAINTS) // DUMP_ASSET_POOL(AssetDumperDestructibleDef, m_destructible_def, ASSET_TYPE_DESTRUCTIBLEDEF) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) diff --git a/src/ObjWriting/Game/T6/PhysConstraints/AssetDumperPhysConstraints.cpp b/src/ObjWriting/Game/T6/PhysConstraints/AssetDumperPhysConstraints.cpp deleted file mode 100644 index 7be1250a..00000000 --- a/src/ObjWriting/Game/T6/PhysConstraints/AssetDumperPhysConstraints.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "AssetDumperPhysConstraints.h" - -#include "Game/T6/InfoString/InfoStringFromStructConverter.h" -#include "Game/T6/ObjConstantsT6.h" -#include "Game/T6/PhysConstraints/PhysConstraintsFields.h" - -#include -#include - -using namespace T6; - -namespace T6 -{ - class InfoStringFromPhysConstraintsConverter final : public InfoStringFromStructConverter - { - protected: - void FillFromExtensionField(const cspField_t& field) override - { - switch (static_cast(field.iFieldType)) - { - case CFT_TYPE: - FillFromEnumInt(std::string(field.szName), field.iOffset, s_constraintTypeNames, std::extent_v); - break; - - default: - assert(false); - break; - } - } - - public: - InfoStringFromPhysConstraintsConverter(const PhysConstraints* structure, - const cspField_t* fields, - const size_t fieldCount, - std::function scriptStringValueCallback) - : InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback)) - { - } - }; -} // namespace T6 - -InfoString AssetDumperPhysConstraints::CreateInfoString(XAssetInfo* asset) -{ - assert(asset->Asset()->count <= 4); - - InfoStringFromPhysConstraintsConverter converter(asset->Asset(), - phys_constraints_fields, - std::extent_v, - [asset](const scr_string_t scrStr) -> std::string - { - assert(scrStr < asset->m_zone->m_script_strings.Count()); - if (scrStr >= asset->m_zone->m_script_strings.Count()) - return ""; - - return asset->m_zone->m_script_strings[scrStr]; - }); - - return converter.Convert(); -} - -bool AssetDumperPhysConstraints::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperPhysConstraints::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - // Only dump raw when no gdt available - if (context.m_gdt) - { - const auto infoString = CreateInfoString(asset); - GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_PHYS_CONSTRAINTS); - infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_PHYS_CONSTRAINTS, gdtEntry); - context.m_gdt->WriteEntry(gdtEntry); - } - else - { - const auto assetFile = context.OpenAssetFile("physconstraints/" + asset->m_name); - - if (!assetFile) - return; - - auto& stream = *assetFile; - const auto infoString = CreateInfoString(asset); - const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_PHYS_CONSTRAINTS); - stream.write(stringValue.c_str(), stringValue.size()); - } -} diff --git a/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.cpp b/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.cpp new file mode 100644 index 00000000..e34862e8 --- /dev/null +++ b/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.cpp @@ -0,0 +1,93 @@ +#include "PhysConstraintsInfoStringDumperT6.h" + +#include "Game/T6/InfoString/InfoStringFromStructConverter.h" +#include "Game/T6/ObjConstantsT6.h" +#include "Game/T6/PhysConstraints/PhysConstraintsFields.h" +#include "PhysConstraints/PhysConstraintsCommon.h" + +#include +#include + +using namespace T6; +using namespace ::phys_constraints; + +namespace +{ + class InfoStringFromPhysConstraintsConverter final : public InfoStringFromStructConverter + { + protected: + void FillFromExtensionField(const cspField_t& field) override + { + switch (static_cast(field.iFieldType)) + { + case CFT_TYPE: + FillFromEnumInt(std::string(field.szName), field.iOffset, s_constraintTypeNames, std::extent_v); + break; + + default: + assert(false); + break; + } + } + + public: + InfoStringFromPhysConstraintsConverter(const PhysConstraints* structure, + const cspField_t* fields, + const size_t fieldCount, + std::function scriptStringValueCallback) + : InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback)) + { + } + }; + + InfoString CreateInfoString(XAssetInfo* asset) + { + assert(asset->Asset()->count <= 4); + + InfoStringFromPhysConstraintsConverter converter(asset->Asset(), + phys_constraints_fields, + std::extent_v, + [asset](const scr_string_t scrStr) -> std::string + { + assert(scrStr < asset->m_zone->m_script_strings.Count()); + if (scrStr >= asset->m_zone->m_script_strings.Count()) + return ""; + + return asset->m_zone->m_script_strings[scrStr]; + }); + + return converter.Convert(); + } +} // namespace + +namespace T6::phys_constraints +{ + bool InfoStringDumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void InfoStringDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + // Only dump raw when no gdt available + if (context.m_gdt) + { + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_PHYS_CONSTRAINTS); + infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_PHYS_CONSTRAINTS, gdtEntry); + context.m_gdt->WriteEntry(gdtEntry); + } + else + { + const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name)); + + if (!assetFile) + return; + + auto& stream = *assetFile; + const auto infoString = CreateInfoString(asset); + const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_PHYS_CONSTRAINTS); + stream.write(stringValue.c_str(), stringValue.size()); + } + } +} // namespace T6::phys_constraints diff --git a/src/ObjWriting/Game/T6/PhysConstraints/AssetDumperPhysConstraints.h b/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.h similarity index 60% rename from src/ObjWriting/Game/T6/PhysConstraints/AssetDumperPhysConstraints.h rename to src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.h index 8f3d938e..2af16570 100644 --- a/src/ObjWriting/Game/T6/PhysConstraints/AssetDumperPhysConstraints.h +++ b/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.h @@ -4,14 +4,12 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" -namespace T6 +namespace T6::phys_constraints { - class AssetDumperPhysConstraints final : public AbstractAssetDumper + class InfoStringDumper final : public AbstractAssetDumper { - static InfoString CreateInfoString(XAssetInfo* asset); - protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6 +} // namespace T6::phys_constraints From 24c9e08046e82ff62a4bb2efe44e0018c7cd4a32 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Wed, 30 Jul 2025 18:48:59 +0100 Subject: [PATCH 12/35] refactor: streamline phys preset dumping --- src/ObjCommon/PhysPreset/PhysPresetCommon.cpp | 11 ++ src/ObjCommon/PhysPreset/PhysPresetCommon.h | 8 ++ .../IW4/PhysPreset/RawLoaderPhysPresetIW4.cpp | 3 +- .../T6/PhysPreset/RawLoaderPhysPresetT6.cpp | 3 +- src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 4 +- .../IW4/PhysPreset/AssetDumperPhysPreset.cpp | 107 ---------------- .../PhysPresetInfoStringDumperIW4.cpp | 112 +++++++++++++++++ ...eset.h => PhysPresetInfoStringDumperIW4.h} | 7 +- src/ObjWriting/Game/T5/ObjWriterT5.cpp | 1 - .../T5/PhysPreset/AssetDumperPhysPreset.cpp | 0 .../T5/PhysPreset/AssetDumperPhysPreset.h | 0 src/ObjWriting/Game/T6/ObjWriterT6.cpp | 4 +- .../T6/PhysPreset/AssetDumperPhysPreset.cpp | 109 ----------------- .../PhysPresetInfoStringDumperT6.cpp | 114 ++++++++++++++++++ ...reset.h => PhysPresetInfoStringDumperT6.h} | 9 +- 15 files changed, 258 insertions(+), 234 deletions(-) create mode 100644 src/ObjCommon/PhysPreset/PhysPresetCommon.cpp create mode 100644 src/ObjCommon/PhysPreset/PhysPresetCommon.h delete mode 100644 src/ObjWriting/Game/IW4/PhysPreset/AssetDumperPhysPreset.cpp create mode 100644 src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.cpp rename src/ObjWriting/Game/IW4/PhysPreset/{AssetDumperPhysPreset.h => PhysPresetInfoStringDumperIW4.h} (54%) delete mode 100644 src/ObjWriting/Game/T5/PhysPreset/AssetDumperPhysPreset.cpp delete mode 100644 src/ObjWriting/Game/T5/PhysPreset/AssetDumperPhysPreset.h delete mode 100644 src/ObjWriting/Game/T6/PhysPreset/AssetDumperPhysPreset.cpp create mode 100644 src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.cpp rename src/ObjWriting/Game/T6/PhysPreset/{AssetDumperPhysPreset.h => PhysPresetInfoStringDumperT6.h} (51%) diff --git a/src/ObjCommon/PhysPreset/PhysPresetCommon.cpp b/src/ObjCommon/PhysPreset/PhysPresetCommon.cpp new file mode 100644 index 00000000..66c08396 --- /dev/null +++ b/src/ObjCommon/PhysPreset/PhysPresetCommon.cpp @@ -0,0 +1,11 @@ +#include "PhysPresetCommon.h" + +#include + +namespace phys_preset +{ + std::string GetFileNameForAssetName(const std::string& assetName) + { + return std::format("physic/{}", assetName); + } +} // namespace phys_preset diff --git a/src/ObjCommon/PhysPreset/PhysPresetCommon.h b/src/ObjCommon/PhysPreset/PhysPresetCommon.h new file mode 100644 index 00000000..d627051c --- /dev/null +++ b/src/ObjCommon/PhysPreset/PhysPresetCommon.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace phys_preset +{ + std::string GetFileNameForAssetName(const std::string& assetName); +} diff --git a/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.cpp b/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.cpp index ada031ac..11bd6813 100644 --- a/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.cpp +++ b/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.cpp @@ -4,6 +4,7 @@ #include "Game/IW4/ObjConstantsIW4.h" #include "InfoString/InfoString.h" #include "InfoStringLoaderPhysPresetIW4.h" +#include "PhysPreset/PhysPresetCommon.h" #include #include @@ -19,7 +20,7 @@ RawLoaderPhysPreset::RawLoaderPhysPreset(MemoryManager& memory, ISearchPath& sea AssetCreationResult RawLoaderPhysPreset::CreateAsset(const std::string& assetName, AssetCreationContext& context) { - const auto fileName = std::format("physic/{}", assetName); + const auto fileName = phys_preset::GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); diff --git a/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.cpp b/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.cpp index 4fe78db8..237ccbc8 100644 --- a/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.cpp +++ b/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.cpp @@ -4,6 +4,7 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" #include "InfoStringLoaderPhysPresetT6.h" +#include "PhysPreset/PhysPresetCommon.h" #include #include @@ -24,7 +25,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = std::format("physic/{}", assetName); + const auto fileName = phys_preset::GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index d14504d6..4dd466d9 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -13,7 +13,7 @@ #include "Menu/AssetDumperMenuList.h" #include "ObjWriting.h" #include "PhysCollmap/AssetDumperPhysCollmap.h" -#include "PhysPreset/AssetDumperPhysPreset.h" +#include "PhysPreset/PhysPresetInfoStringDumperIW4.h" #include "RawFile/AssetDumperRawFile.h" #include "Shader/AssetDumperPixelShader.h" #include "Shader/AssetDumperVertexShader.h" @@ -39,7 +39,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const const auto* assetPools = dynamic_cast(context.m_zone.m_pools.get()); - DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset, ASSET_TYPE_PHYSPRESET) + DUMP_ASSET_POOL(phys_preset::InfoStringDumper, m_phys_preset, ASSET_TYPE_PHYSPRESET) DUMP_ASSET_POOL(AssetDumperPhysCollmap, m_phys_collmap, ASSET_TYPE_PHYSCOLLMAP) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) diff --git a/src/ObjWriting/Game/IW4/PhysPreset/AssetDumperPhysPreset.cpp b/src/ObjWriting/Game/IW4/PhysPreset/AssetDumperPhysPreset.cpp deleted file mode 100644 index bfd6d990..00000000 --- a/src/ObjWriting/Game/IW4/PhysPreset/AssetDumperPhysPreset.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include "AssetDumperPhysPreset.h" - -#include "Game/IW4/InfoString/InfoStringFromStructConverter.h" -#include "Game/IW4/ObjConstantsIW4.h" -#include "Game/IW4/PhysPreset/PhysPresetFields.h" - -#include -#include -#include -#include - -using namespace IW4; - -namespace IW4 -{ - class InfoStringFromPhysPresetConverter final : public InfoStringFromStructConverter - { - protected: - void FillFromExtensionField(const cspField_t& field) override - { - assert(false); - } - - public: - InfoStringFromPhysPresetConverter(const PhysPresetInfo* structure, - const cspField_t* fields, - const size_t fieldCount, - std::function scriptStringValueCallback) - : InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback)) - { - } - }; -} // namespace IW4 - -void AssetDumperPhysPreset::CopyToPhysPresetInfo(const PhysPreset* physPreset, PhysPresetInfo* physPresetInfo) -{ - physPresetInfo->mass = std::clamp(physPreset->mass * 1000.0f, 1.0f, 2000.0f); - physPresetInfo->bounce = physPreset->bounce; - - if (std::isinf(physPreset->friction)) - { - physPresetInfo->isFrictionInfinity = 1; - physPresetInfo->friction = 0; - } - else - { - physPresetInfo->isFrictionInfinity = 0; - physPresetInfo->friction = physPreset->friction; - } - - physPresetInfo->bulletForceScale = physPreset->bulletForceScale; - physPresetInfo->explosiveForceScale = physPreset->explosiveForceScale; - physPresetInfo->sndAliasPrefix = physPreset->sndAliasPrefix; - physPresetInfo->piecesSpreadFraction = physPreset->piecesSpreadFraction; - physPresetInfo->piecesUpwardVelocity = physPreset->piecesUpwardVelocity; - physPresetInfo->tempDefaultToCylinder = physPreset->tempDefaultToCylinder ? 1 : 0; - physPresetInfo->perSurfaceSndAlias = physPreset->perSurfaceSndAlias ? 1 : 0; -} - -InfoString AssetDumperPhysPreset::CreateInfoString(XAssetInfo* asset) -{ - auto* physPresetInfo = new PhysPresetInfo; - CopyToPhysPresetInfo(asset->Asset(), physPresetInfo); - - InfoStringFromPhysPresetConverter converter(physPresetInfo, - phys_preset_fields, - std::extent_v, - [asset](const scr_string_t scrStr) -> std::string - { - assert(scrStr < asset->m_zone->m_script_strings.Count()); - if (scrStr >= asset->m_zone->m_script_strings.Count()) - return ""; - - return asset->m_zone->m_script_strings[scrStr]; - }); - - return converter.Convert(); -} - -bool AssetDumperPhysPreset::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperPhysPreset::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - // Only dump raw when no gdt available - if (context.m_gdt) - { - const auto infoString = CreateInfoString(asset); - GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_PHYS_PRESET); - infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_PHYS_PRESET, gdtEntry); - context.m_gdt->WriteEntry(gdtEntry); - } - else - { - const auto assetFile = context.OpenAssetFile("physic/" + asset->m_name); - - if (!assetFile) - return; - - auto& stream = *assetFile; - const auto infoString = CreateInfoString(asset); - const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_PHYS_PRESET); - stream.write(stringValue.c_str(), stringValue.size()); - } -} diff --git a/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.cpp b/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.cpp new file mode 100644 index 00000000..734bd8d8 --- /dev/null +++ b/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.cpp @@ -0,0 +1,112 @@ +#include "PhysPresetInfoStringDumperIW4.h" + +#include "Game/IW4/InfoString/InfoStringFromStructConverter.h" +#include "Game/IW4/ObjConstantsIW4.h" +#include "Game/IW4/PhysPreset/PhysPresetFields.h" +#include "PhysPreset/PhysPresetCommon.h" + +#include +#include +#include +#include + +using namespace IW4; +using namespace ::phys_preset; + +namespace +{ + class InfoStringFromPhysPresetConverter final : public InfoStringFromStructConverter + { + protected: + void FillFromExtensionField(const cspField_t& field) override + { + assert(false); + } + + public: + InfoStringFromPhysPresetConverter(const PhysPresetInfo* structure, + const cspField_t* fields, + const size_t fieldCount, + std::function scriptStringValueCallback) + : InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback)) + { + } + }; + + void CopyToPhysPresetInfo(const PhysPreset* physPreset, PhysPresetInfo* physPresetInfo) + { + physPresetInfo->mass = std::clamp(physPreset->mass * 1000.0f, 1.0f, 2000.0f); + physPresetInfo->bounce = physPreset->bounce; + + if (std::isinf(physPreset->friction)) + { + physPresetInfo->isFrictionInfinity = 1; + physPresetInfo->friction = 0; + } + else + { + physPresetInfo->isFrictionInfinity = 0; + physPresetInfo->friction = physPreset->friction; + } + + physPresetInfo->bulletForceScale = physPreset->bulletForceScale; + physPresetInfo->explosiveForceScale = physPreset->explosiveForceScale; + physPresetInfo->sndAliasPrefix = physPreset->sndAliasPrefix; + physPresetInfo->piecesSpreadFraction = physPreset->piecesSpreadFraction; + physPresetInfo->piecesUpwardVelocity = physPreset->piecesUpwardVelocity; + physPresetInfo->tempDefaultToCylinder = physPreset->tempDefaultToCylinder ? 1 : 0; + physPresetInfo->perSurfaceSndAlias = physPreset->perSurfaceSndAlias ? 1 : 0; + } + + InfoString CreateInfoString(XAssetInfo* asset) + { + auto* physPresetInfo = new PhysPresetInfo; + CopyToPhysPresetInfo(asset->Asset(), physPresetInfo); + + InfoStringFromPhysPresetConverter converter(physPresetInfo, + phys_preset_fields, + std::extent_v, + [asset](const scr_string_t scrStr) -> std::string + { + assert(scrStr < asset->m_zone->m_script_strings.Count()); + if (scrStr >= asset->m_zone->m_script_strings.Count()) + return ""; + + return asset->m_zone->m_script_strings[scrStr]; + }); + + return converter.Convert(); + } +} // namespace + +namespace IW4::phys_preset +{ + bool InfoStringDumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void InfoStringDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + // Only dump raw when no gdt available + if (context.m_gdt) + { + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_PHYS_PRESET); + infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_PHYS_PRESET, gdtEntry); + context.m_gdt->WriteEntry(gdtEntry); + } + else + { + const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name)); + + if (!assetFile) + return; + + auto& stream = *assetFile; + const auto infoString = CreateInfoString(asset); + const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_PHYS_PRESET); + stream.write(stringValue.c_str(), stringValue.size()); + } + } +} // namespace IW4::phys_preset diff --git a/src/ObjWriting/Game/IW4/PhysPreset/AssetDumperPhysPreset.h b/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.h similarity index 54% rename from src/ObjWriting/Game/IW4/PhysPreset/AssetDumperPhysPreset.h rename to src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.h index 5de816cc..98b6a366 100644 --- a/src/ObjWriting/Game/IW4/PhysPreset/AssetDumperPhysPreset.h +++ b/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.h @@ -4,13 +4,10 @@ #include "Game/IW4/IW4.h" #include "InfoString/InfoString.h" -namespace IW4 +namespace IW4::phys_preset { - class AssetDumperPhysPreset final : public AbstractAssetDumper + class InfoStringDumper final : public AbstractAssetDumper { - static void CopyToPhysPresetInfo(const PhysPreset* physPreset, PhysPresetInfo* physPresetInfo); - static InfoString CreateInfoString(XAssetInfo* asset); - protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; diff --git a/src/ObjWriting/Game/T5/ObjWriterT5.cpp b/src/ObjWriting/Game/T5/ObjWriterT5.cpp index b12857e8..baaf5a32 100644 --- a/src/ObjWriting/Game/T5/ObjWriterT5.cpp +++ b/src/ObjWriting/Game/T5/ObjWriterT5.cpp @@ -6,7 +6,6 @@ #include "Image/ImageDumperT5.h" #include "Localize/LocalizeDumperT5.h" #include "ObjWriting.h" -#include "PhysPreset/AssetDumperPhysPreset.h" #include "RawFile/AssetDumperRawFile.h" #include "Sound/AssetDumperSndBank.h" #include "StringTable/AssetDumperStringTable.h" diff --git a/src/ObjWriting/Game/T5/PhysPreset/AssetDumperPhysPreset.cpp b/src/ObjWriting/Game/T5/PhysPreset/AssetDumperPhysPreset.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/src/ObjWriting/Game/T5/PhysPreset/AssetDumperPhysPreset.h b/src/ObjWriting/Game/T5/PhysPreset/AssetDumperPhysPreset.h deleted file mode 100644 index e69de29b..00000000 diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 3aeaf091..3e8de73d 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -10,7 +10,7 @@ #include "Maps/MapEntsDumperT6.h" #include "ObjWriting.h" #include "PhysConstraints/PhysConstraintsInfoStringDumperT6.h" -#include "PhysPreset/AssetDumperPhysPreset.h" +#include "PhysPreset/PhysPresetInfoStringDumperT6.h" #include "Qdb/AssetDumperQdb.h" #include "RawFile/AssetDumperRawFile.h" #include "Script/AssetDumperScriptParseTree.h" @@ -46,7 +46,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const const auto* assetPools = dynamic_cast(context.m_zone.m_pools.get()); - DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset, ASSET_TYPE_PHYSPRESET) + DUMP_ASSET_POOL(phys_preset::InfoStringDumper, m_phys_preset, ASSET_TYPE_PHYSPRESET) DUMP_ASSET_POOL(phys_constraints::InfoStringDumper, m_phys_constraints, ASSET_TYPE_PHYSCONSTRAINTS) // DUMP_ASSET_POOL(AssetDumperDestructibleDef, m_destructible_def, ASSET_TYPE_DESTRUCTIBLEDEF) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) diff --git a/src/ObjWriting/Game/T6/PhysPreset/AssetDumperPhysPreset.cpp b/src/ObjWriting/Game/T6/PhysPreset/AssetDumperPhysPreset.cpp deleted file mode 100644 index d11819f4..00000000 --- a/src/ObjWriting/Game/T6/PhysPreset/AssetDumperPhysPreset.cpp +++ /dev/null @@ -1,109 +0,0 @@ -#include "AssetDumperPhysPreset.h" - -#include "Game/T6/InfoString/InfoStringFromStructConverter.h" -#include "Game/T6/ObjConstantsT6.h" -#include "Game/T6/PhysPreset/PhysPresetFields.h" - -#include -#include -#include -#include - -using namespace T6; - -namespace T6 -{ - class InfoStringFromPhysPresetConverter final : public InfoStringFromStructConverter - { - protected: - void FillFromExtensionField(const cspField_t& field) override - { - assert(false); - } - - public: - InfoStringFromPhysPresetConverter(const PhysPresetInfo* structure, - const cspField_t* fields, - const size_t fieldCount, - std::function scriptStringValueCallback) - : InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback)) - { - } - }; -} // namespace T6 - -void AssetDumperPhysPreset::CopyToPhysPresetInfo(const PhysPreset* physPreset, PhysPresetInfo* physPresetInfo) -{ - physPresetInfo->mass = std::clamp(physPreset->mass * 1000.0f, 1.0f, 2000.0f); - physPresetInfo->bounce = physPreset->bounce; - - if (std::isinf(physPreset->friction)) - { - physPresetInfo->isFrictionInfinity = 1; - physPresetInfo->friction = 0; - } - else - { - physPresetInfo->isFrictionInfinity = 0; - physPresetInfo->friction = physPreset->friction; - } - - physPresetInfo->bulletForceScale = physPreset->bulletForceScale; - physPresetInfo->explosiveForceScale = physPreset->explosiveForceScale; - physPresetInfo->piecesSpreadFraction = physPreset->piecesSpreadFraction; - physPresetInfo->piecesUpwardVelocity = physPreset->piecesUpwardVelocity; - physPresetInfo->canFloat = physPreset->canFloat; - physPresetInfo->gravityScale = std::clamp(physPreset->gravityScale, 0.01f, 10.0f); - physPresetInfo->centerOfMassOffset = physPreset->centerOfMassOffset; - physPresetInfo->buoyancyBoxMin = physPreset->buoyancyBoxMin; - physPresetInfo->buoyancyBoxMax = physPreset->buoyancyBoxMax; -} - -InfoString AssetDumperPhysPreset::CreateInfoString(XAssetInfo* asset) -{ - auto* physPresetInfo = new PhysPresetInfo; - CopyToPhysPresetInfo(asset->Asset(), physPresetInfo); - - InfoStringFromPhysPresetConverter converter(physPresetInfo, - phys_preset_fields, - std::extent_v, - [asset](const scr_string_t scrStr) -> std::string - { - assert(scrStr < asset->m_zone->m_script_strings.Count()); - if (scrStr >= asset->m_zone->m_script_strings.Count()) - return ""; - - return asset->m_zone->m_script_strings[scrStr]; - }); - - return converter.Convert(); -} - -bool AssetDumperPhysPreset::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperPhysPreset::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - // Only dump raw when no gdt available - if (context.m_gdt) - { - const auto infoString = CreateInfoString(asset); - GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_PHYS_PRESET); - infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_PHYS_PRESET, gdtEntry); - context.m_gdt->WriteEntry(gdtEntry); - } - else - { - const auto assetFile = context.OpenAssetFile("physic/" + asset->m_name); - - if (!assetFile) - return; - - auto& stream = *assetFile; - const auto infoString = CreateInfoString(asset); - const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_PHYS_PRESET); - stream.write(stringValue.c_str(), stringValue.size()); - } -} diff --git a/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.cpp b/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.cpp new file mode 100644 index 00000000..8941af2d --- /dev/null +++ b/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.cpp @@ -0,0 +1,114 @@ +#include "PhysPresetInfoStringDumperT6.h" + +#include "Game/T6/InfoString/InfoStringFromStructConverter.h" +#include "Game/T6/ObjConstantsT6.h" +#include "Game/T6/PhysPreset/PhysPresetFields.h" +#include "PhysPreset/PhysPresetCommon.h" + +#include +#include +#include +#include + +using namespace T6; +using namespace ::phys_preset; + +namespace +{ + class InfoStringFromPhysPresetConverter final : public InfoStringFromStructConverter + { + protected: + void FillFromExtensionField(const cspField_t& field) override + { + assert(false); + } + + public: + InfoStringFromPhysPresetConverter(const PhysPresetInfo* structure, + const cspField_t* fields, + const size_t fieldCount, + std::function scriptStringValueCallback) + : InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback)) + { + } + }; + + void CopyToPhysPresetInfo(const PhysPreset* physPreset, PhysPresetInfo* physPresetInfo) + { + physPresetInfo->mass = std::clamp(physPreset->mass * 1000.0f, 1.0f, 2000.0f); + physPresetInfo->bounce = physPreset->bounce; + + if (std::isinf(physPreset->friction)) + { + physPresetInfo->isFrictionInfinity = 1; + physPresetInfo->friction = 0; + } + else + { + physPresetInfo->isFrictionInfinity = 0; + physPresetInfo->friction = physPreset->friction; + } + + physPresetInfo->bulletForceScale = physPreset->bulletForceScale; + physPresetInfo->explosiveForceScale = physPreset->explosiveForceScale; + physPresetInfo->piecesSpreadFraction = physPreset->piecesSpreadFraction; + physPresetInfo->piecesUpwardVelocity = physPreset->piecesUpwardVelocity; + physPresetInfo->canFloat = physPreset->canFloat; + physPresetInfo->gravityScale = std::clamp(physPreset->gravityScale, 0.01f, 10.0f); + physPresetInfo->centerOfMassOffset = physPreset->centerOfMassOffset; + physPresetInfo->buoyancyBoxMin = physPreset->buoyancyBoxMin; + physPresetInfo->buoyancyBoxMax = physPreset->buoyancyBoxMax; + } + + InfoString CreateInfoString(XAssetInfo* asset) + { + auto* physPresetInfo = new PhysPresetInfo; + CopyToPhysPresetInfo(asset->Asset(), physPresetInfo); + + InfoStringFromPhysPresetConverter converter(physPresetInfo, + phys_preset_fields, + std::extent_v, + [asset](const scr_string_t scrStr) -> std::string + { + assert(scrStr < asset->m_zone->m_script_strings.Count()); + if (scrStr >= asset->m_zone->m_script_strings.Count()) + return ""; + + return asset->m_zone->m_script_strings[scrStr]; + }); + + return converter.Convert(); + } +} // namespace + +namespace T6::phys_preset +{ + bool InfoStringDumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void InfoStringDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + // Only dump raw when no gdt available + if (context.m_gdt) + { + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_PHYS_PRESET); + infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_PHYS_PRESET, gdtEntry); + context.m_gdt->WriteEntry(gdtEntry); + } + else + { + const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name)); + + if (!assetFile) + return; + + auto& stream = *assetFile; + const auto infoString = CreateInfoString(asset); + const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_PHYS_PRESET); + stream.write(stringValue.c_str(), stringValue.size()); + } + } +} // namespace T6::phys_preset diff --git a/src/ObjWriting/Game/T6/PhysPreset/AssetDumperPhysPreset.h b/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.h similarity index 51% rename from src/ObjWriting/Game/T6/PhysPreset/AssetDumperPhysPreset.h rename to src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.h index a760ef45..26ce2296 100644 --- a/src/ObjWriting/Game/T6/PhysPreset/AssetDumperPhysPreset.h +++ b/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.h @@ -4,15 +4,12 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" -namespace T6 +namespace T6::phys_preset { - class AssetDumperPhysPreset final : public AbstractAssetDumper + class InfoStringDumper final : public AbstractAssetDumper { - static void CopyToPhysPresetInfo(const PhysPreset* physPreset, PhysPresetInfo* physPresetInfo); - static InfoString CreateInfoString(XAssetInfo* asset); - protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6 +} // namespace T6::phys_preset From bcb52391dce6209baeec4efe56ea601d34b1a003 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Wed, 30 Jul 2025 19:55:57 +0100 Subject: [PATCH 13/35] refactor: streamline rawfile dumping --- src/ObjWriting/Game/IW3/ObjWriterIW3.cpp | 4 +- .../Game/IW3/RawFile/AssetDumperRawFile.cpp | 20 --- .../Game/IW3/RawFile/RawFileDumperIW3.cpp | 23 ++++ ...ssetDumperRawFile.h => RawFileDumperIW3.h} | 6 +- src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 4 +- .../Game/IW4/RawFile/RawFileDumperIW4.cpp | 70 ++++++++++ ...ssetDumperRawFile.h => RawFileDumperIW4.h} | 6 +- src/ObjWriting/Game/IW5/ObjWriterIW5.cpp | 4 +- .../Game/IW5/RawFile/AssetDumperRawFile.cpp | 62 --------- .../RawFile/RawFileDumperIW5.cpp} | 44 +++---- ...ssetDumperRawFile.h => RawFileDumperIW5.h} | 6 +- src/ObjWriting/Game/T5/ObjWriterT5.cpp | 4 +- .../Game/T5/RawFile/AssetDumperRawFile.cpp | 114 ----------------- .../Game/T5/RawFile/AssetDumperRawFile.h | 18 --- .../Game/T5/RawFile/RawFileDumperT5.cpp | 121 ++++++++++++++++++ .../Game/T5/RawFile/RawFileDumperT5.h | 14 ++ src/ObjWriting/Game/T6/ObjWriterT6.cpp | 4 +- .../Game/T6/RawFile/AssetDumperRawFile.cpp | 96 -------------- .../Game/T6/RawFile/RawFileDumperT6.cpp | 104 +++++++++++++++ ...AssetDumperRawFile.h => RawFileDumperT6.h} | 8 +- 20 files changed, 374 insertions(+), 358 deletions(-) delete mode 100644 src/ObjWriting/Game/IW3/RawFile/AssetDumperRawFile.cpp create mode 100644 src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.cpp rename src/ObjWriting/Game/IW3/RawFile/{AssetDumperRawFile.h => RawFileDumperIW3.h} (69%) create mode 100644 src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.cpp rename src/ObjWriting/Game/IW4/RawFile/{AssetDumperRawFile.h => RawFileDumperIW4.h} (69%) delete mode 100644 src/ObjWriting/Game/IW5/RawFile/AssetDumperRawFile.cpp rename src/ObjWriting/Game/{IW4/RawFile/AssetDumperRawFile.cpp => IW5/RawFile/RawFileDumperIW5.cpp} (61%) rename src/ObjWriting/Game/IW5/RawFile/{AssetDumperRawFile.h => RawFileDumperIW5.h} (69%) delete mode 100644 src/ObjWriting/Game/T5/RawFile/AssetDumperRawFile.cpp delete mode 100644 src/ObjWriting/Game/T5/RawFile/AssetDumperRawFile.h create mode 100644 src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.cpp create mode 100644 src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.h delete mode 100644 src/ObjWriting/Game/T6/RawFile/AssetDumperRawFile.cpp create mode 100644 src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.cpp rename src/ObjWriting/Game/T6/RawFile/{AssetDumperRawFile.h => RawFileDumperT6.h} (52%) diff --git a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp index 5aa9db1d..be2b3472 100644 --- a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp +++ b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp @@ -7,7 +7,7 @@ #include "Localize/LocalizeDumperIW3.h" #include "Maps/MapEntsDumperIW3.h" #include "ObjWriting.h" -#include "RawFile/AssetDumperRawFile.h" +#include "RawFile/RawFileDumperIW3.h" #include "Sound/AssetDumperLoadedSound.h" #include "StringTable/AssetDumperStringTable.h" #include "Weapon/AssetDumperWeapon.h" @@ -49,7 +49,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) - DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file, ASSET_TYPE_RAWFILE) + DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE) DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE) return true; diff --git a/src/ObjWriting/Game/IW3/RawFile/AssetDumperRawFile.cpp b/src/ObjWriting/Game/IW3/RawFile/AssetDumperRawFile.cpp deleted file mode 100644 index bd9b7ecd..00000000 --- a/src/ObjWriting/Game/IW3/RawFile/AssetDumperRawFile.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "AssetDumperRawFile.h" - -using namespace IW3; - -bool AssetDumperRawFile::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperRawFile::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* rawFile = asset->Asset(); - const auto assetFile = context.OpenAssetFile(asset->m_name); - - if (!assetFile) - return; - - auto& stream = *assetFile; - stream.write(rawFile->buffer, rawFile->len); -} diff --git a/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.cpp b/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.cpp new file mode 100644 index 00000000..22af389d --- /dev/null +++ b/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.cpp @@ -0,0 +1,23 @@ +#include "RawFileDumperIW3.h" + +using namespace IW3; + +namespace IW3::raw_file +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* rawFile = asset->Asset(); + const auto assetFile = context.OpenAssetFile(asset->m_name); + + if (!assetFile) + return; + + auto& stream = *assetFile; + stream.write(rawFile->buffer, rawFile->len); + } +} // namespace IW3::raw_file diff --git a/src/ObjWriting/Game/IW3/RawFile/AssetDumperRawFile.h b/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.h similarity index 69% rename from src/ObjWriting/Game/IW3/RawFile/AssetDumperRawFile.h rename to src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.h index abeeda26..3ea995c8 100644 --- a/src/ObjWriting/Game/IW3/RawFile/AssetDumperRawFile.h +++ b/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW3/IW3.h" -namespace IW3 +namespace IW3::raw_file { - class AssetDumperRawFile final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW3 +} // namespace IW3::raw_file diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 4dd466d9..c00e44f0 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -14,7 +14,7 @@ #include "ObjWriting.h" #include "PhysCollmap/AssetDumperPhysCollmap.h" #include "PhysPreset/PhysPresetInfoStringDumperIW4.h" -#include "RawFile/AssetDumperRawFile.h" +#include "RawFile/RawFileDumperIW4.h" #include "Shader/AssetDumperPixelShader.h" #include "Shader/AssetDumperVertexShader.h" #include "Sound/AssetDumperLoadedSound.h" @@ -70,7 +70,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) - DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file, ASSET_TYPE_RAWFILE) + DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE) DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE) DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD) DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF) diff --git a/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.cpp b/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.cpp new file mode 100644 index 00000000..ec4224af --- /dev/null +++ b/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.cpp @@ -0,0 +1,70 @@ +#include "RawFileDumperIW4.h" + +#include +#include +#include + +using namespace IW4; + +namespace IW4::raw_file +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* rawFile = asset->Asset(); + const auto assetFile = context.OpenAssetFile(asset->m_name); + + if (!assetFile) + return; + + auto& stream = *assetFile; + if (rawFile->compressedLen > 0) + { + z_stream_s zs{}; + + zs.zalloc = Z_NULL; + zs.zfree = Z_NULL; + zs.opaque = Z_NULL; + zs.avail_in = 0; + zs.next_in = Z_NULL; + + int ret = inflateInit(&zs); + + if (ret != Z_OK) + { + throw std::runtime_error("Initializing inflate failed"); + } + + zs.next_in = reinterpret_cast(rawFile->data.compressedBuffer); + zs.avail_in = rawFile->compressedLen; + + Bytef buffer[0x1000]; + + while (zs.avail_in > 0) + { + zs.next_out = buffer; + zs.avail_out = sizeof(buffer); + ret = inflate(&zs, Z_SYNC_FLUSH); + + if (ret < 0) + { + std::cerr << std::format("Inflate failed when attempting to dump rawfile '{}'\n", rawFile->name); + inflateEnd(&zs); + return; + } + + stream.write(reinterpret_cast(buffer), sizeof(buffer) - zs.avail_out); + } + + inflateEnd(&zs); + } + else if (rawFile->len > 0) + { + stream.write(rawFile->data.buffer, rawFile->len); + } + } +} // namespace IW4::raw_file diff --git a/src/ObjWriting/Game/IW4/RawFile/AssetDumperRawFile.h b/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.h similarity index 69% rename from src/ObjWriting/Game/IW4/RawFile/AssetDumperRawFile.h rename to src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.h index 5b2c2120..a1657fb5 100644 --- a/src/ObjWriting/Game/IW4/RawFile/AssetDumperRawFile.h +++ b/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4 +namespace IW4::raw_file { - class AssetDumperRawFile final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4 +} // namespace IW4::raw_file diff --git a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp index 2e735cb7..254a0d9b 100644 --- a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp +++ b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp @@ -10,7 +10,7 @@ #include "Menu/AssetDumperMenuDef.h" #include "Menu/AssetDumperMenuList.h" #include "ObjWriting.h" -#include "RawFile/AssetDumperRawFile.h" +#include "RawFile/RawFileDumperIW5.h" #include "Script/AssetDumperScriptFile.h" #include "Sound/AssetDumperLoadedSound.h" #include "StringTable/AssetDumperStringTable.h" @@ -61,7 +61,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) // DUMP_ASSET_POOL(AssetDumperSurfaceFxTable, m_surface_fx_table, ASSET_TYPE_SURFACE_FX) - DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file, ASSET_TYPE_RAWFILE) + DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE) DUMP_ASSET_POOL(AssetDumperScriptFile, m_script_file, ASSET_TYPE_SCRIPTFILE) DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE) DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD) diff --git a/src/ObjWriting/Game/IW5/RawFile/AssetDumperRawFile.cpp b/src/ObjWriting/Game/IW5/RawFile/AssetDumperRawFile.cpp deleted file mode 100644 index 283b8bda..00000000 --- a/src/ObjWriting/Game/IW5/RawFile/AssetDumperRawFile.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "AssetDumperRawFile.h" - -#include -#include -#include - -using namespace IW5; - -bool AssetDumperRawFile::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperRawFile::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* rawFile = asset->Asset(); - const auto assetFile = context.OpenAssetFile(asset->m_name); - - if (!assetFile) - return; - - auto& stream = *assetFile; - if (rawFile->compressedLen <= 0) - return; - - z_stream_s zs{}; - zs.zalloc = Z_NULL; - zs.zfree = Z_NULL; - zs.opaque = Z_NULL; - zs.avail_in = 0; - zs.next_in = Z_NULL; - - int ret = inflateInit(&zs); - - if (ret != Z_OK) - { - throw std::runtime_error("Initializing inflate failed"); - } - - zs.next_in = reinterpret_cast(rawFile->buffer); - zs.avail_in = rawFile->compressedLen; - - Bytef buffer[0x1000]; - - while (zs.avail_in > 0) - { - zs.next_out = buffer; - zs.avail_out = sizeof(buffer); - ret = inflate(&zs, Z_SYNC_FLUSH); - - if (ret < 0) - { - std::cerr << std::format("Inflate failed when attempting to dump rawfile '{}'\n", rawFile->name); - inflateEnd(&zs); - return; - } - - stream.write(reinterpret_cast(buffer), sizeof(buffer) - zs.avail_out); - } - - inflateEnd(&zs); -} diff --git a/src/ObjWriting/Game/IW4/RawFile/AssetDumperRawFile.cpp b/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.cpp similarity index 61% rename from src/ObjWriting/Game/IW4/RawFile/AssetDumperRawFile.cpp rename to src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.cpp index a1669136..ba444e30 100644 --- a/src/ObjWriting/Game/IW4/RawFile/AssetDumperRawFile.cpp +++ b/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.cpp @@ -1,29 +1,31 @@ -#include "AssetDumperRawFile.h" +#include "RawFileDumperIW5.h" #include #include #include -using namespace IW4; +using namespace IW5; -bool AssetDumperRawFile::ShouldDump(XAssetInfo* asset) +namespace IW5::raw_file { - return true; -} - -void AssetDumperRawFile::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* rawFile = asset->Asset(); - const auto assetFile = context.OpenAssetFile(asset->m_name); - - if (!assetFile) - return; - - auto& stream = *assetFile; - if (rawFile->compressedLen > 0) + bool Dumper::ShouldDump(XAssetInfo* asset) { - z_stream_s zs{}; + return true; + } + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* rawFile = asset->Asset(); + const auto assetFile = context.OpenAssetFile(asset->m_name); + + if (!assetFile) + return; + + auto& stream = *assetFile; + if (rawFile->compressedLen <= 0) + return; + + z_stream_s zs{}; zs.zalloc = Z_NULL; zs.zfree = Z_NULL; zs.opaque = Z_NULL; @@ -37,7 +39,7 @@ void AssetDumperRawFile::DumpAsset(AssetDumpingContext& context, XAssetInfo(rawFile->data.compressedBuffer); + zs.next_in = reinterpret_cast(rawFile->buffer); zs.avail_in = rawFile->compressedLen; Bytef buffer[0x1000]; @@ -60,8 +62,4 @@ void AssetDumperRawFile::DumpAsset(AssetDumpingContext& context, XAssetInfolen > 0) - { - stream.write(rawFile->data.buffer, rawFile->len); - } -} +} // namespace IW5::raw_file diff --git a/src/ObjWriting/Game/IW5/RawFile/AssetDumperRawFile.h b/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.h similarity index 69% rename from src/ObjWriting/Game/IW5/RawFile/AssetDumperRawFile.h rename to src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.h index 57e35274..b3fff52f 100644 --- a/src/ObjWriting/Game/IW5/RawFile/AssetDumperRawFile.h +++ b/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW5/IW5.h" -namespace IW5 +namespace IW5::raw_file { - class AssetDumperRawFile final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW5 +} // namespace IW5::raw_file diff --git a/src/ObjWriting/Game/T5/ObjWriterT5.cpp b/src/ObjWriting/Game/T5/ObjWriterT5.cpp index baaf5a32..ce3c8eec 100644 --- a/src/ObjWriting/Game/T5/ObjWriterT5.cpp +++ b/src/ObjWriting/Game/T5/ObjWriterT5.cpp @@ -6,7 +6,7 @@ #include "Image/ImageDumperT5.h" #include "Localize/LocalizeDumperT5.h" #include "ObjWriting.h" -#include "RawFile/AssetDumperRawFile.h" +#include "RawFile/RawFileDumperT5.h" #include "Sound/AssetDumperSndBank.h" #include "StringTable/AssetDumperStringTable.h" #include "Weapon/AssetDumperWeapon.h" @@ -49,7 +49,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) - DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file, ASSET_TYPE_RAWFILE) + DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE) DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE) // DUMP_ASSET_POOL(AssetDumperPackIndex, m_pack_index, ASSET_TYPE_PACK_INDEX) // DUMP_ASSET_POOL(AssetDumperXGlobals, m_xglobals, ASSET_TYPE_XGLOBALS) diff --git a/src/ObjWriting/Game/T5/RawFile/AssetDumperRawFile.cpp b/src/ObjWriting/Game/T5/RawFile/AssetDumperRawFile.cpp deleted file mode 100644 index 45827890..00000000 --- a/src/ObjWriting/Game/T5/RawFile/AssetDumperRawFile.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include "AssetDumperRawFile.h" - -#include -#include -#include - -using namespace T5; - -namespace fs = std::filesystem; - -void AssetDumperRawFile::DumpGsc(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) -{ - const auto* rawFile = asset->Asset(); - - if (rawFile->len <= 8) - { - std::cout << "Invalid len of gsc file \"" << rawFile->name << "\"\n"; - return; - } - - const auto outLen = reinterpret_cast(rawFile->buffer)[0]; - const auto inLen = reinterpret_cast(rawFile->buffer)[1]; - - assert(inLen == static_cast(rawFile->len) - 8); - - if (inLen > static_cast(rawFile->len - 8) + 1) - { - std::cout << "Invalid compression of gsc file \"" << rawFile->name << "\": " << inLen << "\n"; - return; - } - - if (outLen > GSC_MAX_SIZE) - { - std::cout << "Invalid size of gsc file \"" << rawFile->name << "\": " << outLen << "\n"; - return; - } - - z_stream_s zs{}; - - zs.zalloc = Z_NULL; - zs.zfree = Z_NULL; - zs.opaque = Z_NULL; - zs.avail_in = 0; - zs.next_in = Z_NULL; - - int ret = inflateInit(&zs); - - if (ret != Z_OK) - { - throw std::runtime_error("Initializing inflate failed"); - } - - zs.next_in = reinterpret_cast(&rawFile->buffer[8]); - zs.avail_in = inLen; - - Bytef buffer[0x1000]; - - size_t writtenSize = 0; - while (zs.avail_in > 0) - { - zs.next_out = buffer; - zs.avail_out = sizeof(buffer); - ret = inflate(&zs, Z_SYNC_FLUSH); - - if (ret < 0) - { - std::cout << "Inflate failed for dumping gsc file \"" << rawFile->name << "\"\n"; - inflateEnd(&zs); - return; - } - - const auto inflateOutSize = sizeof(buffer) - zs.avail_out; - - if (writtenSize + inflateOutSize >= outLen) - { - // Last byte is a \0 byte. Skip it. - stream.write(reinterpret_cast(buffer), inflateOutSize - 1); - } - else - { - stream.write(reinterpret_cast(buffer), inflateOutSize); - } - writtenSize += inflateOutSize; - } - - inflateEnd(&zs); -} - -bool AssetDumperRawFile::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperRawFile::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* rawFile = asset->Asset(); - const auto assetFile = context.OpenAssetFile(asset->m_name); - - if (!assetFile) - return; - - auto& stream = *assetFile; - const fs::path rawFilePath(rawFile->name); - const auto extension = rawFilePath.extension().string(); - - if (extension == ".gsc" || extension == ".csc") - { - DumpGsc(context, asset, stream); - } - else - { - stream.write(rawFile->buffer, rawFile->len); - } -} diff --git a/src/ObjWriting/Game/T5/RawFile/AssetDumperRawFile.h b/src/ObjWriting/Game/T5/RawFile/AssetDumperRawFile.h deleted file mode 100644 index b2d10763..00000000 --- a/src/ObjWriting/Game/T5/RawFile/AssetDumperRawFile.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/T5/T5.h" - -namespace T5 -{ - class AssetDumperRawFile final : public AbstractAssetDumper - { - constexpr static size_t GSC_MAX_SIZE = 0xC000000; - - static void DumpGsc(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream); - - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace T5 diff --git a/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.cpp b/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.cpp new file mode 100644 index 00000000..5c57964a --- /dev/null +++ b/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.cpp @@ -0,0 +1,121 @@ +#include "RawFileDumperT5.h" + +#include "Utils/StringUtils.h" + +#include +#include +#include + +using namespace T5; + +namespace fs = std::filesystem; + +namespace +{ + constexpr static size_t GSC_MAX_SIZE = 0xC000000; + + void DumpGsc(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) + { + const auto* rawFile = asset->Asset(); + + if (rawFile->len <= 8) + { + std::cout << "Invalid len of gsc file \"" << rawFile->name << "\"\n"; + return; + } + + const auto outLen = reinterpret_cast(rawFile->buffer)[0]; + const auto inLen = reinterpret_cast(rawFile->buffer)[1]; + + assert(inLen == static_cast(rawFile->len) - 8); + + if (inLen > static_cast(rawFile->len - 8) + 1) + { + std::cout << "Invalid compression of gsc file \"" << rawFile->name << "\": " << inLen << "\n"; + return; + } + + if (outLen > GSC_MAX_SIZE) + { + std::cout << "Invalid size of gsc file \"" << rawFile->name << "\": " << outLen << "\n"; + return; + } + + z_stream_s zs{}; + + zs.zalloc = Z_NULL; + zs.zfree = Z_NULL; + zs.opaque = Z_NULL; + zs.avail_in = 0; + zs.next_in = Z_NULL; + + int ret = inflateInit(&zs); + + if (ret != Z_OK) + { + throw std::runtime_error("Initializing inflate failed"); + } + + zs.next_in = reinterpret_cast(&rawFile->buffer[8]); + zs.avail_in = inLen; + + Bytef buffer[0x1000]; + + size_t writtenSize = 0; + while (zs.avail_in > 0) + { + zs.next_out = buffer; + zs.avail_out = sizeof(buffer); + ret = inflate(&zs, Z_SYNC_FLUSH); + + if (ret < 0) + { + std::cout << "Inflate failed for dumping gsc file \"" << rawFile->name << "\"\n"; + inflateEnd(&zs); + return; + } + + const auto inflateOutSize = sizeof(buffer) - zs.avail_out; + + if (writtenSize + inflateOutSize >= outLen) + { + // Last byte is a \0 byte. Skip it. + stream.write(reinterpret_cast(buffer), inflateOutSize - 1); + } + else + { + stream.write(reinterpret_cast(buffer), inflateOutSize); + } + writtenSize += inflateOutSize; + } + + inflateEnd(&zs); + } +} // namespace + +namespace T5::raw_file +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* rawFile = asset->Asset(); + const auto assetFile = context.OpenAssetFile(asset->m_name); + + if (!assetFile) + return; + + auto& stream = *assetFile; + const fs::path rawFilePath(rawFile->name); + auto extension = rawFilePath.extension().string(); + utils::MakeStringLowerCase(extension); + + if (extension == ".gsc" || extension == ".csc") + DumpGsc(context, asset, stream); + else + stream.write(rawFile->buffer, rawFile->len); + } +} // namespace T5::raw_file diff --git a/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.h b/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.h new file mode 100644 index 00000000..2c6f6ba2 --- /dev/null +++ b/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.h @@ -0,0 +1,14 @@ +#pragma once + +#include "Dumping/AbstractAssetDumper.h" +#include "Game/T5/T5.h" + +namespace T5::raw_file +{ + class Dumper final : public AbstractAssetDumper + { + protected: + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + }; +} // namespace T5::raw_file diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 3e8de73d..79c6778c 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -12,7 +12,7 @@ #include "PhysConstraints/PhysConstraintsInfoStringDumperT6.h" #include "PhysPreset/PhysPresetInfoStringDumperT6.h" #include "Qdb/AssetDumperQdb.h" -#include "RawFile/AssetDumperRawFile.h" +#include "RawFile/RawFileDumperT6.h" #include "Script/AssetDumperScriptParseTree.h" #include "Slug/AssetDumperSlug.h" #include "Sound/AssetDumperSndBank.h" @@ -75,7 +75,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) - DUMP_ASSET_POOL(AssetDumperRawFile, m_raw_file, ASSET_TYPE_RAWFILE) + DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE) DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE) DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD) // DUMP_ASSET_POOL(AssetDumperXGlobals, m_xglobals, ASSET_TYPE_XGLOBALS) diff --git a/src/ObjWriting/Game/T6/RawFile/AssetDumperRawFile.cpp b/src/ObjWriting/Game/T6/RawFile/AssetDumperRawFile.cpp deleted file mode 100644 index 291d969e..00000000 --- a/src/ObjWriting/Game/T6/RawFile/AssetDumperRawFile.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include "AssetDumperRawFile.h" - -#include -#include -#include - -using namespace T6; - -namespace fs = std::filesystem; - -bool AssetDumperRawFile::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperRawFile::DumpAnimtree(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) -{ - const auto* rawFile = asset->Asset(); - - if (rawFile->len <= 4) - { - std::cerr << "Invalid len of animtree file \"" << rawFile->name << "\"\n"; - return; - } - - const auto outLen = reinterpret_cast(rawFile->buffer)[0]; - const auto inLen = rawFile->len; - - if (outLen > ANIMTREE_MAX_SIZE) - { - std::cerr << "Invalid size of animtree file \"" << rawFile->name << "\": " << outLen << "\n"; - return; - } - - z_stream_s zs{}; - - zs.zalloc = Z_NULL; - zs.zfree = Z_NULL; - zs.opaque = Z_NULL; - zs.avail_in = 0; - zs.next_in = Z_NULL; - - int ret = inflateInit2(&zs, -DEF_WBITS); - - if (ret != Z_OK) - { - throw std::runtime_error("Initializing inflate failed"); - } - - zs.next_in = reinterpret_cast(&rawFile->buffer[4]); - zs.avail_in = inLen - sizeof(uint32_t); - - Bytef buffer[0x1000]; - - while (zs.avail_in > 0) - { - zs.next_out = buffer; - zs.avail_out = sizeof(buffer); - ret = inflate(&zs, Z_SYNC_FLUSH); - - if (ret < 0) - { - std::cerr << "Inflate failed for dumping animtree file \"" << rawFile->name << "\"\n"; - inflateEnd(&zs); - return; - } - - const auto inflateOutSize = sizeof(buffer) - zs.avail_out; - - stream.write(reinterpret_cast(buffer), inflateOutSize); - } - - inflateEnd(&zs); -} - -void AssetDumperRawFile::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* rawFile = asset->Asset(); - const auto assetFile = context.OpenAssetFile(asset->m_name); - - if (!assetFile) - return; - - auto& stream = *assetFile; - const fs::path rawFilePath(rawFile->name); - const auto extension = rawFilePath.extension().string(); - - if (extension == ".atr") - { - DumpAnimtree(context, asset, stream); - } - else - { - stream.write(rawFile->buffer, rawFile->len); - } -} diff --git a/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.cpp b/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.cpp new file mode 100644 index 00000000..b456eb9c --- /dev/null +++ b/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.cpp @@ -0,0 +1,104 @@ +#include "RawFileDumperT6.h" + +#include +#include +#include + +using namespace T6; + +namespace fs = std::filesystem; + +namespace +{ + constexpr size_t ANIMTREE_MAX_SIZE = 0xC000000; + + void DumpAnimtree(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream) + { + const auto* rawFile = asset->Asset(); + + if (rawFile->len <= 4) + { + std::cerr << "Invalid len of animtree file \"" << rawFile->name << "\"\n"; + return; + } + + const auto outLen = reinterpret_cast(rawFile->buffer)[0]; + const auto inLen = rawFile->len; + + if (outLen > ANIMTREE_MAX_SIZE) + { + std::cerr << "Invalid size of animtree file \"" << rawFile->name << "\": " << outLen << "\n"; + return; + } + + z_stream_s zs{}; + + zs.zalloc = Z_NULL; + zs.zfree = Z_NULL; + zs.opaque = Z_NULL; + zs.avail_in = 0; + zs.next_in = Z_NULL; + + int ret = inflateInit2(&zs, -DEF_WBITS); + + if (ret != Z_OK) + { + throw std::runtime_error("Initializing inflate failed"); + } + + zs.next_in = reinterpret_cast(&rawFile->buffer[4]); + zs.avail_in = inLen - sizeof(uint32_t); + + Bytef buffer[0x1000]; + + while (zs.avail_in > 0) + { + zs.next_out = buffer; + zs.avail_out = sizeof(buffer); + ret = inflate(&zs, Z_SYNC_FLUSH); + + if (ret < 0) + { + std::cerr << "Inflate failed for dumping animtree file \"" << rawFile->name << "\"\n"; + inflateEnd(&zs); + return; + } + + const auto inflateOutSize = sizeof(buffer) - zs.avail_out; + + stream.write(reinterpret_cast(buffer), inflateOutSize); + } + + inflateEnd(&zs); + } +} // namespace + +namespace T6::raw_file +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* rawFile = asset->Asset(); + const auto assetFile = context.OpenAssetFile(asset->m_name); + + if (!assetFile) + return; + + auto& stream = *assetFile; + const fs::path rawFilePath(rawFile->name); + const auto extension = rawFilePath.extension().string(); + + if (extension == ".atr") + { + DumpAnimtree(context, asset, stream); + } + else + { + stream.write(rawFile->buffer, rawFile->len); + } + } +} // namespace T6::raw_file diff --git a/src/ObjWriting/Game/T6/RawFile/AssetDumperRawFile.h b/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.h similarity index 52% rename from src/ObjWriting/Game/T6/RawFile/AssetDumperRawFile.h rename to src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.h index 1f9f033f..b784a1f2 100644 --- a/src/ObjWriting/Game/T6/RawFile/AssetDumperRawFile.h +++ b/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.h @@ -3,14 +3,10 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6 +namespace T6::raw_file { - class AssetDumperRawFile final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { - constexpr static size_t ANIMTREE_MAX_SIZE = 0xC000000; - - void DumpAnimtree(AssetDumpingContext& context, XAssetInfo* asset, std::ostream& stream); - protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; From 0eb14890ab937f2329652dae813c29587721e804 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Wed, 30 Jul 2025 21:41:39 +0100 Subject: [PATCH 14/35] refactor: streamline slug, qdb and script dumper --- src/ObjWriting/Game/IW5/ObjWriterIW5.cpp | 4 +-- .../Game/IW5/Script/AssetDumperScriptFile.cpp | 30 ----------------- .../Game/IW5/Script/ScriptDumperIW5.cpp | 33 +++++++++++++++++++ ...etDumperScriptFile.h => ScriptDumperIW5.h} | 6 ++-- src/ObjWriting/Game/T6/ObjWriterT6.cpp | 12 +++---- src/ObjWriting/Game/T6/Qdb/AssetDumperQdb.cpp | 20 ----------- src/ObjWriting/Game/T6/Qdb/QdbDumperT6.cpp | 23 +++++++++++++ .../Qdb/{AssetDumperQdb.h => QdbDumperT6.h} | 6 ++-- .../T6/Script/AssetDumperScriptParseTree.cpp | 20 ----------- .../Game/T6/Script/ScriptDumperT6.cpp | 23 +++++++++++++ ...mperScriptParseTree.h => ScriptDumperT6.h} | 6 ++-- .../Game/T6/Slug/AssetDumperSlug.cpp | 20 ----------- src/ObjWriting/Game/T6/Slug/SlugDumperT6.cpp | 23 +++++++++++++ .../{AssetDumperSlug.h => SlugDumperT6.h} | 6 ++-- 14 files changed, 122 insertions(+), 110 deletions(-) delete mode 100644 src/ObjWriting/Game/IW5/Script/AssetDumperScriptFile.cpp create mode 100644 src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.cpp rename src/ObjWriting/Game/IW5/Script/{AssetDumperScriptFile.h => ScriptDumperIW5.h} (70%) delete mode 100644 src/ObjWriting/Game/T6/Qdb/AssetDumperQdb.cpp create mode 100644 src/ObjWriting/Game/T6/Qdb/QdbDumperT6.cpp rename src/ObjWriting/Game/T6/Qdb/{AssetDumperQdb.h => QdbDumperT6.h} (72%) delete mode 100644 src/ObjWriting/Game/T6/Script/AssetDumperScriptParseTree.cpp create mode 100644 src/ObjWriting/Game/T6/Script/ScriptDumperT6.cpp rename src/ObjWriting/Game/T6/Script/{AssetDumperScriptParseTree.h => ScriptDumperT6.h} (69%) delete mode 100644 src/ObjWriting/Game/T6/Slug/AssetDumperSlug.cpp create mode 100644 src/ObjWriting/Game/T6/Slug/SlugDumperT6.cpp rename src/ObjWriting/Game/T6/Slug/{AssetDumperSlug.h => SlugDumperT6.h} (71%) diff --git a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp index 254a0d9b..89618e2c 100644 --- a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp +++ b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp @@ -11,7 +11,7 @@ #include "Menu/AssetDumperMenuList.h" #include "ObjWriting.h" #include "RawFile/RawFileDumperIW5.h" -#include "Script/AssetDumperScriptFile.h" +#include "Script/ScriptDumperIW5.h" #include "Sound/AssetDumperLoadedSound.h" #include "StringTable/AssetDumperStringTable.h" #include "Weapon/AssetDumperWeapon.h" @@ -62,7 +62,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) // DUMP_ASSET_POOL(AssetDumperSurfaceFxTable, m_surface_fx_table, ASSET_TYPE_SURFACE_FX) DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE) - DUMP_ASSET_POOL(AssetDumperScriptFile, m_script_file, ASSET_TYPE_SCRIPTFILE) + DUMP_ASSET_POOL(script::Dumper, m_script_file, ASSET_TYPE_SCRIPTFILE) DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE) DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD) // DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF) diff --git a/src/ObjWriting/Game/IW5/Script/AssetDumperScriptFile.cpp b/src/ObjWriting/Game/IW5/Script/AssetDumperScriptFile.cpp deleted file mode 100644 index c432a700..00000000 --- a/src/ObjWriting/Game/IW5/Script/AssetDumperScriptFile.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "AssetDumperScriptFile.h" - -using namespace IW5; - -bool AssetDumperScriptFile::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -// See https://github.com/xensik/gsc-tool#file-format for an in-depth explanation about the .gscbin format -void AssetDumperScriptFile::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - auto* scriptFile = asset->Asset(); - const auto assetFile = context.OpenAssetFile(asset->m_name + ".gscbin"); - - if (!assetFile) - return; - - auto& stream = *assetFile; - - // Dump the name and the numeric fields - stream.write(asset->m_name.c_str(), asset->m_name.size() + 1); - stream.write(reinterpret_cast(&scriptFile->compressedLen), sizeof(scriptFile->compressedLen)); - stream.write(reinterpret_cast(&scriptFile->len), sizeof(scriptFile->len)); - stream.write(reinterpret_cast(&scriptFile->bytecodeLen), sizeof(scriptFile->bytecodeLen)); - - // Dump the buffers - stream.write(scriptFile->buffer, scriptFile->compressedLen); - stream.write(reinterpret_cast(scriptFile->bytecode), scriptFile->bytecodeLen); -} diff --git a/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.cpp b/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.cpp new file mode 100644 index 00000000..c81ba1d4 --- /dev/null +++ b/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.cpp @@ -0,0 +1,33 @@ +#include "ScriptDumperIW5.h" + +using namespace IW5; + +namespace IW5::script +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + // See https://github.com/xensik/gsc-tool#file-format for an in-depth explanation about the .gscbin format + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + auto* scriptFile = asset->Asset(); + const auto assetFile = context.OpenAssetFile(asset->m_name + ".gscbin"); + + if (!assetFile) + return; + + auto& stream = *assetFile; + + // Dump the name and the numeric fields + stream.write(asset->m_name.c_str(), asset->m_name.size() + 1); + stream.write(reinterpret_cast(&scriptFile->compressedLen), sizeof(scriptFile->compressedLen)); + stream.write(reinterpret_cast(&scriptFile->len), sizeof(scriptFile->len)); + stream.write(reinterpret_cast(&scriptFile->bytecodeLen), sizeof(scriptFile->bytecodeLen)); + + // Dump the buffers + stream.write(scriptFile->buffer, scriptFile->compressedLen); + stream.write(reinterpret_cast(scriptFile->bytecode), scriptFile->bytecodeLen); + } +} // namespace IW5::script diff --git a/src/ObjWriting/Game/IW5/Script/AssetDumperScriptFile.h b/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.h similarity index 70% rename from src/ObjWriting/Game/IW5/Script/AssetDumperScriptFile.h rename to src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.h index 2397f387..7a3dce2b 100644 --- a/src/ObjWriting/Game/IW5/Script/AssetDumperScriptFile.h +++ b/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW5/IW5.h" -namespace IW5 +namespace IW5::script { - class AssetDumperScriptFile final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW5 +} // namespace IW5::script diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 79c6778c..73315ffe 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -11,10 +11,10 @@ #include "ObjWriting.h" #include "PhysConstraints/PhysConstraintsInfoStringDumperT6.h" #include "PhysPreset/PhysPresetInfoStringDumperT6.h" -#include "Qdb/AssetDumperQdb.h" +#include "Qdb/QdbDumperT6.h" #include "RawFile/RawFileDumperT6.h" -#include "Script/AssetDumperScriptParseTree.h" -#include "Slug/AssetDumperSlug.h" +#include "Script/ScriptDumperT6.h" +#include "Slug/SlugDumperT6.h" #include "Sound/AssetDumperSndBank.h" #include "Sound/AssetDumperSndDriverGlobals.h" #include "StringTable/AssetDumperStringTable.h" @@ -82,15 +82,15 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperDDLRoot, m_ddl, ASSET_TYPE_DDL) // DUMP_ASSET_POOL(AssetDumperGlasses, m_glasses, ASSET_TYPE_GLASSES) // DUMP_ASSET_POOL(AssetDumperEmblemSet, m_emblem_set, ASSET_TYPE_EMBLEMSET) - DUMP_ASSET_POOL(AssetDumperScriptParseTree, m_script, ASSET_TYPE_SCRIPTPARSETREE) + DUMP_ASSET_POOL(script::Dumper, m_script, ASSET_TYPE_SCRIPTPARSETREE) // DUMP_ASSET_POOL(AssetDumperKeyValuePairs, m_key_value_pairs, ASSET_TYPE_KEYVALUEPAIRS) DUMP_ASSET_POOL(AssetDumperVehicle, m_vehicle, ASSET_TYPE_VEHICLEDEF) // DUMP_ASSET_POOL(AssetDumperMemoryBlock, m_memory_block, ASSET_TYPE_MEMORYBLOCK) // DUMP_ASSET_POOL(AssetDumperAddonMapEnts, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS) DUMP_ASSET_POOL(AssetDumperTracer, m_tracer, ASSET_TYPE_TRACER) // DUMP_ASSET_POOL(AssetDumperSkinnedVertsDef, m_skinned_verts, ASSET_TYPE_SKINNEDVERTS) - DUMP_ASSET_POOL(AssetDumperQdb, m_qdb, ASSET_TYPE_QDB) - DUMP_ASSET_POOL(AssetDumperSlug, m_slug, ASSET_TYPE_SLUG) + DUMP_ASSET_POOL(qdb::Dumper, m_qdb, ASSET_TYPE_QDB) + DUMP_ASSET_POOL(slug::Dumper, m_slug, ASSET_TYPE_SLUG) // DUMP_ASSET_POOL(AssetDumperFootstepTableDef, m_footstep_table, ASSET_TYPE_FOOTSTEP_TABLE) // DUMP_ASSET_POOL(AssetDumperFootstepFXTableDef, m_footstep_fx_table, ASSET_TYPE_FOOTSTEPFX_TABLE) DUMP_ASSET_POOL(AssetDumperZBarrier, m_zbarrier, ASSET_TYPE_ZBARRIER) diff --git a/src/ObjWriting/Game/T6/Qdb/AssetDumperQdb.cpp b/src/ObjWriting/Game/T6/Qdb/AssetDumperQdb.cpp deleted file mode 100644 index dde4a739..00000000 --- a/src/ObjWriting/Game/T6/Qdb/AssetDumperQdb.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "AssetDumperQdb.h" - -using namespace T6; - -bool AssetDumperQdb::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperQdb::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* qdb = asset->Asset(); - const auto assetFile = context.OpenAssetFile(asset->m_name); - - if (!assetFile) - return; - - auto& stream = *assetFile; - stream.write(qdb->buffer, qdb->len); -} diff --git a/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.cpp b/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.cpp new file mode 100644 index 00000000..5d4aa41b --- /dev/null +++ b/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.cpp @@ -0,0 +1,23 @@ +#include "QdbDumperT6.h" + +using namespace T6; + +namespace T6::qdb +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* qdb = asset->Asset(); + const auto assetFile = context.OpenAssetFile(asset->m_name); + + if (!assetFile) + return; + + auto& stream = *assetFile; + stream.write(qdb->buffer, qdb->len); + } +} // namespace T6::qdb diff --git a/src/ObjWriting/Game/T6/Qdb/AssetDumperQdb.h b/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.h similarity index 72% rename from src/ObjWriting/Game/T6/Qdb/AssetDumperQdb.h rename to src/ObjWriting/Game/T6/Qdb/QdbDumperT6.h index fd6a7456..9f270398 100644 --- a/src/ObjWriting/Game/T6/Qdb/AssetDumperQdb.h +++ b/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6 +namespace T6::qdb { - class AssetDumperQdb final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6 +} // namespace T6::qdb diff --git a/src/ObjWriting/Game/T6/Script/AssetDumperScriptParseTree.cpp b/src/ObjWriting/Game/T6/Script/AssetDumperScriptParseTree.cpp deleted file mode 100644 index fb1ff079..00000000 --- a/src/ObjWriting/Game/T6/Script/AssetDumperScriptParseTree.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "AssetDumperScriptParseTree.h" - -using namespace T6; - -bool AssetDumperScriptParseTree::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperScriptParseTree::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* scriptParseTree = asset->Asset(); - const auto assetFile = context.OpenAssetFile(asset->m_name); - - if (!assetFile) - return; - - auto& stream = *assetFile; - stream.write(scriptParseTree->buffer, scriptParseTree->len); -} diff --git a/src/ObjWriting/Game/T6/Script/ScriptDumperT6.cpp b/src/ObjWriting/Game/T6/Script/ScriptDumperT6.cpp new file mode 100644 index 00000000..15c4eb6c --- /dev/null +++ b/src/ObjWriting/Game/T6/Script/ScriptDumperT6.cpp @@ -0,0 +1,23 @@ +#include "ScriptDumperT6.h" + +using namespace T6; + +namespace T6::script +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* scriptParseTree = asset->Asset(); + const auto assetFile = context.OpenAssetFile(asset->m_name); + + if (!assetFile) + return; + + auto& stream = *assetFile; + stream.write(scriptParseTree->buffer, scriptParseTree->len); + } +} // namespace T6::script diff --git a/src/ObjWriting/Game/T6/Script/AssetDumperScriptParseTree.h b/src/ObjWriting/Game/T6/Script/ScriptDumperT6.h similarity index 69% rename from src/ObjWriting/Game/T6/Script/AssetDumperScriptParseTree.h rename to src/ObjWriting/Game/T6/Script/ScriptDumperT6.h index 8ff1db2e..fb388b36 100644 --- a/src/ObjWriting/Game/T6/Script/AssetDumperScriptParseTree.h +++ b/src/ObjWriting/Game/T6/Script/ScriptDumperT6.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6 +namespace T6::script { - class AssetDumperScriptParseTree final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6 +} // namespace T6::script diff --git a/src/ObjWriting/Game/T6/Slug/AssetDumperSlug.cpp b/src/ObjWriting/Game/T6/Slug/AssetDumperSlug.cpp deleted file mode 100644 index 09dd50a4..00000000 --- a/src/ObjWriting/Game/T6/Slug/AssetDumperSlug.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "AssetDumperSlug.h" - -using namespace T6; - -bool AssetDumperSlug::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperSlug::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* slug = asset->Asset(); - const auto assetFile = context.OpenAssetFile(asset->m_name); - - if (!assetFile) - return; - - auto& stream = *assetFile; - stream.write(slug->buffer, slug->len); -} diff --git a/src/ObjWriting/Game/T6/Slug/SlugDumperT6.cpp b/src/ObjWriting/Game/T6/Slug/SlugDumperT6.cpp new file mode 100644 index 00000000..63f07f7a --- /dev/null +++ b/src/ObjWriting/Game/T6/Slug/SlugDumperT6.cpp @@ -0,0 +1,23 @@ +#include "SlugDumperT6.h" + +using namespace T6; + +namespace T6::slug +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* slug = asset->Asset(); + const auto assetFile = context.OpenAssetFile(asset->m_name); + + if (!assetFile) + return; + + auto& stream = *assetFile; + stream.write(slug->buffer, slug->len); + } +} // namespace T6::slug diff --git a/src/ObjWriting/Game/T6/Slug/AssetDumperSlug.h b/src/ObjWriting/Game/T6/Slug/SlugDumperT6.h similarity index 71% rename from src/ObjWriting/Game/T6/Slug/AssetDumperSlug.h rename to src/ObjWriting/Game/T6/Slug/SlugDumperT6.h index 01598810..f33960e6 100644 --- a/src/ObjWriting/Game/T6/Slug/AssetDumperSlug.h +++ b/src/ObjWriting/Game/T6/Slug/SlugDumperT6.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6 +namespace T6::slug { - class AssetDumperSlug final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6 +} // namespace T6::slug From e26c66ed605b2b498d7cd782a3fba989ca87a3cc Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Wed, 30 Jul 2025 22:59:57 +0100 Subject: [PATCH 15/35] refactor: streamline stringtable dumper --- src/ObjWriting/Game/IW3/ObjWriterIW3.cpp | 4 +- .../StringTable/AssetDumperStringTable.cpp | 31 -------------- .../IW3/StringTable/StringTableDumperIW3.cpp | 34 +++++++++++++++ ...erStringTable.h => StringTableDumperIW3.h} | 4 +- src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 4 +- .../StringTable/AssetDumperStringTable.cpp | 39 ----------------- .../IW4/StringTable/StringTableDumperIW4.cpp | 42 +++++++++++++++++++ ...erStringTable.h => StringTableDumperIW4.h} | 6 +-- src/ObjWriting/Game/IW5/ObjWriterIW5.cpp | 4 +- .../StringTable/AssetDumperStringTable.cpp | 39 ----------------- .../IW5/StringTable/StringTableDumperIW5.cpp | 42 +++++++++++++++++++ ...erStringTable.h => StringTableDumperIW5.h} | 6 +-- src/ObjWriting/Game/T5/ObjWriterT5.cpp | 4 +- .../T5/StringTable/AssetDumperStringTable.cpp | 39 ----------------- .../T5/StringTable/StringTableDumperT5.cpp | 42 +++++++++++++++++++ ...perStringTable.h => StringTableDumperT5.h} | 6 +-- src/ObjWriting/Game/T6/ObjWriterT6.cpp | 4 +- .../T6/StringTable/AssetDumperStringTable.cpp | 39 ----------------- .../T6/StringTable/StringTableDumperT6.cpp | 42 +++++++++++++++++++ ...perStringTable.h => StringTableDumperT6.h} | 6 +-- 20 files changed, 226 insertions(+), 211 deletions(-) delete mode 100644 src/ObjWriting/Game/IW3/StringTable/AssetDumperStringTable.cpp create mode 100644 src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.cpp rename src/ObjWriting/Game/IW3/StringTable/{AssetDumperStringTable.h => StringTableDumperIW3.h} (75%) delete mode 100644 src/ObjWriting/Game/IW4/StringTable/AssetDumperStringTable.cpp create mode 100644 src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.cpp rename src/ObjWriting/Game/IW4/StringTable/{AssetDumperStringTable.h => StringTableDumperIW4.h} (68%) delete mode 100644 src/ObjWriting/Game/IW5/StringTable/AssetDumperStringTable.cpp create mode 100644 src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.cpp rename src/ObjWriting/Game/IW5/StringTable/{AssetDumperStringTable.h => StringTableDumperIW5.h} (68%) delete mode 100644 src/ObjWriting/Game/T5/StringTable/AssetDumperStringTable.cpp create mode 100644 src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.cpp rename src/ObjWriting/Game/T5/StringTable/{AssetDumperStringTable.h => StringTableDumperT5.h} (68%) delete mode 100644 src/ObjWriting/Game/T6/StringTable/AssetDumperStringTable.cpp create mode 100644 src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.cpp rename src/ObjWriting/Game/T6/StringTable/{AssetDumperStringTable.h => StringTableDumperT6.h} (68%) diff --git a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp index be2b3472..2c5d2e13 100644 --- a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp +++ b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp @@ -9,7 +9,7 @@ #include "ObjWriting.h" #include "RawFile/RawFileDumperIW3.h" #include "Sound/AssetDumperLoadedSound.h" -#include "StringTable/AssetDumperStringTable.h" +#include "StringTable/StringTableDumperIW3.h" #include "Weapon/AssetDumperWeapon.h" using namespace IW3; @@ -50,7 +50,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE) - DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE) + DUMP_ASSET_POOL(string_table::Dumper, m_string_table, ASSET_TYPE_STRINGTABLE) return true; diff --git a/src/ObjWriting/Game/IW3/StringTable/AssetDumperStringTable.cpp b/src/ObjWriting/Game/IW3/StringTable/AssetDumperStringTable.cpp deleted file mode 100644 index 26c8d514..00000000 --- a/src/ObjWriting/Game/IW3/StringTable/AssetDumperStringTable.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "AssetDumperStringTable.h" - -#include "Csv/CsvStream.h" - -using namespace IW3; - -bool AssetDumperStringTable::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperStringTable::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* stringTable = asset->Asset(); - const auto assetFile = context.OpenAssetFile(asset->m_name); - - if (!assetFile) - return; - - CsvOutputStream csv(*assetFile); - - for (auto row = 0; row < stringTable->rowCount; row++) - { - for (auto column = 0; column < stringTable->columnCount; column++) - { - csv.WriteColumn(stringTable->values[column + row * stringTable->columnCount]); - } - - csv.NextRow(); - } -} diff --git a/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.cpp b/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.cpp new file mode 100644 index 00000000..381660a7 --- /dev/null +++ b/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.cpp @@ -0,0 +1,34 @@ +#include "StringTableDumperIW3.h" + +#include "Csv/CsvStream.h" + +using namespace IW3; + +namespace IW3::string_table +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* stringTable = asset->Asset(); + const auto assetFile = context.OpenAssetFile(asset->m_name); + + if (!assetFile) + return; + + CsvOutputStream csv(*assetFile); + + for (auto row = 0; row < stringTable->rowCount; row++) + { + for (auto column = 0; column < stringTable->columnCount; column++) + { + csv.WriteColumn(stringTable->values[column + row * stringTable->columnCount]); + } + + csv.NextRow(); + } + } +} // namespace IW3::string_table diff --git a/src/ObjWriting/Game/IW3/StringTable/AssetDumperStringTable.h b/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.h similarity index 75% rename from src/ObjWriting/Game/IW3/StringTable/AssetDumperStringTable.h rename to src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.h index 915f4a40..dcdbec06 100644 --- a/src/ObjWriting/Game/IW3/StringTable/AssetDumperStringTable.h +++ b/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.h @@ -3,9 +3,9 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW3/IW3.h" -namespace IW3 +namespace IW3::string_table { - class AssetDumperStringTable final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index c00e44f0..6da19f72 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -19,7 +19,7 @@ #include "Shader/AssetDumperVertexShader.h" #include "Sound/AssetDumperLoadedSound.h" #include "Sound/AssetDumperSndCurve.h" -#include "StringTable/AssetDumperStringTable.h" +#include "StringTable/StringTableDumperIW4.h" #include "StructuredDataDef/AssetDumperStructuredDataDefSet.h" #include "Techset/AssetDumperTechniqueSet.h" #include "Tracer/AssetDumperTracer.h" @@ -71,7 +71,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE) - DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE) + DUMP_ASSET_POOL(string_table::Dumper, m_string_table, ASSET_TYPE_STRINGTABLE) DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD) DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF) DUMP_ASSET_POOL(AssetDumperTracer, m_tracer, ASSET_TYPE_TRACER) diff --git a/src/ObjWriting/Game/IW4/StringTable/AssetDumperStringTable.cpp b/src/ObjWriting/Game/IW4/StringTable/AssetDumperStringTable.cpp deleted file mode 100644 index 8a7bd5e4..00000000 --- a/src/ObjWriting/Game/IW4/StringTable/AssetDumperStringTable.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "AssetDumperStringTable.h" - -#include "Csv/CsvStream.h" - -using namespace IW4; - -bool AssetDumperStringTable::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperStringTable::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* stringTable = asset->Asset(); - const auto assetFile = context.OpenAssetFile(asset->m_name); - - if (!assetFile) - return; - - CsvOutputStream csv(*assetFile); - - for (auto row = 0; row < stringTable->rowCount; row++) - { - for (auto column = 0; column < stringTable->columnCount; column++) - { - const auto* cell = &stringTable->values[column + row * stringTable->columnCount]; - if (cell->string != nullptr) - { - csv.WriteColumn(cell->string); - } - else - { - csv.WriteColumn(""); - } - } - - csv.NextRow(); - } -} diff --git a/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.cpp b/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.cpp new file mode 100644 index 00000000..7e86896a --- /dev/null +++ b/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.cpp @@ -0,0 +1,42 @@ +#include "StringTableDumperIW4.h" + +#include "Csv/CsvStream.h" + +using namespace IW4; + +namespace IW4::string_table +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* stringTable = asset->Asset(); + const auto assetFile = context.OpenAssetFile(asset->m_name); + + if (!assetFile) + return; + + CsvOutputStream csv(*assetFile); + + for (auto row = 0; row < stringTable->rowCount; row++) + { + for (auto column = 0; column < stringTable->columnCount; column++) + { + const auto* cell = &stringTable->values[column + row * stringTable->columnCount]; + if (cell->string != nullptr) + { + csv.WriteColumn(cell->string); + } + else + { + csv.WriteColumn(""); + } + } + + csv.NextRow(); + } + } +} // namespace IW4::string_table diff --git a/src/ObjWriting/Game/IW4/StringTable/AssetDumperStringTable.h b/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.h similarity index 68% rename from src/ObjWriting/Game/IW4/StringTable/AssetDumperStringTable.h rename to src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.h index 9d50d431..2321c6ae 100644 --- a/src/ObjWriting/Game/IW4/StringTable/AssetDumperStringTable.h +++ b/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4 +namespace IW4::string_table { - class AssetDumperStringTable final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4 +} // namespace IW4::string_table diff --git a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp index 89618e2c..5bf579ea 100644 --- a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp +++ b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp @@ -13,7 +13,7 @@ #include "RawFile/RawFileDumperIW5.h" #include "Script/ScriptDumperIW5.h" #include "Sound/AssetDumperLoadedSound.h" -#include "StringTable/AssetDumperStringTable.h" +#include "StringTable/StringTableDumperIW5.h" #include "Weapon/AssetDumperWeapon.h" #include "Weapon/AssetDumperWeaponAttachment.h" @@ -63,7 +63,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperSurfaceFxTable, m_surface_fx_table, ASSET_TYPE_SURFACE_FX) DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE) DUMP_ASSET_POOL(script::Dumper, m_script_file, ASSET_TYPE_SCRIPTFILE) - DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE) + DUMP_ASSET_POOL(string_table::Dumper, m_string_table, ASSET_TYPE_STRINGTABLE) DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD) // DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF) // DUMP_ASSET_POOL(AssetDumperTracerDef, m_tracer, ASSET_TYPE_TRACER) diff --git a/src/ObjWriting/Game/IW5/StringTable/AssetDumperStringTable.cpp b/src/ObjWriting/Game/IW5/StringTable/AssetDumperStringTable.cpp deleted file mode 100644 index 0612c075..00000000 --- a/src/ObjWriting/Game/IW5/StringTable/AssetDumperStringTable.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "AssetDumperStringTable.h" - -#include "Csv/CsvStream.h" - -using namespace IW5; - -bool AssetDumperStringTable::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperStringTable::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* stringTable = asset->Asset(); - const auto assetFile = context.OpenAssetFile(asset->m_name); - - if (!assetFile) - return; - - CsvOutputStream csv(*assetFile); - - for (auto row = 0; row < stringTable->rowCount; row++) - { - for (auto column = 0; column < stringTable->columnCount; column++) - { - const auto* cell = &stringTable->values[column + row * stringTable->columnCount]; - if (cell->string != nullptr) - { - csv.WriteColumn(cell->string); - } - else - { - csv.WriteColumn(""); - } - } - - csv.NextRow(); - } -} diff --git a/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.cpp b/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.cpp new file mode 100644 index 00000000..023013c1 --- /dev/null +++ b/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.cpp @@ -0,0 +1,42 @@ +#include "StringTableDumperIW5.h" + +#include "Csv/CsvStream.h" + +using namespace IW5; + +namespace IW5::string_table +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* stringTable = asset->Asset(); + const auto assetFile = context.OpenAssetFile(asset->m_name); + + if (!assetFile) + return; + + CsvOutputStream csv(*assetFile); + + for (auto row = 0; row < stringTable->rowCount; row++) + { + for (auto column = 0; column < stringTable->columnCount; column++) + { + const auto* cell = &stringTable->values[column + row * stringTable->columnCount]; + if (cell->string != nullptr) + { + csv.WriteColumn(cell->string); + } + else + { + csv.WriteColumn(""); + } + } + + csv.NextRow(); + } + } +} // namespace IW5::string_table diff --git a/src/ObjWriting/Game/IW5/StringTable/AssetDumperStringTable.h b/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.h similarity index 68% rename from src/ObjWriting/Game/IW5/StringTable/AssetDumperStringTable.h rename to src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.h index 9e834267..fe6d5e4c 100644 --- a/src/ObjWriting/Game/IW5/StringTable/AssetDumperStringTable.h +++ b/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW5/IW5.h" -namespace IW5 +namespace IW5::string_table { - class AssetDumperStringTable final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW5 +} // namespace IW5::string_table diff --git a/src/ObjWriting/Game/T5/ObjWriterT5.cpp b/src/ObjWriting/Game/T5/ObjWriterT5.cpp index ce3c8eec..f224f067 100644 --- a/src/ObjWriting/Game/T5/ObjWriterT5.cpp +++ b/src/ObjWriting/Game/T5/ObjWriterT5.cpp @@ -8,7 +8,7 @@ #include "ObjWriting.h" #include "RawFile/RawFileDumperT5.h" #include "Sound/AssetDumperSndBank.h" -#include "StringTable/AssetDumperStringTable.h" +#include "StringTable/StringTableDumperT5.h" #include "Weapon/AssetDumperWeapon.h" using namespace T5; @@ -50,7 +50,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE) - DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE) + DUMP_ASSET_POOL(string_table::Dumper, m_string_table, ASSET_TYPE_STRINGTABLE) // DUMP_ASSET_POOL(AssetDumperPackIndex, m_pack_index, ASSET_TYPE_PACK_INDEX) // DUMP_ASSET_POOL(AssetDumperXGlobals, m_xglobals, ASSET_TYPE_XGLOBALS) // DUMP_ASSET_POOL(AssetDumperDDLRoot, m_ddl, ASSET_TYPE_DDL) diff --git a/src/ObjWriting/Game/T5/StringTable/AssetDumperStringTable.cpp b/src/ObjWriting/Game/T5/StringTable/AssetDumperStringTable.cpp deleted file mode 100644 index 77899c6f..00000000 --- a/src/ObjWriting/Game/T5/StringTable/AssetDumperStringTable.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "AssetDumperStringTable.h" - -#include "Csv/CsvStream.h" - -using namespace T5; - -bool AssetDumperStringTable::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperStringTable::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* stringTable = asset->Asset(); - const auto assetFile = context.OpenAssetFile(asset->m_name); - - if (!assetFile) - return; - - CsvOutputStream csv(*assetFile); - - for (auto row = 0; row < stringTable->rowCount; row++) - { - for (auto column = 0; column < stringTable->columnCount; column++) - { - const auto* cell = &stringTable->values[column + row * stringTable->columnCount]; - if (cell->string != nullptr) - { - csv.WriteColumn(cell->string); - } - else - { - csv.WriteColumn(""); - } - } - - csv.NextRow(); - } -} diff --git a/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.cpp b/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.cpp new file mode 100644 index 00000000..e77ade0b --- /dev/null +++ b/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.cpp @@ -0,0 +1,42 @@ +#include "StringTableDumperT5.h" + +#include "Csv/CsvStream.h" + +using namespace T5; + +namespace T5::string_table +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* stringTable = asset->Asset(); + const auto assetFile = context.OpenAssetFile(asset->m_name); + + if (!assetFile) + return; + + CsvOutputStream csv(*assetFile); + + for (auto row = 0; row < stringTable->rowCount; row++) + { + for (auto column = 0; column < stringTable->columnCount; column++) + { + const auto* cell = &stringTable->values[column + row * stringTable->columnCount]; + if (cell->string != nullptr) + { + csv.WriteColumn(cell->string); + } + else + { + csv.WriteColumn(""); + } + } + + csv.NextRow(); + } + } +} // namespace T5::string_table diff --git a/src/ObjWriting/Game/T5/StringTable/AssetDumperStringTable.h b/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.h similarity index 68% rename from src/ObjWriting/Game/T5/StringTable/AssetDumperStringTable.h rename to src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.h index 64b2739c..c9621b4d 100644 --- a/src/ObjWriting/Game/T5/StringTable/AssetDumperStringTable.h +++ b/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T5/T5.h" -namespace T5 +namespace T5::string_table { - class AssetDumperStringTable final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T5 +} // namespace T5::string_table diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 73315ffe..4edd49fa 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -17,7 +17,7 @@ #include "Slug/SlugDumperT6.h" #include "Sound/AssetDumperSndBank.h" #include "Sound/AssetDumperSndDriverGlobals.h" -#include "StringTable/AssetDumperStringTable.h" +#include "StringTable/StringTableDumperT6.h" #include "Techset/AssetDumperTechniqueSet.h" #include "Tracer/AssetDumperTracer.h" #include "Vehicle/AssetDumperVehicle.h" @@ -76,7 +76,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE) - DUMP_ASSET_POOL(AssetDumperStringTable, m_string_table, ASSET_TYPE_STRINGTABLE) + DUMP_ASSET_POOL(string_table::Dumper, m_string_table, ASSET_TYPE_STRINGTABLE) DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD) // DUMP_ASSET_POOL(AssetDumperXGlobals, m_xglobals, ASSET_TYPE_XGLOBALS) // DUMP_ASSET_POOL(AssetDumperDDLRoot, m_ddl, ASSET_TYPE_DDL) diff --git a/src/ObjWriting/Game/T6/StringTable/AssetDumperStringTable.cpp b/src/ObjWriting/Game/T6/StringTable/AssetDumperStringTable.cpp deleted file mode 100644 index 2fb76cec..00000000 --- a/src/ObjWriting/Game/T6/StringTable/AssetDumperStringTable.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "AssetDumperStringTable.h" - -#include "Csv/CsvStream.h" - -using namespace T6; - -bool AssetDumperStringTable::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperStringTable::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* stringTable = asset->Asset(); - const auto assetFile = context.OpenAssetFile(asset->m_name); - - if (!assetFile) - return; - - CsvOutputStream csv(*assetFile); - - for (auto row = 0; row < stringTable->rowCount; row++) - { - for (auto column = 0; column < stringTable->columnCount; column++) - { - const auto* cell = &stringTable->values[column + row * stringTable->columnCount]; - if (cell->string != nullptr) - { - csv.WriteColumn(cell->string); - } - else - { - csv.WriteColumn(""); - } - } - - csv.NextRow(); - } -} diff --git a/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.cpp b/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.cpp new file mode 100644 index 00000000..83f0c860 --- /dev/null +++ b/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.cpp @@ -0,0 +1,42 @@ +#include "StringTableDumperT6.h" + +#include "Csv/CsvStream.h" + +using namespace T6; + +namespace T6::string_table +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* stringTable = asset->Asset(); + const auto assetFile = context.OpenAssetFile(asset->m_name); + + if (!assetFile) + return; + + CsvOutputStream csv(*assetFile); + + for (auto row = 0; row < stringTable->rowCount; row++) + { + for (auto column = 0; column < stringTable->columnCount; column++) + { + const auto* cell = &stringTable->values[column + row * stringTable->columnCount]; + if (cell->string != nullptr) + { + csv.WriteColumn(cell->string); + } + else + { + csv.WriteColumn(""); + } + } + + csv.NextRow(); + } + } +} // namespace T6::string_table diff --git a/src/ObjWriting/Game/T6/StringTable/AssetDumperStringTable.h b/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.h similarity index 68% rename from src/ObjWriting/Game/T6/StringTable/AssetDumperStringTable.h rename to src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.h index 1618db88..0fbbdb18 100644 --- a/src/ObjWriting/Game/T6/StringTable/AssetDumperStringTable.h +++ b/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6 +namespace T6::string_table { - class AssetDumperStringTable final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6 +} // namespace T6::string_table From ea1c2321641743c2f36dadae81624529cad35c5a Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Wed, 30 Jul 2025 23:22:18 +0100 Subject: [PATCH 16/35] refactor: streamline techset dumper --- src/ObjCommon/Shader/ShaderCommon.cpp | 16 +++ src/ObjCommon/Shader/ShaderCommon.h | 9 ++ src/ObjCommon/Techset/TechsetCommon.cpp | 16 +++ src/ObjCommon/Techset/TechsetCommon.h | 9 ++ src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 4 +- .../IW4/Techset/AssetDumperTechniqueSet.h | 17 --- ...rTechniqueSet.cpp => TechsetDumperIW4.cpp} | 63 +++++------ .../Game/IW4/Techset/TechsetDumperIW4.h | 14 +++ src/ObjWriting/Game/T6/ObjWriterT6.cpp | 4 +- .../T6/Techset/AssetDumperTechniqueSet.cpp | 106 ----------------- .../Game/T6/Techset/AssetDumperTechniqueSet.h | 17 --- .../Game/T6/Techset/TechsetDumperT6.cpp | 107 ++++++++++++++++++ .../Game/T6/Techset/TechsetDumperT6.h | 14 +++ 13 files changed, 216 insertions(+), 180 deletions(-) create mode 100644 src/ObjCommon/Shader/ShaderCommon.cpp create mode 100644 src/ObjCommon/Shader/ShaderCommon.h create mode 100644 src/ObjCommon/Techset/TechsetCommon.cpp create mode 100644 src/ObjCommon/Techset/TechsetCommon.h delete mode 100644 src/ObjWriting/Game/IW4/Techset/AssetDumperTechniqueSet.h rename src/ObjWriting/Game/IW4/Techset/{AssetDumperTechniqueSet.cpp => TechsetDumperIW4.cpp} (94%) create mode 100644 src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.h delete mode 100644 src/ObjWriting/Game/T6/Techset/AssetDumperTechniqueSet.cpp delete mode 100644 src/ObjWriting/Game/T6/Techset/AssetDumperTechniqueSet.h create mode 100644 src/ObjWriting/Game/T6/Techset/TechsetDumperT6.cpp create mode 100644 src/ObjWriting/Game/T6/Techset/TechsetDumperT6.h diff --git a/src/ObjCommon/Shader/ShaderCommon.cpp b/src/ObjCommon/Shader/ShaderCommon.cpp new file mode 100644 index 00000000..e7cb5994 --- /dev/null +++ b/src/ObjCommon/Shader/ShaderCommon.cpp @@ -0,0 +1,16 @@ +#include "ShaderCommon.h" + +#include + +namespace shader +{ + std::string GetFileNameForPixelShaderAssetName(const std::string& assetName) + { + return std::format("shader_bin/ps_{}.cso", assetName); + } + + std::string GetFileNameForVertexShaderAssetName(const std::string& assetName) + { + return std::format("shader_bin/vs_{}.cso", assetName); + } +} // namespace phys_constraints diff --git a/src/ObjCommon/Shader/ShaderCommon.h b/src/ObjCommon/Shader/ShaderCommon.h new file mode 100644 index 00000000..0e3ef878 --- /dev/null +++ b/src/ObjCommon/Shader/ShaderCommon.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +namespace shader +{ + std::string GetFileNameForPixelShaderAssetName(const std::string& assetName); + std::string GetFileNameForVertexShaderAssetName(const std::string& assetName); +} // namespace shader diff --git a/src/ObjCommon/Techset/TechsetCommon.cpp b/src/ObjCommon/Techset/TechsetCommon.cpp new file mode 100644 index 00000000..0deff7f2 --- /dev/null +++ b/src/ObjCommon/Techset/TechsetCommon.cpp @@ -0,0 +1,16 @@ +#include "TechsetCommon.h" + +#include + +namespace techset +{ + std::string GetFileNameForTechniqueName(const std::string& assetName) + { + return std::format("techniques/{}.tech", assetName); + } + + std::string GetFileNameForTechsetName(const std::string& assetName) + { + return std::format("techsets/{}.techset", assetName); + } +} // namespace phys_constraints diff --git a/src/ObjCommon/Techset/TechsetCommon.h b/src/ObjCommon/Techset/TechsetCommon.h new file mode 100644 index 00000000..61e467c0 --- /dev/null +++ b/src/ObjCommon/Techset/TechsetCommon.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +namespace techset +{ + std::string GetFileNameForTechniqueName(const std::string& assetName); + std::string GetFileNameForTechsetName(const std::string& assetName); +} diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 6da19f72..9bf0047c 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -21,7 +21,7 @@ #include "Sound/AssetDumperSndCurve.h" #include "StringTable/StringTableDumperIW4.h" #include "StructuredDataDef/AssetDumperStructuredDataDefSet.h" -#include "Techset/AssetDumperTechniqueSet.h" +#include "Techset/TechsetDumperIW4.h" #include "Tracer/AssetDumperTracer.h" #include "Vehicle/AssetDumperVehicle.h" #include "Weapon/AssetDumperWeapon.h" @@ -49,7 +49,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const #endif DUMP_ASSET_POOL(AssetDumperPixelShader, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER) DUMP_ASSET_POOL(AssetDumperVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER) - DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) + DUMP_ASSET_POOL(techset::Dumper, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) // DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND) DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE) diff --git a/src/ObjWriting/Game/IW4/Techset/AssetDumperTechniqueSet.h b/src/ObjWriting/Game/IW4/Techset/AssetDumperTechniqueSet.h deleted file mode 100644 index 67495b9b..00000000 --- a/src/ObjWriting/Game/IW4/Techset/AssetDumperTechniqueSet.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/IW4/IW4.h" - -namespace IW4 -{ - class AssetDumperTechniqueSet final : public AbstractAssetDumper - { - static std::string GetTechniqueFileName(const MaterialTechnique* technique); - static std::string GetTechsetFileName(const MaterialTechniqueSet* techset); - - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace IW4 diff --git a/src/ObjWriting/Game/IW4/Techset/AssetDumperTechniqueSet.cpp b/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.cpp similarity index 94% rename from src/ObjWriting/Game/IW4/Techset/AssetDumperTechniqueSet.cpp rename to src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.cpp index 101d323d..2fa97986 100644 --- a/src/ObjWriting/Game/IW4/Techset/AssetDumperTechniqueSet.cpp +++ b/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.cpp @@ -1,9 +1,10 @@ -#include "AssetDumperTechniqueSet.h" +#include "TechsetDumperIW4.h" #include "Dumping/AbstractTextDumper.h" #include "Game/IW4/TechsetConstantsIW4.h" #include "Pool/GlobalAssetPool.h" #include "Shader/D3D9ShaderAnalyser.h" +#include "Techset/TechsetCommon.h" #include #include @@ -12,6 +13,7 @@ #include using namespace IW4; +using namespace ::techset; namespace IW4 { @@ -531,48 +533,37 @@ namespace IW4 }; } // namespace IW4 -std::string AssetDumperTechniqueSet::GetTechniqueFileName(const MaterialTechnique* technique) +namespace IW4::techset { - std::ostringstream ss; - ss << "techniques/" << technique->name << ".tech"; - return ss.str(); -} - -std::string AssetDumperTechniqueSet::GetTechsetFileName(const MaterialTechniqueSet* techset) -{ - std::ostringstream ss; - ss << "techsets/" << techset->name << ".techset"; - return ss.str(); -} - -bool AssetDumperTechniqueSet::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperTechniqueSet::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* techset = asset->Asset(); - - const auto techsetFile = context.OpenAssetFile(GetTechsetFileName(techset)); - - if (techsetFile) + bool Dumper::ShouldDump(XAssetInfo* asset) { - TechsetFileWriter writer(*techsetFile); - writer.DumpTechset(techset); + return true; } - auto* techniqueState = context.GetZoneAssetDumperState(); - for (const auto* technique : techset->techniques) + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { - if (technique && techniqueState->ShouldDumpTechnique(technique)) + const auto* techset = asset->Asset(); + + const auto techsetFile = context.OpenAssetFile(GetFileNameForTechsetName(techset->name)); + + if (techsetFile) { - const auto techniqueFile = context.OpenAssetFile(GetTechniqueFileName(technique)); - if (techniqueFile) + TechsetFileWriter writer(*techsetFile); + writer.DumpTechset(techset); + } + + auto* techniqueState = context.GetZoneAssetDumperState(); + for (const auto* technique : techset->techniques) + { + if (technique && techniqueState->ShouldDumpTechnique(technique)) { - TechniqueFileWriter writer(*techniqueFile); - writer.DumpTechnique(technique); + const auto techniqueFile = context.OpenAssetFile(GetFileNameForTechniqueName(technique->name)); + if (techniqueFile) + { + TechniqueFileWriter writer(*techniqueFile); + writer.DumpTechnique(technique); + } } } } -} +} // namespace IW4::techset diff --git a/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.h b/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.h new file mode 100644 index 00000000..97535e3e --- /dev/null +++ b/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.h @@ -0,0 +1,14 @@ +#pragma once + +#include "Dumping/AbstractAssetDumper.h" +#include "Game/IW4/IW4.h" + +namespace IW4::techset +{ + class Dumper final : public AbstractAssetDumper + { + protected: + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + }; +} // namespace IW4::techset diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 4edd49fa..937ea121 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -18,7 +18,7 @@ #include "Sound/AssetDumperSndBank.h" #include "Sound/AssetDumperSndDriverGlobals.h" #include "StringTable/StringTableDumperT6.h" -#include "Techset/AssetDumperTechniqueSet.h" +#include "Techset/TechsetDumperT6.h" #include "Tracer/AssetDumperTracer.h" #include "Vehicle/AssetDumperVehicle.h" #include "Weapon/AssetDumperWeapon.h" @@ -52,7 +52,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) - DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) + DUMP_ASSET_POOL(techset::Dumper, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank, ASSET_TYPE_SOUND) // DUMP_ASSET_POOL(AssetDumperSndPatch, m_sound_patch, ASSET_TYPE_SOUND_PATCH) diff --git a/src/ObjWriting/Game/T6/Techset/AssetDumperTechniqueSet.cpp b/src/ObjWriting/Game/T6/Techset/AssetDumperTechniqueSet.cpp deleted file mode 100644 index e5b0b142..00000000 --- a/src/ObjWriting/Game/T6/Techset/AssetDumperTechniqueSet.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "AssetDumperTechniqueSet.h" - -#include -#include - -using namespace T6; - -class ShaderZoneState final : public IZoneAssetDumperState -{ -public: - bool ShouldDumpTechnique(const MaterialTechnique* technique) - { - const auto existingTechnique = m_dumped_techniques.find(technique); - if (existingTechnique == m_dumped_techniques.end()) - { - m_dumped_techniques.emplace(technique); - return true; - } - - return false; - } - - bool ShouldDumpPixelShader(const MaterialPixelShader* pixelShader) - { - const auto existingPixelShader = m_dumped_pixel_shaders.find(pixelShader); - if (existingPixelShader == m_dumped_pixel_shaders.end()) - { - m_dumped_pixel_shaders.emplace(pixelShader); - return true; - } - - return false; - } - - bool ShouldDumpVertexShader(const MaterialVertexShader* vertexShader) - { - const auto existingVertexShader = m_dumped_vertex_shaders.find(vertexShader); - if (existingVertexShader == m_dumped_vertex_shaders.end()) - { - m_dumped_vertex_shaders.emplace(vertexShader); - return true; - } - - return false; - } - -private: - std::unordered_set m_dumped_techniques; - std::unordered_set m_dumped_pixel_shaders; - std::unordered_set m_dumped_vertex_shaders; -}; - -bool AssetDumperTechniqueSet::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperTechniqueSet::DumpPixelShader(const AssetDumpingContext& context, const MaterialPixelShader* pixelShader) -{ - std::ostringstream ss; - ss << "shader_bin/ps_" << pixelShader->name << ".cso"; - - const auto shaderFile = context.OpenAssetFile(ss.str()); - - if (!shaderFile) - return; - - shaderFile->write(pixelShader->prog.loadDef.program, pixelShader->prog.loadDef.programSize); -} - -void AssetDumperTechniqueSet::DumpVertexShader(const AssetDumpingContext& context, const MaterialVertexShader* vertexShader) -{ - std::ostringstream ss; - ss << "shader_bin/vs_" << vertexShader->name << ".cso"; - - const auto shaderFile = context.OpenAssetFile(ss.str()); - - if (!shaderFile) - return; - - shaderFile->write(vertexShader->prog.loadDef.program, vertexShader->prog.loadDef.programSize); -} - -void AssetDumperTechniqueSet::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* techniqueSet = asset->Asset(); - auto* shaderState = context.GetZoneAssetDumperState(); - - for (const auto* technique : techniqueSet->techniques) - { - if (!technique || !shaderState->ShouldDumpTechnique(technique)) - continue; - - for (auto passIndex = 0u; passIndex < technique->passCount; passIndex++) - { - const auto* pixelShader = technique->passArray[passIndex].pixelShader; - - if (pixelShader && shaderState->ShouldDumpPixelShader(pixelShader)) - DumpPixelShader(context, pixelShader); - - const auto* vertexShader = technique->passArray[passIndex].vertexShader; - if (vertexShader && shaderState->ShouldDumpVertexShader(vertexShader)) - DumpVertexShader(context, vertexShader); - } - } -} diff --git a/src/ObjWriting/Game/T6/Techset/AssetDumperTechniqueSet.h b/src/ObjWriting/Game/T6/Techset/AssetDumperTechniqueSet.h deleted file mode 100644 index 5a34305e..00000000 --- a/src/ObjWriting/Game/T6/Techset/AssetDumperTechniqueSet.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/T6/T6.h" - -namespace T6 -{ - class AssetDumperTechniqueSet final : public AbstractAssetDumper - { - static void DumpPixelShader(const AssetDumpingContext& context, const MaterialPixelShader* pixelShader); - static void DumpVertexShader(const AssetDumpingContext& context, const MaterialVertexShader* vertexShader); - - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace T6 diff --git a/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.cpp b/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.cpp new file mode 100644 index 00000000..abbb953a --- /dev/null +++ b/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.cpp @@ -0,0 +1,107 @@ +#include "TechsetDumperT6.h" + +#include "Shader/ShaderCommon.h" + +#include +#include + +using namespace T6; + +namespace +{ + class ShaderZoneState final : public IZoneAssetDumperState + { + public: + bool ShouldDumpTechnique(const MaterialTechnique* technique) + { + const auto existingTechnique = m_dumped_techniques.find(technique); + if (existingTechnique == m_dumped_techniques.end()) + { + m_dumped_techniques.emplace(technique); + return true; + } + + return false; + } + + bool ShouldDumpPixelShader(const MaterialPixelShader* pixelShader) + { + const auto existingPixelShader = m_dumped_pixel_shaders.find(pixelShader); + if (existingPixelShader == m_dumped_pixel_shaders.end()) + { + m_dumped_pixel_shaders.emplace(pixelShader); + return true; + } + + return false; + } + + bool ShouldDumpVertexShader(const MaterialVertexShader* vertexShader) + { + const auto existingVertexShader = m_dumped_vertex_shaders.find(vertexShader); + if (existingVertexShader == m_dumped_vertex_shaders.end()) + { + m_dumped_vertex_shaders.emplace(vertexShader); + return true; + } + + return false; + } + + private: + std::unordered_set m_dumped_techniques; + std::unordered_set m_dumped_pixel_shaders; + std::unordered_set m_dumped_vertex_shaders; + }; + + void DumpPixelShader(const AssetDumpingContext& context, const MaterialPixelShader& pixelShader) + { + const auto shaderFile = context.OpenAssetFile(shader::GetFileNameForPixelShaderAssetName(pixelShader.name)); + + if (!shaderFile) + return; + + shaderFile->write(pixelShader.prog.loadDef.program, pixelShader.prog.loadDef.programSize); + } + + void DumpVertexShader(const AssetDumpingContext& context, const MaterialVertexShader& vertexShader) + { + const auto shaderFile = context.OpenAssetFile(shader::GetFileNameForVertexShaderAssetName(vertexShader.name)); + + if (!shaderFile) + return; + + shaderFile->write(vertexShader.prog.loadDef.program, vertexShader.prog.loadDef.programSize); + } +} // namespace + +namespace T6::techset +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* techniqueSet = asset->Asset(); + auto* shaderState = context.GetZoneAssetDumperState(); + + for (const auto* technique : techniqueSet->techniques) + { + if (!technique || !shaderState->ShouldDumpTechnique(technique)) + continue; + + for (auto passIndex = 0u; passIndex < technique->passCount; passIndex++) + { + const auto* pixelShader = technique->passArray[passIndex].pixelShader; + if (pixelShader && shaderState->ShouldDumpPixelShader(pixelShader)) + DumpPixelShader(context, *pixelShader); + + const auto* vertexShader = technique->passArray[passIndex].vertexShader; + if (vertexShader && shaderState->ShouldDumpVertexShader(vertexShader)) + DumpVertexShader(context, *vertexShader); + } + } + } +} // namespace T6::techset diff --git a/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.h b/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.h new file mode 100644 index 00000000..885be6c2 --- /dev/null +++ b/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.h @@ -0,0 +1,14 @@ +#pragma once + +#include "Dumping/AbstractAssetDumper.h" +#include "Game/T6/T6.h" + +namespace T6::techset +{ + class Dumper final : public AbstractAssetDumper + { + protected: + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + }; +} // namespace T6::techset From d05f4fd43eff3c670a87c88c5d091a87a3745765 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Wed, 30 Jul 2025 23:29:08 +0100 Subject: [PATCH 17/35] refactor: streamline tracer dumper --- src/ObjCommon/Tracer/TracerCommon.cpp | 11 +++ src/ObjCommon/Tracer/TracerCommon.h | 8 ++ .../Game/T6/Tracer/RawLoaderTracerT6.cpp | 4 +- src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 4 +- .../Game/IW4/Tracer/AssetDumperTracer.cpp | 79 ---------------- .../Game/IW4/Tracer/TracerDumperIW4.cpp | 84 +++++++++++++++++ ...{AssetDumperTracer.h => TracerDumperIW4.h} | 6 +- src/ObjWriting/Game/T6/ObjWriterT6.cpp | 4 +- .../Game/T6/Tracer/AssetDumperTracer.cpp | 87 ------------------ .../Game/T6/Tracer/TracerDumperT6.cpp | 92 +++++++++++++++++++ .../{AssetDumperTracer.h => TracerDumperT6.h} | 8 +- 11 files changed, 207 insertions(+), 180 deletions(-) create mode 100644 src/ObjCommon/Tracer/TracerCommon.cpp create mode 100644 src/ObjCommon/Tracer/TracerCommon.h delete mode 100644 src/ObjWriting/Game/IW4/Tracer/AssetDumperTracer.cpp create mode 100644 src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.cpp rename src/ObjWriting/Game/IW4/Tracer/{AssetDumperTracer.h => TracerDumperIW4.h} (66%) delete mode 100644 src/ObjWriting/Game/T6/Tracer/AssetDumperTracer.cpp create mode 100644 src/ObjWriting/Game/T6/Tracer/TracerDumperT6.cpp rename src/ObjWriting/Game/T6/Tracer/{AssetDumperTracer.h => TracerDumperT6.h} (62%) diff --git a/src/ObjCommon/Tracer/TracerCommon.cpp b/src/ObjCommon/Tracer/TracerCommon.cpp new file mode 100644 index 00000000..d48a0740 --- /dev/null +++ b/src/ObjCommon/Tracer/TracerCommon.cpp @@ -0,0 +1,11 @@ +#include "TracerCommon.h" + +#include + +namespace tracer +{ + std::string GetFileNameForAssetName(const std::string& assetName) + { + return std::format("tracer/{}", assetName); + } +} // namespace tracer diff --git a/src/ObjCommon/Tracer/TracerCommon.h b/src/ObjCommon/Tracer/TracerCommon.h new file mode 100644 index 00000000..d95136b7 --- /dev/null +++ b/src/ObjCommon/Tracer/TracerCommon.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace tracer +{ + std::string GetFileNameForAssetName(const std::string& assetName); +} diff --git a/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.cpp b/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.cpp index 16eb7ea9..2361a4ed 100644 --- a/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.cpp +++ b/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.cpp @@ -4,12 +4,14 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" #include "InfoStringLoaderTracerT6.h" +#include "Tracer/TracerCommon.h" #include #include #include using namespace T6; +using namespace ::tracer; namespace { @@ -24,7 +26,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = std::format("tracer/{}", assetName); + const auto fileName = GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 9bf0047c..858846f1 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -22,7 +22,7 @@ #include "StringTable/StringTableDumperIW4.h" #include "StructuredDataDef/AssetDumperStructuredDataDefSet.h" #include "Techset/TechsetDumperIW4.h" -#include "Tracer/AssetDumperTracer.h" +#include "Tracer/TracerDumperIW4.h" #include "Vehicle/AssetDumperVehicle.h" #include "Weapon/AssetDumperWeapon.h" @@ -74,7 +74,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(string_table::Dumper, m_string_table, ASSET_TYPE_STRINGTABLE) DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD) DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF) - DUMP_ASSET_POOL(AssetDumperTracer, m_tracer, ASSET_TYPE_TRACER) + DUMP_ASSET_POOL(tracer::Dumper, m_tracer, ASSET_TYPE_TRACER) DUMP_ASSET_POOL(AssetDumperVehicle, m_vehicle, ASSET_TYPE_VEHICLE) DUMP_ASSET_POOL(addon_map_ents::Dumper, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS) diff --git a/src/ObjWriting/Game/IW4/Tracer/AssetDumperTracer.cpp b/src/ObjWriting/Game/IW4/Tracer/AssetDumperTracer.cpp deleted file mode 100644 index 3a903ebc..00000000 --- a/src/ObjWriting/Game/IW4/Tracer/AssetDumperTracer.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "AssetDumperTracer.h" - -#include "Game/IW4/CommonIW4.h" -#include "Game/IW4/InfoString/InfoStringFromStructConverter.h" -#include "Game/IW4/ObjConstantsIW4.h" -#include "Game/IW4/Tracer/TracerFields.h" - -#include -#include -#include - -using namespace IW4; - -namespace IW4 -{ - class InfoStringFromTracerConverter final : public InfoStringFromStructConverter - { - protected: - void FillFromExtensionField(const cspField_t& field) override - { - assert(false); - } - - public: - InfoStringFromTracerConverter(const TracerDef* structure, - const cspField_t* fields, - const size_t fieldCount, - std::function scriptStringValueCallback) - : InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback)) - { - } - }; -} // namespace IW4 - -InfoString AssetDumperTracer::CreateInfoString(XAssetInfo* asset) -{ - InfoStringFromTracerConverter converter(asset->Asset(), - tracer_fields, - std::extent_v, - [asset](const scr_string_t scrStr) -> std::string - { - assert(scrStr < asset->m_zone->m_script_strings.Count()); - if (scrStr >= asset->m_zone->m_script_strings.Count()) - return ""; - - return asset->m_zone->m_script_strings[scrStr]; - }); - - return converter.Convert(); -} - -bool AssetDumperTracer::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperTracer::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - // Only dump raw when no gdt available - if (context.m_gdt) - { - const auto infoString = CreateInfoString(asset); - GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_TRACER); - infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_TRACER, gdtEntry); - context.m_gdt->WriteEntry(gdtEntry); - } - else - { - const auto assetFile = context.OpenAssetFile("tracer/" + asset->m_name); - - if (!assetFile) - return; - - auto& stream = *assetFile; - const auto infoString = CreateInfoString(asset); - const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_TRACER); - stream.write(stringValue.c_str(), stringValue.size()); - } -} diff --git a/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.cpp b/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.cpp new file mode 100644 index 00000000..1cf1eb84 --- /dev/null +++ b/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.cpp @@ -0,0 +1,84 @@ +#include "TracerDumperIW4.h" + +#include "Game/IW4/CommonIW4.h" +#include "Game/IW4/InfoString/InfoStringFromStructConverter.h" +#include "Game/IW4/ObjConstantsIW4.h" +#include "Game/IW4/Tracer/TracerFields.h" +#include "Tracer/TracerCommon.h" + +#include +#include +#include + +using namespace IW4; +using namespace ::tracer; + +namespace +{ + class InfoStringFromTracerConverter final : public InfoStringFromStructConverter + { + protected: + void FillFromExtensionField(const cspField_t& field) override + { + assert(false); + } + + public: + InfoStringFromTracerConverter(const TracerDef* structure, + const cspField_t* fields, + const size_t fieldCount, + std::function scriptStringValueCallback) + : InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback)) + { + } + }; + + InfoString CreateInfoString(XAssetInfo* asset) + { + InfoStringFromTracerConverter converter(asset->Asset(), + tracer_fields, + std::extent_v, + [asset](const scr_string_t scrStr) -> std::string + { + assert(scrStr < asset->m_zone->m_script_strings.Count()); + if (scrStr >= asset->m_zone->m_script_strings.Count()) + return ""; + + return asset->m_zone->m_script_strings[scrStr]; + }); + + return converter.Convert(); + } +} // namespace + +namespace IW4::tracer +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + // Only dump raw when no gdt available + if (context.m_gdt) + { + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_TRACER); + infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_TRACER, gdtEntry); + context.m_gdt->WriteEntry(gdtEntry); + } + else + { + const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name)); + + if (!assetFile) + return; + + auto& stream = *assetFile; + const auto infoString = CreateInfoString(asset); + const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_TRACER); + stream.write(stringValue.c_str(), stringValue.size()); + } + } +} // namespace IW4::tracer diff --git a/src/ObjWriting/Game/IW4/Tracer/AssetDumperTracer.h b/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.h similarity index 66% rename from src/ObjWriting/Game/IW4/Tracer/AssetDumperTracer.h rename to src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.h index 6e32b860..b141a586 100644 --- a/src/ObjWriting/Game/IW4/Tracer/AssetDumperTracer.h +++ b/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.h @@ -4,12 +4,10 @@ #include "Game/IW4/IW4.h" #include "InfoString/InfoString.h" -namespace IW4 +namespace IW4::tracer { - class AssetDumperTracer final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { - static InfoString CreateInfoString(XAssetInfo* asset); - protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 937ea121..3e89711e 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -19,7 +19,7 @@ #include "Sound/AssetDumperSndDriverGlobals.h" #include "StringTable/StringTableDumperT6.h" #include "Techset/TechsetDumperT6.h" -#include "Tracer/AssetDumperTracer.h" +#include "Tracer/TracerDumperT6.h" #include "Vehicle/AssetDumperVehicle.h" #include "Weapon/AssetDumperWeapon.h" #include "Weapon/AssetDumperWeaponAttachment.h" @@ -87,7 +87,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(AssetDumperVehicle, m_vehicle, ASSET_TYPE_VEHICLEDEF) // DUMP_ASSET_POOL(AssetDumperMemoryBlock, m_memory_block, ASSET_TYPE_MEMORYBLOCK) // DUMP_ASSET_POOL(AssetDumperAddonMapEnts, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS) - DUMP_ASSET_POOL(AssetDumperTracer, m_tracer, ASSET_TYPE_TRACER) + DUMP_ASSET_POOL(tracer::Dumper, m_tracer, ASSET_TYPE_TRACER) // DUMP_ASSET_POOL(AssetDumperSkinnedVertsDef, m_skinned_verts, ASSET_TYPE_SKINNEDVERTS) DUMP_ASSET_POOL(qdb::Dumper, m_qdb, ASSET_TYPE_QDB) DUMP_ASSET_POOL(slug::Dumper, m_slug, ASSET_TYPE_SLUG) diff --git a/src/ObjWriting/Game/T6/Tracer/AssetDumperTracer.cpp b/src/ObjWriting/Game/T6/Tracer/AssetDumperTracer.cpp deleted file mode 100644 index 0c87e4ee..00000000 --- a/src/ObjWriting/Game/T6/Tracer/AssetDumperTracer.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include "AssetDumperTracer.h" - -#include "Game/T6/InfoString/InfoStringFromStructConverter.h" -#include "Game/T6/ObjConstantsT6.h" -#include "Game/T6/Tracer/TracerFields.h" - -#include -#include - -using namespace T6; - -namespace T6 -{ - class InfoStringFromTracerConverter final : public InfoStringFromStructConverter - { - protected: - void FillFromExtensionField(const cspField_t& field) override - { - switch (static_cast(field.iFieldType)) - { - case TFT_TRACERTYPE: - FillFromEnumInt(std::string(field.szName), field.iOffset, tracerTypeNames, std::extent_v); - break; - - case TFT_NUM_FIELD_TYPES: - default: - assert(false); - break; - } - } - - public: - InfoStringFromTracerConverter(const TracerDef* structure, - const cspField_t* fields, - const size_t fieldCount, - std::function scriptStringValueCallback) - : InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback)) - { - } - }; -} // namespace T6 - -InfoString AssetDumperTracer::CreateInfoString(XAssetInfo* asset) -{ - InfoStringFromTracerConverter converter(asset->Asset(), - tracer_fields, - std::extent_v, - [asset](const scr_string_t scrStr) -> std::string - { - assert(scrStr < asset->m_zone->m_script_strings.Count()); - if (scrStr >= asset->m_zone->m_script_strings.Count()) - return ""; - - return asset->m_zone->m_script_strings[scrStr]; - }); - - return converter.Convert(); -} - -bool AssetDumperTracer::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperTracer::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - // Only dump raw when no gdt available - if (context.m_gdt) - { - const auto infoString = CreateInfoString(asset); - GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_TRACER); - infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_TRACER, gdtEntry); - context.m_gdt->WriteEntry(gdtEntry); - } - else - { - const auto assetFile = context.OpenAssetFile("tracer/" + asset->m_name); - - if (!assetFile) - return; - - auto& stream = *assetFile; - const auto infoString = CreateInfoString(asset); - const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_TRACER); - stream.write(stringValue.c_str(), stringValue.size()); - } -} diff --git a/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.cpp b/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.cpp new file mode 100644 index 00000000..6a3b1cab --- /dev/null +++ b/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.cpp @@ -0,0 +1,92 @@ +#include "TracerDumperT6.h" + +#include "Game/T6/InfoString/InfoStringFromStructConverter.h" +#include "Game/T6/ObjConstantsT6.h" +#include "Game/T6/Tracer/TracerFields.h" +#include "Tracer/TracerCommon.h" + +#include +#include + +using namespace T6; +using namespace ::tracer; + +namespace +{ + class InfoStringFromTracerConverter final : public InfoStringFromStructConverter + { + protected: + void FillFromExtensionField(const cspField_t& field) override + { + switch (static_cast(field.iFieldType)) + { + case TFT_TRACERTYPE: + FillFromEnumInt(std::string(field.szName), field.iOffset, tracerTypeNames, std::extent_v); + break; + + case TFT_NUM_FIELD_TYPES: + default: + assert(false); + break; + } + } + + public: + InfoStringFromTracerConverter(const TracerDef* structure, + const cspField_t* fields, + const size_t fieldCount, + std::function scriptStringValueCallback) + : InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback)) + { + } + }; + + InfoString CreateInfoString(XAssetInfo* asset) + { + InfoStringFromTracerConverter converter(asset->Asset(), + tracer_fields, + std::extent_v, + [asset](const scr_string_t scrStr) -> std::string + { + assert(scrStr < asset->m_zone->m_script_strings.Count()); + if (scrStr >= asset->m_zone->m_script_strings.Count()) + return ""; + + return asset->m_zone->m_script_strings[scrStr]; + }); + + return converter.Convert(); + } +} // namespace + +namespace T6::tracer +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + // Only dump raw when no gdt available + if (context.m_gdt) + { + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_TRACER); + infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_TRACER, gdtEntry); + context.m_gdt->WriteEntry(gdtEntry); + } + else + { + const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name)); + + if (!assetFile) + return; + + auto& stream = *assetFile; + const auto infoString = CreateInfoString(asset); + const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_TRACER); + stream.write(stringValue.c_str(), stringValue.size()); + } + } +} // namespace T6::tracer diff --git a/src/ObjWriting/Game/T6/Tracer/AssetDumperTracer.h b/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.h similarity index 62% rename from src/ObjWriting/Game/T6/Tracer/AssetDumperTracer.h rename to src/ObjWriting/Game/T6/Tracer/TracerDumperT6.h index 51c25c02..b3a54052 100644 --- a/src/ObjWriting/Game/T6/Tracer/AssetDumperTracer.h +++ b/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.h @@ -4,14 +4,12 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" -namespace T6 +namespace T6::tracer { - class AssetDumperTracer final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { - static InfoString CreateInfoString(XAssetInfo* asset); - protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6 +} // namespace T6::tracer From ab118f3528b3406d5172e7b7449322008954d677 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Thu, 31 Jul 2025 19:24:28 +0100 Subject: [PATCH 18/35] refactor: streamline vehicle dumping --- src/ObjCommon/Vehicle/VehicleCommon.cpp | 11 +++ src/ObjCommon/Vehicle/VehicleCommon.h | 8 ++ .../Game/T6/Vehicle/RawLoaderVehicleT6.cpp | 4 +- src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 4 +- ...DumperVehicle.cpp => VehicleDumperIW4.cpp} | 93 ++++++++++--------- ...ssetDumperVehicle.h => VehicleDumperIW4.h} | 8 +- src/ObjWriting/Game/T6/ObjWriterT6.cpp | 4 +- ...tDumperVehicle.cpp => VehicleDumperT6.cpp} | 93 ++++++++++--------- ...AssetDumperVehicle.h => VehicleDumperT6.h} | 8 +- 9 files changed, 130 insertions(+), 103 deletions(-) create mode 100644 src/ObjCommon/Vehicle/VehicleCommon.cpp create mode 100644 src/ObjCommon/Vehicle/VehicleCommon.h rename src/ObjWriting/Game/IW4/Vehicle/{AssetDumperVehicle.cpp => VehicleDumperIW4.cpp} (54%) rename src/ObjWriting/Game/IW4/Vehicle/{AssetDumperVehicle.h => VehicleDumperIW4.h} (62%) rename src/ObjWriting/Game/T6/Vehicle/{AssetDumperVehicle.cpp => VehicleDumperT6.cpp} (61%) rename src/ObjWriting/Game/T6/Vehicle/{AssetDumperVehicle.h => VehicleDumperT6.h} (62%) diff --git a/src/ObjCommon/Vehicle/VehicleCommon.cpp b/src/ObjCommon/Vehicle/VehicleCommon.cpp new file mode 100644 index 00000000..6b1ca27f --- /dev/null +++ b/src/ObjCommon/Vehicle/VehicleCommon.cpp @@ -0,0 +1,11 @@ +#include "VehicleCommon.h" + +#include + +namespace vehicle +{ + std::string GetFileNameForAssetName(const std::string& assetName) + { + return std::format("vehicles/{}", assetName); + } +} // namespace vehicle diff --git a/src/ObjCommon/Vehicle/VehicleCommon.h b/src/ObjCommon/Vehicle/VehicleCommon.h new file mode 100644 index 00000000..ecd96304 --- /dev/null +++ b/src/ObjCommon/Vehicle/VehicleCommon.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace vehicle +{ + std::string GetFileNameForAssetName(const std::string& assetName); +} diff --git a/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.cpp b/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.cpp index 68a8299e..154a9da3 100644 --- a/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.cpp +++ b/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.cpp @@ -4,12 +4,14 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" #include "InfoStringLoaderVehicleT6.h" +#include "Vehicle/VehicleCommon.h" #include #include #include using namespace T6; +using namespace ::vehicle; namespace { @@ -24,7 +26,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = std::format("vehicles/{}", assetName); + const auto fileName = GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 858846f1..2dfd1df1 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -23,7 +23,7 @@ #include "StructuredDataDef/AssetDumperStructuredDataDefSet.h" #include "Techset/TechsetDumperIW4.h" #include "Tracer/TracerDumperIW4.h" -#include "Vehicle/AssetDumperVehicle.h" +#include "Vehicle/VehicleDumperIW4.h" #include "Weapon/AssetDumperWeapon.h" using namespace IW4; @@ -75,7 +75,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD) DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF) DUMP_ASSET_POOL(tracer::Dumper, m_tracer, ASSET_TYPE_TRACER) - DUMP_ASSET_POOL(AssetDumperVehicle, m_vehicle, ASSET_TYPE_VEHICLE) + DUMP_ASSET_POOL(vehicle::Dumper, m_vehicle, ASSET_TYPE_VEHICLE) DUMP_ASSET_POOL(addon_map_ents::Dumper, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS) return true; diff --git a/src/ObjWriting/Game/IW4/Vehicle/AssetDumperVehicle.cpp b/src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.cpp similarity index 54% rename from src/ObjWriting/Game/IW4/Vehicle/AssetDumperVehicle.cpp rename to src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.cpp index 56ab8de7..137c30de 100644 --- a/src/ObjWriting/Game/IW4/Vehicle/AssetDumperVehicle.cpp +++ b/src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.cpp @@ -1,18 +1,20 @@ -#include "AssetDumperVehicle.h" +#include "VehicleDumperIW4.h" #include "Game/IW4/CommonIW4.h" #include "Game/IW4/InfoString/EnumStrings.h" #include "Game/IW4/InfoString/InfoStringFromStructConverter.h" #include "Game/IW4/ObjConstantsIW4.h" #include "Game/IW4/Vehicle/VehicleFields.h" +#include "Vehicle/VehicleCommon.h" #include #include #include using namespace IW4; +using namespace ::vehicle; -namespace IW4 +namespace { class InfoStringFromVehicleConverter final : public InfoStringFromStructConverter { @@ -71,50 +73,53 @@ namespace IW4 { } }; -} // namespace IW4 -InfoString AssetDumperVehicle::CreateInfoString(XAssetInfo* asset) -{ - InfoStringFromVehicleConverter converter(asset->Asset(), - vehicle_fields, - std::extent_v, - [asset](const scr_string_t scrStr) -> std::string - { - assert(scrStr < asset->m_zone->m_script_strings.Count()); - if (scrStr >= asset->m_zone->m_script_strings.Count()) - return ""; - - return asset->m_zone->m_script_strings[scrStr]; - }); - - return converter.Convert(); -} - -bool AssetDumperVehicle::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperVehicle::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - // Only dump raw when no gdt available - if (context.m_gdt) + InfoString CreateInfoString(XAssetInfo* asset) { - const auto infoString = CreateInfoString(asset); - GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_VEHICLE); - infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_VEHICLE, gdtEntry); - context.m_gdt->WriteEntry(gdtEntry); + InfoStringFromVehicleConverter converter(asset->Asset(), + vehicle_fields, + std::extent_v, + [asset](const scr_string_t scrStr) -> std::string + { + assert(scrStr < asset->m_zone->m_script_strings.Count()); + if (scrStr >= asset->m_zone->m_script_strings.Count()) + return ""; + + return asset->m_zone->m_script_strings[scrStr]; + }); + + return converter.Convert(); } - else +} // namespace + +namespace IW4::vehicle +{ + bool Dumper::ShouldDump(XAssetInfo* asset) { - const auto assetFile = context.OpenAssetFile("vehicles/" + asset->m_name); - - if (!assetFile) - return; - - auto& stream = *assetFile; - const auto infoString = CreateInfoString(asset); - const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_VEHICLE); - stream.write(stringValue.c_str(), stringValue.size()); + return true; } -} + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + // Only dump raw when no gdt available + if (context.m_gdt) + { + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_VEHICLE); + infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_VEHICLE, gdtEntry); + context.m_gdt->WriteEntry(gdtEntry); + } + else + { + const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name)); + + if (!assetFile) + return; + + auto& stream = *assetFile; + const auto infoString = CreateInfoString(asset); + const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_VEHICLE); + stream.write(stringValue.c_str(), stringValue.size()); + } + } +} // namespace IW4::vehicle diff --git a/src/ObjWriting/Game/IW4/Vehicle/AssetDumperVehicle.h b/src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.h similarity index 62% rename from src/ObjWriting/Game/IW4/Vehicle/AssetDumperVehicle.h rename to src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.h index 66a1f074..c4c230e2 100644 --- a/src/ObjWriting/Game/IW4/Vehicle/AssetDumperVehicle.h +++ b/src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.h @@ -4,14 +4,12 @@ #include "Game/IW4/IW4.h" #include "InfoString/InfoString.h" -namespace IW4 +namespace IW4::vehicle { - class AssetDumperVehicle final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { - static InfoString CreateInfoString(XAssetInfo* asset); - protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4 +} // namespace IW4::vehicle diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 3e89711e..00317cd7 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -20,7 +20,7 @@ #include "StringTable/StringTableDumperT6.h" #include "Techset/TechsetDumperT6.h" #include "Tracer/TracerDumperT6.h" -#include "Vehicle/AssetDumperVehicle.h" +#include "Vehicle/VehicleDumperT6.h" #include "Weapon/AssetDumperWeapon.h" #include "Weapon/AssetDumperWeaponAttachment.h" #include "Weapon/AssetDumperWeaponAttachmentUnique.h" @@ -84,7 +84,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperEmblemSet, m_emblem_set, ASSET_TYPE_EMBLEMSET) DUMP_ASSET_POOL(script::Dumper, m_script, ASSET_TYPE_SCRIPTPARSETREE) // DUMP_ASSET_POOL(AssetDumperKeyValuePairs, m_key_value_pairs, ASSET_TYPE_KEYVALUEPAIRS) - DUMP_ASSET_POOL(AssetDumperVehicle, m_vehicle, ASSET_TYPE_VEHICLEDEF) + DUMP_ASSET_POOL(vehicle::Dumper, m_vehicle, ASSET_TYPE_VEHICLEDEF) // DUMP_ASSET_POOL(AssetDumperMemoryBlock, m_memory_block, ASSET_TYPE_MEMORYBLOCK) // DUMP_ASSET_POOL(AssetDumperAddonMapEnts, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS) DUMP_ASSET_POOL(tracer::Dumper, m_tracer, ASSET_TYPE_TRACER) diff --git a/src/ObjWriting/Game/T6/Vehicle/AssetDumperVehicle.cpp b/src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.cpp similarity index 61% rename from src/ObjWriting/Game/T6/Vehicle/AssetDumperVehicle.cpp rename to src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.cpp index cccf418a..40eb02ad 100644 --- a/src/ObjWriting/Game/T6/Vehicle/AssetDumperVehicle.cpp +++ b/src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.cpp @@ -1,15 +1,17 @@ -#include "AssetDumperVehicle.h" +#include "VehicleDumperT6.h" #include "Game/T6/InfoString/InfoStringFromStructConverter.h" #include "Game/T6/ObjConstantsT6.h" #include "Game/T6/Vehicle/VehicleFields.h" +#include "Vehicle/VehicleCommon.h" #include #include using namespace T6; +using namespace ::vehicle; -namespace T6 +namespace { class InfoStringFromVehicleConverter final : public InfoStringFromStructConverter { @@ -88,50 +90,53 @@ namespace T6 { } }; -} // namespace T6 -InfoString AssetDumperVehicle::CreateInfoString(XAssetInfo* asset) -{ - InfoStringFromVehicleConverter converter(asset->Asset(), - vehicle_fields, - std::extent_v, - [asset](const scr_string_t scrStr) -> std::string - { - assert(scrStr < asset->m_zone->m_script_strings.Count()); - if (scrStr >= asset->m_zone->m_script_strings.Count()) - return ""; - - return asset->m_zone->m_script_strings[scrStr]; - }); - - return converter.Convert(); -} - -bool AssetDumperVehicle::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperVehicle::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - // Only dump raw when no gdt available - if (context.m_gdt) + InfoString CreateInfoString(XAssetInfo* asset) { - const auto infoString = CreateInfoString(asset); - GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_VEHICLE); - infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_VEHICLE, gdtEntry); - context.m_gdt->WriteEntry(gdtEntry); + InfoStringFromVehicleConverter converter(asset->Asset(), + vehicle_fields, + std::extent_v, + [asset](const scr_string_t scrStr) -> std::string + { + assert(scrStr < asset->m_zone->m_script_strings.Count()); + if (scrStr >= asset->m_zone->m_script_strings.Count()) + return ""; + + return asset->m_zone->m_script_strings[scrStr]; + }); + + return converter.Convert(); } - else +} // namespace + +namespace T6::vehicle +{ + bool Dumper::ShouldDump(XAssetInfo* asset) { - const auto assetFile = context.OpenAssetFile("vehicles/" + asset->m_name); - - if (!assetFile) - return; - - auto& stream = *assetFile; - const auto infoString = CreateInfoString(asset); - const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_VEHICLE); - stream.write(stringValue.c_str(), stringValue.size()); + return true; } -} + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + // Only dump raw when no gdt available + if (context.m_gdt) + { + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_VEHICLE); + infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_VEHICLE, gdtEntry); + context.m_gdt->WriteEntry(gdtEntry); + } + else + { + const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name)); + + if (!assetFile) + return; + + auto& stream = *assetFile; + const auto infoString = CreateInfoString(asset); + const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_VEHICLE); + stream.write(stringValue.c_str(), stringValue.size()); + } + } +} // namespace T6::vehicle diff --git a/src/ObjWriting/Game/T6/Vehicle/AssetDumperVehicle.h b/src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.h similarity index 62% rename from src/ObjWriting/Game/T6/Vehicle/AssetDumperVehicle.h rename to src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.h index a8c8421e..61c53ebf 100644 --- a/src/ObjWriting/Game/T6/Vehicle/AssetDumperVehicle.h +++ b/src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.h @@ -4,14 +4,12 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" -namespace T6 +namespace T6::vehicle { - class AssetDumperVehicle final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { - static InfoString CreateInfoString(XAssetInfo* asset); - protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6 +} // namespace T6::vehicle From 566f3994e3206cfb36c5b8f28e1bc905e75d956b Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Thu, 31 Jul 2025 19:46:21 +0100 Subject: [PATCH 19/35] refactor: streamline zbarrier dumping --- src/ObjCommon/ZBarrier/ZBarrierCommon.cpp | 11 +++ src/ObjCommon/ZBarrier/ZBarrierCommon.h | 8 ++ .../Game/T6/ZBarrier/RawLoaderZBarrierT6.cpp | 4 +- src/ObjWriting/Game/T6/ObjWriterT6.cpp | 4 +- .../Game/T6/ZBarrier/AssetDumperZBarrier.cpp | 77 ----------------- .../Game/T6/ZBarrier/ZBarrierDumperT6.cpp | 82 +++++++++++++++++++ ...setDumperZBarrier.h => ZBarrierDumperT6.h} | 8 +- 7 files changed, 109 insertions(+), 85 deletions(-) create mode 100644 src/ObjCommon/ZBarrier/ZBarrierCommon.cpp create mode 100644 src/ObjCommon/ZBarrier/ZBarrierCommon.h delete mode 100644 src/ObjWriting/Game/T6/ZBarrier/AssetDumperZBarrier.cpp create mode 100644 src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.cpp rename src/ObjWriting/Game/T6/ZBarrier/{AssetDumperZBarrier.h => ZBarrierDumperT6.h} (62%) diff --git a/src/ObjCommon/ZBarrier/ZBarrierCommon.cpp b/src/ObjCommon/ZBarrier/ZBarrierCommon.cpp new file mode 100644 index 00000000..354ccaba --- /dev/null +++ b/src/ObjCommon/ZBarrier/ZBarrierCommon.cpp @@ -0,0 +1,11 @@ +#include "ZBarrierCommon.h" + +#include + +namespace z_barrier +{ + std::string GetFileNameForAssetName(const std::string& assetName) + { + return std::format("zbarrier/{}", assetName); + } +} // namespace z_barrier diff --git a/src/ObjCommon/ZBarrier/ZBarrierCommon.h b/src/ObjCommon/ZBarrier/ZBarrierCommon.h new file mode 100644 index 00000000..e647286c --- /dev/null +++ b/src/ObjCommon/ZBarrier/ZBarrierCommon.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace z_barrier +{ + std::string GetFileNameForAssetName(const std::string& assetName); +} diff --git a/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.cpp b/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.cpp index 0a7d56d0..0d51eca5 100644 --- a/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.cpp +++ b/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.cpp @@ -4,12 +4,14 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" #include "InfoStringLoaderZBarrierT6.h" +#include "ZBarrier/ZBarrierCommon.h" #include #include #include using namespace T6; +using namespace ::z_barrier; namespace { @@ -24,7 +26,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = std::format("zbarrier/{}", assetName); + const auto fileName = GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 00317cd7..3a3f05a8 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -25,7 +25,7 @@ #include "Weapon/AssetDumperWeaponAttachment.h" #include "Weapon/AssetDumperWeaponAttachmentUnique.h" #include "Weapon/AssetDumperWeaponCamo.h" -#include "ZBarrier/AssetDumperZBarrier.h" +#include "ZBarrier/ZBarrierDumperT6.h" using namespace T6; @@ -93,7 +93,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(slug::Dumper, m_slug, ASSET_TYPE_SLUG) // DUMP_ASSET_POOL(AssetDumperFootstepTableDef, m_footstep_table, ASSET_TYPE_FOOTSTEP_TABLE) // DUMP_ASSET_POOL(AssetDumperFootstepFXTableDef, m_footstep_fx_table, ASSET_TYPE_FOOTSTEPFX_TABLE) - DUMP_ASSET_POOL(AssetDumperZBarrier, m_zbarrier, ASSET_TYPE_ZBARRIER) + DUMP_ASSET_POOL(z_barrier::Dumper, m_zbarrier, ASSET_TYPE_ZBARRIER) return true; diff --git a/src/ObjWriting/Game/T6/ZBarrier/AssetDumperZBarrier.cpp b/src/ObjWriting/Game/T6/ZBarrier/AssetDumperZBarrier.cpp deleted file mode 100644 index da165648..00000000 --- a/src/ObjWriting/Game/T6/ZBarrier/AssetDumperZBarrier.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include "AssetDumperZBarrier.h" - -#include "Game/T6/InfoString/InfoStringFromStructConverter.h" -#include "Game/T6/ObjConstantsT6.h" -#include "Game/T6/ZBarrier/ZBarrierFields.h" - -#include -#include - -using namespace T6; - -namespace T6 -{ - class InfoStringFromZBarrierConverter final : public InfoStringFromStructConverter - { - protected: - void FillFromExtensionField(const cspField_t& field) override - { - assert(false); - } - - public: - InfoStringFromZBarrierConverter(const ZBarrierDef* structure, - const cspField_t* fields, - const size_t fieldCount, - std::function scriptStringValueCallback) - : InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback)) - { - } - }; -} // namespace T6 - -InfoString AssetDumperZBarrier::CreateInfoString(XAssetInfo* asset) -{ - InfoStringFromZBarrierConverter converter(asset->Asset(), - zbarrier_fields, - std::extent_v, - [asset](const scr_string_t scrStr) -> std::string - { - assert(scrStr < asset->m_zone->m_script_strings.Count()); - if (scrStr >= asset->m_zone->m_script_strings.Count()) - return ""; - - return asset->m_zone->m_script_strings[scrStr]; - }); - - return converter.Convert(); -} - -bool AssetDumperZBarrier::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperZBarrier::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - // Only dump raw when no gdt available - if (context.m_gdt) - { - const auto infoString = CreateInfoString(asset); - GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_ZBARRIER); - infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_ZBARRIER, gdtEntry); - context.m_gdt->WriteEntry(gdtEntry); - } - else - { - const auto assetFile = context.OpenAssetFile("zbarrier/" + asset->m_name); - - if (!assetFile) - return; - - auto& stream = *assetFile; - const auto infoString = CreateInfoString(asset); - const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_ZBARRIER); - stream.write(stringValue.c_str(), stringValue.size()); - } -} diff --git a/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.cpp b/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.cpp new file mode 100644 index 00000000..23710e54 --- /dev/null +++ b/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.cpp @@ -0,0 +1,82 @@ +#include "ZBarrierDumperT6.h" + +#include "Game/T6/InfoString/InfoStringFromStructConverter.h" +#include "Game/T6/ObjConstantsT6.h" +#include "Game/T6/ZBarrier/ZBarrierFields.h" +#include "ZBarrier/ZBarrierCommon.h" + +#include +#include + +using namespace T6; +using namespace ::z_barrier; + +namespace +{ + class InfoStringFromZBarrierConverter final : public InfoStringFromStructConverter + { + protected: + void FillFromExtensionField(const cspField_t& field) override + { + assert(false); + } + + public: + InfoStringFromZBarrierConverter(const ZBarrierDef* structure, + const cspField_t* fields, + const size_t fieldCount, + std::function scriptStringValueCallback) + : InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback)) + { + } + }; + + InfoString CreateInfoString(XAssetInfo* asset) + { + InfoStringFromZBarrierConverter converter(asset->Asset(), + zbarrier_fields, + std::extent_v, + [asset](const scr_string_t scrStr) -> std::string + { + assert(scrStr < asset->m_zone->m_script_strings.Count()); + if (scrStr >= asset->m_zone->m_script_strings.Count()) + return ""; + + return asset->m_zone->m_script_strings[scrStr]; + }); + + return converter.Convert(); + } +} // namespace + +namespace T6::z_barrier +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + // Only dump raw when no gdt available + if (context.m_gdt) + { + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_ZBARRIER); + infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_ZBARRIER, gdtEntry); + context.m_gdt->WriteEntry(gdtEntry); + } + else + { + const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name)); + + if (!assetFile) + return; + + auto& stream = *assetFile; + const auto infoString = CreateInfoString(asset); + const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_ZBARRIER); + stream.write(stringValue.c_str(), stringValue.size()); + } + } +} // namespace T6::z_barrier diff --git a/src/ObjWriting/Game/T6/ZBarrier/AssetDumperZBarrier.h b/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.h similarity index 62% rename from src/ObjWriting/Game/T6/ZBarrier/AssetDumperZBarrier.h rename to src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.h index 0a2ba56d..efde331b 100644 --- a/src/ObjWriting/Game/T6/ZBarrier/AssetDumperZBarrier.h +++ b/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.h @@ -4,14 +4,12 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" -namespace T6 +namespace T6::z_barrier { - class AssetDumperZBarrier final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { - static InfoString CreateInfoString(XAssetInfo* asset); - protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6 +} // namespace T6::z_barrier From 58de885ebe078371af586adc689a7f643641fe51 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Thu, 31 Jul 2025 20:57:13 +0100 Subject: [PATCH 20/35] refactor: streamline sound dumping --- src/ObjLoading/Game/T6/ObjLoaderT6.cpp | 2 +- .../Game/T6/Sound/LoaderSoundBankT6.cpp | 2 +- .../Game/T6/Sound/LoaderSoundBankT6.h | 2 +- src/ObjWriting/Game/IW3/ObjWriterIW3.cpp | 4 +- .../Game/IW3/Sound/AssetDumperLoadedSound.cpp | 46 -- .../Game/IW3/Sound/LoadedSoundDumperIW3.cpp | 52 +++ ...erLoadedSound.h => LoadedSoundDumperIW3.h} | 8 +- src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 8 +- .../Game/IW4/Sound/AssetDumperLoadedSound.cpp | 46 -- .../Game/IW4/Sound/AssetDumperSndCurve.cpp | 39 -- .../Game/IW4/Sound/LoadedSoundDumperIW4.cpp | 52 +++ ...erLoadedSound.h => LoadedSoundDumperIW4.h} | 8 +- .../Game/IW4/Sound/SndCurveDumperIW4.cpp | 45 ++ ...etDumperSndCurve.h => SndCurveDumperIW4.h} | 8 +- src/ObjWriting/Game/IW5/ObjWriterIW5.cpp | 4 +- .../Game/IW5/Sound/AssetDumperLoadedSound.cpp | 46 -- .../Game/IW5/Sound/LoadedSoundDumperIW5.cpp | 52 +++ ...erLoadedSound.h => LoadedSoundDumperIW5.h} | 8 +- src/ObjWriting/Game/T5/ObjWriterT5.cpp | 1 - .../Game/T5/Sound/AssetDumperSndBank.cpp | 0 .../Game/T5/Sound/AssetDumperSndBank.h | 0 src/ObjWriting/Game/T6/ObjWriterT6.cpp | 8 +- .../T6/Sound/AssetDumperSndDriverGlobals.cpp | 385 ----------------- ...tDumperSndBank.cpp => SndBankDumperT6.cpp} | 21 +- ...AssetDumperSndBank.h => SndBankDumperT6.h} | 8 +- .../T6/Sound/SndDriverGlobalsDumperT6.cpp | 392 ++++++++++++++++++ ...erGlobals.h => SndDriverGlobalsDumperT6.h} | 8 +- 27 files changed, 638 insertions(+), 617 deletions(-) delete mode 100644 src/ObjWriting/Game/IW3/Sound/AssetDumperLoadedSound.cpp create mode 100644 src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.cpp rename src/ObjWriting/Game/IW3/Sound/{AssetDumperLoadedSound.h => LoadedSoundDumperIW3.h} (58%) delete mode 100644 src/ObjWriting/Game/IW4/Sound/AssetDumperLoadedSound.cpp delete mode 100644 src/ObjWriting/Game/IW4/Sound/AssetDumperSndCurve.cpp create mode 100644 src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.cpp rename src/ObjWriting/Game/IW4/Sound/{AssetDumperLoadedSound.h => LoadedSoundDumperIW4.h} (58%) create mode 100644 src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.cpp rename src/ObjWriting/Game/IW4/Sound/{AssetDumperSndCurve.h => SndCurveDumperIW4.h} (59%) delete mode 100644 src/ObjWriting/Game/IW5/Sound/AssetDumperLoadedSound.cpp create mode 100644 src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.cpp rename src/ObjWriting/Game/IW5/Sound/{AssetDumperLoadedSound.h => LoadedSoundDumperIW5.h} (58%) delete mode 100644 src/ObjWriting/Game/T5/Sound/AssetDumperSndBank.cpp delete mode 100644 src/ObjWriting/Game/T5/Sound/AssetDumperSndBank.h delete mode 100644 src/ObjWriting/Game/T6/Sound/AssetDumperSndDriverGlobals.cpp rename src/ObjWriting/Game/T6/Sound/{AssetDumperSndBank.cpp => SndBankDumperT6.cpp} (98%) rename src/ObjWriting/Game/T6/Sound/{AssetDumperSndBank.h => SndBankDumperT6.h} (61%) create mode 100644 src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.cpp rename src/ObjWriting/Game/T6/Sound/{AssetDumperSndDriverGlobals.h => SndDriverGlobalsDumperT6.h} (59%) diff --git a/src/ObjLoading/Game/T6/ObjLoaderT6.cpp b/src/ObjLoading/Game/T6/ObjLoaderT6.cpp index a1f029f3..7ebfbc3b 100644 --- a/src/ObjLoading/Game/T6/ObjLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/ObjLoaderT6.cpp @@ -403,7 +403,7 @@ namespace T6 collection.AddAssetCreator(CreateMaterialLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); collection.AddAssetCreator(CreateImageLoader(memory, searchPath)); - collection.AddAssetCreator(CreateSoundBankLoader(memory, searchPath)); + collection.AddAssetCreator(sound::CreateSoundBankLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); diff --git a/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.cpp b/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.cpp index f72d2a77..eac377d0 100644 --- a/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.cpp +++ b/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.cpp @@ -1079,7 +1079,7 @@ namespace }; } // namespace -namespace T6 +namespace T6::sound { std::unique_ptr> CreateSoundBankLoader(MemoryManager& memory, ISearchPath& searchPath) { diff --git a/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.h b/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.h index 6e99e962..6bc4a5df 100644 --- a/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.h +++ b/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.h @@ -7,7 +7,7 @@ #include -namespace T6 +namespace T6::sound { std::unique_ptr> CreateSoundBankLoader(MemoryManager& memory, ISearchPath& searchPath); } // namespace T6 diff --git a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp index 2c5d2e13..8a7ce5e0 100644 --- a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp +++ b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp @@ -8,7 +8,7 @@ #include "Maps/MapEntsDumperIW3.h" #include "ObjWriting.h" #include "RawFile/RawFileDumperIW3.h" -#include "Sound/AssetDumperLoadedSound.h" +#include "Sound/LoadedSoundDumperIW3.h" #include "StringTable/StringTableDumperIW3.h" #include "Weapon/AssetDumperWeapon.h" @@ -33,7 +33,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) // DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND) // DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE) - DUMP_ASSET_POOL(AssetDumperLoadedSound, m_loaded_sound, ASSET_TYPE_LOADED_SOUND) + DUMP_ASSET_POOL(sound::LoadedSoundDumper, m_loaded_sound, ASSET_TYPE_LOADED_SOUND) // DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_PVS) // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD) // DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP) diff --git a/src/ObjWriting/Game/IW3/Sound/AssetDumperLoadedSound.cpp b/src/ObjWriting/Game/IW3/Sound/AssetDumperLoadedSound.cpp deleted file mode 100644 index de40981f..00000000 --- a/src/ObjWriting/Game/IW3/Sound/AssetDumperLoadedSound.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "AssetDumperLoadedSound.h" - -#include "Sound/WavTypes.h" -#include "Sound/WavWriter.h" - -#include - -using namespace IW3; - -bool AssetDumperLoadedSound::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperLoadedSound::DumpWavPcm(const LoadedSound* asset, std::ostream& stream) -{ - const WavWriter writer(stream); - - const WavMetaData metaData{.channelCount = static_cast(asset->sound.info.channels), - .samplesPerSec = static_cast(asset->sound.info.rate), - .bitsPerSample = static_cast(asset->sound.info.bits)}; - - writer.WritePcmHeader(metaData, asset->sound.info.data_len); - writer.WritePcmData(asset->sound.data, asset->sound.info.data_len); -} - -void AssetDumperLoadedSound::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* loadedSound = asset->Asset(); - const auto assetFile = context.OpenAssetFile(std::format("sound/{}", asset->m_name)); - - if (!assetFile) - return; - - auto& stream = *assetFile; - switch (static_cast(loadedSound->sound.info.format)) - { - case WavFormat::PCM: - DumpWavPcm(loadedSound, stream); - break; - - default: - std::cerr << std::format("Unknown format {} for loaded sound: {}\n", loadedSound->sound.info.format, loadedSound->name); - break; - } -} diff --git a/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.cpp b/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.cpp new file mode 100644 index 00000000..4e3ab817 --- /dev/null +++ b/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.cpp @@ -0,0 +1,52 @@ +#include "LoadedSoundDumperIW3.h" + +#include "Sound/WavTypes.h" +#include "Sound/WavWriter.h" + +#include + +using namespace IW3; + +namespace +{ + void DumpWavPcm(const LoadedSound* asset, std::ostream& stream) + { + const WavWriter writer(stream); + + const WavMetaData metaData{.channelCount = static_cast(asset->sound.info.channels), + .samplesPerSec = static_cast(asset->sound.info.rate), + .bitsPerSample = static_cast(asset->sound.info.bits)}; + + writer.WritePcmHeader(metaData, asset->sound.info.data_len); + writer.WritePcmData(asset->sound.data, asset->sound.info.data_len); + } +} // namespace + +namespace IW3::sound +{ + bool LoadedSoundDumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void LoadedSoundDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* loadedSound = asset->Asset(); + const auto assetFile = context.OpenAssetFile(std::format("sound/{}", asset->m_name)); + + if (!assetFile) + return; + + auto& stream = *assetFile; + switch (static_cast(loadedSound->sound.info.format)) + { + case WavFormat::PCM: + DumpWavPcm(loadedSound, stream); + break; + + default: + std::cerr << std::format("Unknown format {} for loaded sound: {}\n", loadedSound->sound.info.format, loadedSound->name); + break; + } + } +} // namespace IW3::sound diff --git a/src/ObjWriting/Game/IW3/Sound/AssetDumperLoadedSound.h b/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.h similarity index 58% rename from src/ObjWriting/Game/IW3/Sound/AssetDumperLoadedSound.h rename to src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.h index 239e3b5b..cfe8b811 100644 --- a/src/ObjWriting/Game/IW3/Sound/AssetDumperLoadedSound.h +++ b/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.h @@ -3,14 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW3/IW3.h" -namespace IW3 +namespace IW3::sound { - class AssetDumperLoadedSound final : public AbstractAssetDumper + class LoadedSoundDumper final : public AbstractAssetDumper { - static void DumpWavPcm(const LoadedSound* asset, std::ostream& stream); - protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW3 +} // namespace IW3::sound diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 2dfd1df1..3723fbe2 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -17,8 +17,8 @@ #include "RawFile/RawFileDumperIW4.h" #include "Shader/AssetDumperPixelShader.h" #include "Shader/AssetDumperVertexShader.h" -#include "Sound/AssetDumperLoadedSound.h" -#include "Sound/AssetDumperSndCurve.h" +#include "Sound/LoadedSoundDumperIW4.h" +#include "Sound/SndCurveDumperIW4.h" #include "StringTable/StringTableDumperIW4.h" #include "StructuredDataDef/AssetDumperStructuredDataDefSet.h" #include "Techset/TechsetDumperIW4.h" @@ -52,8 +52,8 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(techset::Dumper, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) // DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND) - DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE) - DUMP_ASSET_POOL(AssetDumperLoadedSound, m_loaded_sound, ASSET_TYPE_LOADED_SOUND) + DUMP_ASSET_POOL(sound::SndCurveDumper, m_sound_curve, ASSET_TYPE_SOUND_CURVE) + DUMP_ASSET_POOL(sound::LoadedSoundDumper, m_loaded_sound, ASSET_TYPE_LOADED_SOUND) // DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_MP) // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD) // DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP) diff --git a/src/ObjWriting/Game/IW4/Sound/AssetDumperLoadedSound.cpp b/src/ObjWriting/Game/IW4/Sound/AssetDumperLoadedSound.cpp deleted file mode 100644 index 7348db5e..00000000 --- a/src/ObjWriting/Game/IW4/Sound/AssetDumperLoadedSound.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "AssetDumperLoadedSound.h" - -#include "Sound/WavTypes.h" -#include "Sound/WavWriter.h" - -#include - -using namespace IW4; - -bool AssetDumperLoadedSound::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperLoadedSound::DumpWavPcm(const LoadedSound* asset, std::ostream& stream) -{ - const WavWriter writer(stream); - - const WavMetaData metaData{.channelCount = static_cast(asset->sound.info.channels), - .samplesPerSec = static_cast(asset->sound.info.rate), - .bitsPerSample = static_cast(asset->sound.info.bits)}; - - writer.WritePcmHeader(metaData, asset->sound.info.data_len); - writer.WritePcmData(asset->sound.data, asset->sound.info.data_len); -} - -void AssetDumperLoadedSound::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* loadedSound = asset->Asset(); - const auto assetFile = context.OpenAssetFile(std::format("sound/{}", asset->m_name)); - - if (!assetFile) - return; - - auto& stream = *assetFile; - switch (static_cast(loadedSound->sound.info.format)) - { - case WavFormat::PCM: - DumpWavPcm(loadedSound, stream); - break; - - default: - std::cerr << std::format("Unknown format {} for loaded sound: {}\n", loadedSound->sound.info.format, loadedSound->name); - break; - } -} diff --git a/src/ObjWriting/Game/IW4/Sound/AssetDumperSndCurve.cpp b/src/ObjWriting/Game/IW4/Sound/AssetDumperSndCurve.cpp deleted file mode 100644 index 71958fbb..00000000 --- a/src/ObjWriting/Game/IW4/Sound/AssetDumperSndCurve.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "AssetDumperSndCurve.h" - -#include "Dumping/SndCurve/SndCurveDumper.h" - -#include - -using namespace IW4; - -std::string AssetDumperSndCurve::GetAssetFilename(const std::string& assetName) -{ - std::ostringstream ss; - - ss << "soundaliases/" << assetName << ".vfcurve"; - - return ss.str(); -} - -bool AssetDumperSndCurve::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperSndCurve::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* sndCurve = asset->Asset(); - - const auto assetFile = context.OpenAssetFile(GetAssetFilename(sndCurve->filename)); - - if (!assetFile) - return; - - SndCurveDumper dumper(*assetFile); - - const auto knotCount = std::min(static_cast(sndCurve->knotCount), std::extent_v); - dumper.Init(knotCount); - - for (auto i = 0u; i < knotCount; i++) - dumper.WriteKnot(sndCurve->knots[i][0], sndCurve->knots[i][1]); -} diff --git a/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.cpp b/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.cpp new file mode 100644 index 00000000..8a363418 --- /dev/null +++ b/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.cpp @@ -0,0 +1,52 @@ +#include "LoadedSoundDumperIW4.h" + +#include "Sound/WavTypes.h" +#include "Sound/WavWriter.h" + +#include + +using namespace IW4; + +namespace +{ + void DumpWavPcm(const LoadedSound* asset, std::ostream& stream) + { + const WavWriter writer(stream); + + const WavMetaData metaData{.channelCount = static_cast(asset->sound.info.channels), + .samplesPerSec = static_cast(asset->sound.info.rate), + .bitsPerSample = static_cast(asset->sound.info.bits)}; + + writer.WritePcmHeader(metaData, asset->sound.info.data_len); + writer.WritePcmData(asset->sound.data, asset->sound.info.data_len); + } +} // namespace + +namespace IW4::sound +{ + bool LoadedSoundDumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void LoadedSoundDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* loadedSound = asset->Asset(); + const auto assetFile = context.OpenAssetFile(std::format("sound/{}", asset->m_name)); + + if (!assetFile) + return; + + auto& stream = *assetFile; + switch (static_cast(loadedSound->sound.info.format)) + { + case WavFormat::PCM: + DumpWavPcm(loadedSound, stream); + break; + + default: + std::cerr << std::format("Unknown format {} for loaded sound: {}\n", loadedSound->sound.info.format, loadedSound->name); + break; + } + } +} // namespace IW4::sound diff --git a/src/ObjWriting/Game/IW4/Sound/AssetDumperLoadedSound.h b/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.h similarity index 58% rename from src/ObjWriting/Game/IW4/Sound/AssetDumperLoadedSound.h rename to src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.h index 8065af76..2799152c 100644 --- a/src/ObjWriting/Game/IW4/Sound/AssetDumperLoadedSound.h +++ b/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.h @@ -3,14 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4 +namespace IW4::sound { - class AssetDumperLoadedSound final : public AbstractAssetDumper + class LoadedSoundDumper final : public AbstractAssetDumper { - static void DumpWavPcm(const LoadedSound* asset, std::ostream& stream); - protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4 +} // namespace IW4::sound diff --git a/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.cpp b/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.cpp new file mode 100644 index 00000000..f5a38e94 --- /dev/null +++ b/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.cpp @@ -0,0 +1,45 @@ +#include "SndCurveDumperIW4.h" + +#include "Dumping/SndCurve/SndCurveDumper.h" + +#include + +using namespace IW4; + +namespace +{ + std::string GetAssetFilename(const std::string& assetName) + { + std::ostringstream ss; + + ss << "soundaliases/" << assetName << ".vfcurve"; + + return ss.str(); + } +} // namespace + +namespace IW4::sound +{ + bool SndCurveDumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void SndCurveDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* sndCurve = asset->Asset(); + + const auto assetFile = context.OpenAssetFile(GetAssetFilename(sndCurve->filename)); + + if (!assetFile) + return; + + ::SndCurveDumper dumper(*assetFile); + + const auto knotCount = std::min(static_cast(sndCurve->knotCount), std::extent_v); + dumper.Init(knotCount); + + for (auto i = 0u; i < knotCount; i++) + dumper.WriteKnot(sndCurve->knots[i][0], sndCurve->knots[i][1]); + } +} // namespace IW4::sound diff --git a/src/ObjWriting/Game/IW4/Sound/AssetDumperSndCurve.h b/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.h similarity index 59% rename from src/ObjWriting/Game/IW4/Sound/AssetDumperSndCurve.h rename to src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.h index 0139fafe..18cc1264 100644 --- a/src/ObjWriting/Game/IW4/Sound/AssetDumperSndCurve.h +++ b/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.h @@ -3,14 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4 +namespace IW4::sound { - class AssetDumperSndCurve final : public AbstractAssetDumper + class SndCurveDumper final : public AbstractAssetDumper { - static std::string GetAssetFilename(const std::string& assetName); - protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4 +} // namespace IW4::sound diff --git a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp index 5bf579ea..43ce039f 100644 --- a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp +++ b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp @@ -12,7 +12,7 @@ #include "ObjWriting.h" #include "RawFile/RawFileDumperIW5.h" #include "Script/ScriptDumperIW5.h" -#include "Sound/AssetDumperLoadedSound.h" +#include "Sound/LoadedSoundDumperIW5.h" #include "StringTable/StringTableDumperIW5.h" #include "Weapon/AssetDumperWeapon.h" #include "Weapon/AssetDumperWeaponAttachment.h" @@ -42,7 +42,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) // DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND) // DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE) - DUMP_ASSET_POOL(AssetDumperLoadedSound, m_loaded_sound, ASSET_TYPE_LOADED_SOUND) + DUMP_ASSET_POOL(sound::LoadedSoundDumper, m_loaded_sound, ASSET_TYPE_LOADED_SOUND) // DUMP_ASSET_POOL(AssetDumperclipMap_t, m_clip_map, ASSET_TYPE_CLIPMAP) // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD) // DUMP_ASSET_POOL(AssetDumperGlassWorld, m_glass_world, ASSET_TYPE_GLASSWORLD) diff --git a/src/ObjWriting/Game/IW5/Sound/AssetDumperLoadedSound.cpp b/src/ObjWriting/Game/IW5/Sound/AssetDumperLoadedSound.cpp deleted file mode 100644 index 7cb254e2..00000000 --- a/src/ObjWriting/Game/IW5/Sound/AssetDumperLoadedSound.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "AssetDumperLoadedSound.h" - -#include "Sound/WavTypes.h" -#include "Sound/WavWriter.h" - -#include - -using namespace IW5; - -bool AssetDumperLoadedSound::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperLoadedSound::DumpWavPcm(const LoadedSound* asset, std::ostream& stream) -{ - const WavWriter writer(stream); - - const WavMetaData metaData{.channelCount = static_cast(asset->sound.info.channels), - .samplesPerSec = static_cast(asset->sound.info.rate), - .bitsPerSample = static_cast(asset->sound.info.bits)}; - - writer.WritePcmHeader(metaData, asset->sound.info.data_len); - writer.WritePcmData(asset->sound.data, asset->sound.info.data_len); -} - -void AssetDumperLoadedSound::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* loadedSound = asset->Asset(); - const auto assetFile = context.OpenAssetFile(std::format("sound/{}", asset->m_name)); - - if (!assetFile) - return; - - auto& stream = *assetFile; - switch (static_cast(loadedSound->sound.info.format)) - { - case WavFormat::PCM: - DumpWavPcm(loadedSound, stream); - break; - - default: - std::cerr << std::format("Unknown format {} for loaded sound: {}\n", loadedSound->sound.info.format, loadedSound->name); - break; - } -} diff --git a/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.cpp b/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.cpp new file mode 100644 index 00000000..8feae9b7 --- /dev/null +++ b/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.cpp @@ -0,0 +1,52 @@ +#include "LoadedSoundDumperIW5.h" + +#include "Sound/WavTypes.h" +#include "Sound/WavWriter.h" + +#include + +using namespace IW5; + +namespace +{ + void DumpWavPcm(const LoadedSound* asset, std::ostream& stream) + { + const WavWriter writer(stream); + + const WavMetaData metaData{.channelCount = static_cast(asset->sound.info.channels), + .samplesPerSec = static_cast(asset->sound.info.rate), + .bitsPerSample = static_cast(asset->sound.info.bits)}; + + writer.WritePcmHeader(metaData, asset->sound.info.data_len); + writer.WritePcmData(asset->sound.data, asset->sound.info.data_len); + } +} // namespace + +namespace IW5::sound +{ + bool LoadedSoundDumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void LoadedSoundDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* loadedSound = asset->Asset(); + const auto assetFile = context.OpenAssetFile(std::format("sound/{}", asset->m_name)); + + if (!assetFile) + return; + + auto& stream = *assetFile; + switch (static_cast(loadedSound->sound.info.format)) + { + case WavFormat::PCM: + DumpWavPcm(loadedSound, stream); + break; + + default: + std::cerr << std::format("Unknown format {} for loaded sound: {}\n", loadedSound->sound.info.format, loadedSound->name); + break; + } + } +} // namespace IW5::sound diff --git a/src/ObjWriting/Game/IW5/Sound/AssetDumperLoadedSound.h b/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.h similarity index 58% rename from src/ObjWriting/Game/IW5/Sound/AssetDumperLoadedSound.h rename to src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.h index 4f575072..9758b545 100644 --- a/src/ObjWriting/Game/IW5/Sound/AssetDumperLoadedSound.h +++ b/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.h @@ -3,14 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW5/IW5.h" -namespace IW5 +namespace IW5::sound { - class AssetDumperLoadedSound final : public AbstractAssetDumper + class LoadedSoundDumper final : public AbstractAssetDumper { - static void DumpWavPcm(const LoadedSound* asset, std::ostream& stream); - protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW5 +} // namespace IW5::sound diff --git a/src/ObjWriting/Game/T5/ObjWriterT5.cpp b/src/ObjWriting/Game/T5/ObjWriterT5.cpp index f224f067..55466d5d 100644 --- a/src/ObjWriting/Game/T5/ObjWriterT5.cpp +++ b/src/ObjWriting/Game/T5/ObjWriterT5.cpp @@ -7,7 +7,6 @@ #include "Localize/LocalizeDumperT5.h" #include "ObjWriting.h" #include "RawFile/RawFileDumperT5.h" -#include "Sound/AssetDumperSndBank.h" #include "StringTable/StringTableDumperT5.h" #include "Weapon/AssetDumperWeapon.h" diff --git a/src/ObjWriting/Game/T5/Sound/AssetDumperSndBank.cpp b/src/ObjWriting/Game/T5/Sound/AssetDumperSndBank.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/src/ObjWriting/Game/T5/Sound/AssetDumperSndBank.h b/src/ObjWriting/Game/T5/Sound/AssetDumperSndBank.h deleted file mode 100644 index e69de29b..00000000 diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 3a3f05a8..93cfea5a 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -15,8 +15,8 @@ #include "RawFile/RawFileDumperT6.h" #include "Script/ScriptDumperT6.h" #include "Slug/SlugDumperT6.h" -#include "Sound/AssetDumperSndBank.h" -#include "Sound/AssetDumperSndDriverGlobals.h" +#include "Sound/SndBankDumperT6.h" +#include "Sound/SndDriverGlobalsDumperT6.h" #include "StringTable/StringTableDumperT6.h" #include "Techset/TechsetDumperT6.h" #include "Tracer/TracerDumperT6.h" @@ -54,7 +54,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) DUMP_ASSET_POOL(techset::Dumper, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) - DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank, ASSET_TYPE_SOUND) + DUMP_ASSET_POOL(sound::SndBankDumper, m_sound_bank, ASSET_TYPE_SOUND) // DUMP_ASSET_POOL(AssetDumperSndPatch, m_sound_patch, ASSET_TYPE_SOUND_PATCH) // DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_PVS) // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD) @@ -72,7 +72,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(AssetDumperWeaponAttachment, m_attachment, ASSET_TYPE_ATTACHMENT) DUMP_ASSET_POOL(AssetDumperWeaponAttachmentUnique, m_attachment_unique, ASSET_TYPE_ATTACHMENT_UNIQUE) DUMP_ASSET_POOL(AssetDumperWeaponCamo, m_camo, ASSET_TYPE_WEAPON_CAMO) - DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) + DUMP_ASSET_POOL(sound::SndDriverGlobalsDumper, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE) diff --git a/src/ObjWriting/Game/T6/Sound/AssetDumperSndDriverGlobals.cpp b/src/ObjWriting/Game/T6/Sound/AssetDumperSndDriverGlobals.cpp deleted file mode 100644 index 452858ce..00000000 --- a/src/ObjWriting/Game/T6/Sound/AssetDumperSndDriverGlobals.cpp +++ /dev/null @@ -1,385 +0,0 @@ -#include "AssetDumperSndDriverGlobals.h" - -#include "Csv/CsvStream.h" -#include "ObjContainer/SoundBank/SoundBank.h" - -using namespace T6; - -class AssetDumperSndDriverGlobals::Internal -{ - AssetDumpingContext& m_context; - - inline static const std::string GROUPS_HEADERS[]{ - "name", - "attenuationSp", - "attenuationMp", - "category", - "parent", - "id", - }; - - inline static const std::string GROUPS_CATEGORIES[]{ - "sfx", - "music", - "void", - "ui", - "cinematic", - "id", - }; - - inline static const std::string CURVE_HEADERS[]{ - "name", - "x0", - "y0", - "x1", - "y1", - "x2", - "y2", - "x3", - "y3", - "x4", - "y4", - "x5", - "y5", - "x6", - "y6", - "x7", - "y7", - "id", - }; - - inline static const std::string PAN_HEADERS[]{ - "name", - "front", - "back", - "center", - "lfe", - "left", - "right", - "id", - }; - - inline static const std::string MASTER_HEADERS[]{ - "name", "lowE", "lowG", "lowF", "lowQ", "peak1E", "peak1G", "peak1F", "peak1Q", "peak2E", "peak2G", - "peak2F", "peak2Q", "hiE", "hiG", "hiF", "hiQ", "eqG", "compE", "compPG", "compMG", "compT", - "compR", "compTA", "compTR", "limitE", "limitPG", "limitMG", "limitT", "limitR", "limitTA", "limitTR", "busReverbG", - "busFxG", "busVoiceG", "busPfutzG", "busHdrfxG", "busUiG", "busMusicG", "busMovieG", "busVcsG", "busReverbE", "busFxE", "busVoiceE", - "busPfutzE", "busHdrfxE", "busUiE", "busMusicE", "busMovieE", "hdrfxCompE", "voiceEqE", "voiceCompE", "id", - }; - - inline static const std::string SIDECHAIN_HEADERS[]{ - "name", - "g", - "f", - "q", - "ta", - "tr", - "tf", - "id", - }; - - inline static const std::string FUTZ_HEADERS[]{ - "name", - "bpfF", - "bpfQ", - "lsG", - "lsF", - "lsQ", - "dist", - "preG", - "postG", - "th", - "tg", - "clippre", - "clippost", - "blend", - "startAliasId", - "stopAliasId", - "loopAliasId", - "id", - }; - - std::unique_ptr OpenAssetFile(const std::string& filename) - { - auto outputFile = this->m_context.OpenAssetFile(filename); - if (outputFile == nullptr) - { - std::cout << "Failed to open sound driver globals output file for: \"" << filename << "\"\n"; - } - - return outputFile; - } - - static void WriteFileHeader(CsvOutputStream& stream, const std::string* headers, size_t count) - { - for (auto i = 0u; i < count; i++) - { - stream.WriteColumn(headers[i]); - } - - stream.NextRow(); - } - - void DumpSndVolumesGroups(const SndVolumeGroup* groups, const size_t count) - { - const auto outputFile = this->OpenAssetFile("soundbank/globals/group.csv"); - - if (outputFile != nullptr) - { - CsvOutputStream csvStream(*outputFile); - WriteFileHeader(csvStream, GROUPS_HEADERS, std::extent_v); - - for (auto i = 0u; i < count; i++) - { - const auto& group = groups[i]; - csvStream.WriteColumn(group.name); - csvStream.WriteColumn(std::to_string(group.attenuationSp)); - csvStream.WriteColumn(std::to_string(group.attenuationMp)); - csvStream.WriteColumn(GROUPS_CATEGORIES[group.category]); - csvStream.WriteColumn(group.parentName); - csvStream.WriteColumn(std::to_string(group.id)); - csvStream.NextRow(); - } - } - } - - void DumpSndCurves(const SndCurve* curves, const size_t count) - { - const auto outputFile = this->OpenAssetFile("soundbank/globals/curves.csv"); - - if (outputFile != nullptr) - { - CsvOutputStream csvStream(*outputFile); - WriteFileHeader(csvStream, CURVE_HEADERS, std::extent_v); - - for (auto i = 0u; i < count; i++) - { - const auto& curve = curves[i]; - csvStream.WriteColumn(curve.name); - - for (auto j = 0u; j < 8; j++) - { - csvStream.WriteColumn(std::to_string(curve.points[j].x)); - csvStream.WriteColumn(std::to_string(curve.points[j].y)); - } - - csvStream.WriteColumn(std::to_string(curve.id)); - - csvStream.NextRow(); - } - } - } - - void DumpSndPans(const SndPan* pans, const size_t count) - { - const auto outputFile = this->OpenAssetFile("soundbank/globals/pan.csv"); - - if (outputFile != nullptr) - { - CsvOutputStream csvStream(*outputFile); - WriteFileHeader(csvStream, PAN_HEADERS, std::extent_v); - - for (auto i = 0u; i < count; i++) - { - const auto& pan = pans[i]; - csvStream.WriteColumn(pan.name); - csvStream.WriteColumn(std::to_string(pan.front)); - csvStream.WriteColumn(std::to_string(pan.back)); - csvStream.WriteColumn(std::to_string(pan.center)); - csvStream.WriteColumn(std::to_string(pan.lfe)); - csvStream.WriteColumn(std::to_string(pan.left)); - csvStream.WriteColumn(std::to_string(pan.right)); - csvStream.WriteColumn(std::to_string(pan.id)); - csvStream.NextRow(); - } - } - } - - void DumpSndDuckGroups(const SndDuckGroup* duckGroups, const size_t count) - { - const auto outputFile = this->OpenAssetFile("soundbank/globals/duck_groups.csv"); - - if (outputFile != nullptr) - { - CsvOutputStream csvStream(*outputFile); - csvStream.WriteColumn("name"); - csvStream.WriteColumn("id"); - csvStream.NextRow(); - - for (auto i = 0u; i < count; i++) - { - const auto& duckGroup = duckGroups[i]; - csvStream.WriteColumn(duckGroup.name); - csvStream.WriteColumn(std::to_string(duckGroup.id)); - csvStream.NextRow(); - } - } - } - - void DumpSndMasters(const SndMaster* masters, const size_t count) - { - const auto outputFile = this->OpenAssetFile("soundbank/globals/master.csv"); - - if (outputFile != nullptr) - { - CsvOutputStream csvStream(*outputFile); - WriteFileHeader(csvStream, MASTER_HEADERS, std::extent_v); - - for (auto i = 0u; i < count; i++) - { - const auto& master = masters[i]; - csvStream.WriteColumn(master.name); - csvStream.WriteColumn(std::to_string(master.lowE)); - csvStream.WriteColumn(std::to_string(master.lowG)); - csvStream.WriteColumn(std::to_string(master.lowF)); - csvStream.WriteColumn(std::to_string(master.lowQ)); - csvStream.WriteColumn(std::to_string(master.peak1E)); - csvStream.WriteColumn(std::to_string(master.peak1G)); - csvStream.WriteColumn(std::to_string(master.peak1F)); - csvStream.WriteColumn(std::to_string(master.peak1Q)); - csvStream.WriteColumn(std::to_string(master.peak2E)); - csvStream.WriteColumn(std::to_string(master.peak2G)); - csvStream.WriteColumn(std::to_string(master.peak2F)); - csvStream.WriteColumn(std::to_string(master.peak2Q)); - csvStream.WriteColumn(std::to_string(master.hiE)); - csvStream.WriteColumn(std::to_string(master.hiG)); - csvStream.WriteColumn(std::to_string(master.hiF)); - csvStream.WriteColumn(std::to_string(master.hiQ)); - csvStream.WriteColumn(std::to_string(master.eqG)); - csvStream.WriteColumn(std::to_string(master.compE)); - csvStream.WriteColumn(std::to_string(master.compPG)); - csvStream.WriteColumn(std::to_string(master.compMG)); - csvStream.WriteColumn(std::to_string(master.compT)); - csvStream.WriteColumn(std::to_string(master.compR)); - csvStream.WriteColumn(std::to_string(master.compTA)); - csvStream.WriteColumn(std::to_string(master.compTR)); - csvStream.WriteColumn(std::to_string(master.limitE)); - csvStream.WriteColumn(std::to_string(master.limitPG)); - csvStream.WriteColumn(std::to_string(master.limitMG)); - csvStream.WriteColumn(std::to_string(master.limitT)); - csvStream.WriteColumn(std::to_string(master.limitR)); - csvStream.WriteColumn(std::to_string(master.limitTA)); - csvStream.WriteColumn(std::to_string(master.limitTR)); - csvStream.WriteColumn(std::to_string(master.busReverbG)); - csvStream.WriteColumn(std::to_string(master.busFxG)); - csvStream.WriteColumn(std::to_string(master.busVoiceG)); - csvStream.WriteColumn(std::to_string(master.busPfutzG)); - csvStream.WriteColumn(std::to_string(master.busHdrfxG)); - csvStream.WriteColumn(std::to_string(master.busUiG)); - csvStream.WriteColumn(std::to_string(master.busMusicG)); - csvStream.WriteColumn(std::to_string(master.busMovieG)); - csvStream.WriteColumn(std::to_string(master.busVcsG)); - csvStream.WriteColumn(std::to_string(master.busReverbE)); - csvStream.WriteColumn(std::to_string(master.busFxE)); - csvStream.WriteColumn(std::to_string(master.busVoiceE)); - csvStream.WriteColumn(std::to_string(master.busPfutzE)); - csvStream.WriteColumn(std::to_string(master.busHdrfxE)); - csvStream.WriteColumn(std::to_string(master.busUiE)); - csvStream.WriteColumn(std::to_string(master.busMusicE)); - csvStream.WriteColumn(std::to_string(master.busMovieE)); - csvStream.WriteColumn(std::to_string(master.hdrfxCompE)); - csvStream.WriteColumn(std::to_string(master.voiceEqE)); - csvStream.WriteColumn(std::to_string(master.voiceCompE)); - csvStream.WriteColumn(std::to_string(master.id)); - csvStream.NextRow(); - } - } - } - - void DumpSndSidechainDucks(const SndSidechainDuck* sidechains, const size_t count) - { - const auto outputFile = this->OpenAssetFile("soundbank/globals/sidechain_duck.csv"); - - if (outputFile != nullptr) - { - CsvOutputStream csvStream(*outputFile); - WriteFileHeader(csvStream, SIDECHAIN_HEADERS, std::extent_v); - - for (auto i = 0u; i < count; i++) - { - const auto& sidechain = sidechains[i]; - csvStream.WriteColumn(sidechain.name); - csvStream.WriteColumn(std::to_string(sidechain.g)); - csvStream.WriteColumn(std::to_string(sidechain.f)); - csvStream.WriteColumn(std::to_string(sidechain.q)); - csvStream.WriteColumn(std::to_string(sidechain.ta)); - csvStream.WriteColumn(std::to_string(sidechain.tr)); - csvStream.WriteColumn(std::to_string(sidechain.tf)); - csvStream.WriteColumn(std::to_string(sidechain.id)); - csvStream.NextRow(); - } - } - } - - void DumpSndFutz(const SndFutz* futzes, const size_t count) - { - const auto outputFile = this->OpenAssetFile("soundbank/globals/futz.csv"); - - if (outputFile != nullptr) - { - CsvOutputStream csvStream(*outputFile); - WriteFileHeader(csvStream, FUTZ_HEADERS, std::extent_v); - - for (auto i = 0u; i < count; i++) - { - const auto& futz = futzes[i]; - csvStream.WriteColumn(futz.name); - csvStream.WriteColumn(std::to_string(futz.bpfF)); - csvStream.WriteColumn(std::to_string(futz.bpfQ)); - csvStream.WriteColumn(std::to_string(futz.lsG)); - csvStream.WriteColumn(std::to_string(futz.lsF)); - csvStream.WriteColumn(std::to_string(futz.lsQ)); - csvStream.WriteColumn(std::to_string(futz.dist)); - csvStream.WriteColumn(std::to_string(futz.preG)); - csvStream.WriteColumn(std::to_string(futz.postG)); - csvStream.WriteColumn(std::to_string(futz.th)); - csvStream.WriteColumn(std::to_string(futz.tg)); - csvStream.WriteColumn(std::to_string(futz.clippre)); - csvStream.WriteColumn(std::to_string(futz.clippost)); - csvStream.WriteColumn(std::to_string(futz.blend)); - csvStream.WriteColumn(std::to_string(futz.startAliasId)); - csvStream.WriteColumn(std::to_string(futz.stopAliasId)); - csvStream.WriteColumn(std::to_string(futz.loopAliasId)); - csvStream.WriteColumn(std::to_string(futz.id)); - csvStream.NextRow(); - } - } - } - - void DumpSndDriverGlobals(const XAssetInfo* sndDriverGlobalsInfo) - { - const auto* sndDriverGlobals = sndDriverGlobalsInfo->Asset(); - - DumpSndVolumesGroups(sndDriverGlobals->groups, sndDriverGlobals->groupCount); - DumpSndCurves(sndDriverGlobals->curves, sndDriverGlobals->curveCount); - DumpSndPans(sndDriverGlobals->pans, sndDriverGlobals->panCount); - DumpSndDuckGroups(sndDriverGlobals->duckGroups, sndDriverGlobals->duckGroupCount); - // DumpSndContexts(sndDriverGlobals->contexts, sndDriverGlobals->contextCount); - DumpSndMasters(sndDriverGlobals->masters, sndDriverGlobals->masterCount); - DumpSndSidechainDucks(sndDriverGlobals->voiceDucks, sndDriverGlobals->voiceDuckCount); - DumpSndFutz(sndDriverGlobals->futzes, sndDriverGlobals->futzCount); - } - -public: - explicit Internal(AssetDumpingContext& context) - : m_context(context) - { - } - - void DumpPool(AssetPool* pool) - { - for (const auto* assetInfo : *pool) - { - if (!assetInfo->m_name.empty() && assetInfo->m_name[0] == ',') - continue; - - DumpSndDriverGlobals(assetInfo); - } - } -}; - -void AssetDumperSndDriverGlobals::DumpPool(AssetDumpingContext& context, AssetPool* pool) -{ - Internal internal(context); - internal.DumpPool(pool); -} diff --git a/src/ObjWriting/Game/T6/Sound/AssetDumperSndBank.cpp b/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.cpp similarity index 98% rename from src/ObjWriting/Game/T6/Sound/AssetDumperSndBank.cpp rename to src/ObjWriting/Game/T6/Sound/SndBankDumperT6.cpp index 5d407b86..f72517a4 100644 --- a/src/ObjWriting/Game/T6/Sound/AssetDumperSndBank.cpp +++ b/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.cpp @@ -1,4 +1,4 @@ -#include "AssetDumperSndBank.h" +#include "SndBankDumperT6.h" #include "Csv/CsvStream.h" #include "Game/T6/CommonT6.h" @@ -910,15 +910,18 @@ namespace } } // namespace -void AssetDumperSndBank::DumpPool(AssetDumpingContext& context, AssetPool* pool) +namespace T6::sound { - LoadedSoundBankHashes soundBankHashes; - soundBankHashes.Initialize(); - for (const auto* assetInfo : *pool) + void SndBankDumper::DumpPool(AssetDumpingContext& context, AssetPool* pool) { - if (!assetInfo->m_name.empty() && assetInfo->m_name[0] == ',') - continue; + LoadedSoundBankHashes soundBankHashes; + soundBankHashes.Initialize(); + for (const auto* assetInfo : *pool) + { + if (!assetInfo->m_name.empty() && assetInfo->m_name[0] == ',') + continue; - DumpSndBank(context, soundBankHashes, *assetInfo); + DumpSndBank(context, soundBankHashes, *assetInfo); + } } -} +} // namespace T6::sound diff --git a/src/ObjWriting/Game/T6/Sound/AssetDumperSndBank.h b/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.h similarity index 61% rename from src/ObjWriting/Game/T6/Sound/AssetDumperSndBank.h rename to src/ObjWriting/Game/T6/Sound/SndBankDumperT6.h index 61883c58..77141ac3 100644 --- a/src/ObjWriting/Game/T6/Sound/AssetDumperSndBank.h +++ b/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.h @@ -3,13 +3,11 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6 +namespace T6::sound { - class AssetDumperSndBank final : public IAssetDumper + class SndBankDumper final : public IAssetDumper { - class Internal; - public: void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; }; -} // namespace T6 +} // namespace T6::sound diff --git a/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.cpp b/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.cpp new file mode 100644 index 00000000..1b27898e --- /dev/null +++ b/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.cpp @@ -0,0 +1,392 @@ +#include "SndDriverGlobalsDumperT6.h" + +#include "Csv/CsvStream.h" +#include "ObjContainer/SoundBank/SoundBank.h" + +#include + +using namespace T6; + +namespace +{ + const std::string GROUPS_HEADERS[]{ + "name", + "attenuationSp", + "attenuationMp", + "category", + "parent", + "id", + }; + + const std::string GROUPS_CATEGORIES[]{ + "sfx", + "music", + "void", + "ui", + "cinematic", + "id", + }; + + const std::string CURVE_HEADERS[]{ + "name", + "x0", + "y0", + "x1", + "y1", + "x2", + "y2", + "x3", + "y3", + "x4", + "y4", + "x5", + "y5", + "x6", + "y6", + "x7", + "y7", + "id", + }; + + const std::string PAN_HEADERS[]{ + "name", + "front", + "back", + "center", + "lfe", + "left", + "right", + "id", + }; + + const std::string MASTER_HEADERS[]{ + "name", "lowE", "lowG", "lowF", "lowQ", "peak1E", "peak1G", "peak1F", "peak1Q", "peak2E", "peak2G", + "peak2F", "peak2Q", "hiE", "hiG", "hiF", "hiQ", "eqG", "compE", "compPG", "compMG", "compT", + "compR", "compTA", "compTR", "limitE", "limitPG", "limitMG", "limitT", "limitR", "limitTA", "limitTR", "busReverbG", + "busFxG", "busVoiceG", "busPfutzG", "busHdrfxG", "busUiG", "busMusicG", "busMovieG", "busVcsG", "busReverbE", "busFxE", "busVoiceE", + "busPfutzE", "busHdrfxE", "busUiE", "busMusicE", "busMovieE", "hdrfxCompE", "voiceEqE", "voiceCompE", "id", + }; + + const std::string SIDECHAIN_HEADERS[]{ + "name", + "g", + "f", + "q", + "ta", + "tr", + "tf", + "id", + }; + + const std::string FUTZ_HEADERS[]{ + "name", + "bpfF", + "bpfQ", + "lsG", + "lsF", + "lsQ", + "dist", + "preG", + "postG", + "th", + "tg", + "clippre", + "clippost", + "blend", + "startAliasId", + "stopAliasId", + "loopAliasId", + "id", + }; + + class Internal + { + public: + explicit Internal(AssetDumpingContext& context) + : m_context(context) + { + } + + void DumpPool(AssetPool* pool) + { + for (const auto* assetInfo : *pool) + { + if (!assetInfo->m_name.empty() && assetInfo->m_name[0] == ',') + continue; + + DumpSndDriverGlobals(assetInfo); + } + } + + private: + std::unique_ptr OpenAssetFile(const std::string& filename) + { + auto outputFile = this->m_context.OpenAssetFile(filename); + if (outputFile == nullptr) + std::cerr << std::format("Failed to open sound driver globals output file for: \"{}\"\n", filename); + + return outputFile; + } + + static void WriteFileHeader(CsvOutputStream& stream, const std::string* headers, size_t count) + { + for (auto i = 0u; i < count; i++) + { + stream.WriteColumn(headers[i]); + } + + stream.NextRow(); + } + + void DumpSndVolumesGroups(const SndVolumeGroup* groups, const size_t count) + { + const auto outputFile = this->OpenAssetFile("soundbank/globals/group.csv"); + + if (outputFile != nullptr) + { + CsvOutputStream csvStream(*outputFile); + WriteFileHeader(csvStream, GROUPS_HEADERS, std::extent_v); + + for (auto i = 0u; i < count; i++) + { + const auto& group = groups[i]; + csvStream.WriteColumn(group.name); + csvStream.WriteColumn(std::to_string(group.attenuationSp)); + csvStream.WriteColumn(std::to_string(group.attenuationMp)); + csvStream.WriteColumn(GROUPS_CATEGORIES[group.category]); + csvStream.WriteColumn(group.parentName); + csvStream.WriteColumn(std::to_string(group.id)); + csvStream.NextRow(); + } + } + } + + void DumpSndCurves(const SndCurve* curves, const size_t count) + { + const auto outputFile = this->OpenAssetFile("soundbank/globals/curves.csv"); + + if (outputFile != nullptr) + { + CsvOutputStream csvStream(*outputFile); + WriteFileHeader(csvStream, CURVE_HEADERS, std::extent_v); + + for (auto i = 0u; i < count; i++) + { + const auto& curve = curves[i]; + csvStream.WriteColumn(curve.name); + + for (auto j = 0u; j < 8; j++) + { + csvStream.WriteColumn(std::to_string(curve.points[j].x)); + csvStream.WriteColumn(std::to_string(curve.points[j].y)); + } + + csvStream.WriteColumn(std::to_string(curve.id)); + + csvStream.NextRow(); + } + } + } + + void DumpSndPans(const SndPan* pans, const size_t count) + { + const auto outputFile = this->OpenAssetFile("soundbank/globals/pan.csv"); + + if (outputFile != nullptr) + { + CsvOutputStream csvStream(*outputFile); + WriteFileHeader(csvStream, PAN_HEADERS, std::extent_v); + + for (auto i = 0u; i < count; i++) + { + const auto& pan = pans[i]; + csvStream.WriteColumn(pan.name); + csvStream.WriteColumn(std::to_string(pan.front)); + csvStream.WriteColumn(std::to_string(pan.back)); + csvStream.WriteColumn(std::to_string(pan.center)); + csvStream.WriteColumn(std::to_string(pan.lfe)); + csvStream.WriteColumn(std::to_string(pan.left)); + csvStream.WriteColumn(std::to_string(pan.right)); + csvStream.WriteColumn(std::to_string(pan.id)); + csvStream.NextRow(); + } + } + } + + void DumpSndDuckGroups(const SndDuckGroup* duckGroups, const size_t count) + { + const auto outputFile = this->OpenAssetFile("soundbank/globals/duck_groups.csv"); + + if (outputFile != nullptr) + { + CsvOutputStream csvStream(*outputFile); + csvStream.WriteColumn("name"); + csvStream.WriteColumn("id"); + csvStream.NextRow(); + + for (auto i = 0u; i < count; i++) + { + const auto& duckGroup = duckGroups[i]; + csvStream.WriteColumn(duckGroup.name); + csvStream.WriteColumn(std::to_string(duckGroup.id)); + csvStream.NextRow(); + } + } + } + + void DumpSndMasters(const SndMaster* masters, const size_t count) + { + const auto outputFile = this->OpenAssetFile("soundbank/globals/master.csv"); + + if (outputFile != nullptr) + { + CsvOutputStream csvStream(*outputFile); + WriteFileHeader(csvStream, MASTER_HEADERS, std::extent_v); + + for (auto i = 0u; i < count; i++) + { + const auto& master = masters[i]; + csvStream.WriteColumn(master.name); + csvStream.WriteColumn(std::to_string(master.lowE)); + csvStream.WriteColumn(std::to_string(master.lowG)); + csvStream.WriteColumn(std::to_string(master.lowF)); + csvStream.WriteColumn(std::to_string(master.lowQ)); + csvStream.WriteColumn(std::to_string(master.peak1E)); + csvStream.WriteColumn(std::to_string(master.peak1G)); + csvStream.WriteColumn(std::to_string(master.peak1F)); + csvStream.WriteColumn(std::to_string(master.peak1Q)); + csvStream.WriteColumn(std::to_string(master.peak2E)); + csvStream.WriteColumn(std::to_string(master.peak2G)); + csvStream.WriteColumn(std::to_string(master.peak2F)); + csvStream.WriteColumn(std::to_string(master.peak2Q)); + csvStream.WriteColumn(std::to_string(master.hiE)); + csvStream.WriteColumn(std::to_string(master.hiG)); + csvStream.WriteColumn(std::to_string(master.hiF)); + csvStream.WriteColumn(std::to_string(master.hiQ)); + csvStream.WriteColumn(std::to_string(master.eqG)); + csvStream.WriteColumn(std::to_string(master.compE)); + csvStream.WriteColumn(std::to_string(master.compPG)); + csvStream.WriteColumn(std::to_string(master.compMG)); + csvStream.WriteColumn(std::to_string(master.compT)); + csvStream.WriteColumn(std::to_string(master.compR)); + csvStream.WriteColumn(std::to_string(master.compTA)); + csvStream.WriteColumn(std::to_string(master.compTR)); + csvStream.WriteColumn(std::to_string(master.limitE)); + csvStream.WriteColumn(std::to_string(master.limitPG)); + csvStream.WriteColumn(std::to_string(master.limitMG)); + csvStream.WriteColumn(std::to_string(master.limitT)); + csvStream.WriteColumn(std::to_string(master.limitR)); + csvStream.WriteColumn(std::to_string(master.limitTA)); + csvStream.WriteColumn(std::to_string(master.limitTR)); + csvStream.WriteColumn(std::to_string(master.busReverbG)); + csvStream.WriteColumn(std::to_string(master.busFxG)); + csvStream.WriteColumn(std::to_string(master.busVoiceG)); + csvStream.WriteColumn(std::to_string(master.busPfutzG)); + csvStream.WriteColumn(std::to_string(master.busHdrfxG)); + csvStream.WriteColumn(std::to_string(master.busUiG)); + csvStream.WriteColumn(std::to_string(master.busMusicG)); + csvStream.WriteColumn(std::to_string(master.busMovieG)); + csvStream.WriteColumn(std::to_string(master.busVcsG)); + csvStream.WriteColumn(std::to_string(master.busReverbE)); + csvStream.WriteColumn(std::to_string(master.busFxE)); + csvStream.WriteColumn(std::to_string(master.busVoiceE)); + csvStream.WriteColumn(std::to_string(master.busPfutzE)); + csvStream.WriteColumn(std::to_string(master.busHdrfxE)); + csvStream.WriteColumn(std::to_string(master.busUiE)); + csvStream.WriteColumn(std::to_string(master.busMusicE)); + csvStream.WriteColumn(std::to_string(master.busMovieE)); + csvStream.WriteColumn(std::to_string(master.hdrfxCompE)); + csvStream.WriteColumn(std::to_string(master.voiceEqE)); + csvStream.WriteColumn(std::to_string(master.voiceCompE)); + csvStream.WriteColumn(std::to_string(master.id)); + csvStream.NextRow(); + } + } + } + + void DumpSndSidechainDucks(const SndSidechainDuck* sidechains, const size_t count) + { + const auto outputFile = this->OpenAssetFile("soundbank/globals/sidechain_duck.csv"); + + if (outputFile != nullptr) + { + CsvOutputStream csvStream(*outputFile); + WriteFileHeader(csvStream, SIDECHAIN_HEADERS, std::extent_v); + + for (auto i = 0u; i < count; i++) + { + const auto& sidechain = sidechains[i]; + csvStream.WriteColumn(sidechain.name); + csvStream.WriteColumn(std::to_string(sidechain.g)); + csvStream.WriteColumn(std::to_string(sidechain.f)); + csvStream.WriteColumn(std::to_string(sidechain.q)); + csvStream.WriteColumn(std::to_string(sidechain.ta)); + csvStream.WriteColumn(std::to_string(sidechain.tr)); + csvStream.WriteColumn(std::to_string(sidechain.tf)); + csvStream.WriteColumn(std::to_string(sidechain.id)); + csvStream.NextRow(); + } + } + } + + void DumpSndFutz(const SndFutz* futzes, const size_t count) + { + const auto outputFile = this->OpenAssetFile("soundbank/globals/futz.csv"); + + if (outputFile != nullptr) + { + CsvOutputStream csvStream(*outputFile); + WriteFileHeader(csvStream, FUTZ_HEADERS, std::extent_v); + + for (auto i = 0u; i < count; i++) + { + const auto& futz = futzes[i]; + csvStream.WriteColumn(futz.name); + csvStream.WriteColumn(std::to_string(futz.bpfF)); + csvStream.WriteColumn(std::to_string(futz.bpfQ)); + csvStream.WriteColumn(std::to_string(futz.lsG)); + csvStream.WriteColumn(std::to_string(futz.lsF)); + csvStream.WriteColumn(std::to_string(futz.lsQ)); + csvStream.WriteColumn(std::to_string(futz.dist)); + csvStream.WriteColumn(std::to_string(futz.preG)); + csvStream.WriteColumn(std::to_string(futz.postG)); + csvStream.WriteColumn(std::to_string(futz.th)); + csvStream.WriteColumn(std::to_string(futz.tg)); + csvStream.WriteColumn(std::to_string(futz.clippre)); + csvStream.WriteColumn(std::to_string(futz.clippost)); + csvStream.WriteColumn(std::to_string(futz.blend)); + csvStream.WriteColumn(std::to_string(futz.startAliasId)); + csvStream.WriteColumn(std::to_string(futz.stopAliasId)); + csvStream.WriteColumn(std::to_string(futz.loopAliasId)); + csvStream.WriteColumn(std::to_string(futz.id)); + csvStream.NextRow(); + } + } + } + + void DumpSndDriverGlobals(const XAssetInfo* sndDriverGlobalsInfo) + { + const auto* sndDriverGlobals = sndDriverGlobalsInfo->Asset(); + + DumpSndVolumesGroups(sndDriverGlobals->groups, sndDriverGlobals->groupCount); + DumpSndCurves(sndDriverGlobals->curves, sndDriverGlobals->curveCount); + DumpSndPans(sndDriverGlobals->pans, sndDriverGlobals->panCount); + DumpSndDuckGroups(sndDriverGlobals->duckGroups, sndDriverGlobals->duckGroupCount); + // DumpSndContexts(sndDriverGlobals->contexts, sndDriverGlobals->contextCount); + DumpSndMasters(sndDriverGlobals->masters, sndDriverGlobals->masterCount); + DumpSndSidechainDucks(sndDriverGlobals->voiceDucks, sndDriverGlobals->voiceDuckCount); + DumpSndFutz(sndDriverGlobals->futzes, sndDriverGlobals->futzCount); + } + + AssetDumpingContext& m_context; + }; +} // namespace + +namespace T6::sound +{ + void SndDriverGlobalsDumper::DumpPool(AssetDumpingContext& context, AssetPool* pool) + { + Internal internal(context); + internal.DumpPool(pool); + } +} // namespace T6::sound diff --git a/src/ObjWriting/Game/T6/Sound/AssetDumperSndDriverGlobals.h b/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.h similarity index 59% rename from src/ObjWriting/Game/T6/Sound/AssetDumperSndDriverGlobals.h rename to src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.h index 18f0cf89..b20c4f16 100644 --- a/src/ObjWriting/Game/T6/Sound/AssetDumperSndDriverGlobals.h +++ b/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.h @@ -3,13 +3,11 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6 +namespace T6::sound { - class AssetDumperSndDriverGlobals final : public IAssetDumper + class SndDriverGlobalsDumper final : public IAssetDumper { - class Internal; - public: void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; }; -} // namespace T6 +} // namespace T6::sound From 0546572ecf809b5e0cfe2827f9ba3b7ce170a599 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Sun, 3 Aug 2025 13:12:50 +0200 Subject: [PATCH 21/35] refactor: streamline weapon dumping --- src/ObjCommon/Weapon/AttachmentCommon.cpp | 16 + src/ObjCommon/Weapon/AttachmentCommon.h | 9 + .../Weapon/AttachmentUniqueCommon.cpp | 11 + src/ObjCommon/Weapon/AttachmentUniqueCommon.h | 8 + src/ObjCommon/Weapon/CamoCommon.cpp | 11 + src/ObjCommon/Weapon/CamoCommon.h | 8 + src/ObjCommon/Weapon/WeaponCommon.cpp | 11 + src/ObjCommon/Weapon/WeaponCommon.h | 8 + src/ObjLoading/Game/T6/ObjLoaderT6.cpp | 28 +- ...chmentT6.cpp => AttachmentGdtLoaderT6.cpp} | 12 +- .../Game/T6/Weapon/AttachmentGdtLoaderT6.h | 14 + ...6.cpp => AttachmentInfoStringLoaderT6.cpp} | 47 +- ...entT6.h => AttachmentInfoStringLoaderT6.h} | 8 +- ...chmentT6.cpp => AttachmentRawLoaderT6.cpp} | 16 +- .../Game/T6/Weapon/AttachmentRawLoaderT6.h | 13 + ...T6.cpp => AttachmentUniqueGdtLoaderT6.cpp} | 13 +- .../T6/Weapon/AttachmentUniqueGdtLoaderT6.h | 14 + ...=> AttachmentUniqueInfoStringLoaderT6.cpp} | 147 +++---- ...h => AttachmentUniqueInfoStringLoaderT6.h} | 12 +- ...T6.cpp => AttachmentUniqueRawLoaderT6.cpp} | 22 +- ...iqueT6.h => AttachmentUniqueRawLoaderT6.h} | 6 +- ...nCamoLoaderT6.cpp => CamoJsonLoaderT6.cpp} | 55 ++- ...oaderWeaponCamoT6.h => CamoJsonLoaderT6.h} | 6 +- .../Game/T6/Weapon/GdtLoaderAttachmentT6.h | 14 - .../T6/Weapon/GdtLoaderAttachmentUniqueT6.h | 15 - .../Game/T6/Weapon/JsonWeaponCamoLoaderT6.h | 14 - .../Game/T6/Weapon/LoaderWeaponCamoT6.cpp | 55 --- .../Game/T6/Weapon/RawLoaderAttachmentT6.h | 13 - .../Game/T6/Weapon/RawLoaderWeaponT6.h | 13 - ...aderWeaponT6.cpp => WeaponGdtLoaderT6.cpp} | 12 +- ...dtLoaderWeaponT6.h => WeaponGdtLoaderT6.h} | 6 +- ...ponT6.cpp => WeaponInfoStringLoaderT6.cpp} | 60 +-- ...rWeaponT6.h => WeaponInfoStringLoaderT6.h} | 8 +- ...aderWeaponT6.cpp => WeaponRawLoaderT6.cpp} | 22 +- .../Game/T6/Weapon/WeaponRawLoaderT6.h | 13 + src/ObjWriting/Game/IW3/ObjWriterIW3.cpp | 1 - .../Game/IW3/Weapon/AssetDumperWeapon.cpp | 0 .../Game/IW3/Weapon/AssetDumperWeapon.h | 0 src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 4 +- .../Game/IW4/Weapon/AssetDumperWeapon.h | 19 - ...etDumperWeapon.cpp => WeaponDumperIW4.cpp} | 370 ++++++++-------- .../Game/IW4/Weapon/WeaponDumperIW4.h | 15 + src/ObjWriting/Game/IW5/ObjWriterIW5.cpp | 8 +- .../Game/IW5/Weapon/AssetDumperWeapon.h | 19 - .../Weapon/AssetDumperWeaponAttachment.cpp | 22 - ...Writer.cpp => AttachmentJsonDumperIW5.cpp} | 28 +- ...Attachment.h => AttachmentJsonDumperIW5.h} | 6 +- .../IW5/Weapon/JsonWeaponAttachmentWriter.h | 11 - ...etDumperWeapon.cpp => WeaponDumperIW5.cpp} | 402 +++++++++--------- .../Game/IW5/Weapon/WeaponDumperIW5.h | 15 + src/ObjWriting/Game/T5/ObjWriterT5.cpp | 1 - .../Game/T5/Weapon/AssetDumperWeapon.cpp | 0 .../Game/T5/Weapon/AssetDumperWeapon.h | 0 src/ObjWriting/Game/T6/ObjWriterT6.cpp | 16 +- .../Game/T6/Weapon/AssetDumperWeapon.h | 19 - .../T6/Weapon/AssetDumperWeaponAttachment.cpp | 94 ---- .../AssetDumperWeaponAttachmentUnique.cpp | 158 ------- .../AssetDumperWeaponAttachmentUnique.h | 18 - .../Game/T6/Weapon/AssetDumperWeaponCamo.cpp | 23 - .../Game/T6/Weapon/AttachmentDumperT6.cpp | 99 +++++ ...eaponAttachment.h => AttachmentDumperT6.h} | 8 +- .../T6/Weapon/AttachmentUniqueDumperT6.cpp | 163 +++++++ .../Game/T6/Weapon/AttachmentUniqueDumperT6.h | 15 + ...ponCamoWriter.cpp => CamoJsonDumperT6.cpp} | 29 +- ...tDumperWeaponCamo.h => CamoJsonDumperT6.h} | 6 +- .../Game/T6/Weapon/JsonWeaponCamoWriter.h | 11 - ...setDumperWeapon.cpp => WeaponDumperT6.cpp} | 395 ++++++++--------- .../Game/T6/Weapon/WeaponDumperT6.h | 14 + 68 files changed, 1380 insertions(+), 1349 deletions(-) create mode 100644 src/ObjCommon/Weapon/AttachmentCommon.cpp create mode 100644 src/ObjCommon/Weapon/AttachmentCommon.h create mode 100644 src/ObjCommon/Weapon/AttachmentUniqueCommon.cpp create mode 100644 src/ObjCommon/Weapon/AttachmentUniqueCommon.h create mode 100644 src/ObjCommon/Weapon/CamoCommon.cpp create mode 100644 src/ObjCommon/Weapon/CamoCommon.h create mode 100644 src/ObjCommon/Weapon/WeaponCommon.cpp create mode 100644 src/ObjCommon/Weapon/WeaponCommon.h rename src/ObjLoading/Game/T6/Weapon/{GdtLoaderAttachmentT6.cpp => AttachmentGdtLoaderT6.cpp} (80%) create mode 100644 src/ObjLoading/Game/T6/Weapon/AttachmentGdtLoaderT6.h rename src/ObjLoading/Game/T6/Weapon/{InfoStringLoaderAttachmentT6.cpp => AttachmentInfoStringLoaderT6.cpp} (76%) rename src/ObjLoading/Game/T6/Weapon/{InfoStringLoaderAttachmentT6.h => AttachmentInfoStringLoaderT6.h} (70%) rename src/ObjLoading/Game/T6/Weapon/{RawLoaderAttachmentT6.cpp => AttachmentRawLoaderT6.cpp} (74%) create mode 100644 src/ObjLoading/Game/T6/Weapon/AttachmentRawLoaderT6.h rename src/ObjLoading/Game/T6/Weapon/{GdtLoaderAttachmentUniqueT6.cpp => AttachmentUniqueGdtLoaderT6.cpp} (78%) create mode 100644 src/ObjLoading/Game/T6/Weapon/AttachmentUniqueGdtLoaderT6.h rename src/ObjLoading/Game/T6/Weapon/{InfoStringLoaderAttachmentUniqueT6.cpp => AttachmentUniqueInfoStringLoaderT6.cpp} (64%) rename src/ObjLoading/Game/T6/Weapon/{InfoStringLoaderAttachmentUniqueT6.h => AttachmentUniqueInfoStringLoaderT6.h} (59%) rename src/ObjLoading/Game/T6/Weapon/{RawLoaderAttachmentUniqueT6.cpp => AttachmentUniqueRawLoaderT6.cpp} (63%) rename src/ObjLoading/Game/T6/Weapon/{RawLoaderAttachmentUniqueT6.h => AttachmentUniqueRawLoaderT6.h} (61%) rename src/ObjLoading/Game/T6/Weapon/{JsonWeaponCamoLoaderT6.cpp => CamoJsonLoaderT6.cpp} (84%) rename src/ObjLoading/Game/T6/Weapon/{LoaderWeaponCamoT6.h => CamoJsonLoaderT6.h} (50%) delete mode 100644 src/ObjLoading/Game/T6/Weapon/GdtLoaderAttachmentT6.h delete mode 100644 src/ObjLoading/Game/T6/Weapon/GdtLoaderAttachmentUniqueT6.h delete mode 100644 src/ObjLoading/Game/T6/Weapon/JsonWeaponCamoLoaderT6.h delete mode 100644 src/ObjLoading/Game/T6/Weapon/LoaderWeaponCamoT6.cpp delete mode 100644 src/ObjLoading/Game/T6/Weapon/RawLoaderAttachmentT6.h delete mode 100644 src/ObjLoading/Game/T6/Weapon/RawLoaderWeaponT6.h rename src/ObjLoading/Game/T6/Weapon/{GdtLoaderWeaponT6.cpp => WeaponGdtLoaderT6.cpp} (80%) rename src/ObjLoading/Game/T6/Weapon/{GdtLoaderWeaponT6.h => WeaponGdtLoaderT6.h} (50%) rename src/ObjLoading/Game/T6/Weapon/{InfoStringLoaderWeaponT6.cpp => WeaponInfoStringLoaderT6.cpp} (94%) rename src/ObjLoading/Game/T6/Weapon/{InfoStringLoaderWeaponT6.h => WeaponInfoStringLoaderT6.h} (71%) rename src/ObjLoading/Game/T6/Weapon/{RawLoaderWeaponT6.cpp => WeaponRawLoaderT6.cpp} (63%) create mode 100644 src/ObjLoading/Game/T6/Weapon/WeaponRawLoaderT6.h delete mode 100644 src/ObjWriting/Game/IW3/Weapon/AssetDumperWeapon.cpp delete mode 100644 src/ObjWriting/Game/IW3/Weapon/AssetDumperWeapon.h delete mode 100644 src/ObjWriting/Game/IW4/Weapon/AssetDumperWeapon.h rename src/ObjWriting/Game/IW4/Weapon/{AssetDumperWeapon.cpp => WeaponDumperIW4.cpp} (50%) create mode 100644 src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.h delete mode 100644 src/ObjWriting/Game/IW5/Weapon/AssetDumperWeapon.h delete mode 100644 src/ObjWriting/Game/IW5/Weapon/AssetDumperWeaponAttachment.cpp rename src/ObjWriting/Game/IW5/Weapon/{JsonWeaponAttachmentWriter.cpp => AttachmentJsonDumperIW5.cpp} (96%) rename src/ObjWriting/Game/IW5/Weapon/{AssetDumperWeaponAttachment.h => AttachmentJsonDumperIW5.h} (68%) delete mode 100644 src/ObjWriting/Game/IW5/Weapon/JsonWeaponAttachmentWriter.h rename src/ObjWriting/Game/IW5/Weapon/{AssetDumperWeapon.cpp => WeaponDumperIW5.cpp} (67%) create mode 100644 src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.h delete mode 100644 src/ObjWriting/Game/T5/Weapon/AssetDumperWeapon.cpp delete mode 100644 src/ObjWriting/Game/T5/Weapon/AssetDumperWeapon.h delete mode 100644 src/ObjWriting/Game/T6/Weapon/AssetDumperWeapon.h delete mode 100644 src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachment.cpp delete mode 100644 src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachmentUnique.cpp delete mode 100644 src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachmentUnique.h delete mode 100644 src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponCamo.cpp create mode 100644 src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.cpp rename src/ObjWriting/Game/T6/Weapon/{AssetDumperWeaponAttachment.h => AttachmentDumperT6.h} (60%) create mode 100644 src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.cpp create mode 100644 src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.h rename src/ObjWriting/Game/T6/Weapon/{JsonWeaponCamoWriter.cpp => CamoJsonDumperT6.cpp} (86%) rename src/ObjWriting/Game/T6/Weapon/{AssetDumperWeaponCamo.h => CamoJsonDumperT6.h} (70%) delete mode 100644 src/ObjWriting/Game/T6/Weapon/JsonWeaponCamoWriter.h rename src/ObjWriting/Game/T6/Weapon/{AssetDumperWeapon.cpp => WeaponDumperT6.cpp} (53%) create mode 100644 src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.h diff --git a/src/ObjCommon/Weapon/AttachmentCommon.cpp b/src/ObjCommon/Weapon/AttachmentCommon.cpp new file mode 100644 index 00000000..1fd354b3 --- /dev/null +++ b/src/ObjCommon/Weapon/AttachmentCommon.cpp @@ -0,0 +1,16 @@ +#include "AttachmentCommon.h" + +#include + +namespace attachment +{ + std::string GetInfoStringFileNameForAssetName(const std::string& assetName) + { + return std::format("attachment/{}", assetName); + } + + std::string GetJsonFileNameForAssetName(const std::string& assetName) + { + return std::format("attachment/{}.json", assetName); + } +} // namespace attachment diff --git a/src/ObjCommon/Weapon/AttachmentCommon.h b/src/ObjCommon/Weapon/AttachmentCommon.h new file mode 100644 index 00000000..e9566b4f --- /dev/null +++ b/src/ObjCommon/Weapon/AttachmentCommon.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +namespace attachment +{ + std::string GetInfoStringFileNameForAssetName(const std::string& assetName); + std::string GetJsonFileNameForAssetName(const std::string& assetName); +} // namespace attachment diff --git a/src/ObjCommon/Weapon/AttachmentUniqueCommon.cpp b/src/ObjCommon/Weapon/AttachmentUniqueCommon.cpp new file mode 100644 index 00000000..a1b520e3 --- /dev/null +++ b/src/ObjCommon/Weapon/AttachmentUniqueCommon.cpp @@ -0,0 +1,11 @@ +#include "AttachmentUniqueCommon.h" + +#include + +namespace attachment_unique +{ + std::string GetFileNameForAssetName(const std::string& assetName) + { + return std::format("attachmentunique/{}", assetName); + } +} // namespace attachment_unique diff --git a/src/ObjCommon/Weapon/AttachmentUniqueCommon.h b/src/ObjCommon/Weapon/AttachmentUniqueCommon.h new file mode 100644 index 00000000..dcc9accc --- /dev/null +++ b/src/ObjCommon/Weapon/AttachmentUniqueCommon.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace attachment_unique +{ + std::string GetFileNameForAssetName(const std::string& assetName); +} diff --git a/src/ObjCommon/Weapon/CamoCommon.cpp b/src/ObjCommon/Weapon/CamoCommon.cpp new file mode 100644 index 00000000..293794eb --- /dev/null +++ b/src/ObjCommon/Weapon/CamoCommon.cpp @@ -0,0 +1,11 @@ +#include "WeaponCommon.h" + +#include + +namespace camo +{ + std::string GetJsonFileNameForAssetName(const std::string& assetName) + { + return std::format("camo/{}.json", assetName); + } +} // namespace camo diff --git a/src/ObjCommon/Weapon/CamoCommon.h b/src/ObjCommon/Weapon/CamoCommon.h new file mode 100644 index 00000000..b0450767 --- /dev/null +++ b/src/ObjCommon/Weapon/CamoCommon.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace camo +{ + std::string GetJsonFileNameForAssetName(const std::string& assetName); +} diff --git a/src/ObjCommon/Weapon/WeaponCommon.cpp b/src/ObjCommon/Weapon/WeaponCommon.cpp new file mode 100644 index 00000000..704a388c --- /dev/null +++ b/src/ObjCommon/Weapon/WeaponCommon.cpp @@ -0,0 +1,11 @@ +#include "WeaponCommon.h" + +#include + +namespace weapon +{ + std::string GetFileNameForAssetName(const std::string& assetName) + { + return std::format("weapons/{}", assetName); + } +} // namespace weapon diff --git a/src/ObjCommon/Weapon/WeaponCommon.h b/src/ObjCommon/Weapon/WeaponCommon.h new file mode 100644 index 00000000..1d1a350a --- /dev/null +++ b/src/ObjCommon/Weapon/WeaponCommon.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace weapon +{ + std::string GetFileNameForAssetName(const std::string& assetName); +} diff --git a/src/ObjLoading/Game/T6/ObjLoaderT6.cpp b/src/ObjLoading/Game/T6/ObjLoaderT6.cpp index 7ebfbc3b..7232c923 100644 --- a/src/ObjLoading/Game/T6/ObjLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/ObjLoaderT6.cpp @@ -32,13 +32,13 @@ #include "Tracer/RawLoaderTracerT6.h" #include "Vehicle/GdtLoaderVehicleT6.h" #include "Vehicle/RawLoaderVehicleT6.h" -#include "Weapon/GdtLoaderAttachmentT6.h" -#include "Weapon/GdtLoaderAttachmentUniqueT6.h" -#include "Weapon/GdtLoaderWeaponT6.h" -#include "Weapon/LoaderWeaponCamoT6.h" -#include "Weapon/RawLoaderAttachmentT6.h" -#include "Weapon/RawLoaderAttachmentUniqueT6.h" -#include "Weapon/RawLoaderWeaponT6.h" +#include "Weapon/AttachmentGdtLoaderT6.h" +#include "Weapon/AttachmentRawLoaderT6.h" +#include "Weapon/AttachmentUniqueGdtLoaderT6.h" +#include "Weapon/AttachmentUniqueRawLoaderT6.h" +#include "Weapon/CamoJsonLoaderT6.h" +#include "Weapon/WeaponGdtLoaderT6.h" +#include "Weapon/WeaponRawLoaderT6.h" #include "ZBarrier/GdtLoaderZBarrierT6.h" #include "ZBarrier/RawLoaderZBarrierT6.h" @@ -418,13 +418,13 @@ namespace T6 // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); collection.AddAssetCreator(CreateLocalizeLoader(memory, searchPath, zone)); - collection.AddAssetCreator(CreateRawWeaponLoader(memory, searchPath, zone)); - collection.AddAssetCreator(CreateGdtWeaponLoader(memory, searchPath, gdt, zone)); - collection.AddAssetCreator(CreateRawAttachmentLoader(memory, searchPath, zone)); - collection.AddAssetCreator(CreateGdtAttachmentLoader(memory, searchPath, gdt, zone)); - collection.AddAssetCreator(CreateRawAttachmentUniqueLoader(memory, searchPath, zone)); - collection.AddAssetCreator(CreateGdtAttachmentUniqueLoader(memory, searchPath, gdt, zone)); - collection.AddAssetCreator(CreateWeaponCamoLoader(memory, searchPath)); + collection.AddAssetCreator(weapon::CreateRawLoader(memory, searchPath, zone)); + collection.AddAssetCreator(weapon::CreateGdtLoader(memory, searchPath, gdt, zone)); + collection.AddAssetCreator(attachment::CreateRawLoader(memory, searchPath, zone)); + collection.AddAssetCreator(attachment::CreateGdtLoader(memory, searchPath, gdt, zone)); + collection.AddAssetCreator(attachment_unique::CreateRawLoader(memory, searchPath, zone)); + collection.AddAssetCreator(attachment_unique::CreateGdtLoader(memory, searchPath, gdt, zone)); + collection.AddAssetCreator(camo::CreateJsonLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); diff --git a/src/ObjLoading/Game/T6/Weapon/GdtLoaderAttachmentT6.cpp b/src/ObjLoading/Game/T6/Weapon/AttachmentGdtLoaderT6.cpp similarity index 80% rename from src/ObjLoading/Game/T6/Weapon/GdtLoaderAttachmentT6.cpp rename to src/ObjLoading/Game/T6/Weapon/AttachmentGdtLoaderT6.cpp index ceecfd7f..0357b7d8 100644 --- a/src/ObjLoading/Game/T6/Weapon/GdtLoaderAttachmentT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentGdtLoaderT6.cpp @@ -1,9 +1,9 @@ -#include "GdtLoaderAttachmentT6.h" +#include "AttachmentGdtLoaderT6.h" +#include "AttachmentInfoStringLoaderT6.h" #include "Game/T6/ObjConstantsT6.h" #include "Game/T6/T6.h" #include "InfoString/InfoString.h" -#include "InfoStringLoaderAttachmentT6.h" #include #include @@ -40,14 +40,14 @@ namespace private: IGdtQueryable& m_gdt; - InfoStringLoaderAttachment m_info_string_loader; + T6::attachment::InfoStringLoader m_info_string_loader; }; } // namespace -namespace T6 +namespace T6::attachment { - std::unique_ptr> CreateGdtAttachmentLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) { return std::make_unique(memory, searchPath, gdt, zone); } -} // namespace T6 +} // namespace T6::attachment diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentGdtLoaderT6.h b/src/ObjLoading/Game/T6/Weapon/AttachmentGdtLoaderT6.h new file mode 100644 index 00000000..799507bf --- /dev/null +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentGdtLoaderT6.h @@ -0,0 +1,14 @@ +#pragma once + +#include "Asset/IAssetCreator.h" +#include "Game/T6/T6.h" +#include "Gdt/IGdtQueryable.h" +#include "SearchPath/ISearchPath.h" +#include "Utils/MemoryManager.h" + +#include + +namespace T6::attachment +{ + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); +} // namespace T6::attachment diff --git a/src/ObjLoading/Game/T6/Weapon/InfoStringLoaderAttachmentT6.cpp b/src/ObjLoading/Game/T6/Weapon/AttachmentInfoStringLoaderT6.cpp similarity index 76% rename from src/ObjLoading/Game/T6/Weapon/InfoStringLoaderAttachmentT6.cpp rename to src/ObjLoading/Game/T6/Weapon/AttachmentInfoStringLoaderT6.cpp index 83f71735..721a4b81 100644 --- a/src/ObjLoading/Game/T6/Weapon/InfoStringLoaderAttachmentT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentInfoStringLoaderT6.cpp @@ -1,4 +1,4 @@ -#include "InfoStringLoaderAttachmentT6.h" +#include "AttachmentInfoStringLoaderT6.h" #include "Game/T6/InfoString/InfoStringToStructConverter.h" #include "Game/T6/T6.h" @@ -93,29 +93,32 @@ namespace } } // namespace -InfoStringLoaderAttachment::InfoStringLoaderAttachment(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) - : m_memory(memory), - m_search_path(searchPath), - m_zone(zone) +namespace T6::attachment { -} - -AssetCreationResult InfoStringLoaderAttachment::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) -{ - auto* attachment = m_memory.Alloc(); - attachment->szInternalName = m_memory.Dup(assetName.c_str()); - - AssetRegistration registration(assetName, attachment); - - InfoStringToAttachmentConverter converter( - infoString, *attachment, m_zone.m_script_strings, m_memory, context, registration, attachment_fields, std::extent_v); - if (!converter.Convert()) + InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + : m_memory(memory), + m_search_path(searchPath), + m_zone(zone) { - std::cerr << std::format("Failed to parse attachment: \"{}\"\n", assetName); - return AssetCreationResult::Failure(); } - CalculateAttachmentFields(*attachment); + AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) + { + auto* attachment = m_memory.Alloc(); + attachment->szInternalName = m_memory.Dup(assetName.c_str()); - return AssetCreationResult::Success(context.AddAsset(std::move(registration))); -} + AssetRegistration registration(assetName, attachment); + + InfoStringToAttachmentConverter converter( + infoString, *attachment, m_zone.m_script_strings, m_memory, context, registration, attachment_fields, std::extent_v); + if (!converter.Convert()) + { + std::cerr << std::format("Failed to parse attachment: \"{}\"\n", assetName); + return AssetCreationResult::Failure(); + } + + CalculateAttachmentFields(*attachment); + + return AssetCreationResult::Success(context.AddAsset(std::move(registration))); + } +} // namespace T6::attachment diff --git a/src/ObjLoading/Game/T6/Weapon/InfoStringLoaderAttachmentT6.h b/src/ObjLoading/Game/T6/Weapon/AttachmentInfoStringLoaderT6.h similarity index 70% rename from src/ObjLoading/Game/T6/Weapon/InfoStringLoaderAttachmentT6.h rename to src/ObjLoading/Game/T6/Weapon/AttachmentInfoStringLoaderT6.h index fc6d020d..c9dd12d7 100644 --- a/src/ObjLoading/Game/T6/Weapon/InfoStringLoaderAttachmentT6.h +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentInfoStringLoaderT6.h @@ -4,12 +4,12 @@ #include "Asset/AssetCreationResult.h" #include "InfoString/InfoString.h" -namespace T6 +namespace T6::attachment { - class InfoStringLoaderAttachment + class InfoStringLoader { public: - InfoStringLoaderAttachment(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); + InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context); @@ -18,4 +18,4 @@ namespace T6 ISearchPath& m_search_path; Zone& m_zone; }; -} // namespace T6 +} // namespace T6::attachment diff --git a/src/ObjLoading/Game/T6/Weapon/RawLoaderAttachmentT6.cpp b/src/ObjLoading/Game/T6/Weapon/AttachmentRawLoaderT6.cpp similarity index 74% rename from src/ObjLoading/Game/T6/Weapon/RawLoaderAttachmentT6.cpp rename to src/ObjLoading/Game/T6/Weapon/AttachmentRawLoaderT6.cpp index bf318b2d..c2158ba2 100644 --- a/src/ObjLoading/Game/T6/Weapon/RawLoaderAttachmentT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentRawLoaderT6.cpp @@ -1,15 +1,17 @@ -#include "RawLoaderAttachmentT6.h" +#include "AttachmentRawLoaderT6.h" +#include "AttachmentInfoStringLoaderT6.h" #include "Game/T6/ObjConstantsT6.h" #include "Game/T6/T6.h" #include "InfoString/InfoString.h" -#include "InfoStringLoaderAttachmentT6.h" +#include "Weapon/AttachmentCommon.h" #include #include #include using namespace T6; +using namespace ::attachment; namespace { @@ -24,7 +26,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = std::format("attachment/{}", assetName); + const auto fileName = GetInfoStringFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -41,14 +43,14 @@ namespace private: ISearchPath& m_search_path; - InfoStringLoaderAttachment m_info_string_loader; + T6::attachment::InfoStringLoader m_info_string_loader; }; } // namespace -namespace T6 +namespace T6::attachment { - std::unique_ptr> CreateRawAttachmentLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace T6 +} // namespace T6::attachment diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentRawLoaderT6.h b/src/ObjLoading/Game/T6/Weapon/AttachmentRawLoaderT6.h new file mode 100644 index 00000000..5726e166 --- /dev/null +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentRawLoaderT6.h @@ -0,0 +1,13 @@ +#pragma once + +#include "Asset/IAssetCreator.h" +#include "Game/T6/T6.h" +#include "SearchPath/ISearchPath.h" +#include "Utils/MemoryManager.h" + +#include + +namespace T6::attachment +{ + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace T6::attachment diff --git a/src/ObjLoading/Game/T6/Weapon/GdtLoaderAttachmentUniqueT6.cpp b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueGdtLoaderT6.cpp similarity index 78% rename from src/ObjLoading/Game/T6/Weapon/GdtLoaderAttachmentUniqueT6.cpp rename to src/ObjLoading/Game/T6/Weapon/AttachmentUniqueGdtLoaderT6.cpp index ab53d947..b79492ff 100644 --- a/src/ObjLoading/Game/T6/Weapon/GdtLoaderAttachmentUniqueT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueGdtLoaderT6.cpp @@ -1,9 +1,9 @@ -#include "GdtLoaderAttachmentUniqueT6.h" +#include "AttachmentUniqueGdtLoaderT6.h" +#include "AttachmentUniqueInfoStringLoaderT6.h" #include "Game/T6/ObjConstantsT6.h" #include "Game/T6/T6.h" #include "InfoString/InfoString.h" -#include "InfoStringLoaderAttachmentUniqueT6.h" #include #include @@ -40,15 +40,14 @@ namespace private: IGdtQueryable& m_gdt; - InfoStringLoaderAttachmentUnique m_info_string_loader; + T6::attachment_unique::InfoStringLoader m_info_string_loader; }; } // namespace -namespace T6 +namespace T6::attachment_unique { - std::unique_ptr> - CreateGdtAttachmentUniqueLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) { return std::make_unique(memory, searchPath, gdt, zone); } -} // namespace T6 +} // namespace T6::attachment_unique diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueGdtLoaderT6.h b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueGdtLoaderT6.h new file mode 100644 index 00000000..b7065166 --- /dev/null +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueGdtLoaderT6.h @@ -0,0 +1,14 @@ +#pragma once + +#include "Asset/IAssetCreator.h" +#include "Game/T6/T6.h" +#include "Gdt/IGdtQueryable.h" +#include "SearchPath/ISearchPath.h" +#include "Utils/MemoryManager.h" + +#include + +namespace T6::attachment_unique +{ + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); +} // namespace T6::attachment_unique diff --git a/src/ObjLoading/Game/T6/Weapon/InfoStringLoaderAttachmentUniqueT6.cpp b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueInfoStringLoaderT6.cpp similarity index 64% rename from src/ObjLoading/Game/T6/Weapon/InfoStringLoaderAttachmentUniqueT6.cpp rename to src/ObjLoading/Game/T6/Weapon/AttachmentUniqueInfoStringLoaderT6.cpp index 98a17081..02429b3f 100644 --- a/src/ObjLoading/Game/T6/Weapon/InfoStringLoaderAttachmentUniqueT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueInfoStringLoaderT6.cpp @@ -1,4 +1,4 @@ -#include "InfoStringLoaderAttachmentUniqueT6.h" +#include "AttachmentUniqueInfoStringLoaderT6.h" #include "Game/T6/InfoString/InfoStringToStructConverter.h" #include "Game/T6/T6.h" @@ -141,7 +141,7 @@ namespace { // combinedAttachmentTypeMask std::vector attachmentsFromName; - if (!InfoStringLoaderAttachmentUnique::ExtractAttachmentsFromAssetName(assetName, attachmentsFromName)) + if (!T6::attachment_unique::ExtractAttachmentsFromAssetName(assetName, attachmentsFromName)) { std::cerr << std::format("Failed to determine attachments from attachment unique name \"{}\"\n", assetName); return false; @@ -159,86 +159,89 @@ namespace } } // namespace -bool InfoStringLoaderAttachmentUnique::ExtractAttachmentsFromAssetName(const std::string& assetName, std::vector& attachmentList) +namespace T6::attachment_unique { - std::vector parts; - - auto attachCount = 1u; - auto partStart = 0u; - for (auto ci = 0u; ci < assetName.size(); ci++) + bool ExtractAttachmentsFromAssetName(const std::string& assetName, std::vector& attachmentList) { - if (assetName[ci] == '_') + std::vector parts; + + auto attachCount = 1u; + auto partStart = 0u; + for (auto ci = 0u; ci < assetName.size(); ci++) { - parts.emplace_back(assetName, partStart, ci - partStart); - partStart = ci + 1; - } - else if (assetName[ci] == '+') - { - attachCount++; - parts.emplace_back(assetName, partStart, ci - partStart); - partStart = ci + 1; - } - } - - if (partStart < assetName.size()) - parts.emplace_back(assetName, partStart, assetName.size() - partStart); - - for (auto attachPartOffset = parts.size() - attachCount; attachPartOffset < parts.size(); attachPartOffset++) - { - auto& specifiedAttachName = parts[attachPartOffset]; - - for (auto& c : specifiedAttachName) - c = static_cast(tolower(c)); - - auto foundAttachment = false; - for (auto attachIndex = 0u; attachIndex < std::extent_v; attachIndex++) - { - if (specifiedAttachName == szAttachmentTypeNames[attachIndex]) + if (assetName[ci] == '_') { - attachmentList.push_back(static_cast(attachIndex)); - foundAttachment = true; - break; + parts.emplace_back(assetName, partStart, ci - partStart); + partStart = ci + 1; + } + else if (assetName[ci] == '+') + { + attachCount++; + parts.emplace_back(assetName, partStart, ci - partStart); + partStart = ci + 1; } } - if (!foundAttachment) - return false; + if (partStart < assetName.size()) + parts.emplace_back(assetName, partStart, assetName.size() - partStart); + + for (auto attachPartOffset = parts.size() - attachCount; attachPartOffset < parts.size(); attachPartOffset++) + { + auto& specifiedAttachName = parts[attachPartOffset]; + + for (auto& c : specifiedAttachName) + c = static_cast(tolower(c)); + + auto foundAttachment = false; + for (auto attachIndex = 0u; attachIndex < std::extent_v; attachIndex++) + { + if (specifiedAttachName == szAttachmentTypeNames[attachIndex]) + { + attachmentList.push_back(static_cast(attachIndex)); + foundAttachment = true; + break; + } + } + + if (!foundAttachment) + return false; + } + + return true; } - return true; -} - -InfoStringLoaderAttachmentUnique::InfoStringLoaderAttachmentUnique(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) - : m_memory(memory), - m_search_path(searchPath), - m_zone(zone) -{ -} - -AssetCreationResult InfoStringLoaderAttachmentUnique::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) -{ - auto* attachmentUniqueFull = m_memory.Alloc(); - attachmentUniqueFull->attachment.szInternalName = m_memory.Dup(assetName.c_str()); - - LinkAttachmentUniqueFullSubStructs(*attachmentUniqueFull); - - AssetRegistration registration(assetName, &attachmentUniqueFull->attachment); - - InfoStringToAttachmentUniqueConverter converter(infoString, - *attachmentUniqueFull, - m_zone.m_script_strings, - m_memory, - context, - registration, - attachment_unique_fields, - std::extent_v); - if (!converter.Convert()) + InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + : m_memory(memory), + m_search_path(searchPath), + m_zone(zone) { - std::cerr << std::format("Failed to parse attachment unique: \"{}\"\n", assetName); - return AssetCreationResult::Failure(); } - CalculateAttachmentUniqueFields(assetName, *attachmentUniqueFull); + AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) + { + auto* attachmentUniqueFull = m_memory.Alloc(); + attachmentUniqueFull->attachment.szInternalName = m_memory.Dup(assetName.c_str()); - return AssetCreationResult::Success(context.AddAsset(std::move(registration))); -} + LinkAttachmentUniqueFullSubStructs(*attachmentUniqueFull); + + AssetRegistration registration(assetName, &attachmentUniqueFull->attachment); + + InfoStringToAttachmentUniqueConverter converter(infoString, + *attachmentUniqueFull, + m_zone.m_script_strings, + m_memory, + context, + registration, + attachment_unique_fields, + std::extent_v); + if (!converter.Convert()) + { + std::cerr << std::format("Failed to parse attachment unique: \"{}\"\n", assetName); + return AssetCreationResult::Failure(); + } + + CalculateAttachmentUniqueFields(assetName, *attachmentUniqueFull); + + return AssetCreationResult::Success(context.AddAsset(std::move(registration))); + } +} // namespace T6::attachment_unique diff --git a/src/ObjLoading/Game/T6/Weapon/InfoStringLoaderAttachmentUniqueT6.h b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueInfoStringLoaderT6.h similarity index 59% rename from src/ObjLoading/Game/T6/Weapon/InfoStringLoaderAttachmentUniqueT6.h rename to src/ObjLoading/Game/T6/Weapon/AttachmentUniqueInfoStringLoaderT6.h index 3ff89621..5c50650b 100644 --- a/src/ObjLoading/Game/T6/Weapon/InfoStringLoaderAttachmentUniqueT6.h +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueInfoStringLoaderT6.h @@ -7,20 +7,20 @@ #include -namespace T6 +namespace T6::attachment_unique { - class InfoStringLoaderAttachmentUnique + bool ExtractAttachmentsFromAssetName(const std::string& assetName, std::vector& attachmentList); + + class InfoStringLoader { public: - InfoStringLoaderAttachmentUnique(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); + InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context); - static bool ExtractAttachmentsFromAssetName(const std::string& assetName, std::vector& attachmentList); - private: MemoryManager& m_memory; ISearchPath& m_search_path; Zone& m_zone; }; -} // namespace T6 +} // namespace T6::attachment_unique diff --git a/src/ObjLoading/Game/T6/Weapon/RawLoaderAttachmentUniqueT6.cpp b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueRawLoaderT6.cpp similarity index 63% rename from src/ObjLoading/Game/T6/Weapon/RawLoaderAttachmentUniqueT6.cpp rename to src/ObjLoading/Game/T6/Weapon/AttachmentUniqueRawLoaderT6.cpp index f3af0c30..4023168f 100644 --- a/src/ObjLoading/Game/T6/Weapon/RawLoaderAttachmentUniqueT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueRawLoaderT6.cpp @@ -1,22 +1,24 @@ -#include "RawLoaderAttachmentUniqueT6.h" +#include "AttachmentUniqueRawLoaderT6.h" +#include "AttachmentUniqueInfoStringLoaderT6.h" #include "Game/T6/ObjConstantsT6.h" #include "Game/T6/T6.h" #include "InfoString/InfoString.h" -#include "InfoStringLoaderAttachmentUniqueT6.h" +#include "Weapon/AttachmentUniqueCommon.h" #include #include #include using namespace T6; +using namespace ::attachment_unique; namespace { - class RawLoaderAttachmentUnique final : public AssetCreator + class RawLoader final : public AssetCreator { public: - RawLoaderAttachmentUnique(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + RawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) : m_search_path(searchPath), m_info_string_loader(memory, searchPath, zone) { @@ -24,7 +26,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = std::format("attachmentunique/{}", assetName); + const auto fileName = GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -41,14 +43,14 @@ namespace private: ISearchPath& m_search_path; - InfoStringLoaderAttachmentUnique m_info_string_loader; + T6::attachment_unique::InfoStringLoader m_info_string_loader; }; } // namespace -namespace T6 +namespace T6::attachment_unique { - std::unique_ptr> CreateRawAttachmentUniqueLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { - return std::make_unique(memory, searchPath, zone); + return std::make_unique(memory, searchPath, zone); } -} // namespace T6 +} // namespace T6::attachment_unique diff --git a/src/ObjLoading/Game/T6/Weapon/RawLoaderAttachmentUniqueT6.h b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueRawLoaderT6.h similarity index 61% rename from src/ObjLoading/Game/T6/Weapon/RawLoaderAttachmentUniqueT6.h rename to src/ObjLoading/Game/T6/Weapon/AttachmentUniqueRawLoaderT6.h index 47b66237..afdf3584 100644 --- a/src/ObjLoading/Game/T6/Weapon/RawLoaderAttachmentUniqueT6.h +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueRawLoaderT6.h @@ -7,7 +7,7 @@ #include -namespace T6 +namespace T6::attachment_unique { - std::unique_ptr> CreateRawAttachmentUniqueLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace T6 + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace T6::attachment_unique diff --git a/src/ObjLoading/Game/T6/Weapon/JsonWeaponCamoLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/CamoJsonLoaderT6.cpp similarity index 84% rename from src/ObjLoading/Game/T6/Weapon/JsonWeaponCamoLoaderT6.cpp rename to src/ObjLoading/Game/T6/Weapon/CamoJsonLoaderT6.cpp index 75bbe247..65a57723 100644 --- a/src/ObjLoading/Game/T6/Weapon/JsonWeaponCamoLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/CamoJsonLoaderT6.cpp @@ -1,14 +1,18 @@ -#include "JsonWeaponCamoLoaderT6.h" +#include "CamoJsonLoaderT6.h" -#include "Game/T6/CommonT6.h" #include "Game/T6/Json/JsonWeaponCamo.h" +#include "Game/T6/T6.h" +#include "Pool/GlobalAssetPool.h" +#include "Weapon/CamoCommon.h" +#include #include #include #include using namespace nlohmann; using namespace T6; +using namespace ::camo; namespace { @@ -55,7 +59,7 @@ namespace private: static void PrintError(const WeaponCamo& weaponCamo, const std::string& message) { - std::cerr << "Cannot load weapon camo \"" << weaponCamo.name << "\": " << message << "\n"; + std::cerr << std::format("Cannot load weapon camo \"{}\": {}\n", weaponCamo.name, message); } bool CreateWeaponCamoSetFromJson(const JsonWeaponCamoSet& jWeaponCamoSet, WeaponCamoSet& weaponCamoSet, const WeaponCamo& weaponCamo) const @@ -237,15 +241,46 @@ namespace AssetCreationContext& m_context; AssetRegistration& m_registration; }; + + class WeaponCamoLoader final : public AssetCreator + { + public: + WeaponCamoLoader(MemoryManager& memory, ISearchPath& searchPath) + : m_memory(memory), + m_search_path(searchPath) + { + } + + AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override + { + const auto file = m_search_path.Open(GetJsonFileNameForAssetName(assetName)); + if (!file.IsOpen()) + return AssetCreationResult::NoAction(); + + auto* weaponCamo = m_memory.Alloc(); + weaponCamo->name = m_memory.Dup(assetName.c_str()); + + AssetRegistration registration(assetName, weaponCamo); + const JsonLoader loader(*file.m_stream, m_memory, context, registration); + if (!loader.Load(*weaponCamo)) + { + std::cerr << std::format("Failed to load weapon camo \"{}\"\n", assetName); + return AssetCreationResult::Failure(); + } + + return AssetCreationResult::Success(context.AddAsset(std::move(registration))); + } + + private: + MemoryManager& m_memory; + ISearchPath& m_search_path; + }; } // namespace -namespace T6 +namespace T6::camo { - bool LoadWeaponCamoAsJson( - std::istream& stream, WeaponCamo& weaponCamo, MemoryManager& memory, AssetCreationContext& context, AssetRegistration& registration) + std::unique_ptr> CreateJsonLoader(MemoryManager& memory, ISearchPath& searchPath) { - const JsonLoader loader(stream, memory, context, registration); - - return loader.Load(weaponCamo); + return std::make_unique(memory, searchPath); } -} // namespace T6 +} // namespace T6::camo diff --git a/src/ObjLoading/Game/T6/Weapon/LoaderWeaponCamoT6.h b/src/ObjLoading/Game/T6/Weapon/CamoJsonLoaderT6.h similarity index 50% rename from src/ObjLoading/Game/T6/Weapon/LoaderWeaponCamoT6.h rename to src/ObjLoading/Game/T6/Weapon/CamoJsonLoaderT6.h index b5270fba..3b5f7f7f 100644 --- a/src/ObjLoading/Game/T6/Weapon/LoaderWeaponCamoT6.h +++ b/src/ObjLoading/Game/T6/Weapon/CamoJsonLoaderT6.h @@ -7,7 +7,7 @@ #include -namespace T6 +namespace T6::camo { - std::unique_ptr> CreateWeaponCamoLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6 + std::unique_ptr> CreateJsonLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace T6::camo diff --git a/src/ObjLoading/Game/T6/Weapon/GdtLoaderAttachmentT6.h b/src/ObjLoading/Game/T6/Weapon/GdtLoaderAttachmentT6.h deleted file mode 100644 index 6455b204..00000000 --- a/src/ObjLoading/Game/T6/Weapon/GdtLoaderAttachmentT6.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "Asset/IAssetCreator.h" -#include "Game/T6/T6.h" -#include "Gdt/IGdtQueryable.h" -#include "SearchPath/ISearchPath.h" -#include "Utils/MemoryManager.h" - -#include - -namespace T6 -{ - std::unique_ptr> CreateGdtAttachmentLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); -} // namespace T6 diff --git a/src/ObjLoading/Game/T6/Weapon/GdtLoaderAttachmentUniqueT6.h b/src/ObjLoading/Game/T6/Weapon/GdtLoaderAttachmentUniqueT6.h deleted file mode 100644 index 3e39221d..00000000 --- a/src/ObjLoading/Game/T6/Weapon/GdtLoaderAttachmentUniqueT6.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "Asset/IAssetCreator.h" -#include "Game/T6/T6.h" -#include "Gdt/IGdtQueryable.h" -#include "SearchPath/ISearchPath.h" -#include "Utils/MemoryManager.h" - -#include - -namespace T6 -{ - std::unique_ptr> - CreateGdtAttachmentUniqueLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); -} // namespace T6 diff --git a/src/ObjLoading/Game/T6/Weapon/JsonWeaponCamoLoaderT6.h b/src/ObjLoading/Game/T6/Weapon/JsonWeaponCamoLoaderT6.h deleted file mode 100644 index 6f5aea17..00000000 --- a/src/ObjLoading/Game/T6/Weapon/JsonWeaponCamoLoaderT6.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "Asset/AssetCreationContext.h" -#include "Asset/AssetRegistration.h" -#include "Game/T6/T6.h" -#include "Utils/MemoryManager.h" - -#include - -namespace T6 -{ - bool LoadWeaponCamoAsJson( - std::istream& stream, WeaponCamo& weaponCamo, MemoryManager& memory, AssetCreationContext& context, AssetRegistration& registration); -} // namespace T6 diff --git a/src/ObjLoading/Game/T6/Weapon/LoaderWeaponCamoT6.cpp b/src/ObjLoading/Game/T6/Weapon/LoaderWeaponCamoT6.cpp deleted file mode 100644 index c3409ac8..00000000 --- a/src/ObjLoading/Game/T6/Weapon/LoaderWeaponCamoT6.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "LoaderWeaponCamoT6.h" - -#include "Game/T6/T6.h" -#include "JsonWeaponCamoLoaderT6.h" -#include "Pool/GlobalAssetPool.h" - -#include -#include -#include - -using namespace T6; - -namespace -{ - class WeaponCamoLoader final : public AssetCreator - { - public: - WeaponCamoLoader(MemoryManager& memory, ISearchPath& searchPath) - : m_memory(memory), - m_search_path(searchPath) - { - } - - AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override - { - const auto file = m_search_path.Open(std::format("camo/{}.json", assetName)); - if (!file.IsOpen()) - return AssetCreationResult::NoAction(); - - auto* weaponCamo = m_memory.Alloc(); - weaponCamo->name = m_memory.Dup(assetName.c_str()); - - AssetRegistration registration(assetName, weaponCamo); - if (!LoadWeaponCamoAsJson(*file.m_stream, *weaponCamo, m_memory, context, registration)) - { - std::cerr << std::format("Failed to load weapon camo \"{}\"\n", assetName); - return AssetCreationResult::Failure(); - } - - return AssetCreationResult::Success(context.AddAsset(std::move(registration))); - } - - private: - MemoryManager& m_memory; - ISearchPath& m_search_path; - }; -} // namespace - -namespace T6 -{ - std::unique_ptr> CreateWeaponCamoLoader(MemoryManager& memory, ISearchPath& searchPath) - { - return std::make_unique(memory, searchPath); - } -} // namespace T6 diff --git a/src/ObjLoading/Game/T6/Weapon/RawLoaderAttachmentT6.h b/src/ObjLoading/Game/T6/Weapon/RawLoaderAttachmentT6.h deleted file mode 100644 index d83631d1..00000000 --- a/src/ObjLoading/Game/T6/Weapon/RawLoaderAttachmentT6.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "Asset/IAssetCreator.h" -#include "Game/T6/T6.h" -#include "SearchPath/ISearchPath.h" -#include "Utils/MemoryManager.h" - -#include - -namespace T6 -{ - std::unique_ptr> CreateRawAttachmentLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace T6 diff --git a/src/ObjLoading/Game/T6/Weapon/RawLoaderWeaponT6.h b/src/ObjLoading/Game/T6/Weapon/RawLoaderWeaponT6.h deleted file mode 100644 index 8eedbb71..00000000 --- a/src/ObjLoading/Game/T6/Weapon/RawLoaderWeaponT6.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "Asset/IAssetCreator.h" -#include "Game/T6/T6.h" -#include "SearchPath/ISearchPath.h" -#include "Utils/MemoryManager.h" - -#include - -namespace T6 -{ - std::unique_ptr> CreateRawWeaponLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace T6 diff --git a/src/ObjLoading/Game/T6/Weapon/GdtLoaderWeaponT6.cpp b/src/ObjLoading/Game/T6/Weapon/WeaponGdtLoaderT6.cpp similarity index 80% rename from src/ObjLoading/Game/T6/Weapon/GdtLoaderWeaponT6.cpp rename to src/ObjLoading/Game/T6/Weapon/WeaponGdtLoaderT6.cpp index 702213dd..9caabce5 100644 --- a/src/ObjLoading/Game/T6/Weapon/GdtLoaderWeaponT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/WeaponGdtLoaderT6.cpp @@ -1,9 +1,9 @@ -#include "GdtLoaderWeaponT6.h" +#include "WeaponGdtLoaderT6.h" #include "Game/T6/ObjConstantsT6.h" #include "Game/T6/T6.h" #include "InfoString/InfoString.h" -#include "InfoStringLoaderWeaponT6.h" +#include "WeaponInfoStringLoaderT6.h" #include #include @@ -40,14 +40,14 @@ namespace private: IGdtQueryable& m_gdt; - InfoStringLoaderWeapon m_info_string_loader; + T6::weapon::InfoStringLoader m_info_string_loader; }; } // namespace -namespace T6 +namespace T6::weapon { - std::unique_ptr> CreateGdtWeaponLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) { return std::make_unique(memory, searchPath, gdt, zone); } -} // namespace T6 +} // namespace T6::weapon diff --git a/src/ObjLoading/Game/T6/Weapon/GdtLoaderWeaponT6.h b/src/ObjLoading/Game/T6/Weapon/WeaponGdtLoaderT6.h similarity index 50% rename from src/ObjLoading/Game/T6/Weapon/GdtLoaderWeaponT6.h rename to src/ObjLoading/Game/T6/Weapon/WeaponGdtLoaderT6.h index fdb1882b..34670907 100644 --- a/src/ObjLoading/Game/T6/Weapon/GdtLoaderWeaponT6.h +++ b/src/ObjLoading/Game/T6/Weapon/WeaponGdtLoaderT6.h @@ -8,7 +8,7 @@ #include -namespace T6 +namespace T6::weapon { - std::unique_ptr> CreateGdtWeaponLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); -} // namespace T6 + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); +} // namespace T6::weapon diff --git a/src/ObjLoading/Game/T6/Weapon/InfoStringLoaderWeaponT6.cpp b/src/ObjLoading/Game/T6/Weapon/WeaponInfoStringLoaderT6.cpp similarity index 94% rename from src/ObjLoading/Game/T6/Weapon/InfoStringLoaderWeaponT6.cpp rename to src/ObjLoading/Game/T6/Weapon/WeaponInfoStringLoaderT6.cpp index 6d97ceab..d5cefc6f 100644 --- a/src/ObjLoading/Game/T6/Weapon/InfoStringLoaderWeaponT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/WeaponInfoStringLoaderT6.cpp @@ -1,10 +1,10 @@ -#include "InfoStringLoaderWeaponT6.h" +#include "WeaponInfoStringLoaderT6.h" +#include "AttachmentUniqueInfoStringLoaderT6.h" #include "Game/T6/InfoString/InfoStringToStructConverter.h" #include "Game/T6/T6.h" #include "Game/T6/Weapon/WeaponFields.h" #include "Game/T6/Weapon/WeaponStrings.h" -#include "InfoStringLoaderAttachmentUniqueT6.h" #include "Weapon/AccuracyGraphLoader.h" #include @@ -568,8 +568,7 @@ namespace && weapon.attachmentUniques[attachmentUniqueIndex]->attachmentType != attachmentUnique.attachmentType) { std::vector attachments; - if (InfoStringLoaderAttachmentUnique::ExtractAttachmentsFromAssetName(weapon.attachmentUniques[attachmentUniqueIndex]->szInternalName, - attachments) + if (T6::attachment_unique::ExtractAttachmentsFromAssetName(weapon.attachmentUniques[attachmentUniqueIndex]->szInternalName, attachments) && attachments.front() == attachmentUnique.attachmentType) { if (lastSibling == nullptr) @@ -600,34 +599,37 @@ namespace } } // namespace -InfoStringLoaderWeapon::InfoStringLoaderWeapon(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) - : m_memory(memory), - m_search_path(searchPath), - m_zone(zone) +namespace T6::weapon { -} - -AssetCreationResult InfoStringLoaderWeapon::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) -{ - auto* weaponFullDef = m_memory.Alloc(); - weaponFullDef->weapVariantDef.szInternalName = m_memory.Dup(assetName.c_str()); - - LinkWeaponFullDefSubStructs(*weaponFullDef); - - AssetRegistration registration(assetName, &weaponFullDef->weapVariantDef); - - InfoStringToWeaponConverter converter( - infoString, *weaponFullDef, m_zone.m_script_strings, m_memory, context, registration, weapon_fields, std::extent_v); - if (!converter.Convert()) + InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + : m_memory(memory), + m_search_path(searchPath), + m_zone(zone) { - std::cerr << std::format("Failed to parse weapon: \"{}\"\n", assetName); - return AssetCreationResult::Failure(); } - CalculateWeaponFields(*weaponFullDef); - CalculateAttachmentFields(*weaponFullDef); + AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) + { + auto* weaponFullDef = m_memory.Alloc(); + weaponFullDef->weapVariantDef.szInternalName = m_memory.Dup(assetName.c_str()); - LoadAccuracyGraphs(*weaponFullDef, m_memory, m_search_path, context); + LinkWeaponFullDefSubStructs(*weaponFullDef); - return AssetCreationResult::Success(context.AddAsset(std::move(registration))); -} + AssetRegistration registration(assetName, &weaponFullDef->weapVariantDef); + + InfoStringToWeaponConverter converter( + infoString, *weaponFullDef, m_zone.m_script_strings, m_memory, context, registration, weapon_fields, std::extent_v); + if (!converter.Convert()) + { + std::cerr << std::format("Failed to parse weapon: \"{}\"\n", assetName); + return AssetCreationResult::Failure(); + } + + CalculateWeaponFields(*weaponFullDef); + CalculateAttachmentFields(*weaponFullDef); + + LoadAccuracyGraphs(*weaponFullDef, m_memory, m_search_path, context); + + return AssetCreationResult::Success(context.AddAsset(std::move(registration))); + } +} // namespace T6::weapon diff --git a/src/ObjLoading/Game/T6/Weapon/InfoStringLoaderWeaponT6.h b/src/ObjLoading/Game/T6/Weapon/WeaponInfoStringLoaderT6.h similarity index 71% rename from src/ObjLoading/Game/T6/Weapon/InfoStringLoaderWeaponT6.h rename to src/ObjLoading/Game/T6/Weapon/WeaponInfoStringLoaderT6.h index f745963a..7ba8a410 100644 --- a/src/ObjLoading/Game/T6/Weapon/InfoStringLoaderWeaponT6.h +++ b/src/ObjLoading/Game/T6/Weapon/WeaponInfoStringLoaderT6.h @@ -4,12 +4,12 @@ #include "Asset/AssetCreationResult.h" #include "InfoString/InfoString.h" -namespace T6 +namespace T6::weapon { - class InfoStringLoaderWeapon + class InfoStringLoader { public: - InfoStringLoaderWeapon(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); + InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context); @@ -18,4 +18,4 @@ namespace T6 ISearchPath& m_search_path; Zone& m_zone; }; -} // namespace T6 +} // namespace T6::weapon diff --git a/src/ObjLoading/Game/T6/Weapon/RawLoaderWeaponT6.cpp b/src/ObjLoading/Game/T6/Weapon/WeaponRawLoaderT6.cpp similarity index 63% rename from src/ObjLoading/Game/T6/Weapon/RawLoaderWeaponT6.cpp rename to src/ObjLoading/Game/T6/Weapon/WeaponRawLoaderT6.cpp index 36cbcd48..09304559 100644 --- a/src/ObjLoading/Game/T6/Weapon/RawLoaderWeaponT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/WeaponRawLoaderT6.cpp @@ -1,22 +1,24 @@ -#include "RawLoaderWeaponT6.h" +#include "WeaponRawLoaderT6.h" #include "Game/T6/ObjConstantsT6.h" #include "Game/T6/T6.h" #include "InfoString/InfoString.h" -#include "InfoStringLoaderWeaponT6.h" +#include "Weapon/WeaponCommon.h" +#include "WeaponInfoStringLoaderT6.h" #include #include #include using namespace T6; +using namespace ::weapon; namespace { - class RawLoaderWeapon final : public AssetCreator + class RawLoader final : public AssetCreator { public: - RawLoaderWeapon(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + RawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) : m_search_path(searchPath), m_info_string_loader(memory, searchPath, zone) { @@ -24,7 +26,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = std::format("weapons/{}", assetName); + const auto fileName = GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -41,14 +43,14 @@ namespace private: ISearchPath& m_search_path; - InfoStringLoaderWeapon m_info_string_loader; + T6::weapon::InfoStringLoader m_info_string_loader; }; } // namespace -namespace T6 +namespace T6::weapon { - std::unique_ptr> CreateRawWeaponLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { - return std::make_unique(memory, searchPath, zone); + return std::make_unique(memory, searchPath, zone); } -} // namespace T6 +} // namespace T6::weapon diff --git a/src/ObjLoading/Game/T6/Weapon/WeaponRawLoaderT6.h b/src/ObjLoading/Game/T6/Weapon/WeaponRawLoaderT6.h new file mode 100644 index 00000000..e02ce562 --- /dev/null +++ b/src/ObjLoading/Game/T6/Weapon/WeaponRawLoaderT6.h @@ -0,0 +1,13 @@ +#pragma once + +#include "Asset/IAssetCreator.h" +#include "Game/T6/T6.h" +#include "SearchPath/ISearchPath.h" +#include "Utils/MemoryManager.h" + +#include + +namespace T6::weapon +{ + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace T6::weapon diff --git a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp index 8a7ce5e0..8e840474 100644 --- a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp +++ b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp @@ -10,7 +10,6 @@ #include "RawFile/RawFileDumperIW3.h" #include "Sound/LoadedSoundDumperIW3.h" #include "StringTable/StringTableDumperIW3.h" -#include "Weapon/AssetDumperWeapon.h" using namespace IW3; diff --git a/src/ObjWriting/Game/IW3/Weapon/AssetDumperWeapon.cpp b/src/ObjWriting/Game/IW3/Weapon/AssetDumperWeapon.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/src/ObjWriting/Game/IW3/Weapon/AssetDumperWeapon.h b/src/ObjWriting/Game/IW3/Weapon/AssetDumperWeapon.h deleted file mode 100644 index e69de29b..00000000 diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 3723fbe2..4ab99c42 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -24,7 +24,7 @@ #include "Techset/TechsetDumperIW4.h" #include "Tracer/TracerDumperIW4.h" #include "Vehicle/VehicleDumperIW4.h" -#include "Weapon/AssetDumperWeapon.h" +#include "Weapon/WeaponDumperIW4.h" using namespace IW4; @@ -66,7 +66,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST) DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU) DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) - DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON) + DUMP_ASSET_POOL(weapon::Dumper, m_weapon, ASSET_TYPE_WEAPON) // DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) diff --git a/src/ObjWriting/Game/IW4/Weapon/AssetDumperWeapon.h b/src/ObjWriting/Game/IW4/Weapon/AssetDumperWeapon.h deleted file mode 100644 index 3abade7f..00000000 --- a/src/ObjWriting/Game/IW4/Weapon/AssetDumperWeapon.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/IW4/IW4.h" -#include "InfoString/InfoString.h" - -namespace IW4 -{ - class AssetDumperWeapon final : public AbstractAssetDumper - { - static void CopyToFullDef(const WeaponCompleteDef* weapon, WeaponFullDef* fullDef); - static InfoString CreateInfoString(XAssetInfo* asset); - static void DumpAccuracyGraphs(AssetDumpingContext& context, XAssetInfo* asset); - - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace IW4 diff --git a/src/ObjWriting/Game/IW4/Weapon/AssetDumperWeapon.cpp b/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.cpp similarity index 50% rename from src/ObjWriting/Game/IW4/Weapon/AssetDumperWeapon.cpp rename to src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.cpp index 0d388e3c..7fce3396 100644 --- a/src/ObjWriting/Game/IW4/Weapon/AssetDumperWeapon.cpp +++ b/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.cpp @@ -1,4 +1,4 @@ -#include "AssetDumperWeapon.h" +#include "WeaponDumperIW4.h" #include "Game/IW4/CommonIW4.h" #include "Game/IW4/InfoString/EnumStrings.h" @@ -6,6 +6,7 @@ #include "Game/IW4/ObjConstantsIW4.h" #include "Game/IW4/Weapon/WeaponFields.h" #include "Weapon/AccuracyGraphWriter.h" +#include "Weapon/WeaponCommon.h" #include #include @@ -13,8 +14,9 @@ #include using namespace IW4; +using namespace ::weapon; -namespace IW4 +namespace { class InfoStringFromWeaponConverter final : public InfoStringFromStructConverter { @@ -237,195 +239,201 @@ namespace IW4 return graph; } -} // namespace IW4 -void AssetDumperWeapon::CopyToFullDef(const WeaponCompleteDef* weapon, WeaponFullDef* fullDef) -{ - fullDef->weapCompleteDef = *weapon; - - if (weapon->weapDef) + void CopyToFullDef(const WeaponCompleteDef* weapon, WeaponFullDef* fullDef) { - fullDef->weapDef = *weapon->weapDef; - fullDef->weapCompleteDef.weapDef = &fullDef->weapDef; + fullDef->weapCompleteDef = *weapon; + + if (weapon->weapDef) + { + fullDef->weapDef = *weapon->weapDef; + fullDef->weapCompleteDef.weapDef = &fullDef->weapDef; + } + + if (weapon->hideTags) + { + assert(sizeof(WeaponFullDef::hideTags) >= sizeof(scr_string_t) * std::extent_v); + memcpy(fullDef->hideTags, weapon->hideTags, sizeof(scr_string_t) * std::extent_v); + fullDef->weapCompleteDef.hideTags = fullDef->hideTags; + } + + if (weapon->szXAnims) + { + assert(sizeof(WeaponFullDef::szXAnims) >= sizeof(void*) * NUM_WEAP_ANIMS); + memcpy(fullDef->szXAnims, weapon->szXAnims, sizeof(void*) * NUM_WEAP_ANIMS); + fullDef->weapCompleteDef.szXAnims = fullDef->szXAnims; + } + + if (fullDef->weapDef.gunXModel) + { + assert(sizeof(WeaponFullDef::gunXModel) >= sizeof(void*) * std::extent_v); + memcpy(fullDef->gunXModel, fullDef->weapDef.gunXModel, sizeof(void*) * std::extent_v); + fullDef->weapDef.gunXModel = fullDef->gunXModel; + } + + if (fullDef->weapDef.szXAnimsRightHanded) + { + assert(sizeof(WeaponFullDef::szXAnimsRightHanded) >= sizeof(void*) * NUM_WEAP_ANIMS); + memcpy(fullDef->szXAnimsRightHanded, fullDef->weapDef.szXAnimsRightHanded, sizeof(void*) * NUM_WEAP_ANIMS); + fullDef->weapDef.szXAnimsRightHanded = fullDef->szXAnimsRightHanded; + } + + if (fullDef->weapDef.szXAnimsLeftHanded) + { + assert(sizeof(WeaponFullDef::szXAnimsLeftHanded) >= sizeof(void*) * NUM_WEAP_ANIMS); + memcpy(fullDef->szXAnimsLeftHanded, fullDef->weapDef.szXAnimsLeftHanded, sizeof(void*) * NUM_WEAP_ANIMS); + fullDef->weapDef.szXAnimsLeftHanded = fullDef->szXAnimsLeftHanded; + } + + if (fullDef->weapDef.notetrackSoundMapKeys) + { + assert(sizeof(WeaponFullDef::notetrackSoundMapKeys) >= sizeof(scr_string_t) * std::extent_v); + memcpy(fullDef->notetrackSoundMapKeys, + fullDef->weapDef.notetrackSoundMapKeys, + sizeof(scr_string_t) * std::extent_v); + fullDef->weapDef.notetrackSoundMapKeys = fullDef->notetrackSoundMapKeys; + } + + if (fullDef->weapDef.notetrackSoundMapValues) + { + assert(sizeof(WeaponFullDef::notetrackSoundMapValues) >= sizeof(scr_string_t) * std::extent_v); + memcpy(fullDef->notetrackSoundMapValues, + fullDef->weapDef.notetrackSoundMapValues, + sizeof(scr_string_t) * std::extent_v); + fullDef->weapDef.notetrackSoundMapValues = fullDef->notetrackSoundMapValues; + } + + if (fullDef->weapDef.notetrackRumbleMapKeys) + { + assert(sizeof(WeaponFullDef::notetrackRumbleMapKeys) >= sizeof(scr_string_t) * std::extent_v); + memcpy(fullDef->notetrackRumbleMapKeys, + fullDef->weapDef.notetrackRumbleMapKeys, + sizeof(scr_string_t) * std::extent_v); + fullDef->weapDef.notetrackRumbleMapKeys = fullDef->notetrackRumbleMapKeys; + } + + if (fullDef->weapDef.notetrackRumbleMapValues) + { + assert(sizeof(WeaponFullDef::notetrackRumbleMapValues) >= sizeof(scr_string_t) * std::extent_v); + memcpy(fullDef->notetrackRumbleMapValues, + fullDef->weapDef.notetrackRumbleMapValues, + sizeof(scr_string_t) * std::extent_v); + fullDef->weapDef.notetrackRumbleMapValues = fullDef->notetrackRumbleMapValues; + } + + if (fullDef->weapDef.worldModel) + { + assert(sizeof(WeaponFullDef::worldModel) >= sizeof(void*) * std::extent_v); + memcpy(fullDef->worldModel, fullDef->weapDef.worldModel, sizeof(void*) * std::extent_v); + fullDef->weapDef.worldModel = fullDef->worldModel; + } + + if (fullDef->weapDef.parallelBounce) + { + assert(sizeof(WeaponFullDef::parallelBounce) >= sizeof(float) * std::extent_v); + memcpy(fullDef->parallelBounce, fullDef->weapDef.parallelBounce, sizeof(float) * std::extent_v); + fullDef->weapDef.parallelBounce = fullDef->parallelBounce; + } + + if (fullDef->weapDef.perpendicularBounce) + { + assert(sizeof(WeaponFullDef::perpendicularBounce) >= sizeof(float) * std::extent_v); + memcpy(fullDef->perpendicularBounce, + fullDef->weapDef.perpendicularBounce, + sizeof(float) * std::extent_v); + fullDef->weapDef.perpendicularBounce = fullDef->perpendicularBounce; + } + + if (fullDef->weapDef.locationDamageMultipliers) + { + assert(sizeof(WeaponFullDef::locationDamageMultipliers) >= sizeof(float) * std::extent_v); + memcpy(fullDef->locationDamageMultipliers, + fullDef->weapDef.locationDamageMultipliers, + sizeof(float) * std::extent_v); + fullDef->weapDef.locationDamageMultipliers = fullDef->locationDamageMultipliers; + } } - if (weapon->hideTags) + InfoString CreateInfoString(XAssetInfo* asset) { - assert(sizeof(WeaponFullDef::hideTags) >= sizeof(scr_string_t) * std::extent_v); - memcpy(fullDef->hideTags, weapon->hideTags, sizeof(scr_string_t) * std::extent_v); - fullDef->weapCompleteDef.hideTags = fullDef->hideTags; + const auto fullDef = std::make_unique(); + memset(fullDef.get(), 0, sizeof(WeaponFullDef)); + CopyToFullDef(asset->Asset(), fullDef.get()); + + InfoStringFromWeaponConverter converter(fullDef.get(), + weapon_fields, + std::extent_v, + [asset](const scr_string_t scrStr) -> std::string + { + assert(scrStr < asset->m_zone->m_script_strings.Count()); + if (scrStr >= asset->m_zone->m_script_strings.Count()) + return ""; + + return asset->m_zone->m_script_strings[scrStr]; + }); + + return converter.Convert(); } - if (weapon->szXAnims) + void DumpAccuracyGraphs(AssetDumpingContext& context, XAssetInfo* asset) { - assert(sizeof(WeaponFullDef::szXAnims) >= sizeof(void*) * NUM_WEAP_ANIMS); - memcpy(fullDef->szXAnims, weapon->szXAnims, sizeof(void*) * NUM_WEAP_ANIMS); - fullDef->weapCompleteDef.szXAnims = fullDef->szXAnims; - } + auto* accuracyGraphWriter = context.GetZoneAssetDumperState(); + const auto weapon = asset->Asset(); + const auto* weapDef = weapon->weapDef; - if (fullDef->weapDef.gunXModel) - { - assert(sizeof(WeaponFullDef::gunXModel) >= sizeof(void*) * std::extent_v); - memcpy(fullDef->gunXModel, fullDef->weapDef.gunXModel, sizeof(void*) * std::extent_v); - fullDef->weapDef.gunXModel = fullDef->gunXModel; - } - - if (fullDef->weapDef.szXAnimsRightHanded) - { - assert(sizeof(WeaponFullDef::szXAnimsRightHanded) >= sizeof(void*) * NUM_WEAP_ANIMS); - memcpy(fullDef->szXAnimsRightHanded, fullDef->weapDef.szXAnimsRightHanded, sizeof(void*) * NUM_WEAP_ANIMS); - fullDef->weapDef.szXAnimsRightHanded = fullDef->szXAnimsRightHanded; - } - - if (fullDef->weapDef.szXAnimsLeftHanded) - { - assert(sizeof(WeaponFullDef::szXAnimsLeftHanded) >= sizeof(void*) * NUM_WEAP_ANIMS); - memcpy(fullDef->szXAnimsLeftHanded, fullDef->weapDef.szXAnimsLeftHanded, sizeof(void*) * NUM_WEAP_ANIMS); - fullDef->weapDef.szXAnimsLeftHanded = fullDef->szXAnimsLeftHanded; - } - - if (fullDef->weapDef.notetrackSoundMapKeys) - { - assert(sizeof(WeaponFullDef::notetrackSoundMapKeys) >= sizeof(scr_string_t) * std::extent_v); - memcpy(fullDef->notetrackSoundMapKeys, - fullDef->weapDef.notetrackSoundMapKeys, - sizeof(scr_string_t) * std::extent_v); - fullDef->weapDef.notetrackSoundMapKeys = fullDef->notetrackSoundMapKeys; - } - - if (fullDef->weapDef.notetrackSoundMapValues) - { - assert(sizeof(WeaponFullDef::notetrackSoundMapValues) >= sizeof(scr_string_t) * std::extent_v); - memcpy(fullDef->notetrackSoundMapValues, - fullDef->weapDef.notetrackSoundMapValues, - sizeof(scr_string_t) * std::extent_v); - fullDef->weapDef.notetrackSoundMapValues = fullDef->notetrackSoundMapValues; - } - - if (fullDef->weapDef.notetrackRumbleMapKeys) - { - assert(sizeof(WeaponFullDef::notetrackRumbleMapKeys) >= sizeof(scr_string_t) * std::extent_v); - memcpy(fullDef->notetrackRumbleMapKeys, - fullDef->weapDef.notetrackRumbleMapKeys, - sizeof(scr_string_t) * std::extent_v); - fullDef->weapDef.notetrackRumbleMapKeys = fullDef->notetrackRumbleMapKeys; - } - - if (fullDef->weapDef.notetrackRumbleMapValues) - { - assert(sizeof(WeaponFullDef::notetrackRumbleMapValues) >= sizeof(scr_string_t) * std::extent_v); - memcpy(fullDef->notetrackRumbleMapValues, - fullDef->weapDef.notetrackRumbleMapValues, - sizeof(scr_string_t) * std::extent_v); - fullDef->weapDef.notetrackRumbleMapValues = fullDef->notetrackRumbleMapValues; - } - - if (fullDef->weapDef.worldModel) - { - assert(sizeof(WeaponFullDef::worldModel) >= sizeof(void*) * std::extent_v); - memcpy(fullDef->worldModel, fullDef->weapDef.worldModel, sizeof(void*) * std::extent_v); - fullDef->weapDef.worldModel = fullDef->worldModel; - } - - if (fullDef->weapDef.parallelBounce) - { - assert(sizeof(WeaponFullDef::parallelBounce) >= sizeof(float) * std::extent_v); - memcpy(fullDef->parallelBounce, fullDef->weapDef.parallelBounce, sizeof(float) * std::extent_v); - fullDef->weapDef.parallelBounce = fullDef->parallelBounce; - } - - if (fullDef->weapDef.perpendicularBounce) - { - assert(sizeof(WeaponFullDef::perpendicularBounce) >= sizeof(float) * std::extent_v); - memcpy(fullDef->perpendicularBounce, fullDef->weapDef.perpendicularBounce, sizeof(float) * std::extent_v); - fullDef->weapDef.perpendicularBounce = fullDef->perpendicularBounce; - } - - if (fullDef->weapDef.locationDamageMultipliers) - { - assert(sizeof(WeaponFullDef::locationDamageMultipliers) >= sizeof(float) * std::extent_v); - memcpy(fullDef->locationDamageMultipliers, - fullDef->weapDef.locationDamageMultipliers, - sizeof(float) * std::extent_v); - fullDef->weapDef.locationDamageMultipliers = fullDef->locationDamageMultipliers; - } -} - -InfoString AssetDumperWeapon::CreateInfoString(XAssetInfo* asset) -{ - const auto fullDef = std::make_unique(); - memset(fullDef.get(), 0, sizeof(WeaponFullDef)); - CopyToFullDef(asset->Asset(), fullDef.get()); - - InfoStringFromWeaponConverter converter(fullDef.get(), - weapon_fields, - std::extent_v, - [asset](const scr_string_t scrStr) -> std::string - { - assert(scrStr < asset->m_zone->m_script_strings.Count()); - if (scrStr >= asset->m_zone->m_script_strings.Count()) - return ""; - - return asset->m_zone->m_script_strings[scrStr]; - }); - - return converter.Convert(); -} - -void AssetDumperWeapon::DumpAccuracyGraphs(AssetDumpingContext& context, XAssetInfo* asset) -{ - auto* accuracyGraphWriter = context.GetZoneAssetDumperState(); - const auto weapon = asset->Asset(); - const auto* weapDef = weapon->weapDef; - - if (!weapDef) - return; - - if (weapDef->aiVsAiAccuracyGraphName && weapDef->originalAiVsAiAccuracyGraphKnots - && accuracyGraphWriter->ShouldDumpAiVsAiGraph(weapDef->aiVsAiAccuracyGraphName)) - { - AccuracyGraphWriter::DumpAiVsAiGraph( - context, - ConvertAccuracyGraph(weapDef->aiVsAiAccuracyGraphName, weapDef->originalAiVsAiAccuracyGraphKnots, weapDef->originalAiVsAiAccuracyGraphKnotCount)); - } - - if (weapDef->aiVsPlayerAccuracyGraphName && weapDef->originalAiVsPlayerAccuracyGraphKnots - && accuracyGraphWriter->ShouldDumpAiVsPlayerGraph(weapDef->aiVsPlayerAccuracyGraphName)) - { - AccuracyGraphWriter::DumpAiVsPlayerGraph(context, - ConvertAccuracyGraph(weapDef->aiVsPlayerAccuracyGraphName, - weapDef->originalAiVsPlayerAccuracyGraphKnots, - weapDef->originalAiVsPlayerAccuracyGraphKnotCount)); - } -} - -bool AssetDumperWeapon::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperWeapon::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - // Only dump raw when no gdt available - if (context.m_gdt) - { - const auto infoString = CreateInfoString(asset); - GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_WEAPON); - infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_WEAPON, gdtEntry); - context.m_gdt->WriteEntry(gdtEntry); - } - else - { - const auto assetFile = context.OpenAssetFile("weapons/" + asset->m_name); - - if (!assetFile) + if (!weapDef) return; - auto& stream = *assetFile; - const auto infoString = CreateInfoString(asset); - const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_WEAPON); - stream.write(stringValue.c_str(), stringValue.size()); + if (weapDef->aiVsAiAccuracyGraphName && weapDef->originalAiVsAiAccuracyGraphKnots + && accuracyGraphWriter->ShouldDumpAiVsAiGraph(weapDef->aiVsAiAccuracyGraphName)) + { + AccuracyGraphWriter::DumpAiVsAiGraph(context, + ConvertAccuracyGraph(weapDef->aiVsAiAccuracyGraphName, + weapDef->originalAiVsAiAccuracyGraphKnots, + weapDef->originalAiVsAiAccuracyGraphKnotCount)); + } + + if (weapDef->aiVsPlayerAccuracyGraphName && weapDef->originalAiVsPlayerAccuracyGraphKnots + && accuracyGraphWriter->ShouldDumpAiVsPlayerGraph(weapDef->aiVsPlayerAccuracyGraphName)) + { + AccuracyGraphWriter::DumpAiVsPlayerGraph(context, + ConvertAccuracyGraph(weapDef->aiVsPlayerAccuracyGraphName, + weapDef->originalAiVsPlayerAccuracyGraphKnots, + weapDef->originalAiVsPlayerAccuracyGraphKnotCount)); + } + } +} // namespace + +namespace IW4::weapon +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; } - DumpAccuracyGraphs(context, asset); -} + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + // Only dump raw when no gdt available + if (context.m_gdt) + { + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_WEAPON); + infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_WEAPON, gdtEntry); + context.m_gdt->WriteEntry(gdtEntry); + } + else + { + const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name)); + + if (!assetFile) + return; + + auto& stream = *assetFile; + const auto infoString = CreateInfoString(asset); + const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_WEAPON); + stream.write(stringValue.c_str(), stringValue.size()); + } + + DumpAccuracyGraphs(context, asset); + } +} // namespace IW4::weapon diff --git a/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.h b/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.h new file mode 100644 index 00000000..0beff65e --- /dev/null +++ b/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.h @@ -0,0 +1,15 @@ +#pragma once + +#include "Dumping/AbstractAssetDumper.h" +#include "Game/IW4/IW4.h" +#include "InfoString/InfoString.h" + +namespace IW4::weapon +{ + class Dumper final : public AbstractAssetDumper + { + protected: + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + }; +} // namespace IW4::weapon diff --git a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp index 43ce039f..8ed1bf82 100644 --- a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp +++ b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp @@ -14,8 +14,8 @@ #include "Script/ScriptDumperIW5.h" #include "Sound/LoadedSoundDumperIW5.h" #include "StringTable/StringTableDumperIW5.h" -#include "Weapon/AssetDumperWeapon.h" -#include "Weapon/AssetDumperWeaponAttachment.h" +#include "Weapon/AttachmentJsonDumperIW5.h" +#include "Weapon/WeaponDumperIW5.h" using namespace IW5; @@ -56,8 +56,8 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST) DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU) DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) - DUMP_ASSET_POOL(AssetDumperWeaponAttachment, m_attachment, ASSET_TYPE_ATTACHMENT) - DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON) + DUMP_ASSET_POOL(attachment::JsonDumper, m_attachment, ASSET_TYPE_ATTACHMENT) + DUMP_ASSET_POOL(weapon::Dumper, m_weapon, ASSET_TYPE_WEAPON) // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) // DUMP_ASSET_POOL(AssetDumperSurfaceFxTable, m_surface_fx_table, ASSET_TYPE_SURFACE_FX) diff --git a/src/ObjWriting/Game/IW5/Weapon/AssetDumperWeapon.h b/src/ObjWriting/Game/IW5/Weapon/AssetDumperWeapon.h deleted file mode 100644 index d13b00a5..00000000 --- a/src/ObjWriting/Game/IW5/Weapon/AssetDumperWeapon.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/IW5/IW5.h" -#include "InfoString/InfoString.h" - -namespace IW5 -{ - class AssetDumperWeapon final : public AbstractAssetDumper - { - static void CopyToFullDef(const WeaponCompleteDef* weapon, WeaponFullDef* fullDef); - static InfoString CreateInfoString(XAssetInfo* asset); - static void DumpAccuracyGraphs(AssetDumpingContext& context, XAssetInfo* asset); - - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace IW5 diff --git a/src/ObjWriting/Game/IW5/Weapon/AssetDumperWeaponAttachment.cpp b/src/ObjWriting/Game/IW5/Weapon/AssetDumperWeaponAttachment.cpp deleted file mode 100644 index d63e1649..00000000 --- a/src/ObjWriting/Game/IW5/Weapon/AssetDumperWeaponAttachment.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "AssetDumperWeaponAttachment.h" - -#include "Game/IW5/Weapon/JsonWeaponAttachmentWriter.h" - -#include - -using namespace IW5; - -bool AssetDumperWeaponAttachment::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperWeaponAttachment::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto assetFile = context.OpenAssetFile(std::format("attachment/{}.json", asset->m_name)); - - if (!assetFile) - return; - - DumpWeaponAttachmentAsJson(*assetFile, asset->Asset(), context); -} diff --git a/src/ObjWriting/Game/IW5/Weapon/JsonWeaponAttachmentWriter.cpp b/src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.cpp similarity index 96% rename from src/ObjWriting/Game/IW5/Weapon/JsonWeaponAttachmentWriter.cpp rename to src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.cpp index 69f50071..763e96fe 100644 --- a/src/ObjWriting/Game/IW5/Weapon/JsonWeaponAttachmentWriter.cpp +++ b/src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.cpp @@ -1,20 +1,22 @@ -#include "JsonWeaponAttachmentWriter.h" +#include "AttachmentJsonDumperIW5.h" #include "Game/IW5/CommonIW5.h" #include "Game/IW5/Weapon/JsonWeaponAttachment.h" +#include "Weapon/AttachmentCommon.h" #include #include using namespace nlohmann; using namespace IW5; +using namespace ::attachment; namespace { - class JsonDumper + class JsonDumperImpl { public: - JsonDumper(AssetDumpingContext& context, std::ostream& stream) + JsonDumperImpl(AssetDumpingContext& context, std::ostream& stream) : m_stream(stream) { } @@ -392,11 +394,21 @@ namespace }; } // namespace -namespace IW5 +namespace IW5::attachment { - void DumpWeaponAttachmentAsJson(std::ostream& stream, const WeaponAttachment* attachment, AssetDumpingContext& context) + bool JsonDumper::ShouldDump(XAssetInfo* asset) { - const JsonDumper dumper(context, stream); - dumper.Dump(attachment); + return true; } -} // namespace IW5 + + void JsonDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAssetName(asset->m_name)); + + if (!assetFile) + return; + + const JsonDumperImpl dumper(context, *assetFile); + dumper.Dump(asset->Asset()); + } +} // namespace IW5::attachment diff --git a/src/ObjWriting/Game/IW5/Weapon/AssetDumperWeaponAttachment.h b/src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.h similarity index 68% rename from src/ObjWriting/Game/IW5/Weapon/AssetDumperWeaponAttachment.h rename to src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.h index 11f32004..26547be9 100644 --- a/src/ObjWriting/Game/IW5/Weapon/AssetDumperWeaponAttachment.h +++ b/src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW5/IW5.h" -namespace IW5 +namespace IW5::attachment { - class AssetDumperWeaponAttachment final : public AbstractAssetDumper + class JsonDumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW5 +} // namespace IW5::attachment diff --git a/src/ObjWriting/Game/IW5/Weapon/JsonWeaponAttachmentWriter.h b/src/ObjWriting/Game/IW5/Weapon/JsonWeaponAttachmentWriter.h deleted file mode 100644 index dc0a84c2..00000000 --- a/src/ObjWriting/Game/IW5/Weapon/JsonWeaponAttachmentWriter.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "Dumping/AssetDumpingContext.h" -#include "Game/IW5/IW5.h" - -#include - -namespace IW5 -{ - void DumpWeaponAttachmentAsJson(std::ostream& stream, const WeaponAttachment* attachment, AssetDumpingContext& context); -} // namespace IW5 diff --git a/src/ObjWriting/Game/IW5/Weapon/AssetDumperWeapon.cpp b/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.cpp similarity index 67% rename from src/ObjWriting/Game/IW5/Weapon/AssetDumperWeapon.cpp rename to src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.cpp index 83e4cc93..adc4b899 100644 --- a/src/ObjWriting/Game/IW5/Weapon/AssetDumperWeapon.cpp +++ b/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.cpp @@ -1,10 +1,11 @@ -#include "AssetDumperWeapon.h" +#include "WeaponDumperIW5.h" #include "Game/IW5/CommonIW5.h" #include "Game/IW5/InfoString/InfoStringFromStructConverter.h" #include "Game/IW5/ObjConstantsIW5.h" #include "Game/IW5/Weapon/WeaponFields.h" #include "Weapon/AccuracyGraphWriter.h" +#include "Weapon/WeaponCommon.h" #include #include @@ -14,8 +15,9 @@ #include using namespace IW5; +using namespace ::weapon; -namespace IW5 +namespace { class InfoStringFromWeaponConverter final : public InfoStringFromStructConverter { @@ -551,211 +553,217 @@ namespace IW5 return graph; } -} // namespace IW5 -void AssetDumperWeapon::CopyToFullDef(const WeaponCompleteDef* weapon, WeaponFullDef* fullDef) -{ - fullDef->weapCompleteDef = *weapon; - - if (weapon->weapDef) + void CopyToFullDef(const WeaponCompleteDef* weapon, WeaponFullDef* fullDef) { - fullDef->weapDef = *weapon->weapDef; - fullDef->weapCompleteDef.weapDef = &fullDef->weapDef; + fullDef->weapCompleteDef = *weapon; + + if (weapon->weapDef) + { + fullDef->weapDef = *weapon->weapDef; + fullDef->weapCompleteDef.weapDef = &fullDef->weapDef; + } + + if (weapon->hideTags) + { + memcpy(fullDef->hideTags, weapon->hideTags, sizeof(scr_string_t) * std::extent_v); + fullDef->weapCompleteDef.hideTags = fullDef->hideTags; + } + + if (weapon->szXAnims) + { + static_assert(std::extent_v == WEAP_ANIM_COUNT); + memcpy(fullDef->szXAnims, weapon->szXAnims, sizeof(void*) * WEAP_ANIM_COUNT); + fullDef->weapCompleteDef.szXAnims = fullDef->szXAnims; + } + + if (fullDef->weapDef.gunXModel) + { + memcpy(fullDef->gunXModel, fullDef->weapDef.gunXModel, sizeof(void*) * std::extent_v); + fullDef->weapDef.gunXModel = fullDef->gunXModel; + } + + if (fullDef->weapDef.szXAnimsRightHanded) + { + static_assert(std::extent_v == WEAP_ANIM_COUNT); + memcpy(fullDef->szXAnimsRightHanded, fullDef->weapDef.szXAnimsRightHanded, sizeof(void*) * WEAP_ANIM_COUNT); + fullDef->weapDef.szXAnimsRightHanded = fullDef->szXAnimsRightHanded; + } + + if (fullDef->weapDef.szXAnimsLeftHanded) + { + static_assert(std::extent_v == WEAP_ANIM_COUNT); + memcpy(fullDef->szXAnimsLeftHanded, fullDef->weapDef.szXAnimsLeftHanded, sizeof(void*) * WEAP_ANIM_COUNT); + fullDef->weapDef.szXAnimsLeftHanded = fullDef->szXAnimsLeftHanded; + } + + if (fullDef->weapDef.notetrackSoundMapKeys) + { + memcpy(fullDef->notetrackSoundMapKeys, + fullDef->weapDef.notetrackSoundMapKeys, + sizeof(scr_string_t) * std::extent_v); + fullDef->weapDef.notetrackSoundMapKeys = fullDef->notetrackSoundMapKeys; + } + + if (fullDef->weapDef.notetrackSoundMapValues) + { + memcpy(fullDef->notetrackSoundMapValues, + fullDef->weapDef.notetrackSoundMapValues, + sizeof(scr_string_t) * std::extent_v); + fullDef->weapDef.notetrackSoundMapValues = fullDef->notetrackSoundMapValues; + } + + if (fullDef->weapDef.notetrackRumbleMapKeys) + { + memcpy(fullDef->notetrackRumbleMapKeys, + fullDef->weapDef.notetrackRumbleMapKeys, + sizeof(scr_string_t) * std::extent_v); + fullDef->weapDef.notetrackRumbleMapKeys = fullDef->notetrackRumbleMapKeys; + } + + if (fullDef->weapDef.notetrackRumbleMapValues) + { + memcpy(fullDef->notetrackRumbleMapValues, + fullDef->weapDef.notetrackRumbleMapValues, + sizeof(scr_string_t) * std::extent_v); + fullDef->weapDef.notetrackRumbleMapValues = fullDef->notetrackRumbleMapValues; + } + + if (fullDef->weapDef.worldModel) + { + memcpy(fullDef->worldModel, fullDef->weapDef.worldModel, sizeof(void*) * std::extent_v); + fullDef->weapDef.worldModel = fullDef->worldModel; + } + + if (fullDef->weapDef.parallelBounce) + { + static_assert(std::extent_v == SURF_TYPE_COUNT); + assert(sizeof(WeaponFullDef::parallelBounce) >= sizeof(float) * std::extent_v); + memcpy(fullDef->parallelBounce, fullDef->weapDef.parallelBounce, sizeof(float) * std::extent_v); + fullDef->weapDef.parallelBounce = fullDef->parallelBounce; + } + + if (fullDef->weapDef.perpendicularBounce) + { + static_assert(std::extent_v == SURF_TYPE_COUNT); + assert(sizeof(WeaponFullDef::perpendicularBounce) >= sizeof(float) * std::extent_v); + memcpy(fullDef->perpendicularBounce, + fullDef->weapDef.perpendicularBounce, + sizeof(float) * std::extent_v); + fullDef->weapDef.perpendicularBounce = fullDef->perpendicularBounce; + } + + if (fullDef->weapDef.locationDamageMultipliers) + { + static_assert(std::extent_v == HITLOC_COUNT); + assert(sizeof(WeaponFullDef::locationDamageMultipliers) >= sizeof(float) * std::extent_v); + memcpy(fullDef->locationDamageMultipliers, + fullDef->weapDef.locationDamageMultipliers, + sizeof(float) * std::extent_v); + fullDef->weapDef.locationDamageMultipliers = fullDef->locationDamageMultipliers; + } + + if (fullDef->weapCompleteDef.scopes) + { + memcpy(fullDef->scopes, fullDef->weapCompleteDef.scopes, sizeof(void*) * std::extent_v); + fullDef->weapCompleteDef.scopes = fullDef->scopes; + } + + if (fullDef->weapCompleteDef.underBarrels) + { + memcpy(fullDef->underBarrels, fullDef->weapCompleteDef.underBarrels, sizeof(void*) * std::extent_v); + fullDef->weapCompleteDef.underBarrels = fullDef->underBarrels; + } + + if (fullDef->weapCompleteDef.others) + { + memcpy(fullDef->others, fullDef->weapCompleteDef.others, sizeof(void*) * std::extent_v); + fullDef->weapCompleteDef.others = fullDef->others; + } } - if (weapon->hideTags) + InfoString CreateInfoString(XAssetInfo* asset) { - memcpy(fullDef->hideTags, weapon->hideTags, sizeof(scr_string_t) * std::extent_v); - fullDef->weapCompleteDef.hideTags = fullDef->hideTags; + const auto fullDef = std::make_unique(); + memset(fullDef.get(), 0, sizeof(WeaponFullDef)); + CopyToFullDef(asset->Asset(), fullDef.get()); + + InfoStringFromWeaponConverter converter(fullDef.get(), + weapon_fields, + std::extent_v, + [asset](const scr_string_t scrStr) -> std::string + { + assert(scrStr < asset->m_zone->m_script_strings.Count()); + if (scrStr >= asset->m_zone->m_script_strings.Count()) + return ""; + + return asset->m_zone->m_script_strings[scrStr]; + }); + + return converter.Convert(); } - if (weapon->szXAnims) + void DumpAccuracyGraphs(AssetDumpingContext& context, XAssetInfo* asset) { - static_assert(std::extent_v == WEAP_ANIM_COUNT); - memcpy(fullDef->szXAnims, weapon->szXAnims, sizeof(void*) * WEAP_ANIM_COUNT); - fullDef->weapCompleteDef.szXAnims = fullDef->szXAnims; - } + auto* accuracyGraphWriter = context.GetZoneAssetDumperState(); + const auto weapon = asset->Asset(); + const auto* weapDef = weapon->weapDef; - if (fullDef->weapDef.gunXModel) - { - memcpy(fullDef->gunXModel, fullDef->weapDef.gunXModel, sizeof(void*) * std::extent_v); - fullDef->weapDef.gunXModel = fullDef->gunXModel; - } - - if (fullDef->weapDef.szXAnimsRightHanded) - { - static_assert(std::extent_v == WEAP_ANIM_COUNT); - memcpy(fullDef->szXAnimsRightHanded, fullDef->weapDef.szXAnimsRightHanded, sizeof(void*) * WEAP_ANIM_COUNT); - fullDef->weapDef.szXAnimsRightHanded = fullDef->szXAnimsRightHanded; - } - - if (fullDef->weapDef.szXAnimsLeftHanded) - { - static_assert(std::extent_v == WEAP_ANIM_COUNT); - memcpy(fullDef->szXAnimsLeftHanded, fullDef->weapDef.szXAnimsLeftHanded, sizeof(void*) * WEAP_ANIM_COUNT); - fullDef->weapDef.szXAnimsLeftHanded = fullDef->szXAnimsLeftHanded; - } - - if (fullDef->weapDef.notetrackSoundMapKeys) - { - memcpy(fullDef->notetrackSoundMapKeys, - fullDef->weapDef.notetrackSoundMapKeys, - sizeof(scr_string_t) * std::extent_v); - fullDef->weapDef.notetrackSoundMapKeys = fullDef->notetrackSoundMapKeys; - } - - if (fullDef->weapDef.notetrackSoundMapValues) - { - memcpy(fullDef->notetrackSoundMapValues, - fullDef->weapDef.notetrackSoundMapValues, - sizeof(scr_string_t) * std::extent_v); - fullDef->weapDef.notetrackSoundMapValues = fullDef->notetrackSoundMapValues; - } - - if (fullDef->weapDef.notetrackRumbleMapKeys) - { - memcpy(fullDef->notetrackRumbleMapKeys, - fullDef->weapDef.notetrackRumbleMapKeys, - sizeof(scr_string_t) * std::extent_v); - fullDef->weapDef.notetrackRumbleMapKeys = fullDef->notetrackRumbleMapKeys; - } - - if (fullDef->weapDef.notetrackRumbleMapValues) - { - memcpy(fullDef->notetrackRumbleMapValues, - fullDef->weapDef.notetrackRumbleMapValues, - sizeof(scr_string_t) * std::extent_v); - fullDef->weapDef.notetrackRumbleMapValues = fullDef->notetrackRumbleMapValues; - } - - if (fullDef->weapDef.worldModel) - { - memcpy(fullDef->worldModel, fullDef->weapDef.worldModel, sizeof(void*) * std::extent_v); - fullDef->weapDef.worldModel = fullDef->worldModel; - } - - if (fullDef->weapDef.parallelBounce) - { - static_assert(std::extent_v == SURF_TYPE_COUNT); - assert(sizeof(WeaponFullDef::parallelBounce) >= sizeof(float) * std::extent_v); - memcpy(fullDef->parallelBounce, fullDef->weapDef.parallelBounce, sizeof(float) * std::extent_v); - fullDef->weapDef.parallelBounce = fullDef->parallelBounce; - } - - if (fullDef->weapDef.perpendicularBounce) - { - static_assert(std::extent_v == SURF_TYPE_COUNT); - assert(sizeof(WeaponFullDef::perpendicularBounce) >= sizeof(float) * std::extent_v); - memcpy(fullDef->perpendicularBounce, fullDef->weapDef.perpendicularBounce, sizeof(float) * std::extent_v); - fullDef->weapDef.perpendicularBounce = fullDef->perpendicularBounce; - } - - if (fullDef->weapDef.locationDamageMultipliers) - { - static_assert(std::extent_v == HITLOC_COUNT); - assert(sizeof(WeaponFullDef::locationDamageMultipliers) >= sizeof(float) * std::extent_v); - memcpy(fullDef->locationDamageMultipliers, - fullDef->weapDef.locationDamageMultipliers, - sizeof(float) * std::extent_v); - fullDef->weapDef.locationDamageMultipliers = fullDef->locationDamageMultipliers; - } - - if (fullDef->weapCompleteDef.scopes) - { - memcpy(fullDef->scopes, fullDef->weapCompleteDef.scopes, sizeof(void*) * std::extent_v); - fullDef->weapCompleteDef.scopes = fullDef->scopes; - } - - if (fullDef->weapCompleteDef.underBarrels) - { - memcpy(fullDef->underBarrels, fullDef->weapCompleteDef.underBarrels, sizeof(void*) * std::extent_v); - fullDef->weapCompleteDef.underBarrels = fullDef->underBarrels; - } - - if (fullDef->weapCompleteDef.others) - { - memcpy(fullDef->others, fullDef->weapCompleteDef.others, sizeof(void*) * std::extent_v); - fullDef->weapCompleteDef.others = fullDef->others; - } -} - -InfoString AssetDumperWeapon::CreateInfoString(XAssetInfo* asset) -{ - const auto fullDef = std::make_unique(); - memset(fullDef.get(), 0, sizeof(WeaponFullDef)); - CopyToFullDef(asset->Asset(), fullDef.get()); - - InfoStringFromWeaponConverter converter(fullDef.get(), - weapon_fields, - std::extent_v, - [asset](const scr_string_t scrStr) -> std::string - { - assert(scrStr < asset->m_zone->m_script_strings.Count()); - if (scrStr >= asset->m_zone->m_script_strings.Count()) - return ""; - - return asset->m_zone->m_script_strings[scrStr]; - }); - - return converter.Convert(); -} - -void AssetDumperWeapon::DumpAccuracyGraphs(AssetDumpingContext& context, XAssetInfo* asset) -{ - auto* accuracyGraphWriter = context.GetZoneAssetDumperState(); - const auto weapon = asset->Asset(); - const auto* weapDef = weapon->weapDef; - - if (!weapDef) - return; - - if (weapDef->aiVsAiAccuracyGraphName && weapDef->originalAiVsAiAccuracyGraphKnots - && accuracyGraphWriter->ShouldDumpAiVsAiGraph(weapDef->aiVsAiAccuracyGraphName)) - { - AccuracyGraphWriter::DumpAiVsAiGraph( - context, - ConvertAccuracyGraph(weapDef->aiVsAiAccuracyGraphName, weapDef->originalAiVsAiAccuracyGraphKnots, weapDef->originalAiVsAiAccuracyGraphKnotCount)); - } - - if (weapDef->aiVsPlayerAccuracyGraphName && weapDef->originalAiVsPlayerAccuracyGraphKnots - && accuracyGraphWriter->ShouldDumpAiVsPlayerGraph(weapDef->aiVsPlayerAccuracyGraphName)) - { - AccuracyGraphWriter::DumpAiVsPlayerGraph(context, - ConvertAccuracyGraph(weapDef->aiVsPlayerAccuracyGraphName, - weapDef->originalAiVsPlayerAccuracyGraphKnots, - weapDef->originalAiVsPlayerAccuracyGraphKnotCount)); - } -} - -bool AssetDumperWeapon::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperWeapon::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - // TODO: only dump infostring fields when non-default - - // Only dump raw when no gdt available - if (context.m_gdt) - { - const auto infoString = CreateInfoString(asset); - GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_WEAPON); - infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_WEAPON, gdtEntry); - context.m_gdt->WriteEntry(gdtEntry); - } - else - { - const auto assetFile = context.OpenAssetFile("weapons/" + asset->m_name); - - if (!assetFile) + if (!weapDef) return; - auto& stream = *assetFile; - const auto infoString = CreateInfoString(asset); - const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_WEAPON); - stream.write(stringValue.c_str(), stringValue.size()); + if (weapDef->aiVsAiAccuracyGraphName && weapDef->originalAiVsAiAccuracyGraphKnots + && accuracyGraphWriter->ShouldDumpAiVsAiGraph(weapDef->aiVsAiAccuracyGraphName)) + { + AccuracyGraphWriter::DumpAiVsAiGraph(context, + ConvertAccuracyGraph(weapDef->aiVsAiAccuracyGraphName, + weapDef->originalAiVsAiAccuracyGraphKnots, + weapDef->originalAiVsAiAccuracyGraphKnotCount)); + } + + if (weapDef->aiVsPlayerAccuracyGraphName && weapDef->originalAiVsPlayerAccuracyGraphKnots + && accuracyGraphWriter->ShouldDumpAiVsPlayerGraph(weapDef->aiVsPlayerAccuracyGraphName)) + { + AccuracyGraphWriter::DumpAiVsPlayerGraph(context, + ConvertAccuracyGraph(weapDef->aiVsPlayerAccuracyGraphName, + weapDef->originalAiVsPlayerAccuracyGraphKnots, + weapDef->originalAiVsPlayerAccuracyGraphKnotCount)); + } + } +} // namespace + +namespace IW5::weapon +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; } - DumpAccuracyGraphs(context, asset); -} + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + // TODO: only dump infostring fields when non-default + + // Only dump raw when no gdt available + if (context.m_gdt) + { + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_WEAPON); + infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_WEAPON, gdtEntry); + context.m_gdt->WriteEntry(gdtEntry); + } + else + { + const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name)); + + if (!assetFile) + return; + + auto& stream = *assetFile; + const auto infoString = CreateInfoString(asset); + const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_WEAPON); + stream.write(stringValue.c_str(), stringValue.size()); + } + + DumpAccuracyGraphs(context, asset); + } +} // namespace IW5::weapon diff --git a/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.h b/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.h new file mode 100644 index 00000000..4a33e035 --- /dev/null +++ b/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.h @@ -0,0 +1,15 @@ +#pragma once + +#include "Dumping/AbstractAssetDumper.h" +#include "Game/IW5/IW5.h" +#include "InfoString/InfoString.h" + +namespace IW5::weapon +{ + class Dumper final : public AbstractAssetDumper + { + protected: + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + }; +} // namespace IW5::weapon diff --git a/src/ObjWriting/Game/T5/ObjWriterT5.cpp b/src/ObjWriting/Game/T5/ObjWriterT5.cpp index 55466d5d..5d1ff986 100644 --- a/src/ObjWriting/Game/T5/ObjWriterT5.cpp +++ b/src/ObjWriting/Game/T5/ObjWriterT5.cpp @@ -8,7 +8,6 @@ #include "ObjWriting.h" #include "RawFile/RawFileDumperT5.h" #include "StringTable/StringTableDumperT5.h" -#include "Weapon/AssetDumperWeapon.h" using namespace T5; diff --git a/src/ObjWriting/Game/T5/Weapon/AssetDumperWeapon.cpp b/src/ObjWriting/Game/T5/Weapon/AssetDumperWeapon.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/src/ObjWriting/Game/T5/Weapon/AssetDumperWeapon.h b/src/ObjWriting/Game/T5/Weapon/AssetDumperWeapon.h deleted file mode 100644 index e69de29b..00000000 diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 93cfea5a..f198725b 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -21,10 +21,10 @@ #include "Techset/TechsetDumperT6.h" #include "Tracer/TracerDumperT6.h" #include "Vehicle/VehicleDumperT6.h" -#include "Weapon/AssetDumperWeapon.h" -#include "Weapon/AssetDumperWeaponAttachment.h" -#include "Weapon/AssetDumperWeaponAttachmentUnique.h" -#include "Weapon/AssetDumperWeaponCamo.h" +#include "Weapon/AttachmentDumperT6.h" +#include "Weapon/AttachmentUniqueDumperT6.h" +#include "Weapon/CamoJsonDumperT6.h" +#include "Weapon/WeaponDumperT6.h" #include "ZBarrier/ZBarrierDumperT6.h" using namespace T6; @@ -68,10 +68,10 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST) // DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU) DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) - DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON) - DUMP_ASSET_POOL(AssetDumperWeaponAttachment, m_attachment, ASSET_TYPE_ATTACHMENT) - DUMP_ASSET_POOL(AssetDumperWeaponAttachmentUnique, m_attachment_unique, ASSET_TYPE_ATTACHMENT_UNIQUE) - DUMP_ASSET_POOL(AssetDumperWeaponCamo, m_camo, ASSET_TYPE_WEAPON_CAMO) + DUMP_ASSET_POOL(weapon::Dumper, m_weapon, ASSET_TYPE_WEAPON) + DUMP_ASSET_POOL(attachment::Dumper, m_attachment, ASSET_TYPE_ATTACHMENT) + DUMP_ASSET_POOL(attachment_unique::Dumper, m_attachment_unique, ASSET_TYPE_ATTACHMENT_UNIQUE) + DUMP_ASSET_POOL(camo::JsonDumper, m_camo, ASSET_TYPE_WEAPON_CAMO) DUMP_ASSET_POOL(sound::SndDriverGlobalsDumper, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) diff --git a/src/ObjWriting/Game/T6/Weapon/AssetDumperWeapon.h b/src/ObjWriting/Game/T6/Weapon/AssetDumperWeapon.h deleted file mode 100644 index d8f9d746..00000000 --- a/src/ObjWriting/Game/T6/Weapon/AssetDumperWeapon.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/T6/T6.h" -#include "InfoString/InfoString.h" - -namespace T6 -{ - class AssetDumperWeapon final : public AbstractAssetDumper - { - static void CopyToFullDef(const WeaponVariantDef* weapon, WeaponFullDef* fullDef); - static InfoString CreateInfoString(XAssetInfo* asset); - static void DumpAccuracyGraphs(AssetDumpingContext& context, XAssetInfo* asset); - - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace T6 diff --git a/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachment.cpp b/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachment.cpp deleted file mode 100644 index 0c7fd032..00000000 --- a/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachment.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include "AssetDumperWeaponAttachment.h" - -#include "Game/T6/InfoString/InfoStringFromStructConverter.h" -#include "Game/T6/ObjConstantsT6.h" -#include "Game/T6/Weapon/AttachmentFields.h" -#include "Game/T6/Weapon/WeaponStrings.h" - -#include -#include - -using namespace T6; - -namespace T6 -{ - class InfoStringFromAttachmentConverter final : public InfoStringFromStructConverter - { - protected: - void FillFromExtensionField(const cspField_t& field) override - { - switch (static_cast(field.iFieldType)) - { - case AFT_ATTACHMENTTYPE: - FillFromEnumInt(std::string(field.szName), field.iOffset, szAttachmentTypeNames, std::extent_v); - break; - - case AFT_PENETRATE_TYPE: - FillFromEnumInt(std::string(field.szName), field.iOffset, penetrateTypeNames, std::extent_v); - break; - - case AFT_FIRETYPE: - FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapFireTypeNames, std::extent_v); - break; - - default: - break; - } - } - - public: - InfoStringFromAttachmentConverter(const WeaponAttachment* structure, - const cspField_t* fields, - const size_t fieldCount, - std::function scriptStringValueCallback) - : InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback)) - { - } - }; -} // namespace T6 - -InfoString AssetDumperWeaponAttachment::CreateInfoString(XAssetInfo* asset) -{ - InfoStringFromAttachmentConverter converter(asset->Asset(), - attachment_fields, - std::extent_v, - [asset](const scr_string_t scrStr) -> std::string - { - assert(scrStr < asset->m_zone->m_script_strings.Count()); - if (scrStr >= asset->m_zone->m_script_strings.Count()) - return ""; - - return asset->m_zone->m_script_strings[scrStr]; - }); - - return converter.Convert(); -} - -bool AssetDumperWeaponAttachment::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperWeaponAttachment::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - // Only dump raw when no gdt available - if (context.m_gdt) - { - const auto infoString = CreateInfoString(asset); - GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_WEAPON_ATTACHMENT); - infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_WEAPON_ATTACHMENT, gdtEntry); - context.m_gdt->WriteEntry(gdtEntry); - } - else - { - const auto assetFile = context.OpenAssetFile("attachment/" + asset->m_name); - - if (!assetFile) - return; - - auto& stream = *assetFile; - const auto infoString = CreateInfoString(asset); - const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_WEAPON_ATTACHMENT); - stream.write(stringValue.c_str(), stringValue.size()); - } -} diff --git a/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachmentUnique.cpp b/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachmentUnique.cpp deleted file mode 100644 index 6730771a..00000000 --- a/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachmentUnique.cpp +++ /dev/null @@ -1,158 +0,0 @@ -#include "AssetDumperWeaponAttachmentUnique.h" - -#include "Game/T6/InfoString/InfoStringFromStructConverter.h" -#include "Game/T6/ObjConstantsT6.h" -#include "Game/T6/Weapon/AttachmentUniqueFields.h" -#include "Game/T6/Weapon/WeaponStrings.h" - -#include -#include -#include -#include - -using namespace T6; - -namespace T6 -{ - class InfoStringFromWeaponAttachmentUniqueConverter final : public InfoStringFromStructConverter - { - protected: - void FillFromExtensionField(const cspField_t& field) override - { - switch (static_cast(field.iFieldType)) - { - case AUFT_ATTACHMENTTYPE: - FillFromEnumInt(std::string(field.szName), field.iOffset, szAttachmentTypeNames, std::extent_v); - break; - - case AUFT_HIDETAGS: - { - const auto* hideTags = reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset); - std::stringstream ss; - auto first = true; - - for (auto i = 0u; i < std::extent_v; i++) - { - const auto& str = m_get_scr_string(hideTags[i]); - if (!str.empty()) - { - if (!first) - ss << "\n"; - else - first = false; - - ss << str; - } - } - - m_info_string.SetValueForKey(std::string(field.szName), ss.str()); - break; - } - - case AUFT_OVERLAYRETICLE: - FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapOverlayReticleNames, std::extent_v); - break; - - case AUFT_CAMO: - { - const auto* camo = *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset); - - if (camo) - m_info_string.SetValueForKey(std::string(field.szName), std::string(AssetName(camo->name))); - else - m_info_string.SetValueForKey(std::string(field.szName), ""); - break; - } - - default: - assert(false); - break; - } - } - - public: - InfoStringFromWeaponAttachmentUniqueConverter(const WeaponAttachmentUniqueFull* structure, - const cspField_t* fields, - const size_t fieldCount, - std::function scriptStringValueCallback) - : InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback)) - { - } - }; -} // namespace T6 - -void AssetDumperWeaponAttachmentUnique::CopyToFullDef(const WeaponAttachmentUnique* attachment, WeaponAttachmentUniqueFull* fullDef) -{ - fullDef->attachment = *attachment; - - if (attachment->szXAnims) - { - assert(sizeof(WeaponAttachmentUniqueFull::szXAnims) >= sizeof(void*) * NUM_WEAP_ANIMS); - memcpy(fullDef->szXAnims, attachment->szXAnims, sizeof(void*) * NUM_WEAP_ANIMS); - fullDef->attachment.szXAnims = fullDef->szXAnims; - } - - if (attachment->hideTags) - { - assert(sizeof(WeaponAttachmentUniqueFull::hideTags) >= sizeof(scr_string_t) * std::extent_v); - memcpy(fullDef->hideTags, attachment->hideTags, sizeof(scr_string_t) * std::extent_v); - fullDef->attachment.hideTags = fullDef->hideTags; - } - - if (attachment->locationDamageMultipliers) - { - assert(sizeof(WeaponAttachmentUniqueFull::locationDamageMultipliers) >= sizeof(float) * HITLOC_COUNT); - memcpy(fullDef->locationDamageMultipliers, attachment->locationDamageMultipliers, sizeof(float) * HITLOC_COUNT); - fullDef->attachment.locationDamageMultipliers = fullDef->locationDamageMultipliers; - } -} - -InfoString AssetDumperWeaponAttachmentUnique::CreateInfoString(XAssetInfo* asset) -{ - const auto fullDef = std::make_unique(); - memset(fullDef.get(), 0, sizeof(WeaponAttachmentUniqueFull)); - CopyToFullDef(asset->Asset(), fullDef.get()); - - InfoStringFromWeaponAttachmentUniqueConverter converter(fullDef.get(), - attachment_unique_fields, - std::extent_v, - [asset](const scr_string_t scrStr) -> std::string - { - assert(scrStr < asset->m_zone->m_script_strings.Count()); - if (scrStr >= asset->m_zone->m_script_strings.Count()) - return ""; - - return asset->m_zone->m_script_strings[scrStr]; - }); - - return converter.Convert(); -} - -bool AssetDumperWeaponAttachmentUnique::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperWeaponAttachmentUnique::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - // Only dump raw when no gdt available - if (context.m_gdt) - { - const auto infoString = CreateInfoString(asset); - GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_WEAPON_ATTACHMENT_UNIQUE); - infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_WEAPON_ATTACHMENT_UNIQUE, gdtEntry); - context.m_gdt->WriteEntry(gdtEntry); - } - else - { - const auto assetFile = context.OpenAssetFile("attachmentunique/" + asset->m_name); - - if (!assetFile) - return; - - auto& stream = *assetFile; - const auto infoString = CreateInfoString(asset); - const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_WEAPON_ATTACHMENT_UNIQUE); - stream.write(stringValue.c_str(), stringValue.size()); - } -} diff --git a/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachmentUnique.h b/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachmentUnique.h deleted file mode 100644 index 4d6a9c41..00000000 --- a/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachmentUnique.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/T6/T6.h" -#include "InfoString/InfoString.h" - -namespace T6 -{ - class AssetDumperWeaponAttachmentUnique final : public AbstractAssetDumper - { - static void CopyToFullDef(const WeaponAttachmentUnique* attachment, WeaponAttachmentUniqueFull* fullDef); - static InfoString CreateInfoString(XAssetInfo* asset); - - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace T6 diff --git a/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponCamo.cpp b/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponCamo.cpp deleted file mode 100644 index 4e485235..00000000 --- a/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponCamo.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "AssetDumperWeaponCamo.h" - -#include "JsonWeaponCamoWriter.h" - -#include - -using namespace T6; - -bool AssetDumperWeaponCamo::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperWeaponCamo::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto fileName = std::format("camo/{}.json", asset->m_name); - const auto assetFile = context.OpenAssetFile(fileName); - - if (!assetFile) - return; - - DumpWeaponCamoAsJson(*assetFile, asset->Asset()); -} diff --git a/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.cpp b/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.cpp new file mode 100644 index 00000000..ff521c15 --- /dev/null +++ b/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.cpp @@ -0,0 +1,99 @@ +#include "AttachmentDumperT6.h" + +#include "Game/T6/InfoString/InfoStringFromStructConverter.h" +#include "Game/T6/ObjConstantsT6.h" +#include "Game/T6/Weapon/AttachmentFields.h" +#include "Game/T6/Weapon/WeaponStrings.h" +#include "Weapon/AttachmentCommon.h" + +#include +#include + +using namespace T6; +using namespace ::attachment; + +namespace +{ + class InfoStringFromAttachmentConverter final : public InfoStringFromStructConverter + { + protected: + void FillFromExtensionField(const cspField_t& field) override + { + switch (static_cast(field.iFieldType)) + { + case AFT_ATTACHMENTTYPE: + FillFromEnumInt(std::string(field.szName), field.iOffset, szAttachmentTypeNames, std::extent_v); + break; + + case AFT_PENETRATE_TYPE: + FillFromEnumInt(std::string(field.szName), field.iOffset, penetrateTypeNames, std::extent_v); + break; + + case AFT_FIRETYPE: + FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapFireTypeNames, std::extent_v); + break; + + default: + break; + } + } + + public: + InfoStringFromAttachmentConverter(const WeaponAttachment* structure, + const cspField_t* fields, + const size_t fieldCount, + std::function scriptStringValueCallback) + : InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback)) + { + } + }; + + InfoString CreateInfoString(XAssetInfo* asset) + { + InfoStringFromAttachmentConverter converter(asset->Asset(), + attachment_fields, + std::extent_v, + [asset](const scr_string_t scrStr) -> std::string + { + assert(scrStr < asset->m_zone->m_script_strings.Count()); + if (scrStr >= asset->m_zone->m_script_strings.Count()) + return ""; + + return asset->m_zone->m_script_strings[scrStr]; + }); + + return converter.Convert(); + } +} // namespace + +namespace T6::attachment +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + // Only dump raw when no gdt available + if (context.m_gdt) + { + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_WEAPON_ATTACHMENT); + infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_WEAPON_ATTACHMENT, gdtEntry); + context.m_gdt->WriteEntry(gdtEntry); + } + else + { + const auto assetFile = context.OpenAssetFile(GetInfoStringFileNameForAssetName(asset->m_name)); + + if (!assetFile) + return; + + auto& stream = *assetFile; + const auto infoString = CreateInfoString(asset); + const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_WEAPON_ATTACHMENT); + stream.write(stringValue.c_str(), stringValue.size()); + } + } +} // namespace T6::attachment diff --git a/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachment.h b/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.h similarity index 60% rename from src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachment.h rename to src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.h index cde27cf5..2f386ccc 100644 --- a/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponAttachment.h +++ b/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.h @@ -4,14 +4,12 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" -namespace T6 +namespace T6::attachment { - class AssetDumperWeaponAttachment final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { - static InfoString CreateInfoString(XAssetInfo* asset); - protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6 +} // namespace T6::attachment diff --git a/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.cpp b/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.cpp new file mode 100644 index 00000000..88e4c054 --- /dev/null +++ b/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.cpp @@ -0,0 +1,163 @@ +#include "AttachmentUniqueDumperT6.h" + +#include "Game/T6/InfoString/InfoStringFromStructConverter.h" +#include "Game/T6/ObjConstantsT6.h" +#include "Game/T6/Weapon/AttachmentUniqueFields.h" +#include "Game/T6/Weapon/WeaponStrings.h" +#include "Weapon/AttachmentUniqueCommon.h" + +#include +#include +#include +#include + +using namespace T6; +using namespace ::attachment_unique; + +namespace +{ + class InfoStringFromWeaponAttachmentUniqueConverter final : public InfoStringFromStructConverter + { + protected: + void FillFromExtensionField(const cspField_t& field) override + { + switch (static_cast(field.iFieldType)) + { + case AUFT_ATTACHMENTTYPE: + FillFromEnumInt(std::string(field.szName), field.iOffset, szAttachmentTypeNames, std::extent_v); + break; + + case AUFT_HIDETAGS: + { + const auto* hideTags = reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset); + std::stringstream ss; + auto first = true; + + for (auto i = 0u; i < std::extent_v; i++) + { + const auto& str = m_get_scr_string(hideTags[i]); + if (!str.empty()) + { + if (!first) + ss << "\n"; + else + first = false; + + ss << str; + } + } + + m_info_string.SetValueForKey(std::string(field.szName), ss.str()); + break; + } + + case AUFT_OVERLAYRETICLE: + FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapOverlayReticleNames, std::extent_v); + break; + + case AUFT_CAMO: + { + const auto* camo = *reinterpret_cast(reinterpret_cast(m_structure) + field.iOffset); + + if (camo) + m_info_string.SetValueForKey(std::string(field.szName), std::string(AssetName(camo->name))); + else + m_info_string.SetValueForKey(std::string(field.szName), ""); + break; + } + + default: + assert(false); + break; + } + } + + public: + InfoStringFromWeaponAttachmentUniqueConverter(const WeaponAttachmentUniqueFull* structure, + const cspField_t* fields, + const size_t fieldCount, + std::function scriptStringValueCallback) + : InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback)) + { + } + }; + + void CopyToFullDef(const WeaponAttachmentUnique* attachment, WeaponAttachmentUniqueFull* fullDef) + { + fullDef->attachment = *attachment; + + if (attachment->szXAnims) + { + assert(sizeof(WeaponAttachmentUniqueFull::szXAnims) >= sizeof(void*) * NUM_WEAP_ANIMS); + memcpy(fullDef->szXAnims, attachment->szXAnims, sizeof(void*) * NUM_WEAP_ANIMS); + fullDef->attachment.szXAnims = fullDef->szXAnims; + } + + if (attachment->hideTags) + { + assert(sizeof(WeaponAttachmentUniqueFull::hideTags) >= sizeof(scr_string_t) * std::extent_v); + memcpy(fullDef->hideTags, attachment->hideTags, sizeof(scr_string_t) * std::extent_v); + fullDef->attachment.hideTags = fullDef->hideTags; + } + + if (attachment->locationDamageMultipliers) + { + assert(sizeof(WeaponAttachmentUniqueFull::locationDamageMultipliers) >= sizeof(float) * HITLOC_COUNT); + memcpy(fullDef->locationDamageMultipliers, attachment->locationDamageMultipliers, sizeof(float) * HITLOC_COUNT); + fullDef->attachment.locationDamageMultipliers = fullDef->locationDamageMultipliers; + } + } + + InfoString CreateInfoString(XAssetInfo* asset) + { + const auto fullDef = std::make_unique(); + memset(fullDef.get(), 0, sizeof(WeaponAttachmentUniqueFull)); + CopyToFullDef(asset->Asset(), fullDef.get()); + + InfoStringFromWeaponAttachmentUniqueConverter converter(fullDef.get(), + attachment_unique_fields, + std::extent_v, + [asset](const scr_string_t scrStr) -> std::string + { + assert(scrStr < asset->m_zone->m_script_strings.Count()); + if (scrStr >= asset->m_zone->m_script_strings.Count()) + return ""; + + return asset->m_zone->m_script_strings[scrStr]; + }); + + return converter.Convert(); + } +} // namespace + +namespace T6::attachment_unique +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + // Only dump raw when no gdt available + if (context.m_gdt) + { + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_WEAPON_ATTACHMENT_UNIQUE); + infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_WEAPON_ATTACHMENT_UNIQUE, gdtEntry); + context.m_gdt->WriteEntry(gdtEntry); + } + else + { + const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name)); + + if (!assetFile) + return; + + auto& stream = *assetFile; + const auto infoString = CreateInfoString(asset); + const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_WEAPON_ATTACHMENT_UNIQUE); + stream.write(stringValue.c_str(), stringValue.size()); + } + } +} // namespace T6::attachment_unique diff --git a/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.h b/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.h new file mode 100644 index 00000000..e84fcb74 --- /dev/null +++ b/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.h @@ -0,0 +1,15 @@ +#pragma once + +#include "Dumping/AbstractAssetDumper.h" +#include "Game/T6/T6.h" +#include "InfoString/InfoString.h" + +namespace T6::attachment_unique +{ + class Dumper final : public AbstractAssetDumper + { + protected: + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + }; +} // namespace T6::attachment_unique diff --git a/src/ObjWriting/Game/T6/Weapon/JsonWeaponCamoWriter.cpp b/src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.cpp similarity index 86% rename from src/ObjWriting/Game/T6/Weapon/JsonWeaponCamoWriter.cpp rename to src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.cpp index 3438dae8..958470c7 100644 --- a/src/ObjWriting/Game/T6/Weapon/JsonWeaponCamoWriter.cpp +++ b/src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.cpp @@ -1,20 +1,22 @@ -#include "JsonWeaponCamoWriter.h" +#include "CamoJsonDumperT6.h" #include "Game/T6/CommonT6.h" #include "Game/T6/Json/JsonWeaponCamo.h" +#include "Weapon/CamoCommon.h" #include #include using namespace nlohmann; using namespace T6; +using namespace ::camo; namespace { - class JsonDumper + class JsonDumperImpl { public: - explicit JsonDumper(std::ostream& stream) + explicit JsonDumperImpl(std::ostream& stream) : m_stream(stream) { } @@ -101,11 +103,22 @@ namespace }; } // namespace -namespace T6 +namespace T6::camo { - void DumpWeaponCamoAsJson(std::ostream& stream, const WeaponCamo* weaponCamo) + bool JsonDumper::ShouldDump(XAssetInfo* asset) { - const JsonDumper dumper(stream); - dumper.Dump(weaponCamo); + return true; } -} // namespace T6 + + void JsonDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto fileName = GetJsonFileNameForAssetName(asset->m_name); + const auto assetFile = context.OpenAssetFile(fileName); + + if (!assetFile) + return; + + const JsonDumperImpl dumper(*assetFile); + dumper.Dump(asset->Asset()); + } +} // namespace T6::camo diff --git a/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponCamo.h b/src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.h similarity index 70% rename from src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponCamo.h rename to src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.h index 36b2df92..e7c316e0 100644 --- a/src/ObjWriting/Game/T6/Weapon/AssetDumperWeaponCamo.h +++ b/src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6 +namespace T6::camo { - class AssetDumperWeaponCamo final : public AbstractAssetDumper + class JsonDumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6 +} // namespace T6::camo diff --git a/src/ObjWriting/Game/T6/Weapon/JsonWeaponCamoWriter.h b/src/ObjWriting/Game/T6/Weapon/JsonWeaponCamoWriter.h deleted file mode 100644 index 0da45568..00000000 --- a/src/ObjWriting/Game/T6/Weapon/JsonWeaponCamoWriter.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "Dumping/AssetDumpingContext.h" -#include "Game/T6/T6.h" - -#include - -namespace T6 -{ - void DumpWeaponCamoAsJson(std::ostream& stream, const WeaponCamo* weaponCamo); -} // namespace T6 diff --git a/src/ObjWriting/Game/T6/Weapon/AssetDumperWeapon.cpp b/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.cpp similarity index 53% rename from src/ObjWriting/Game/T6/Weapon/AssetDumperWeapon.cpp rename to src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.cpp index 24223dc4..96ad8700 100644 --- a/src/ObjWriting/Game/T6/Weapon/AssetDumperWeapon.cpp +++ b/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.cpp @@ -1,10 +1,12 @@ -#include "AssetDumperWeapon.h" +#include "WeaponDumperT6.h" #include "Game/T6/InfoString/InfoStringFromStructConverter.h" #include "Game/T6/ObjConstantsT6.h" #include "Game/T6/Weapon/WeaponFields.h" #include "Game/T6/Weapon/WeaponStrings.h" +#include "InfoString/InfoString.h" #include "Weapon/AccuracyGraphWriter.h" +#include "Weapon/WeaponCommon.h" #include #include @@ -12,8 +14,9 @@ #include using namespace T6; +using namespace ::weapon; -namespace T6 +namespace { class InfoStringFromWeaponConverter final : public InfoStringFromStructConverter { @@ -281,208 +284,212 @@ namespace T6 return graph; } -} // namespace T6 -void AssetDumperWeapon::CopyToFullDef(const WeaponVariantDef* weapon, WeaponFullDef* fullDef) -{ - fullDef->weapVariantDef = *weapon; - - if (weapon->weapDef) + void CopyToFullDef(const WeaponVariantDef* weapon, WeaponFullDef* fullDef) { - fullDef->weapDef = *weapon->weapDef; - fullDef->weapVariantDef.weapDef = &fullDef->weapDef; + fullDef->weapVariantDef = *weapon; + + if (weapon->weapDef) + { + fullDef->weapDef = *weapon->weapDef; + fullDef->weapVariantDef.weapDef = &fullDef->weapDef; + } + + if (weapon->attachments) + { + assert(sizeof(WeaponFullDef::attachments) >= sizeof(void*) * std::extent_v); + memcpy(fullDef->attachments, weapon->attachments, sizeof(void*) * std::extent_v); + fullDef->weapVariantDef.attachments = fullDef->attachments; + } + + if (weapon->attachmentUniques) + { + assert(sizeof(WeaponFullDef::attachmentUniques) >= sizeof(void*) * std::extent_v); + memcpy(fullDef->attachmentUniques, weapon->attachmentUniques, sizeof(void*) * std::extent_v); + fullDef->weapVariantDef.attachmentUniques = fullDef->attachmentUniques; + } + + if (fullDef->weapDef.gunXModel) + { + assert(sizeof(WeaponFullDef::gunXModel) >= sizeof(void*) * std::extent_v); + memcpy(fullDef->gunXModel, fullDef->weapDef.gunXModel, sizeof(void*) * std::extent_v); + fullDef->weapDef.gunXModel = fullDef->gunXModel; + } + + if (weapon->szXAnims) + { + assert(sizeof(WeaponFullDef::szXAnims) >= sizeof(void*) * NUM_WEAP_ANIMS); + memcpy(fullDef->szXAnims, weapon->szXAnims, sizeof(void*) * NUM_WEAP_ANIMS); + fullDef->weapVariantDef.szXAnims = fullDef->szXAnims; + } + + if (weapon->hideTags) + { + assert(sizeof(WeaponFullDef::hideTags) >= sizeof(scr_string_t) * std::extent_v); + memcpy(fullDef->hideTags, weapon->hideTags, sizeof(scr_string_t) * std::extent_v); + fullDef->weapVariantDef.hideTags = fullDef->hideTags; + } + + if (fullDef->weapDef.notetrackSoundMapKeys) + { + assert(sizeof(WeaponFullDef::notetrackSoundMapKeys) >= sizeof(scr_string_t) * std::extent_v); + memcpy(fullDef->notetrackSoundMapKeys, + fullDef->weapDef.notetrackSoundMapKeys, + sizeof(scr_string_t) * std::extent_v); + fullDef->weapDef.notetrackSoundMapKeys = fullDef->notetrackSoundMapKeys; + } + + if (fullDef->weapDef.notetrackSoundMapValues) + { + assert(sizeof(WeaponFullDef::notetrackSoundMapValues) >= sizeof(scr_string_t) * std::extent_v); + memcpy(fullDef->notetrackSoundMapValues, + fullDef->weapDef.notetrackSoundMapValues, + sizeof(scr_string_t) * std::extent_v); + fullDef->weapDef.notetrackSoundMapValues = fullDef->notetrackSoundMapValues; + } + + if (fullDef->weapDef.worldModel) + { + assert(sizeof(WeaponFullDef::worldModel) >= sizeof(void*) * std::extent_v); + memcpy(fullDef->worldModel, fullDef->weapDef.worldModel, sizeof(void*) * std::extent_v); + fullDef->weapDef.worldModel = fullDef->worldModel; + } + + if (weapon->attachViewModel) + { + assert(sizeof(WeaponFullDef::attachViewModel) >= sizeof(void*) * std::extent_v); + memcpy(fullDef->attachViewModel, weapon->attachViewModel, sizeof(void*) * std::extent_v); + fullDef->weapVariantDef.attachViewModel = fullDef->attachViewModel; + } + + if (weapon->attachWorldModel) + { + assert(sizeof(WeaponFullDef::attachWorldModel) >= sizeof(void*) * std::extent_v); + memcpy(fullDef->attachWorldModel, weapon->attachWorldModel, sizeof(void*) * std::extent_v); + fullDef->weapVariantDef.attachWorldModel = fullDef->attachWorldModel; + } + + if (weapon->attachViewModelTag) + { + assert(sizeof(WeaponFullDef::attachViewModelTag) >= sizeof(void*) * std::extent_v); + memcpy(fullDef->attachViewModelTag, weapon->attachViewModelTag, sizeof(void*) * std::extent_v); + fullDef->weapVariantDef.attachViewModelTag = fullDef->attachViewModelTag; + } + + if (weapon->attachWorldModelTag) + { + assert(sizeof(WeaponFullDef::attachWorldModelTag) >= sizeof(void*) * std::extent_v); + memcpy(fullDef->attachWorldModelTag, weapon->attachWorldModelTag, sizeof(void*) * std::extent_v); + fullDef->weapVariantDef.attachWorldModelTag = fullDef->attachWorldModelTag; + } + + if (fullDef->weapDef.parallelBounce) + { + assert(sizeof(WeaponFullDef::parallelBounce) >= sizeof(float) * SURF_TYPE_NUM); + memcpy(fullDef->parallelBounce, fullDef->weapDef.parallelBounce, sizeof(float) * SURF_TYPE_NUM); + fullDef->weapDef.parallelBounce = fullDef->parallelBounce; + } + + if (fullDef->weapDef.perpendicularBounce) + { + assert(sizeof(WeaponFullDef::perpendicularBounce) >= sizeof(float) * SURF_TYPE_NUM); + memcpy(fullDef->perpendicularBounce, fullDef->weapDef.perpendicularBounce, sizeof(float) * SURF_TYPE_NUM); + fullDef->weapDef.perpendicularBounce = fullDef->perpendicularBounce; + } + + if (fullDef->weapDef.locationDamageMultipliers) + { + assert(sizeof(WeaponFullDef::locationDamageMultipliers) >= sizeof(float) * HITLOC_COUNT); + memcpy(fullDef->locationDamageMultipliers, fullDef->weapDef.locationDamageMultipliers, sizeof(float) * HITLOC_COUNT); + fullDef->weapDef.locationDamageMultipliers = fullDef->locationDamageMultipliers; + } + + if (fullDef->weapDef.weaponCamo && fullDef->weapDef.weaponCamo->name) + { + strncpy(fullDef->weaponCamo, fullDef->weapDef.weaponCamo->name, std::extent_v); + } } - if (weapon->attachments) + InfoString CreateInfoString(XAssetInfo* asset) { - assert(sizeof(WeaponFullDef::attachments) >= sizeof(void*) * std::extent_v); - memcpy(fullDef->attachments, weapon->attachments, sizeof(void*) * std::extent_v); - fullDef->weapVariantDef.attachments = fullDef->attachments; + const auto fullDef = std::make_unique(); + memset(fullDef.get(), 0, sizeof(WeaponFullDef)); + CopyToFullDef(asset->Asset(), fullDef.get()); + + InfoStringFromWeaponConverter converter(fullDef.get(), + weapon_fields, + std::extent_v, + [asset](const scr_string_t scrStr) -> std::string + { + assert(scrStr < asset->m_zone->m_script_strings.Count()); + if (scrStr >= asset->m_zone->m_script_strings.Count()) + return ""; + + return asset->m_zone->m_script_strings[scrStr]; + }); + + return converter.Convert(); } - if (weapon->attachmentUniques) + void DumpAccuracyGraphs(AssetDumpingContext& context, XAssetInfo* asset) { - assert(sizeof(WeaponFullDef::attachmentUniques) >= sizeof(void*) * std::extent_v); - memcpy(fullDef->attachmentUniques, weapon->attachmentUniques, sizeof(void*) * std::extent_v); - fullDef->weapVariantDef.attachmentUniques = fullDef->attachmentUniques; - } + auto* accuracyGraphWriter = context.GetZoneAssetDumperState(); + const auto weapon = asset->Asset(); + const auto* weapDef = weapon->weapDef; - if (fullDef->weapDef.gunXModel) - { - assert(sizeof(WeaponFullDef::gunXModel) >= sizeof(void*) * std::extent_v); - memcpy(fullDef->gunXModel, fullDef->weapDef.gunXModel, sizeof(void*) * std::extent_v); - fullDef->weapDef.gunXModel = fullDef->gunXModel; - } - - if (weapon->szXAnims) - { - assert(sizeof(WeaponFullDef::szXAnims) >= sizeof(void*) * NUM_WEAP_ANIMS); - memcpy(fullDef->szXAnims, weapon->szXAnims, sizeof(void*) * NUM_WEAP_ANIMS); - fullDef->weapVariantDef.szXAnims = fullDef->szXAnims; - } - - if (weapon->hideTags) - { - assert(sizeof(WeaponFullDef::hideTags) >= sizeof(scr_string_t) * std::extent_v); - memcpy(fullDef->hideTags, weapon->hideTags, sizeof(scr_string_t) * std::extent_v); - fullDef->weapVariantDef.hideTags = fullDef->hideTags; - } - - if (fullDef->weapDef.notetrackSoundMapKeys) - { - assert(sizeof(WeaponFullDef::notetrackSoundMapKeys) >= sizeof(scr_string_t) * std::extent_v); - memcpy(fullDef->notetrackSoundMapKeys, - fullDef->weapDef.notetrackSoundMapKeys, - sizeof(scr_string_t) * std::extent_v); - fullDef->weapDef.notetrackSoundMapKeys = fullDef->notetrackSoundMapKeys; - } - - if (fullDef->weapDef.notetrackSoundMapValues) - { - assert(sizeof(WeaponFullDef::notetrackSoundMapValues) >= sizeof(scr_string_t) * std::extent_v); - memcpy(fullDef->notetrackSoundMapValues, - fullDef->weapDef.notetrackSoundMapValues, - sizeof(scr_string_t) * std::extent_v); - fullDef->weapDef.notetrackSoundMapValues = fullDef->notetrackSoundMapValues; - } - - if (fullDef->weapDef.worldModel) - { - assert(sizeof(WeaponFullDef::worldModel) >= sizeof(void*) * std::extent_v); - memcpy(fullDef->worldModel, fullDef->weapDef.worldModel, sizeof(void*) * std::extent_v); - fullDef->weapDef.worldModel = fullDef->worldModel; - } - - if (weapon->attachViewModel) - { - assert(sizeof(WeaponFullDef::attachViewModel) >= sizeof(void*) * std::extent_v); - memcpy(fullDef->attachViewModel, weapon->attachViewModel, sizeof(void*) * std::extent_v); - fullDef->weapVariantDef.attachViewModel = fullDef->attachViewModel; - } - - if (weapon->attachWorldModel) - { - assert(sizeof(WeaponFullDef::attachWorldModel) >= sizeof(void*) * std::extent_v); - memcpy(fullDef->attachWorldModel, weapon->attachWorldModel, sizeof(void*) * std::extent_v); - fullDef->weapVariantDef.attachWorldModel = fullDef->attachWorldModel; - } - - if (weapon->attachViewModelTag) - { - assert(sizeof(WeaponFullDef::attachViewModelTag) >= sizeof(void*) * std::extent_v); - memcpy(fullDef->attachViewModelTag, weapon->attachViewModelTag, sizeof(void*) * std::extent_v); - fullDef->weapVariantDef.attachViewModelTag = fullDef->attachViewModelTag; - } - - if (weapon->attachWorldModelTag) - { - assert(sizeof(WeaponFullDef::attachWorldModelTag) >= sizeof(void*) * std::extent_v); - memcpy(fullDef->attachWorldModelTag, weapon->attachWorldModelTag, sizeof(void*) * std::extent_v); - fullDef->weapVariantDef.attachWorldModelTag = fullDef->attachWorldModelTag; - } - - if (fullDef->weapDef.parallelBounce) - { - assert(sizeof(WeaponFullDef::parallelBounce) >= sizeof(float) * SURF_TYPE_NUM); - memcpy(fullDef->parallelBounce, fullDef->weapDef.parallelBounce, sizeof(float) * SURF_TYPE_NUM); - fullDef->weapDef.parallelBounce = fullDef->parallelBounce; - } - - if (fullDef->weapDef.perpendicularBounce) - { - assert(sizeof(WeaponFullDef::perpendicularBounce) >= sizeof(float) * SURF_TYPE_NUM); - memcpy(fullDef->perpendicularBounce, fullDef->weapDef.perpendicularBounce, sizeof(float) * SURF_TYPE_NUM); - fullDef->weapDef.perpendicularBounce = fullDef->perpendicularBounce; - } - - if (fullDef->weapDef.locationDamageMultipliers) - { - assert(sizeof(WeaponFullDef::locationDamageMultipliers) >= sizeof(float) * HITLOC_COUNT); - memcpy(fullDef->locationDamageMultipliers, fullDef->weapDef.locationDamageMultipliers, sizeof(float) * HITLOC_COUNT); - fullDef->weapDef.locationDamageMultipliers = fullDef->locationDamageMultipliers; - } - - if (fullDef->weapDef.weaponCamo && fullDef->weapDef.weaponCamo->name) - { - strncpy(fullDef->weaponCamo, fullDef->weapDef.weaponCamo->name, std::extent_v); - } -} - -InfoString AssetDumperWeapon::CreateInfoString(XAssetInfo* asset) -{ - const auto fullDef = std::make_unique(); - memset(fullDef.get(), 0, sizeof(WeaponFullDef)); - CopyToFullDef(asset->Asset(), fullDef.get()); - - InfoStringFromWeaponConverter converter(fullDef.get(), - weapon_fields, - std::extent_v, - [asset](const scr_string_t scrStr) -> std::string - { - assert(scrStr < asset->m_zone->m_script_strings.Count()); - if (scrStr >= asset->m_zone->m_script_strings.Count()) - return ""; - - return asset->m_zone->m_script_strings[scrStr]; - }); - - return converter.Convert(); -} - -void AssetDumperWeapon::DumpAccuracyGraphs(AssetDumpingContext& context, XAssetInfo* asset) -{ - auto* accuracyGraphWriter = context.GetZoneAssetDumperState(); - const auto weapon = asset->Asset(); - const auto* weapDef = weapon->weapDef; - - if (!weapDef) - return; - - if (weapDef->aiVsAiAccuracyGraphName && weapDef->originalAiVsAiAccuracyGraphKnots - && accuracyGraphWriter->ShouldDumpAiVsAiGraph(weapDef->aiVsAiAccuracyGraphName)) - { - AccuracyGraphWriter::DumpAiVsAiGraph( - context, - ConvertAccuracyGraph(weapDef->aiVsAiAccuracyGraphName, weapDef->originalAiVsAiAccuracyGraphKnots, weapDef->originalAiVsAiAccuracyGraphKnotCount)); - } - - if (weapDef->aiVsPlayerAccuracyGraphName && weapDef->originalAiVsPlayerAccuracyGraphKnots - && accuracyGraphWriter->ShouldDumpAiVsPlayerGraph(weapDef->aiVsPlayerAccuracyGraphName)) - { - AccuracyGraphWriter::DumpAiVsPlayerGraph(context, - ConvertAccuracyGraph(weapDef->aiVsPlayerAccuracyGraphName, - weapDef->originalAiVsPlayerAccuracyGraphKnots, - weapDef->originalAiVsPlayerAccuracyGraphKnotCount)); - } -} - -bool AssetDumperWeapon::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperWeapon::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - // Only dump raw when no gdt available - if (context.m_gdt) - { - const auto infoString = CreateInfoString(asset); - GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_WEAPON); - infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_WEAPON, gdtEntry); - context.m_gdt->WriteEntry(gdtEntry); - } - else - { - const auto assetFile = context.OpenAssetFile("weapons/" + asset->m_name); - - if (!assetFile) + if (!weapDef) return; - auto& stream = *assetFile; - const auto infoString = CreateInfoString(asset); - const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_WEAPON); - stream.write(stringValue.c_str(), stringValue.size()); + if (weapDef->aiVsAiAccuracyGraphName && weapDef->originalAiVsAiAccuracyGraphKnots + && accuracyGraphWriter->ShouldDumpAiVsAiGraph(weapDef->aiVsAiAccuracyGraphName)) + { + AccuracyGraphWriter::DumpAiVsAiGraph(context, + ConvertAccuracyGraph(weapDef->aiVsAiAccuracyGraphName, + weapDef->originalAiVsAiAccuracyGraphKnots, + weapDef->originalAiVsAiAccuracyGraphKnotCount)); + } + + if (weapDef->aiVsPlayerAccuracyGraphName && weapDef->originalAiVsPlayerAccuracyGraphKnots + && accuracyGraphWriter->ShouldDumpAiVsPlayerGraph(weapDef->aiVsPlayerAccuracyGraphName)) + { + AccuracyGraphWriter::DumpAiVsPlayerGraph(context, + ConvertAccuracyGraph(weapDef->aiVsPlayerAccuracyGraphName, + weapDef->originalAiVsPlayerAccuracyGraphKnots, + weapDef->originalAiVsPlayerAccuracyGraphKnotCount)); + } + } +} // namespace + +namespace T6::weapon +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; } - DumpAccuracyGraphs(context, asset); -} + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + // Only dump raw when no gdt available + if (context.m_gdt) + { + const auto infoString = CreateInfoString(asset); + GdtEntry gdtEntry(asset->m_name, ObjConstants::GDF_FILENAME_WEAPON); + infoString.ToGdtProperties(ObjConstants::INFO_STRING_PREFIX_WEAPON, gdtEntry); + context.m_gdt->WriteEntry(gdtEntry); + } + else + { + const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name)); + + if (!assetFile) + return; + + auto& stream = *assetFile; + const auto infoString = CreateInfoString(asset); + const auto stringValue = infoString.ToString(ObjConstants::INFO_STRING_PREFIX_WEAPON); + stream.write(stringValue.c_str(), stringValue.size()); + } + + DumpAccuracyGraphs(context, asset); + } +} // namespace T6::weapon diff --git a/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.h b/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.h new file mode 100644 index 00000000..15ac83b6 --- /dev/null +++ b/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.h @@ -0,0 +1,14 @@ +#pragma once + +#include "Dumping/AbstractAssetDumper.h" +#include "Game/T6/T6.h" + +namespace T6::weapon +{ + class Dumper final : public AbstractAssetDumper + { + protected: + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + }; +} // namespace T6::weapon From 250556ab610a43dd64d1a2937a9f64004af5ab72 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Sun, 3 Aug 2025 17:47:21 +0200 Subject: [PATCH 22/35] refactor: streamline namespaces of xmodel dumping and loading --- src/ObjCommon/XModel/XModelCommon.cpp | 9 +++++++++ src/ObjCommon/XModel/XModelCommon.h | 5 +++++ src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp | 3 ++- src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp | 2 +- src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp | 2 +- src/ObjLoading/Game/T5/ObjLoaderT5.cpp | 2 +- src/ObjLoading/Game/T6/ObjLoaderT6.cpp | 2 +- src/ObjLoading/XModel/LoaderXModel.cpp.template | 2 +- src/ObjLoading/XModel/LoaderXModel.h.template | 2 +- src/ObjWriting/Game/IW3/ObjWriterIW3.cpp | 2 +- src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 2 +- src/ObjWriting/Game/IW5/ObjWriterIW5.cpp | 2 +- src/ObjWriting/Game/T5/ObjWriterT5.cpp | 2 +- src/ObjWriting/Game/T6/ObjWriterT6.cpp | 2 +- src/ObjWriting/XModel/XModelDumper.cpp.template | 16 ++++++++++------ src/ObjWriting/XModel/XModelDumper.h.template | 4 ++-- 16 files changed, 39 insertions(+), 20 deletions(-) diff --git a/src/ObjCommon/XModel/XModelCommon.cpp b/src/ObjCommon/XModel/XModelCommon.cpp index a3cfb586..f44e7165 100644 --- a/src/ObjCommon/XModel/XModelCommon.cpp +++ b/src/ObjCommon/XModel/XModelCommon.cpp @@ -1,6 +1,7 @@ #include "XModelCommon.h" #include +#include #include #include @@ -99,3 +100,11 @@ bool operator<(const VertexMergerPos& lhs, const VertexMergerPos& rhs) return false; } + +namespace xmodel +{ + std::string GetJsonFileNameForAssetName(const std::string& assetName) + { + return std::format("xmodel/{}.json", assetName); + } +} // namespace xmodel diff --git a/src/ObjCommon/XModel/XModelCommon.h b/src/ObjCommon/XModel/XModelCommon.h index 2caf68b3..c5f0843c 100644 --- a/src/ObjCommon/XModel/XModelCommon.h +++ b/src/ObjCommon/XModel/XModelCommon.h @@ -127,3 +127,8 @@ struct VertexMergerPos }; typedef DistinctMapper VertexMerger; + +namespace xmodel +{ + std::string GetJsonFileNameForAssetName(const std::string& assetName); +} diff --git a/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp b/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp index 9c2ef22f..c1c5c512 100644 --- a/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp +++ b/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp @@ -3,6 +3,7 @@ #include "Asset/GlobalAssetPoolsLoader.h" #include "Game/IW3/GameIW3.h" #include "Game/IW3/IW3.h" +#include "Game/IW3/XModel/LoaderXModelIW3.h" #include "Image/AssetLoaderImageIW3.h" #include "Localize/AssetLoaderLocalizeIW3.h" #include "Material/LoaderMaterialIW3.h" @@ -90,7 +91,7 @@ namespace // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - // collection.AddAssetCreator(std::make_unique(memory)); + collection.AddAssetCreator(xmodel::CreateXModelLoader(memory, searchPath, zone)); collection.AddAssetCreator(CreateMaterialLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); collection.AddAssetCreator(CreateImageLoader(memory, searchPath)); diff --git a/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp b/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp index 1fc97241..118861ab 100644 --- a/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp +++ b/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp @@ -124,7 +124,7 @@ namespace // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateXModelLoader(memory, searchPath, zone)); + collection.AddAssetCreator(xmodel::CreateXModelLoader(memory, searchPath, zone)); collection.AddAssetCreator(CreateMaterialLoader(memory, searchPath)); collection.AddAssetCreator(CreatePixelShaderLoader(memory, searchPath)); collection.AddAssetCreator(CreateVertexShaderLoader(memory, searchPath)); diff --git a/src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp b/src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp index 4755450f..5f254899 100644 --- a/src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp +++ b/src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp @@ -125,7 +125,7 @@ namespace // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateXModelLoader(memory, searchPath, zone)); + collection.AddAssetCreator(xmodel::CreateXModelLoader(memory, searchPath, zone)); collection.AddAssetCreator(CreateMaterialLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); diff --git a/src/ObjLoading/Game/T5/ObjLoaderT5.cpp b/src/ObjLoading/Game/T5/ObjLoaderT5.cpp index f877d17c..83238561 100644 --- a/src/ObjLoading/Game/T5/ObjLoaderT5.cpp +++ b/src/ObjLoading/Game/T5/ObjLoaderT5.cpp @@ -104,7 +104,7 @@ namespace // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateXModelLoader(memory, searchPath, zone)); + collection.AddAssetCreator(xmodel::CreateXModelLoader(memory, searchPath, zone)); collection.AddAssetCreator(CreateMaterialLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); diff --git a/src/ObjLoading/Game/T6/ObjLoaderT6.cpp b/src/ObjLoading/Game/T6/ObjLoaderT6.cpp index 7232c923..6aa2d966 100644 --- a/src/ObjLoading/Game/T6/ObjLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/ObjLoaderT6.cpp @@ -399,7 +399,7 @@ namespace T6 collection.AddAssetCreator(CreateGdtPhysConstraintsLoader(memory, searchPath, gdt, zone)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateXModelLoader(memory, searchPath, zone)); + collection.AddAssetCreator(xmodel::CreateXModelLoader(memory, searchPath, zone)); collection.AddAssetCreator(CreateMaterialLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); collection.AddAssetCreator(CreateImageLoader(memory, searchPath)); diff --git a/src/ObjLoading/XModel/LoaderXModel.cpp.template b/src/ObjLoading/XModel/LoaderXModel.cpp.template index 493bfc80..08243114 100644 --- a/src/ObjLoading/XModel/LoaderXModel.cpp.template +++ b/src/ObjLoading/XModel/LoaderXModel.cpp.template @@ -1082,7 +1082,7 @@ namespace }; } // namespace -namespace GAME +namespace GAME::xmodel { std::unique_ptr> CreateXModelLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { diff --git a/src/ObjLoading/XModel/LoaderXModel.h.template b/src/ObjLoading/XModel/LoaderXModel.h.template index 4d296a58..20590a8b 100644 --- a/src/ObjLoading/XModel/LoaderXModel.h.template +++ b/src/ObjLoading/XModel/LoaderXModel.h.template @@ -13,7 +13,7 @@ #include -namespace GAME +namespace GAME::xmodel { std::unique_ptr> CreateXModelLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); } // namespace GAME diff --git a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp index 8e840474..59cd7a00 100644 --- a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp +++ b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp @@ -26,7 +26,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset, ASSET_TYPE_PHYSPRESET) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) - DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) + DUMP_ASSET_POOL(xmodel::Dumper, m_xmodel, ASSET_TYPE_XMODEL) DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) // DUMP_ASSET_POOL(AssetDumperMaterialTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 4ab99c42..6fbe38da 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -42,7 +42,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(phys_preset::InfoStringDumper, m_phys_preset, ASSET_TYPE_PHYSPRESET) DUMP_ASSET_POOL(AssetDumperPhysCollmap, m_phys_collmap, ASSET_TYPE_PHYSCOLLMAP) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) - DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) + DUMP_ASSET_POOL(xmodel::Dumper, m_xmodel, ASSET_TYPE_XMODEL) DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) #ifdef EXPERIMENTAL_MATERIAL_COMPILATION DUMP_ASSET_POOL(material::DecompilingGdtDumper, m_material, ASSET_TYPE_MATERIAL) diff --git a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp index 8ed1bf82..28ea516a 100644 --- a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp +++ b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp @@ -33,7 +33,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperPhysCollmap, m_phys_collmap, ASSET_TYPE_PHYSCOLLMAP) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) // DUMP_ASSET_POOL(AssetDumperXModelSurfs, m_xmodel_surfs, ASSET_TYPE_XMODEL_SURFS) - DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) + DUMP_ASSET_POOL(xmodel::Dumper, m_xmodel, ASSET_TYPE_XMODEL) DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) // DUMP_ASSET_POOL(AssetDumperMaterialPixelShader, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER) // DUMP_ASSET_POOL(AssetDumperMaterialVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER) diff --git a/src/ObjWriting/Game/T5/ObjWriterT5.cpp b/src/ObjWriting/Game/T5/ObjWriterT5.cpp index 5d1ff986..2c5a3a2e 100644 --- a/src/ObjWriting/Game/T5/ObjWriterT5.cpp +++ b/src/ObjWriting/Game/T5/ObjWriterT5.cpp @@ -26,7 +26,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperPhysConstraints, m_phys_constraints, ASSET_TYPE_PHYSCONSTRAINTS) // DUMP_ASSET_POOL(AssetDumperDestructibleDef, m_destructible_def, ASSET_TYPE_DESTRUCTIBLEDEF) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) - DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) + DUMP_ASSET_POOL(xmodel::Dumper, m_xmodel, ASSET_TYPE_XMODEL) DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) // DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index f198725b..1b28dba0 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -50,7 +50,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(phys_constraints::InfoStringDumper, m_phys_constraints, ASSET_TYPE_PHYSCONSTRAINTS) // DUMP_ASSET_POOL(AssetDumperDestructibleDef, m_destructible_def, ASSET_TYPE_DESTRUCTIBLEDEF) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) - DUMP_ASSET_POOL(AssetDumperXModel, m_xmodel, ASSET_TYPE_XMODEL) + DUMP_ASSET_POOL(xmodel::Dumper, m_xmodel, ASSET_TYPE_XMODEL) DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) DUMP_ASSET_POOL(techset::Dumper, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) diff --git a/src/ObjWriting/XModel/XModelDumper.cpp.template b/src/ObjWriting/XModel/XModelDumper.cpp.template index f8fcb3ab..f4eabbc6 100644 --- a/src/ObjWriting/XModel/XModelDumper.cpp.template +++ b/src/ObjWriting/XModel/XModelDumper.cpp.template @@ -47,6 +47,7 @@ #include using namespace GAME; +using namespace ::xmodel; namespace { @@ -830,7 +831,7 @@ namespace void DumpXModelJson(AssetDumpingContext& context, XAssetInfo* asset) { - const auto assetFile = context.OpenAssetFile(std::format("xmodel/{}.json", asset->m_name)); + const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAssetName(asset->m_name)); if (!assetFile) return; @@ -839,13 +840,16 @@ namespace } } // namespace -bool AssetDumperXModel::ShouldDump(XAssetInfo* asset) +namespace GAME::xmodel { - return !asset->m_name.empty() && asset->m_name[0] != ','; -} + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return !asset->m_name.empty() && asset->m_name[0] != ','; + } -void AssetDumperXModel::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { DumpXModelJson(context, asset); DumpXModelSurfs(context, asset); + } } diff --git a/src/ObjWriting/XModel/XModelDumper.h.template b/src/ObjWriting/XModel/XModelDumper.h.template index 0a758303..81d5a34c 100644 --- a/src/ObjWriting/XModel/XModelDumper.h.template +++ b/src/ObjWriting/XModel/XModelDumper.h.template @@ -13,9 +13,9 @@ #include "Dumping/AbstractAssetDumper.h" #include GAME_HEADER -namespace GAME +namespace GAME::xmodel { - class AssetDumperXModel final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; From a442d2e49e3523558a32ae47c6df2f37398c44b1 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Sun, 3 Aug 2025 19:53:30 +0200 Subject: [PATCH 23/35] refactor: streamline menu dumping --- .../Game/IW4/Menu/AssetDumperMenuDef.cpp | 53 - .../Game/IW4/Menu/AssetDumperMenuDef.h | 17 - .../Game/IW4/Menu/AssetDumperMenuList.cpp | 179 ---- .../Game/IW4/Menu/AssetDumperMenuList.h | 27 - .../Game/IW4/Menu/MenuDumperIW4.cpp | 943 +---------------- src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.h | 58 +- .../Game/IW4/Menu/MenuListDumperIW4.cpp | 187 ++++ .../Game/IW4/Menu/MenuListDumperIW4.h | 21 + .../Game/IW4/Menu/MenuWriterIW4.cpp | 957 ++++++++++++++++++ src/ObjWriting/Game/IW4/Menu/MenuWriterIW4.h | 19 + src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 8 +- .../Game/IW5/Menu/AssetDumperMenuDef.cpp | 76 -- .../Game/IW5/Menu/AssetDumperMenuDef.h | 17 - .../Game/IW5/Menu/AssetDumperMenuList.cpp | 128 --- .../Game/IW5/Menu/AssetDumperMenuList.h | 20 - .../Game/IW5/Menu/MenuDumperIW5.cpp | 949 +---------------- src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.h | 58 +- .../Game/IW5/Menu/MenuListDumperIW5.cpp | 133 +++ .../Game/IW5/Menu/MenuListDumperIW5.h | 14 + .../Game/IW5/Menu/MenuWriterIW5.cpp | 957 ++++++++++++++++++ src/ObjWriting/Game/IW5/Menu/MenuWriterIW5.h | 19 + src/ObjWriting/Game/IW5/ObjWriterIW5.cpp | 8 +- src/ObjWriting/Menu/AbstractMenuDumper.cpp | 298 ------ src/ObjWriting/Menu/AbstractMenuDumper.h | 53 - src/ObjWriting/Menu/AbstractMenuWriter.cpp | 301 ++++++ src/ObjWriting/Menu/AbstractMenuWriter.h | 59 ++ src/ObjWriting/Menu/IMenuWriter.h | 18 + 27 files changed, 2805 insertions(+), 2772 deletions(-) delete mode 100644 src/ObjWriting/Game/IW4/Menu/AssetDumperMenuDef.cpp delete mode 100644 src/ObjWriting/Game/IW4/Menu/AssetDumperMenuDef.h delete mode 100644 src/ObjWriting/Game/IW4/Menu/AssetDumperMenuList.cpp delete mode 100644 src/ObjWriting/Game/IW4/Menu/AssetDumperMenuList.h create mode 100644 src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.cpp create mode 100644 src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.h create mode 100644 src/ObjWriting/Game/IW4/Menu/MenuWriterIW4.cpp create mode 100644 src/ObjWriting/Game/IW4/Menu/MenuWriterIW4.h delete mode 100644 src/ObjWriting/Game/IW5/Menu/AssetDumperMenuDef.cpp delete mode 100644 src/ObjWriting/Game/IW5/Menu/AssetDumperMenuDef.h delete mode 100644 src/ObjWriting/Game/IW5/Menu/AssetDumperMenuList.cpp delete mode 100644 src/ObjWriting/Game/IW5/Menu/AssetDumperMenuList.h create mode 100644 src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.cpp create mode 100644 src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.h create mode 100644 src/ObjWriting/Game/IW5/Menu/MenuWriterIW5.cpp create mode 100644 src/ObjWriting/Game/IW5/Menu/MenuWriterIW5.h delete mode 100644 src/ObjWriting/Menu/AbstractMenuDumper.cpp delete mode 100644 src/ObjWriting/Menu/AbstractMenuDumper.h create mode 100644 src/ObjWriting/Menu/AbstractMenuWriter.cpp create mode 100644 src/ObjWriting/Menu/AbstractMenuWriter.h create mode 100644 src/ObjWriting/Menu/IMenuWriter.h diff --git a/src/ObjWriting/Game/IW4/Menu/AssetDumperMenuDef.cpp b/src/ObjWriting/Game/IW4/Menu/AssetDumperMenuDef.cpp deleted file mode 100644 index 4a90b9ad..00000000 --- a/src/ObjWriting/Game/IW4/Menu/AssetDumperMenuDef.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include "AssetDumperMenuDef.h" - -#include "AssetDumperMenuList.h" -#include "Game/IW4/GameAssetPoolIW4.h" -#include "Game/IW4/Menu/MenuDumperIW4.h" -#include "Menu/AbstractMenuDumper.h" -#include "ObjWriting.h" - -#include -#include - -using namespace IW4; - -std::string AssetDumperMenuDef::GetPathForMenu(menu::MenuDumpingZoneState* zoneState, XAssetInfo* asset) -{ - const auto menuDumpingState = zoneState->m_menu_dumping_state_map.find(asset->Asset()); - - if (menuDumpingState == zoneState->m_menu_dumping_state_map.end()) - return "ui_mp/" + std::string(asset->Asset()->window.name) + ".menu"; - - return menuDumpingState->second.m_path; -} - -bool AssetDumperMenuDef::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperMenuDef::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* menu = asset->Asset(); - auto* zoneState = context.GetZoneAssetDumperState(); - - if (!ObjWriting::ShouldHandleAssetType(ASSET_TYPE_MENULIST)) - { - // Make sure menu paths based on menu lists are created - const auto* gameAssetPool = dynamic_cast(asset->m_zone->m_pools.get()); - for (auto* menuListAsset : *gameAssetPool->m_menu_list) - AssetDumperMenuList::CreateDumpingStateForMenuList(zoneState, menuListAsset->Asset()); - } - - const auto menuFilePath = GetPathForMenu(zoneState, asset); - const auto assetFile = context.OpenAssetFile(menuFilePath); - - if (!assetFile) - return; - - MenuDumper menuDumper(*assetFile); - - menuDumper.Start(); - menuDumper.WriteMenu(menu); - menuDumper.End(); -} diff --git a/src/ObjWriting/Game/IW4/Menu/AssetDumperMenuDef.h b/src/ObjWriting/Game/IW4/Menu/AssetDumperMenuDef.h deleted file mode 100644 index fbebc2c6..00000000 --- a/src/ObjWriting/Game/IW4/Menu/AssetDumperMenuDef.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/IW4/IW4.h" -#include "Menu/MenuDumpingZoneState.h" - -namespace IW4 -{ - class AssetDumperMenuDef final : public AbstractAssetDumper - { - static std::string GetPathForMenu(menu::MenuDumpingZoneState* zoneState, XAssetInfo* asset); - - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace IW4 diff --git a/src/ObjWriting/Game/IW4/Menu/AssetDumperMenuList.cpp b/src/ObjWriting/Game/IW4/Menu/AssetDumperMenuList.cpp deleted file mode 100644 index 2c4c690d..00000000 --- a/src/ObjWriting/Game/IW4/Menu/AssetDumperMenuList.cpp +++ /dev/null @@ -1,179 +0,0 @@ -#include "AssetDumperMenuList.h" - -#include "Game/IW4/Menu/MenuDumperIW4.h" -#include "Menu/AbstractMenuDumper.h" -#include "ObjWriting.h" - -#include -#include -#include -#include - -namespace fs = std::filesystem; - -using namespace IW4; - -std::vector AssetDumperMenuList::GetAllUniqueExpressionSupportingData(const MenuList* menuList) -{ - std::vector result; - std::set alreadyAddedSupportingData; - - if (menuList->menus == nullptr) - return result; - - for (auto i = 0; i < menuList->menuCount; i++) - { - if (menuList->menus[i] == nullptr) - continue; - - const auto* menu = menuList->menus[i]; - - if (menu->expressionData == nullptr) - continue; - - if (alreadyAddedSupportingData.find(menu->expressionData) == alreadyAddedSupportingData.end()) - { - result.push_back(menu->expressionData); - alreadyAddedSupportingData.emplace(menu->expressionData); - } - } - - return result; -} - -void AssetDumperMenuList::DumpFunctions(MenuDumper& menuDumper, const MenuList* menuList) -{ - const auto allSupportingData = GetAllUniqueExpressionSupportingData(menuList); - auto functionIndex = 0u; - - assert(allSupportingData.size() <= 1); - - for (const auto* supportingData : allSupportingData) - { - if (supportingData->uifunctions.functions == nullptr) - continue; - - for (auto i = 0; i < supportingData->uifunctions.totalFunctions; i++) - { - const auto* function = supportingData->uifunctions.functions[i]; - if (function != nullptr) - { - std::stringstream ss; - ss << "FUNC_" << functionIndex; - - menuDumper.WriteFunctionDef(ss.str(), function); - } - - functionIndex++; - } - } -} - -void AssetDumperMenuList::DumpMenus(MenuDumper& menuDumper, menu::MenuDumpingZoneState* zoneState, const MenuList* menuList) -{ - for (auto menuNum = 0; menuNum < menuList->menuCount; menuNum++) - { - const auto* menu = menuList->menus[menuNum]; - - const auto menuDumpingState = zoneState->m_menu_dumping_state_map.find(menu); - if (menuDumpingState == zoneState->m_menu_dumping_state_map.end()) - continue; - - // If the menu was embedded directly as menu list write its data in the menu list file - if (menuDumpingState->second.m_alias_menu_list == menuList) - menuDumper.WriteMenu(menu); - else - menuDumper.IncludeMenu(menuDumpingState->second.m_path); - } -} - -bool AssetDumperMenuList::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperMenuList::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* menuList = asset->Asset(); - const auto assetFile = context.OpenAssetFile(asset->m_name); - - if (!assetFile) - return; - - auto* zoneState = context.GetZoneAssetDumperState(); - - MenuDumper menuDumper(*assetFile); - - menuDumper.Start(); - - if (!ObjWriting::Configuration.MenuLegacyMode) - DumpFunctions(menuDumper, menuList); - - DumpMenus(menuDumper, zoneState, menuList); - - menuDumper.End(); -} - -std::string AssetDumperMenuList::PathForMenu(const std::string& menuListParentPath, const menuDef_t* menu) -{ - const auto* menuAssetName = menu->window.name; - - if (!menuAssetName) - return ""; - - if (menuAssetName[0] == ',') - menuAssetName = &menuAssetName[1]; - - std::ostringstream ss; - ss << menuListParentPath << menuAssetName << ".menu"; - - return ss.str(); -} - -void AssetDumperMenuList::CreateDumpingStateForMenuList(menu::MenuDumpingZoneState* zoneState, const MenuList* menuList) -{ - if (menuList->menuCount <= 0 || menuList->menus == nullptr || menuList->name == nullptr) - return; - - const std::string menuListName(menuList->name); - const fs::path p(menuListName); - std::string parentPath; - if (p.has_parent_path()) - parentPath = p.parent_path().string() + "/"; - - for (auto i = 0; i < menuList->menuCount; i++) - { - auto* menu = menuList->menus[i]; - - if (menu == nullptr) - continue; - - auto existingState = zoneState->m_menu_dumping_state_map.find(menu); - if (existingState == zoneState->m_menu_dumping_state_map.end()) - { - auto menuPath = PathForMenu(parentPath, menu); - const auto isTheSameAsMenuList = menuPath == menuListName; - zoneState->CreateMenuDumpingState(menu, std::move(menuPath), isTheSameAsMenuList ? menuList : nullptr); - } - else if (existingState->second.m_alias_menu_list == nullptr) - { - auto menuPath = PathForMenu(parentPath, menu); - const auto isTheSameAsMenuList = menuPath == menuListName; - if (isTheSameAsMenuList) - { - existingState->second.m_alias_menu_list = menuList; - existingState->second.m_path = std::move(menuPath); - } - } - } -} - -void AssetDumperMenuList::DumpPool(AssetDumpingContext& context, AssetPool* pool) -{ - auto* zoneState = context.GetZoneAssetDumperState(); - - for (auto* asset : *pool) - CreateDumpingStateForMenuList(zoneState, asset->Asset()); - - AbstractAssetDumper::DumpPool(context, pool); -} diff --git a/src/ObjWriting/Game/IW4/Menu/AssetDumperMenuList.h b/src/ObjWriting/Game/IW4/Menu/AssetDumperMenuList.h deleted file mode 100644 index 2e368d7f..00000000 --- a/src/ObjWriting/Game/IW4/Menu/AssetDumperMenuList.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/IW4/IW4.h" -#include "Game/IW4/Menu/MenuDumperIW4.h" -#include "Menu/MenuDumpingZoneState.h" - -namespace IW4 -{ - class AssetDumperMenuList final : public AbstractAssetDumper - { - static std::vector GetAllUniqueExpressionSupportingData(const MenuList* menuList); - - static void DumpFunctions(MenuDumper& menuDumper, const MenuList* menuList); - static void DumpMenus(MenuDumper& menuDumper, menu::MenuDumpingZoneState* zoneState, const MenuList* menuList); - - static std::string PathForMenu(const std::string& menuListParentPath, const menuDef_t* menu); - - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - - public: - static void CreateDumpingStateForMenuList(menu::MenuDumpingZoneState* zoneState, const MenuList* menuList); - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; - }; -} // namespace IW4 diff --git a/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.cpp b/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.cpp index 5d65da59..995f1cf2 100644 --- a/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.cpp @@ -1,923 +1,60 @@ #include "MenuDumperIW4.h" -#include "Game/IW4/MenuConstantsIW4.h" +#include "Game/IW4/GameAssetPoolIW4.h" +#include "Game/IW4/Menu/MenuDumperIW4.h" +#include "MenuListDumperIW4.h" +#include "MenuWriterIW4.h" #include "ObjWriting.h" -#include -#include -#include +#include +#include using namespace IW4; +using namespace ::menu; -// Uncomment this macro to skip interpretative expression dumping -// #define DUMP_NAIVE - -#ifdef DUMP_NAIVE -#define DUMP_FUNC WriteStatementNaive -#else -#define DUMP_FUNC WriteStatementSkipInitialUnnecessaryParenthesis -#endif - -size_t MenuDumper::FindStatementClosingParenthesis(const Statement_s* statement, const size_t openingParenthesisPosition) +namespace { - assert(statement->numEntries >= 0); - assert(openingParenthesisPosition < static_cast(statement->numEntries)); - - const auto statementEnd = static_cast(statement->numEntries); - - // The openingParenthesisPosition does not necessarily point to an actual opening parenthesis operator. That's fine though. - // We will pretend it does since the game does sometimes leave out opening parenthesis from the entries. - auto currentParenthesisDepth = 1; - for (auto currentSearchPosition = openingParenthesisPosition + 1; currentSearchPosition < statementEnd; currentSearchPosition++) + std::string GetPathForMenu(MenuDumpingZoneState* zoneState, XAssetInfo* asset) { - const auto& expEntry = statement->entries[currentSearchPosition]; - if (expEntry.type != EET_OPERATOR) - continue; + const auto menuDumpingState = zoneState->m_menu_dumping_state_map.find(asset->Asset()); - // Any function means a "left out" left paren - if (expEntry.data.op == OP_LEFTPAREN || expEntry.data.op >= OP_COUNT) - { - currentParenthesisDepth++; - } - else if (expEntry.data.op == OP_RIGHTPAREN) - { - if (currentParenthesisDepth > 0) - currentParenthesisDepth--; - if (currentParenthesisDepth == 0) - return currentSearchPosition; - } + if (menuDumpingState == zoneState->m_menu_dumping_state_map.end()) + return "ui_mp/" + std::string(asset->Asset()->window.name) + ".menu"; + + return menuDumpingState->second.m_path; + } +} // namespace + +namespace IW4::menu +{ + bool MenuDumper::ShouldDump(XAssetInfo* asset) + { + return true; } - return statementEnd; -} - -void MenuDumper::WriteStatementOperator(const Statement_s* statement, size_t& currentPos, bool& spaceNext) const -{ - const auto& expEntry = statement->entries[currentPos]; - - if (spaceNext && expEntry.data.op != OP_COMMA) - m_stream << " "; - - if (expEntry.data.op == OP_LEFTPAREN) + void MenuDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { - const auto closingParenPos = FindStatementClosingParenthesis(statement, currentPos); - m_stream << "("; - WriteStatementEntryRange(statement, currentPos + 1, closingParenPos); - m_stream << ")"; + const auto* menu = asset->Asset(); + auto* zoneState = context.GetZoneAssetDumperState(); - currentPos = closingParenPos + 1; - spaceNext = true; - } - else if (expEntry.data.op >= EXP_FUNC_STATIC_DVAR_INT && expEntry.data.op <= EXP_FUNC_STATIC_DVAR_STRING) - { - switch (expEntry.data.op) + if (!ObjWriting::ShouldHandleAssetType(ASSET_TYPE_MENULIST)) { - case EXP_FUNC_STATIC_DVAR_INT: - m_stream << "dvarint"; - break; - - case EXP_FUNC_STATIC_DVAR_BOOL: - m_stream << "dvarbool"; - break; - - case EXP_FUNC_STATIC_DVAR_FLOAT: - m_stream << "dvarfloat"; - break; - - case EXP_FUNC_STATIC_DVAR_STRING: - m_stream << "dvarstring"; - break; - - default: - break; + // Make sure menu paths based on menu lists are created + const auto* gameAssetPool = dynamic_cast(asset->m_zone->m_pools.get()); + for (auto* menuListAsset : *gameAssetPool->m_menu_list) + CreateDumpingStateForMenuList(zoneState, menuListAsset->Asset()); } - // Functions do not have opening parenthesis in the entries. We can just pretend they do though - const auto closingParenPos = FindStatementClosingParenthesis(statement, currentPos); - m_stream << "("; + const auto menuFilePath = GetPathForMenu(zoneState, asset); + const auto assetFile = context.OpenAssetFile(menuFilePath); - if (closingParenPos - currentPos + 1 >= 1) - { - const auto& staticDvarEntry = statement->entries[currentPos + 1]; - if (staticDvarEntry.type == EET_OPERAND && staticDvarEntry.data.operand.dataType == VAL_INT) - { - if (statement->supportingData && statement->supportingData->staticDvarList.staticDvars && staticDvarEntry.data.operand.internals.intVal >= 0 - && staticDvarEntry.data.operand.internals.intVal < statement->supportingData->staticDvarList.numStaticDvars) - { - const auto* staticDvar = statement->supportingData->staticDvarList.staticDvars[staticDvarEntry.data.operand.internals.intVal]; - if (staticDvar && staticDvar->dvarName) - m_stream << staticDvar->dvarName; - } - else - { - m_stream << "#INVALID_DVAR_INDEX"; - } - } - else - { - m_stream << "#INVALID_DVAR_OPERAND"; - } - } + if (!assetFile) + return; - m_stream << ")"; - currentPos = closingParenPos + 1; - spaceNext = true; + auto menuWriter = CreateMenuWriter(*assetFile); + + menuWriter->Start(); + menuWriter->WriteMenu(*menu); + menuWriter->End(); } - else - { - if (expEntry.data.op >= 0 && static_cast(expEntry.data.op) < std::extent_v) - m_stream << g_expFunctionNames[expEntry.data.op]; - - if (expEntry.data.op >= OP_COUNT) - { - // Functions do not have opening parenthesis in the entries. We can just pretend they do though - const auto closingParenPos = FindStatementClosingParenthesis(statement, currentPos); - m_stream << "("; - WriteStatementEntryRange(statement, currentPos + 1, closingParenPos); - m_stream << ")"; - currentPos = closingParenPos + 1; - } - else - currentPos++; - - spaceNext = expEntry.data.op != OP_NOT; - } -} - -void MenuDumper::WriteStatementOperandFunction(const Statement_s* statement, const size_t currentPos) const -{ - const auto& operand = statement->entries[currentPos].data.operand; - - if (operand.internals.function == nullptr) - return; - - if (!ObjWriting::Configuration.MenuLegacyMode) - { - int functionIndex = -1; - if (statement->supportingData && statement->supportingData->uifunctions.functions) - { - for (auto supportingFunctionIndex = 0; supportingFunctionIndex < statement->supportingData->uifunctions.totalFunctions; supportingFunctionIndex++) - { - if (statement->supportingData->uifunctions.functions[supportingFunctionIndex] == operand.internals.function) - { - functionIndex = supportingFunctionIndex; - break; - } - } - } - - if (functionIndex >= 0) - m_stream << "FUNC_" << functionIndex; - else - m_stream << "INVALID_FUNC"; - m_stream << "()"; - } - else - { - m_stream << "("; - WriteStatementSkipInitialUnnecessaryParenthesis(operand.internals.function); - m_stream << ")"; - } -} - -void MenuDumper::WriteStatementOperand(const Statement_s* statement, size_t& currentPos, bool& spaceNext) const -{ - const auto& expEntry = statement->entries[currentPos]; - - if (spaceNext) - m_stream << " "; - - const auto& operand = expEntry.data.operand; - - switch (operand.dataType) - { - case VAL_FLOAT: - m_stream << operand.internals.floatVal; - break; - - case VAL_INT: - m_stream << operand.internals.intVal; - break; - - case VAL_STRING: - WriteEscapedString(operand.internals.stringVal.string); - break; - - case VAL_FUNCTION: - WriteStatementOperandFunction(statement, currentPos); - break; - - default: - break; - } - - currentPos++; - spaceNext = true; -} - -void MenuDumper::WriteStatementEntryRange(const Statement_s* statement, const size_t startOffset, const size_t endOffset) const -{ - assert(startOffset <= endOffset); - assert(endOffset <= static_cast(statement->numEntries)); - - auto currentPos = startOffset; - auto spaceNext = false; - while (currentPos < endOffset) - { - const auto& expEntry = statement->entries[currentPos]; - - if (expEntry.type == EET_OPERATOR) - { - WriteStatementOperator(statement, currentPos, spaceNext); - } - else - { - WriteStatementOperand(statement, currentPos, spaceNext); - } - } -} - -void MenuDumper::WriteStatement(const Statement_s* statement) const -{ - if (statement == nullptr || statement->numEntries < 0) - return; - - WriteStatementEntryRange(statement, 0, static_cast(statement->numEntries)); -} - -void MenuDumper::WriteStatementSkipInitialUnnecessaryParenthesis(const Statement_s* statementValue) const -{ - if (statementValue == nullptr || statementValue->numEntries < 0) - return; - - const auto statementEnd = static_cast(statementValue->numEntries); - - if (statementValue->numEntries >= 1 && statementValue->entries[0].type == EET_OPERATOR && statementValue->entries[0].data.op == OP_LEFTPAREN) - { - const auto parenthesisEnd = FindStatementClosingParenthesis(statementValue, 0); - - if (parenthesisEnd >= statementEnd) - WriteStatementEntryRange(statementValue, 1, statementEnd); - else if (parenthesisEnd == statementEnd - 1) - WriteStatementEntryRange(statementValue, 1, statementEnd - 1); - else - WriteStatementEntryRange(statementValue, 0, statementEnd); - } - else - { - WriteStatementEntryRange(statementValue, 0, statementEnd); - } -} - -void MenuDumper::WriteStatementNaive(const Statement_s* statement) const -{ - const auto entryCount = static_cast(statement->numEntries); - - const auto missingClosingParenthesis = statement->numEntries > 0 && statement->entries[0].type == EET_OPERATOR - && statement->entries[0].data.op == OP_LEFTPAREN - && FindStatementClosingParenthesis(statement, 0) >= static_cast(statement->numEntries); - - for (auto i = 0uz; i < entryCount; i++) - { - const auto& entry = statement->entries[i]; - if (entry.type == EET_OPERAND) - { - size_t pos = i; - bool discard = false; - WriteStatementOperand(statement, pos, discard); - } - else if (entry.data.op >= EXP_FUNC_STATIC_DVAR_INT && entry.data.op <= EXP_FUNC_STATIC_DVAR_STRING) - { - switch (entry.data.op) - { - case EXP_FUNC_STATIC_DVAR_INT: - m_stream << "dvarint"; - break; - - case EXP_FUNC_STATIC_DVAR_BOOL: - m_stream << "dvarbool"; - break; - - case EXP_FUNC_STATIC_DVAR_FLOAT: - m_stream << "dvarfloat"; - break; - - case EXP_FUNC_STATIC_DVAR_STRING: - m_stream << "dvarstring"; - break; - - default: - break; - } - - // Functions do not have opening parenthesis in the entries. We can just pretend they do though - const auto closingParenPos = FindStatementClosingParenthesis(statement, i); - m_stream << "("; - - if (closingParenPos - i + 1u >= 1u) - { - const auto& staticDvarEntry = statement->entries[i + 1]; - if (staticDvarEntry.type == EET_OPERAND && staticDvarEntry.data.operand.dataType == VAL_INT) - { - if (statement->supportingData && statement->supportingData->staticDvarList.staticDvars && staticDvarEntry.data.operand.internals.intVal >= 0 - && staticDvarEntry.data.operand.internals.intVal < statement->supportingData->staticDvarList.numStaticDvars) - { - const auto* staticDvar = statement->supportingData->staticDvarList.staticDvars[staticDvarEntry.data.operand.internals.intVal]; - if (staticDvar && staticDvar->dvarName) - m_stream << staticDvar->dvarName; - } - else - { - m_stream << "#INVALID_DVAR_INDEX"; - } - } - else - { - m_stream << "#INVALID_DVAR_OPERAND"; - } - } - - m_stream << ")"; - i = closingParenPos; - } - else - { - assert(entry.data.op >= 0 && static_cast(entry.data.op) < std::extent_v); - if (entry.data.op >= 0 && static_cast(entry.data.op) < std::extent_v) - m_stream << g_expFunctionNames[entry.data.op]; - if (entry.data.op >= OP_COUNT) - m_stream << "("; - } - } - - if (missingClosingParenthesis) - m_stream << ")"; -} - -void MenuDumper::WriteStatementProperty(const std::string& propertyKey, const Statement_s* statementValue, bool isBooleanStatement) const -{ - if (statementValue == nullptr || statementValue->numEntries < 0) - return; - - Indent(); - WriteKey(propertyKey); - - if (isBooleanStatement) - { - m_stream << "when("; - DUMP_FUNC(statementValue); - m_stream << ");\n"; - } - else - { - DUMP_FUNC(statementValue); - m_stream << ";\n"; - } -} - -void MenuDumper::WriteSetLocalVarData(const std::string& setFunction, const SetLocalVarData* setLocalVarData) const -{ - if (setLocalVarData == nullptr) - return; - - Indent(); - m_stream << setFunction << " " << setLocalVarData->localVarName << " "; - WriteStatement(setLocalVarData->expression); - m_stream << ";\n"; -} - -// #define WRITE_ORIGINAL_SCRIPT - -void MenuDumper::WriteUnconditionalScript(const char* script) const -{ -#ifdef WRITE_ORIGINAL_SCRIPT - Indent(); - m_stream << script << "\n"; - return; -#endif - - const auto tokenList = CreateScriptTokenList(script); - - auto isNewStatement = true; - for (const auto& token : tokenList) - { - if (isNewStatement) - { - if (token == ";") - continue; - - Indent(); - } - - if (token == ";") - { - m_stream << ";\n"; - isNewStatement = true; - continue; - } - - if (!isNewStatement) - m_stream << " "; - else - isNewStatement = false; - - if (DoesTokenNeedQuotationMarks(token)) - m_stream << "\"" << token << "\""; - else - m_stream << token; - } - - if (!isNewStatement) - m_stream << ";\n"; -} - -void MenuDumper::WriteMenuEventHandlerSet(const MenuEventHandlerSet* eventHandlerSet) -{ - Indent(); - m_stream << "{\n"; - IncIndent(); - - for (auto i = 0; i < eventHandlerSet->eventHandlerCount; i++) - { - const auto* eventHandler = eventHandlerSet->eventHandlers[i]; - if (eventHandler == nullptr) - continue; - - switch (eventHandler->eventType) - { - case EVENT_UNCONDITIONAL: - WriteUnconditionalScript(eventHandler->eventData.unconditionalScript); - break; - - case EVENT_IF: - if (eventHandler->eventData.conditionalScript == nullptr || eventHandler->eventData.conditionalScript->eventExpression == nullptr - || eventHandler->eventData.conditionalScript->eventHandlerSet == nullptr) - { - continue; - } - - Indent(); - m_stream << "if ("; - WriteStatementSkipInitialUnnecessaryParenthesis(eventHandler->eventData.conditionalScript->eventExpression); - m_stream << ")\n"; - WriteMenuEventHandlerSet(eventHandler->eventData.conditionalScript->eventHandlerSet); - break; - - case EVENT_ELSE: - if (eventHandler->eventData.elseScript == nullptr) - continue; - - Indent(); - m_stream << "else\n"; - WriteMenuEventHandlerSet(eventHandler->eventData.elseScript); - break; - - case EVENT_SET_LOCAL_VAR_BOOL: - WriteSetLocalVarData("setLocalVarBool", eventHandler->eventData.setLocalVarData); - break; - - case EVENT_SET_LOCAL_VAR_INT: - WriteSetLocalVarData("setLocalVarInt", eventHandler->eventData.setLocalVarData); - break; - - case EVENT_SET_LOCAL_VAR_FLOAT: - WriteSetLocalVarData("setLocalVarFloat", eventHandler->eventData.setLocalVarData); - break; - - case EVENT_SET_LOCAL_VAR_STRING: - WriteSetLocalVarData("setLocalVarString", eventHandler->eventData.setLocalVarData); - break; - - default: - break; - } - } - - DecIndent(); - Indent(); - m_stream << "}\n"; -} - -void MenuDumper::WriteMenuEventHandlerSetProperty(const std::string& propertyKey, const MenuEventHandlerSet* eventHandlerSetValue) -{ - if (eventHandlerSetValue == nullptr) - return; - - Indent(); - m_stream << propertyKey << "\n"; - WriteMenuEventHandlerSet(eventHandlerSetValue); -} - -void MenuDumper::WriteRectProperty(const std::string& propertyKey, const rectDef_s& rect) const -{ - Indent(); - WriteKey(propertyKey); - m_stream << rect.x << " " << rect.y << " " << rect.w << " " << rect.h << " " << static_cast(rect.horzAlign) << " " << static_cast(rect.vertAlign) - << "\n"; -} - -void MenuDumper::WriteMaterialProperty(const std::string& propertyKey, const Material* materialValue) const -{ - if (materialValue == nullptr || materialValue->info.name == nullptr) - return; - - if (materialValue->info.name[0] == ',') - WriteStringProperty(propertyKey, &materialValue->info.name[1]); - else - WriteStringProperty(propertyKey, materialValue->info.name); -} - -void MenuDumper::WriteSoundAliasProperty(const std::string& propertyKey, const snd_alias_list_t* soundAliasValue) const -{ - if (soundAliasValue == nullptr) - return; - - WriteStringProperty(propertyKey, soundAliasValue->aliasName); -} - -void MenuDumper::WriteDecodeEffectProperty(const std::string& propertyKey, const itemDef_s* item) const -{ - if (!item->decayActive) - return; - - Indent(); - WriteKey(propertyKey); - m_stream << item->fxLetterTime << " " << item->fxDecayStartTime << " " << item->fxDecayDuration << "\n"; -} - -void MenuDumper::WriteItemKeyHandlerProperty(const ItemKeyHandler* itemKeyHandlerValue) -{ - for (const auto* currentHandler = itemKeyHandlerValue; currentHandler; currentHandler = currentHandler->next) - { - if (currentHandler->key >= '!' && currentHandler->key <= '~' && currentHandler->key != '"') - { - std::ostringstream ss; - ss << "execKey \"" << static_cast(currentHandler->key) << "\""; - WriteMenuEventHandlerSetProperty(ss.str(), currentHandler->action); - } - else - { - std::ostringstream ss; - ss << "execKeyInt " << currentHandler->key; - WriteMenuEventHandlerSetProperty(ss.str(), currentHandler->action); - } - } -} - -void MenuDumper::WriteFloatExpressionsProperty(const ItemFloatExpression* floatExpressions, int floatExpressionCount) const -{ - if (!floatExpressions) - return; - - for (int i = 0; i < floatExpressionCount; i++) - { - const auto& floatExpression = floatExpressions[i]; - - if (floatExpression.target < 0 || floatExpression.target >= ITEM_FLOATEXP_TGT_COUNT) - continue; - - std::string propertyName = std::string("exp ") + floatExpressionTargetBindings[floatExpression.target].name + std::string(" ") - + floatExpressionTargetBindings[floatExpression.target].componentName; - - WriteStatementProperty(propertyName, floatExpression.expression, false); - } -} - -void MenuDumper::WriteMultiTokenStringProperty(const std::string& propertyKey, const char* value) const -{ - if (!value) - return; - - Indent(); - WriteKey(propertyKey); - - const auto tokenList = CreateScriptTokenList(value); - - auto firstToken = true; - m_stream << "{ "; - for (const auto& token : tokenList) - { - if (firstToken) - firstToken = false; - else - m_stream << ";"; - m_stream << "\"" << token << "\""; - } - if (!firstToken) - m_stream << " "; - m_stream << "}\n"; -} - -void MenuDumper::WriteColumnProperty(const std::string& propertyKey, const listBoxDef_s* listBox) const -{ - if (listBox->numColumns <= 0) - return; - - Indent(); - WriteKey(propertyKey); - m_stream << listBox->numColumns << "\n"; - - for (auto col = 0; col < listBox->numColumns; col++) - { - Indent(); - for (auto i = 0u; i < MENU_KEY_SPACING; i++) - m_stream << " "; - - m_stream << listBox->columnInfo[col].pos << " " << listBox->columnInfo[col].width << " " << listBox->columnInfo[col].maxChars << " " - << listBox->columnInfo[col].alignment << "\n"; - } -} - -void MenuDumper::WriteListBoxProperties(const itemDef_s* item) -{ - if (item->type != ITEM_TYPE_LISTBOX || item->typeData.listBox == nullptr) - return; - - const auto* listBox = item->typeData.listBox; - WriteKeywordProperty("notselectable", listBox->notselectable != 0); - WriteKeywordProperty("noscrollbars", listBox->noScrollBars != 0); - WriteKeywordProperty("usepaging", listBox->usePaging != 0); - WriteFloatProperty("elementwidth", listBox->elementWidth, 0.0f); - WriteFloatProperty("elementheight", listBox->elementHeight, 0.0f); - WriteFloatProperty("feeder", item->special, 0.0f); - WriteIntProperty("elementtype", listBox->elementStyle, 0); - WriteColumnProperty("columns", listBox); - WriteMenuEventHandlerSetProperty("doubleclick", listBox->onDoubleClick); - WriteColorProperty("selectBorder", listBox->selectBorder, COLOR_0000); - WriteMaterialProperty("selectIcon", listBox->selectIcon); -} - -void MenuDumper::WriteDvarFloatProperty(const std::string& propertyKey, const itemDef_s* item, const editFieldDef_s* editField) const -{ - if (item->dvar == nullptr) - return; - - Indent(); - WriteKey(propertyKey); - m_stream << "\"" << item->dvar << "\" " << editField->defVal << " " << editField->minVal << " " << editField->maxVal << "\n"; -} - -void MenuDumper::WriteEditFieldProperties(const itemDef_s* item) const -{ - switch (item->type) - { - case ITEM_TYPE_TEXT: - case ITEM_TYPE_EDITFIELD: - case ITEM_TYPE_NUMERICFIELD: - case ITEM_TYPE_SLIDER: - case ITEM_TYPE_YESNO: - case ITEM_TYPE_BIND: - case ITEM_TYPE_VALIDFILEFIELD: - case ITEM_TYPE_DECIMALFIELD: - case ITEM_TYPE_UPREDITFIELD: - case ITEM_TYPE_EMAILFIELD: - case ITEM_TYPE_PASSWORDFIELD: - break; - - default: - return; - } - - if (item->typeData.editField == nullptr) - return; - - const auto* editField = item->typeData.editField; - if (std::fabs(-1.0f - editField->defVal) >= std::numeric_limits::epsilon() - || std::fabs(-1.0f - editField->minVal) >= std::numeric_limits::epsilon() - || std::fabs(-1.0f - editField->maxVal) >= std::numeric_limits::epsilon()) - { - WriteDvarFloatProperty("dvarFloat", item, editField); - } - else - { - WriteStringProperty("dvar", item->dvar); - } - WriteStringProperty("localvar", item->localVar); - WriteIntProperty("maxChars", editField->maxChars, 0); - WriteKeywordProperty("maxCharsGotoNext", editField->maxCharsGotoNext != 0); - WriteIntProperty("maxPaintChars", editField->maxPaintChars, 0); -} - -void MenuDumper::WriteMultiValueProperty(const multiDef_s* multiDef) const -{ - Indent(); - if (multiDef->strDef) - WriteKey("dvarStrList"); - else - WriteKey("dvarFloatList"); - - m_stream << "{"; - for (auto i = 0; i < multiDef->count; i++) - { - if (multiDef->dvarList[i] == nullptr || multiDef->strDef && multiDef->dvarStr[i] == nullptr) - continue; - - m_stream << " \"" << multiDef->dvarList[i] << "\""; - - if (multiDef->strDef) - m_stream << " \"" << multiDef->dvarStr[i] << "\""; - else - m_stream << " " << multiDef->dvarValue[i] << ""; - } - m_stream << " }\n"; -} - -void MenuDumper::WriteMultiProperties(const itemDef_s* item) const -{ - if (item->type != ITEM_TYPE_MULTI || item->typeData.multi == nullptr) - return; - - const auto* multiDef = item->typeData.multi; - - if (multiDef->count <= 0) - return; - - WriteStringProperty("dvar", item->dvar); - WriteStringProperty("localvar", item->localVar); - WriteMultiValueProperty(multiDef); -} - -void MenuDumper::WriteEnumDvarProperties(const itemDef_s* item) const -{ - if (item->type != ITEM_TYPE_DVARENUM) - return; - - WriteStringProperty("dvar", item->dvar); - WriteStringProperty("localvar", item->localVar); - WriteStringProperty("dvarEnumList", item->typeData.enumDvarName); -} - -void MenuDumper::WriteTickerProperties(const itemDef_s* item) const -{ - if (item->type != ITEM_TYPE_NEWS_TICKER || item->typeData.ticker == nullptr) - return; - - const auto* newsTickerDef = item->typeData.ticker; - WriteIntProperty("spacing", newsTickerDef->spacing, 0); - WriteIntProperty("speed", newsTickerDef->speed, 0); - WriteIntProperty("newsfeed", newsTickerDef->feedId, 0); -} - -void MenuDumper::WriteItemData(const itemDef_s* item) -{ - WriteStringProperty("name", item->window.name); - WriteStringProperty("text", item->text); - WriteKeywordProperty("textsavegame", item->itemFlags & ITEM_FLAG_SAVE_GAME_INFO); - WriteKeywordProperty("textcinematicsubtitle", item->itemFlags & ITEM_FLAG_CINEMATIC_SUBTITLE); - WriteStringProperty("group", item->window.group); - WriteRectProperty("rect", item->window.rectClient); - WriteIntProperty("style", item->window.style, 0); - WriteKeywordProperty("decoration", item->window.staticFlags & WINDOW_FLAG_DECORATION); - WriteKeywordProperty("autowrapped", item->window.staticFlags & WINDOW_FLAG_AUTO_WRAPPED); - WriteKeywordProperty("horizontalscroll", item->window.staticFlags & WINDOW_FLAG_HORIZONTAL_SCROLL); - WriteIntProperty("type", item->type, ITEM_TYPE_TEXT); - WriteIntProperty("border", item->window.border, 0); - WriteFloatProperty("borderSize", item->window.borderSize, 0.0f); - - if (item->visibleExp) - WriteStatementProperty("visible", item->visibleExp, true); - else if (item->window.dynamicFlags[0] & WINDOW_FLAG_VISIBLE) - WriteIntProperty("visible", 1, 0); - - WriteStatementProperty("disabled", item->disabledExp, true); - WriteIntProperty("ownerdraw", item->window.ownerDraw, 0); - WriteFlagsProperty("ownerdrawFlag", item->window.ownerDrawFlags); - WriteIntProperty("align", item->alignment, 0); - WriteIntProperty("textalign", item->textAlignMode, 0); - WriteFloatProperty("textalignx", item->textalignx, 0.0f); - WriteFloatProperty("textaligny", item->textaligny, 0.0f); - WriteFloatProperty("textscale", item->textscale, 0.0f); - WriteIntProperty("textstyle", item->textStyle, 0); - WriteIntProperty("textfont", item->fontEnum, 0); - WriteColorProperty("backcolor", item->window.backColor, COLOR_0000); - WriteColorProperty("forecolor", item->window.foreColor, COLOR_1111); - WriteColorProperty("bordercolor", item->window.borderColor, COLOR_0000); - WriteColorProperty("outlinecolor", item->window.outlineColor, COLOR_0000); - WriteColorProperty("disablecolor", item->window.disableColor, COLOR_0000); - WriteColorProperty("glowcolor", item->glowColor, COLOR_0000); - WriteMaterialProperty("background", item->window.background); - WriteMenuEventHandlerSetProperty("onFocus", item->onFocus); - WriteMenuEventHandlerSetProperty("leaveFocus", item->leaveFocus); - WriteMenuEventHandlerSetProperty("mouseEnter", item->mouseEnter); - WriteMenuEventHandlerSetProperty("mouseExit", item->mouseExit); - WriteMenuEventHandlerSetProperty("mouseEnterText", item->mouseEnterText); - WriteMenuEventHandlerSetProperty("mouseExitText", item->mouseExitText); - WriteMenuEventHandlerSetProperty("action", item->action); - WriteMenuEventHandlerSetProperty("accept", item->accept); - // WriteFloatProperty("special", item->special, 0.0f); - WriteSoundAliasProperty("focusSound", item->focusSound); - WriteStringProperty("dvarTest", item->dvarTest); - - if (item->dvarFlags & ITEM_DVAR_FLAG_ENABLE) - WriteMultiTokenStringProperty("enableDvar", item->enableDvar); - else if (item->dvarFlags & ITEM_DVAR_FLAG_DISABLE) - WriteMultiTokenStringProperty("disableDvar", item->enableDvar); - else if (item->dvarFlags & ITEM_DVAR_FLAG_SHOW) - WriteMultiTokenStringProperty("showDvar", item->enableDvar); - else if (item->dvarFlags & ITEM_DVAR_FLAG_HIDE) - WriteMultiTokenStringProperty("hideDvar", item->enableDvar); - else if (item->dvarFlags & ITEM_DVAR_FLAG_FOCUS) - WriteMultiTokenStringProperty("focusDvar", item->enableDvar); - - WriteItemKeyHandlerProperty(item->onKey); - WriteStatementProperty("exp text", item->textExp, false); - WriteStatementProperty("exp material", item->materialExp, false); - WriteFloatExpressionsProperty(item->floatExpressions, item->floatExpressionCount); - WriteIntProperty("gamemsgwindowindex", item->gameMsgWindowIndex, 0); - WriteIntProperty("gamemsgwindowmode", item->gameMsgWindowMode, 0); - WriteDecodeEffectProperty("decodeEffect", item); - - WriteListBoxProperties(item); - WriteEditFieldProperties(item); - WriteMultiProperties(item); - WriteEnumDvarProperties(item); - WriteTickerProperties(item); -} - -void MenuDumper::WriteItemDefs(const itemDef_s* const* itemDefs, size_t itemCount) -{ - for (auto i = 0u; i < itemCount; i++) - { - StartItemDefScope(); - - WriteItemData(itemDefs[i]); - - EndScope(); - } -} - -void MenuDumper::WriteMenuData(const menuDef_t* menu) -{ - WriteStringProperty("name", menu->window.name); - WriteBoolProperty("fullscreen", menu->fullScreen, false); - WriteKeywordProperty("screenSpace", menu->window.staticFlags & WINDOW_FLAG_SCREEN_SPACE); - WriteKeywordProperty("decoration", menu->window.staticFlags & WINDOW_FLAG_DECORATION); - WriteRectProperty("rect", menu->window.rect); - WriteIntProperty("style", menu->window.style, 0); - WriteIntProperty("border", menu->window.border, 0); - WriteFloatProperty("borderSize", menu->window.borderSize, 0.0f); - WriteColorProperty("backcolor", menu->window.backColor, COLOR_0000); - WriteColorProperty("forecolor", menu->window.foreColor, COLOR_1111); - WriteColorProperty("bordercolor", menu->window.borderColor, COLOR_0000); - WriteColorProperty("focuscolor", menu->focusColor, COLOR_0000); - WriteColorProperty("outlinecolor", menu->window.outlineColor, COLOR_0000); - WriteMaterialProperty("background", menu->window.background); - WriteIntProperty("ownerdraw", menu->window.ownerDraw, 0); - WriteFlagsProperty("ownerdrawFlag", menu->window.ownerDrawFlags); - WriteKeywordProperty("outOfBoundsClick", menu->window.staticFlags & WINDOW_FLAG_OUT_OF_BOUNDS_CLICK); - WriteStringProperty("soundLoop", menu->soundName); - WriteKeywordProperty("popup", menu->window.staticFlags & WINDOW_FLAG_POPUP); - WriteFloatProperty("fadeClamp", menu->fadeClamp, 0.0f); - WriteIntProperty("fadeCycle", menu->fadeCycle, 0); - WriteFloatProperty("fadeAmount", menu->fadeAmount, 0.0f); - WriteFloatProperty("fadeInAmount", menu->fadeInAmount, 0.0f); - WriteFloatProperty("blurWorld", menu->blurRadius, 0.0f); - WriteKeywordProperty("legacySplitScreenScale", menu->window.staticFlags & WINDOW_FLAG_LEGACY_SPLIT_SCREEN_SCALE); - WriteKeywordProperty("hiddenDuringScope", menu->window.staticFlags & WINDOW_FLAG_HIDDEN_DURING_SCOPE); - WriteKeywordProperty("hiddenDuringFlashbang", menu->window.staticFlags & WINDOW_FLAG_HIDDEN_DURING_FLASH_BANG); - WriteKeywordProperty("hiddenDuringUI", menu->window.staticFlags & WINDOW_FLAG_HIDDEN_DURING_UI); - WriteStringProperty("allowedBinding", menu->allowedBinding); - WriteKeywordProperty("textOnlyFocus", menu->window.staticFlags & WINDOW_FLAG_TEXT_ONLY_FOCUS); - - if (menu->visibleExp) - WriteStatementProperty("visible", menu->visibleExp, true); - else if (menu->window.dynamicFlags[0] & WINDOW_FLAG_VISIBLE) - WriteIntProperty("visible", 1, 0); - - WriteStatementProperty("exp rect X", menu->rectXExp, false); - WriteStatementProperty("exp rect Y", menu->rectYExp, false); - WriteStatementProperty("exp rect W", menu->rectWExp, false); - WriteStatementProperty("exp rect H", menu->rectHExp, false); - WriteStatementProperty("exp openSound", menu->openSoundExp, false); - WriteStatementProperty("exp closeSound", menu->closeSoundExp, false); - WriteMenuEventHandlerSetProperty("onOpen", menu->onOpen); - WriteMenuEventHandlerSetProperty("onClose", menu->onClose); - WriteMenuEventHandlerSetProperty("onRequestClose", menu->onCloseRequest); - WriteMenuEventHandlerSetProperty("onESC", menu->onESC); - WriteItemKeyHandlerProperty(menu->onKey); - WriteItemDefs(menu->items, menu->itemCount); -} - -MenuDumper::MenuDumper(std::ostream& stream) - : AbstractMenuDumper(stream) -{ -} - -void MenuDumper::WriteFunctionDef(const std::string& functionName, const Statement_s* statement) -{ - StartFunctionDefScope(); - - WriteStringProperty("name", functionName); - WriteStatementProperty("value", statement, false); - - EndScope(); -} - -void MenuDumper::WriteMenu(const menuDef_t* menu) -{ - StartMenuDefScope(); - - WriteMenuData(menu); - - EndScope(); -} +} // namespace IW4::menu diff --git a/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.h b/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.h index 9baff905..5567b3f6 100644 --- a/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.h @@ -1,57 +1,15 @@ #pragma once +#include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -#include "Menu/AbstractMenuDumper.h" +#include "Menu/MenuDumpingZoneState.h" -#include - -namespace IW4 +namespace IW4::menu { - class MenuDumper : public AbstractMenuDumper + class MenuDumper final : public AbstractAssetDumper { - static size_t FindStatementClosingParenthesis(const Statement_s* statement, size_t openingParenthesisPosition); - - void WriteStatementNaive(const Statement_s* statement) const; - - void WriteStatementOperator(const Statement_s* statement, size_t& currentPos, bool& spaceNext) const; - void WriteStatementOperandFunction(const Statement_s* statement, size_t currentPos) const; - void WriteStatementOperand(const Statement_s* statement, size_t& currentPos, bool& spaceNext) const; - void WriteStatementEntryRange(const Statement_s* statement, size_t startOffset, size_t endOffset) const; - void WriteStatement(const Statement_s* statement) const; - void WriteStatementSkipInitialUnnecessaryParenthesis(const Statement_s* statementValue) const; - void WriteStatementProperty(const std::string& propertyKey, const Statement_s* statementValue, bool isBooleanStatement) const; - - void WriteSetLocalVarData(const std::string& setFunction, const SetLocalVarData* setLocalVarData) const; - void WriteUnconditionalScript(const char* script) const; - void WriteMenuEventHandlerSet(const MenuEventHandlerSet* eventHandlerSet); - void WriteMenuEventHandlerSetProperty(const std::string& propertyKey, const MenuEventHandlerSet* eventHandlerSetValue); - - void WriteRectProperty(const std::string& propertyKey, const rectDef_s& rect) const; - void WriteMaterialProperty(const std::string& propertyKey, const Material* materialValue) const; - void WriteSoundAliasProperty(const std::string& propertyKey, const snd_alias_list_t* soundAliasValue) const; - void WriteDecodeEffectProperty(const std::string& propertyKey, const itemDef_s* item) const; - void WriteItemKeyHandlerProperty(const ItemKeyHandler* itemKeyHandlerValue); - void WriteMultiTokenStringProperty(const std::string& propertyKey, const char* value) const; - void WriteFloatExpressionsProperty(const ItemFloatExpression* floatExpressions, int floatExpressionCount) const; - void WriteColumnProperty(const std::string& propertyKey, const listBoxDef_s* listBox) const; - - void WriteListBoxProperties(const itemDef_s* item); - void WriteDvarFloatProperty(const std::string& propertyKey, const itemDef_s* item, const editFieldDef_s* editField) const; - void WriteEditFieldProperties(const itemDef_s* item) const; - void WriteMultiValueProperty(const multiDef_s* multiDef) const; - void WriteMultiProperties(const itemDef_s* item) const; - void WriteEnumDvarProperties(const itemDef_s* item) const; - void WriteTickerProperties(const itemDef_s* item) const; - - void WriteItemData(const itemDef_s* item); - void WriteItemDefs(const itemDef_s* const* itemDefs, size_t itemCount); - - void WriteMenuData(const menuDef_t* menu); - - public: - explicit MenuDumper(std::ostream& stream); - - void WriteFunctionDef(const std::string& functionName, const Statement_s* statement); - void WriteMenu(const menuDef_t* menu); + protected: + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4 +} // namespace IW4::menu diff --git a/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.cpp b/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.cpp new file mode 100644 index 00000000..2d2614af --- /dev/null +++ b/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.cpp @@ -0,0 +1,187 @@ +#include "MenuListDumperIW4.h" + +#include "Game/IW4/Menu/MenuDumperIW4.h" +#include "Menu/AbstractMenuWriter.h" +#include "MenuWriterIW4.h" +#include "ObjWriting.h" + +#include +#include +#include +#include + +namespace fs = std::filesystem; + +using namespace IW4; +using namespace ::menu; + +namespace +{ + std::vector GetAllUniqueExpressionSupportingData(const MenuList* menuList) + { + std::vector result; + std::set alreadyAddedSupportingData; + + if (menuList->menus == nullptr) + return result; + + for (auto i = 0; i < menuList->menuCount; i++) + { + if (menuList->menus[i] == nullptr) + continue; + + const auto* menu = menuList->menus[i]; + + if (menu->expressionData == nullptr) + continue; + + if (alreadyAddedSupportingData.find(menu->expressionData) == alreadyAddedSupportingData.end()) + { + result.push_back(menu->expressionData); + alreadyAddedSupportingData.emplace(menu->expressionData); + } + } + + return result; + } + + void DumpFunctions(IW4::menu::IWriterIW4& menuDumper, const MenuList* menuList) + { + const auto allSupportingData = GetAllUniqueExpressionSupportingData(menuList); + auto functionIndex = 0u; + + assert(allSupportingData.size() <= 1); + + for (const auto* supportingData : allSupportingData) + { + if (supportingData->uifunctions.functions == nullptr) + continue; + + for (auto i = 0; i < supportingData->uifunctions.totalFunctions; i++) + { + const auto* function = supportingData->uifunctions.functions[i]; + if (function != nullptr) + { + std::stringstream ss; + ss << "FUNC_" << functionIndex; + + menuDumper.WriteFunctionDef(ss.str(), function); + } + + functionIndex++; + } + } + } + + void DumpMenus(IW4::menu::IWriterIW4& menuDumper, ::menu::MenuDumpingZoneState* zoneState, const MenuList* menuList) + { + for (auto menuNum = 0; menuNum < menuList->menuCount; menuNum++) + { + const auto* menu = menuList->menus[menuNum]; + + const auto menuDumpingState = zoneState->m_menu_dumping_state_map.find(menu); + if (menuDumpingState == zoneState->m_menu_dumping_state_map.end()) + continue; + + // If the menu was embedded directly as menu list write its data in the menu list file + if (menuDumpingState->second.m_alias_menu_list == menuList) + menuDumper.WriteMenu(*menu); + else + menuDumper.IncludeMenu(menuDumpingState->second.m_path); + } + } + + std::string PathForMenu(const std::string& menuListParentPath, const menuDef_t* menu) + { + const auto* menuAssetName = menu->window.name; + + if (!menuAssetName) + return ""; + + if (menuAssetName[0] == ',') + menuAssetName = &menuAssetName[1]; + + std::ostringstream ss; + ss << menuListParentPath << menuAssetName << ".menu"; + + return ss.str(); + } +} // namespace + +namespace IW4::menu +{ + void CreateDumpingStateForMenuList(::menu::MenuDumpingZoneState* zoneState, const MenuList* menuList) + { + if (menuList->menuCount <= 0 || menuList->menus == nullptr || menuList->name == nullptr) + return; + + const std::string menuListName(menuList->name); + const fs::path p(menuListName); + std::string parentPath; + if (p.has_parent_path()) + parentPath = p.parent_path().string() + "/"; + + for (auto i = 0; i < menuList->menuCount; i++) + { + auto* menu = menuList->menus[i]; + + if (menu == nullptr) + continue; + + auto existingState = zoneState->m_menu_dumping_state_map.find(menu); + if (existingState == zoneState->m_menu_dumping_state_map.end()) + { + auto menuPath = PathForMenu(parentPath, menu); + const auto isTheSameAsMenuList = menuPath == menuListName; + zoneState->CreateMenuDumpingState(menu, std::move(menuPath), isTheSameAsMenuList ? menuList : nullptr); + } + else if (existingState->second.m_alias_menu_list == nullptr) + { + auto menuPath = PathForMenu(parentPath, menu); + const auto isTheSameAsMenuList = menuPath == menuListName; + if (isTheSameAsMenuList) + { + existingState->second.m_alias_menu_list = menuList; + existingState->second.m_path = std::move(menuPath); + } + } + } + } + + bool MenuListDumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void MenuListDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* menuList = asset->Asset(); + const auto assetFile = context.OpenAssetFile(asset->m_name); + + if (!assetFile) + return; + + auto* zoneState = context.GetZoneAssetDumperState(); + + auto menuWriter = CreateMenuWriter(*assetFile); + + menuWriter->Start(); + + if (!ObjWriting::Configuration.MenuLegacyMode) + DumpFunctions(*menuWriter, menuList); + + DumpMenus(*menuWriter, zoneState, menuList); + + menuWriter->End(); + } + + void MenuListDumper::DumpPool(AssetDumpingContext& context, AssetPool* pool) + { + auto* zoneState = context.GetZoneAssetDumperState(); + + for (auto* asset : *pool) + CreateDumpingStateForMenuList(zoneState, asset->Asset()); + + AbstractAssetDumper::DumpPool(context, pool); + } +} // namespace IW4::menu diff --git a/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.h b/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.h new file mode 100644 index 00000000..891ba458 --- /dev/null +++ b/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.h @@ -0,0 +1,21 @@ +#pragma once + +#include "Dumping/AbstractAssetDumper.h" +#include "Game/IW4/IW4.h" +#include "Game/IW4/Menu/MenuDumperIW4.h" +#include "Menu/MenuDumpingZoneState.h" + +namespace IW4::menu +{ + void CreateDumpingStateForMenuList(::menu::MenuDumpingZoneState* zoneState, const MenuList* menuList); + + class MenuListDumper final : public AbstractAssetDumper + { + protected: + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + + public: + void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; + }; +} // namespace IW4::menu diff --git a/src/ObjWriting/Game/IW4/Menu/MenuWriterIW4.cpp b/src/ObjWriting/Game/IW4/Menu/MenuWriterIW4.cpp new file mode 100644 index 00000000..ad19833b --- /dev/null +++ b/src/ObjWriting/Game/IW4/Menu/MenuWriterIW4.cpp @@ -0,0 +1,957 @@ +#include "MenuWriterIW4.h" + +#include "Game/IW4/MenuConstantsIW4.h" +#include "Menu/AbstractMenuWriter.h" +#include "ObjWriting.h" + +#include +#include +#include + +using namespace IW4; + +// Uncomment this macro to skip interpretative expression dumping +// #define DUMP_NAIVE + +#ifdef DUMP_NAIVE +#define DUMP_FUNC WriteStatementNaive +#else +#define DUMP_FUNC WriteStatementSkipInitialUnnecessaryParenthesis +#endif + +namespace +{ + size_t FindStatementClosingParenthesis(const Statement_s* statement, const size_t openingParenthesisPosition) + { + assert(statement->numEntries >= 0); + assert(openingParenthesisPosition < static_cast(statement->numEntries)); + + const auto statementEnd = static_cast(statement->numEntries); + + // The openingParenthesisPosition does not necessarily point to an actual opening parenthesis operator. That's fine though. + // We will pretend it does since the game does sometimes leave out opening parenthesis from the entries. + auto currentParenthesisDepth = 1; + for (auto currentSearchPosition = openingParenthesisPosition + 1; currentSearchPosition < statementEnd; currentSearchPosition++) + { + const auto& expEntry = statement->entries[currentSearchPosition]; + if (expEntry.type != EET_OPERATOR) + continue; + + // Any function means a "left out" left paren + if (expEntry.data.op == OP_LEFTPAREN || expEntry.data.op >= OP_COUNT) + { + currentParenthesisDepth++; + } + else if (expEntry.data.op == OP_RIGHTPAREN) + { + if (currentParenthesisDepth > 0) + currentParenthesisDepth--; + if (currentParenthesisDepth == 0) + return currentSearchPosition; + } + } + + return statementEnd; + } + + class MenuWriter final : public ::menu::AbstractBaseWriter, public IW4::menu::IWriterIW4 + { + public: + explicit MenuWriter(std::ostream& stream) + : AbstractBaseWriter(stream) + { + } + + void WriteFunctionDef(const std::string& functionName, const Statement_s* statement) override + { + StartFunctionDefScope(); + + WriteStringProperty("name", functionName); + WriteStatementProperty("value", statement, false); + + EndScope(); + } + + void WriteMenu(const menuDef_t& menu) override + { + StartMenuDefScope(); + + WriteMenuData(&menu); + + EndScope(); + } + + void Start() override + { + AbstractBaseWriter::Start(); + } + + void End() override + { + AbstractBaseWriter::End(); + } + + void IncludeMenu(const std::string& menuPath) const override + { + AbstractBaseWriter::IncludeMenu(menuPath); + } + + private: + void WriteStatementNaive(const Statement_s* statement) const + { + const auto entryCount = static_cast(statement->numEntries); + + const auto missingClosingParenthesis = statement->numEntries > 0 && statement->entries[0].type == EET_OPERATOR + && statement->entries[0].data.op == OP_LEFTPAREN + && FindStatementClosingParenthesis(statement, 0) >= static_cast(statement->numEntries); + + for (auto i = 0uz; i < entryCount; i++) + { + const auto& entry = statement->entries[i]; + if (entry.type == EET_OPERAND) + { + size_t pos = i; + bool discard = false; + WriteStatementOperand(statement, pos, discard); + } + else if (entry.data.op >= EXP_FUNC_STATIC_DVAR_INT && entry.data.op <= EXP_FUNC_STATIC_DVAR_STRING) + { + switch (entry.data.op) + { + case EXP_FUNC_STATIC_DVAR_INT: + m_stream << "dvarint"; + break; + + case EXP_FUNC_STATIC_DVAR_BOOL: + m_stream << "dvarbool"; + break; + + case EXP_FUNC_STATIC_DVAR_FLOAT: + m_stream << "dvarfloat"; + break; + + case EXP_FUNC_STATIC_DVAR_STRING: + m_stream << "dvarstring"; + break; + + default: + break; + } + + // Functions do not have opening parenthesis in the entries. We can just pretend they do though + const auto closingParenPos = FindStatementClosingParenthesis(statement, i); + m_stream << "("; + + if (closingParenPos - i + 1u >= 1u) + { + const auto& staticDvarEntry = statement->entries[i + 1]; + if (staticDvarEntry.type == EET_OPERAND && staticDvarEntry.data.operand.dataType == VAL_INT) + { + if (statement->supportingData && statement->supportingData->staticDvarList.staticDvars + && staticDvarEntry.data.operand.internals.intVal >= 0 + && staticDvarEntry.data.operand.internals.intVal < statement->supportingData->staticDvarList.numStaticDvars) + { + const auto* staticDvar = statement->supportingData->staticDvarList.staticDvars[staticDvarEntry.data.operand.internals.intVal]; + if (staticDvar && staticDvar->dvarName) + m_stream << staticDvar->dvarName; + } + else + { + m_stream << "#INVALID_DVAR_INDEX"; + } + } + else + { + m_stream << "#INVALID_DVAR_OPERAND"; + } + } + + m_stream << ")"; + i = closingParenPos; + } + else + { + assert(entry.data.op >= 0 && static_cast(entry.data.op) < std::extent_v); + if (entry.data.op >= 0 && static_cast(entry.data.op) < std::extent_v) + m_stream << g_expFunctionNames[entry.data.op]; + if (entry.data.op >= OP_COUNT) + m_stream << "("; + } + } + + if (missingClosingParenthesis) + m_stream << ")"; + } + + void WriteStatementOperator(const Statement_s* statement, size_t& currentPos, bool& spaceNext) const + { + const auto& expEntry = statement->entries[currentPos]; + + if (spaceNext && expEntry.data.op != OP_COMMA) + m_stream << " "; + + if (expEntry.data.op == OP_LEFTPAREN) + { + const auto closingParenPos = FindStatementClosingParenthesis(statement, currentPos); + m_stream << "("; + WriteStatementEntryRange(statement, currentPos + 1, closingParenPos); + m_stream << ")"; + + currentPos = closingParenPos + 1; + spaceNext = true; + } + else if (expEntry.data.op >= EXP_FUNC_STATIC_DVAR_INT && expEntry.data.op <= EXP_FUNC_STATIC_DVAR_STRING) + { + switch (expEntry.data.op) + { + case EXP_FUNC_STATIC_DVAR_INT: + m_stream << "dvarint"; + break; + + case EXP_FUNC_STATIC_DVAR_BOOL: + m_stream << "dvarbool"; + break; + + case EXP_FUNC_STATIC_DVAR_FLOAT: + m_stream << "dvarfloat"; + break; + + case EXP_FUNC_STATIC_DVAR_STRING: + m_stream << "dvarstring"; + break; + + default: + break; + } + + // Functions do not have opening parenthesis in the entries. We can just pretend they do though + const auto closingParenPos = FindStatementClosingParenthesis(statement, currentPos); + m_stream << "("; + + if (closingParenPos - currentPos + 1 >= 1) + { + const auto& staticDvarEntry = statement->entries[currentPos + 1]; + if (staticDvarEntry.type == EET_OPERAND && staticDvarEntry.data.operand.dataType == VAL_INT) + { + if (statement->supportingData && statement->supportingData->staticDvarList.staticDvars + && staticDvarEntry.data.operand.internals.intVal >= 0 + && staticDvarEntry.data.operand.internals.intVal < statement->supportingData->staticDvarList.numStaticDvars) + { + const auto* staticDvar = statement->supportingData->staticDvarList.staticDvars[staticDvarEntry.data.operand.internals.intVal]; + if (staticDvar && staticDvar->dvarName) + m_stream << staticDvar->dvarName; + } + else + { + m_stream << "#INVALID_DVAR_INDEX"; + } + } + else + { + m_stream << "#INVALID_DVAR_OPERAND"; + } + } + + m_stream << ")"; + currentPos = closingParenPos + 1; + spaceNext = true; + } + else + { + if (expEntry.data.op >= 0 && static_cast(expEntry.data.op) < std::extent_v) + m_stream << g_expFunctionNames[expEntry.data.op]; + + if (expEntry.data.op >= OP_COUNT) + { + // Functions do not have opening parenthesis in the entries. We can just pretend they do though + const auto closingParenPos = FindStatementClosingParenthesis(statement, currentPos); + m_stream << "("; + WriteStatementEntryRange(statement, currentPos + 1, closingParenPos); + m_stream << ")"; + currentPos = closingParenPos + 1; + } + else + currentPos++; + + spaceNext = expEntry.data.op != OP_NOT; + } + } + + void WriteStatementOperandFunction(const Statement_s* statement, size_t currentPos) const + { + const auto& operand = statement->entries[currentPos].data.operand; + + if (operand.internals.function == nullptr) + return; + + if (!ObjWriting::Configuration.MenuLegacyMode) + { + int functionIndex = -1; + if (statement->supportingData && statement->supportingData->uifunctions.functions) + { + for (auto supportingFunctionIndex = 0; supportingFunctionIndex < statement->supportingData->uifunctions.totalFunctions; + supportingFunctionIndex++) + { + if (statement->supportingData->uifunctions.functions[supportingFunctionIndex] == operand.internals.function) + { + functionIndex = supportingFunctionIndex; + break; + } + } + } + + if (functionIndex >= 0) + m_stream << "FUNC_" << functionIndex; + else + m_stream << "INVALID_FUNC"; + m_stream << "()"; + } + else + { + m_stream << "("; + WriteStatementSkipInitialUnnecessaryParenthesis(operand.internals.function); + m_stream << ")"; + } + } + + void WriteStatementOperand(const Statement_s* statement, size_t& currentPos, bool& spaceNext) const + { + const auto& expEntry = statement->entries[currentPos]; + + if (spaceNext) + m_stream << " "; + + const auto& operand = expEntry.data.operand; + + switch (operand.dataType) + { + case VAL_FLOAT: + m_stream << operand.internals.floatVal; + break; + + case VAL_INT: + m_stream << operand.internals.intVal; + break; + + case VAL_STRING: + WriteEscapedString(operand.internals.stringVal.string); + break; + + case VAL_FUNCTION: + WriteStatementOperandFunction(statement, currentPos); + break; + + default: + break; + } + + currentPos++; + spaceNext = true; + } + + void WriteStatementEntryRange(const Statement_s* statement, size_t startOffset, size_t endOffset) const + { + assert(startOffset <= endOffset); + assert(endOffset <= static_cast(statement->numEntries)); + + auto currentPos = startOffset; + auto spaceNext = false; + while (currentPos < endOffset) + { + const auto& expEntry = statement->entries[currentPos]; + + if (expEntry.type == EET_OPERATOR) + { + WriteStatementOperator(statement, currentPos, spaceNext); + } + else + { + WriteStatementOperand(statement, currentPos, spaceNext); + } + } + } + + void WriteStatement(const Statement_s* statement) const + { + if (statement == nullptr || statement->numEntries < 0) + return; + + WriteStatementEntryRange(statement, 0, static_cast(statement->numEntries)); + } + + void WriteStatementSkipInitialUnnecessaryParenthesis(const Statement_s* statementValue) const + { + if (statementValue == nullptr || statementValue->numEntries < 0) + return; + + const auto statementEnd = static_cast(statementValue->numEntries); + + if (statementValue->numEntries >= 1 && statementValue->entries[0].type == EET_OPERATOR && statementValue->entries[0].data.op == OP_LEFTPAREN) + { + const auto parenthesisEnd = FindStatementClosingParenthesis(statementValue, 0); + + if (parenthesisEnd >= statementEnd) + WriteStatementEntryRange(statementValue, 1, statementEnd); + else if (parenthesisEnd == statementEnd - 1) + WriteStatementEntryRange(statementValue, 1, statementEnd - 1); + else + WriteStatementEntryRange(statementValue, 0, statementEnd); + } + else + { + WriteStatementEntryRange(statementValue, 0, statementEnd); + } + } + + void WriteStatementProperty(const std::string& propertyKey, const Statement_s* statementValue, bool isBooleanStatement) const + { + if (statementValue == nullptr || statementValue->numEntries < 0) + return; + + Indent(); + WriteKey(propertyKey); + + if (isBooleanStatement) + { + m_stream << "when("; + DUMP_FUNC(statementValue); + m_stream << ");\n"; + } + else + { + DUMP_FUNC(statementValue); + m_stream << ";\n"; + } + } + + void WriteSetLocalVarData(const std::string& setFunction, const SetLocalVarData* setLocalVarData) const + { + if (setLocalVarData == nullptr) + return; + + Indent(); + m_stream << setFunction << " " << setLocalVarData->localVarName << " "; + WriteStatement(setLocalVarData->expression); + m_stream << ";\n"; + } + + // #define WRITE_ORIGINAL_SCRIPT + void WriteUnconditionalScript(const char* script) const + { +#ifdef WRITE_ORIGINAL_SCRIPT + Indent(); + m_stream << script << "\n"; + return; +#endif + + const auto tokenList = CreateScriptTokenList(script); + + auto isNewStatement = true; + for (const auto& token : tokenList) + { + if (isNewStatement) + { + if (token == ";") + continue; + + Indent(); + } + + if (token == ";") + { + m_stream << ";\n"; + isNewStatement = true; + continue; + } + + if (!isNewStatement) + m_stream << " "; + else + isNewStatement = false; + + if (DoesTokenNeedQuotationMarks(token)) + m_stream << "\"" << token << "\""; + else + m_stream << token; + } + + if (!isNewStatement) + m_stream << ";\n"; + } + + void WriteMenuEventHandlerSet(const MenuEventHandlerSet* eventHandlerSet) + { + Indent(); + m_stream << "{\n"; + IncIndent(); + + for (auto i = 0; i < eventHandlerSet->eventHandlerCount; i++) + { + const auto* eventHandler = eventHandlerSet->eventHandlers[i]; + if (eventHandler == nullptr) + continue; + + switch (eventHandler->eventType) + { + case EVENT_UNCONDITIONAL: + WriteUnconditionalScript(eventHandler->eventData.unconditionalScript); + break; + + case EVENT_IF: + if (eventHandler->eventData.conditionalScript == nullptr || eventHandler->eventData.conditionalScript->eventExpression == nullptr + || eventHandler->eventData.conditionalScript->eventHandlerSet == nullptr) + { + continue; + } + + Indent(); + m_stream << "if ("; + WriteStatementSkipInitialUnnecessaryParenthesis(eventHandler->eventData.conditionalScript->eventExpression); + m_stream << ")\n"; + WriteMenuEventHandlerSet(eventHandler->eventData.conditionalScript->eventHandlerSet); + break; + + case EVENT_ELSE: + if (eventHandler->eventData.elseScript == nullptr) + continue; + + Indent(); + m_stream << "else\n"; + WriteMenuEventHandlerSet(eventHandler->eventData.elseScript); + break; + + case EVENT_SET_LOCAL_VAR_BOOL: + WriteSetLocalVarData("setLocalVarBool", eventHandler->eventData.setLocalVarData); + break; + + case EVENT_SET_LOCAL_VAR_INT: + WriteSetLocalVarData("setLocalVarInt", eventHandler->eventData.setLocalVarData); + break; + + case EVENT_SET_LOCAL_VAR_FLOAT: + WriteSetLocalVarData("setLocalVarFloat", eventHandler->eventData.setLocalVarData); + break; + + case EVENT_SET_LOCAL_VAR_STRING: + WriteSetLocalVarData("setLocalVarString", eventHandler->eventData.setLocalVarData); + break; + + default: + break; + } + } + + DecIndent(); + Indent(); + m_stream << "}\n"; + } + + void WriteMenuEventHandlerSetProperty(const std::string& propertyKey, const MenuEventHandlerSet* eventHandlerSetValue) + { + if (eventHandlerSetValue == nullptr) + return; + + Indent(); + m_stream << propertyKey << "\n"; + WriteMenuEventHandlerSet(eventHandlerSetValue); + } + + void WriteRectProperty(const std::string& propertyKey, const rectDef_s& rect) const + { + Indent(); + WriteKey(propertyKey); + m_stream << rect.x << " " << rect.y << " " << rect.w << " " << rect.h << " " << static_cast(rect.horzAlign) << " " + << static_cast(rect.vertAlign) << "\n"; + } + + void WriteMaterialProperty(const std::string& propertyKey, const Material* materialValue) const + { + if (materialValue == nullptr || materialValue->info.name == nullptr) + return; + + if (materialValue->info.name[0] == ',') + WriteStringProperty(propertyKey, &materialValue->info.name[1]); + else + WriteStringProperty(propertyKey, materialValue->info.name); + } + + void WriteSoundAliasProperty(const std::string& propertyKey, const snd_alias_list_t* soundAliasValue) const + { + if (soundAliasValue == nullptr) + return; + + WriteStringProperty(propertyKey, soundAliasValue->aliasName); + } + + void WriteDecodeEffectProperty(const std::string& propertyKey, const itemDef_s* item) const + { + if (!item->decayActive) + return; + + Indent(); + WriteKey(propertyKey); + m_stream << item->fxLetterTime << " " << item->fxDecayStartTime << " " << item->fxDecayDuration << "\n"; + } + + void WriteItemKeyHandlerProperty(const ItemKeyHandler* itemKeyHandlerValue) + { + for (const auto* currentHandler = itemKeyHandlerValue; currentHandler; currentHandler = currentHandler->next) + { + if (currentHandler->key >= '!' && currentHandler->key <= '~' && currentHandler->key != '"') + { + std::ostringstream ss; + ss << "execKey \"" << static_cast(currentHandler->key) << "\""; + WriteMenuEventHandlerSetProperty(ss.str(), currentHandler->action); + } + else + { + std::ostringstream ss; + ss << "execKeyInt " << currentHandler->key; + WriteMenuEventHandlerSetProperty(ss.str(), currentHandler->action); + } + } + } + + void WriteMultiTokenStringProperty(const std::string& propertyKey, const char* value) const + { + if (!value) + return; + + Indent(); + WriteKey(propertyKey); + + const auto tokenList = CreateScriptTokenList(value); + + auto firstToken = true; + m_stream << "{ "; + for (const auto& token : tokenList) + { + if (firstToken) + firstToken = false; + else + m_stream << ";"; + m_stream << "\"" << token << "\""; + } + if (!firstToken) + m_stream << " "; + m_stream << "}\n"; + } + + void WriteFloatExpressionsProperty(const ItemFloatExpression* floatExpressions, int floatExpressionCount) const + { + if (!floatExpressions) + return; + + for (int i = 0; i < floatExpressionCount; i++) + { + const auto& floatExpression = floatExpressions[i]; + + if (floatExpression.target < 0 || floatExpression.target >= ITEM_FLOATEXP_TGT_COUNT) + continue; + + std::string propertyName = std::string("exp ") + floatExpressionTargetBindings[floatExpression.target].name + std::string(" ") + + floatExpressionTargetBindings[floatExpression.target].componentName; + + WriteStatementProperty(propertyName, floatExpression.expression, false); + } + } + + void WriteColumnProperty(const std::string& propertyKey, const listBoxDef_s* listBox) const + { + if (listBox->numColumns <= 0) + return; + + Indent(); + WriteKey(propertyKey); + m_stream << listBox->numColumns << "\n"; + + for (auto col = 0; col < listBox->numColumns; col++) + { + Indent(); + for (auto i = 0u; i < MENU_KEY_SPACING; i++) + m_stream << " "; + + m_stream << listBox->columnInfo[col].pos << " " << listBox->columnInfo[col].width << " " << listBox->columnInfo[col].maxChars << " " + << listBox->columnInfo[col].alignment << "\n"; + } + } + + void WriteListBoxProperties(const itemDef_s* item) + { + if (item->type != ITEM_TYPE_LISTBOX || item->typeData.listBox == nullptr) + return; + + const auto* listBox = item->typeData.listBox; + WriteKeywordProperty("notselectable", listBox->notselectable != 0); + WriteKeywordProperty("noscrollbars", listBox->noScrollBars != 0); + WriteKeywordProperty("usepaging", listBox->usePaging != 0); + WriteFloatProperty("elementwidth", listBox->elementWidth, 0.0f); + WriteFloatProperty("elementheight", listBox->elementHeight, 0.0f); + WriteFloatProperty("feeder", item->special, 0.0f); + WriteIntProperty("elementtype", listBox->elementStyle, 0); + WriteColumnProperty("columns", listBox); + WriteMenuEventHandlerSetProperty("doubleclick", listBox->onDoubleClick); + WriteColorProperty("selectBorder", listBox->selectBorder, COLOR_0000); + WriteMaterialProperty("selectIcon", listBox->selectIcon); + } + + void WriteDvarFloatProperty(const std::string& propertyKey, const itemDef_s* item, const editFieldDef_s* editField) const + { + if (item->dvar == nullptr) + return; + + Indent(); + WriteKey(propertyKey); + m_stream << "\"" << item->dvar << "\" " << editField->defVal << " " << editField->minVal << " " << editField->maxVal << "\n"; + } + + void WriteEditFieldProperties(const itemDef_s* item) const + { + switch (item->type) + { + case ITEM_TYPE_TEXT: + case ITEM_TYPE_EDITFIELD: + case ITEM_TYPE_NUMERICFIELD: + case ITEM_TYPE_SLIDER: + case ITEM_TYPE_YESNO: + case ITEM_TYPE_BIND: + case ITEM_TYPE_VALIDFILEFIELD: + case ITEM_TYPE_DECIMALFIELD: + case ITEM_TYPE_UPREDITFIELD: + case ITEM_TYPE_EMAILFIELD: + case ITEM_TYPE_PASSWORDFIELD: + break; + + default: + return; + } + + if (item->typeData.editField == nullptr) + return; + + const auto* editField = item->typeData.editField; + if (std::fabs(-1.0f - editField->defVal) >= std::numeric_limits::epsilon() + || std::fabs(-1.0f - editField->minVal) >= std::numeric_limits::epsilon() + || std::fabs(-1.0f - editField->maxVal) >= std::numeric_limits::epsilon()) + { + WriteDvarFloatProperty("dvarFloat", item, editField); + } + else + { + WriteStringProperty("dvar", item->dvar); + } + WriteStringProperty("localvar", item->localVar); + WriteIntProperty("maxChars", editField->maxChars, 0); + WriteKeywordProperty("maxCharsGotoNext", editField->maxCharsGotoNext != 0); + WriteIntProperty("maxPaintChars", editField->maxPaintChars, 0); + } + + void WriteMultiValueProperty(const multiDef_s* multiDef) const + { + Indent(); + if (multiDef->strDef) + WriteKey("dvarStrList"); + else + WriteKey("dvarFloatList"); + + m_stream << "{"; + for (auto i = 0; i < multiDef->count; i++) + { + if (multiDef->dvarList[i] == nullptr || multiDef->strDef && multiDef->dvarStr[i] == nullptr) + continue; + + m_stream << " \"" << multiDef->dvarList[i] << "\""; + + if (multiDef->strDef) + m_stream << " \"" << multiDef->dvarStr[i] << "\""; + else + m_stream << " " << multiDef->dvarValue[i] << ""; + } + m_stream << " }\n"; + } + + void WriteMultiProperties(const itemDef_s* item) const + { + if (item->type != ITEM_TYPE_MULTI || item->typeData.multi == nullptr) + return; + + const auto* multiDef = item->typeData.multi; + + if (multiDef->count <= 0) + return; + + WriteStringProperty("dvar", item->dvar); + WriteStringProperty("localvar", item->localVar); + WriteMultiValueProperty(multiDef); + } + + void WriteEnumDvarProperties(const itemDef_s* item) const + { + if (item->type != ITEM_TYPE_DVARENUM) + return; + + WriteStringProperty("dvar", item->dvar); + WriteStringProperty("localvar", item->localVar); + WriteStringProperty("dvarEnumList", item->typeData.enumDvarName); + } + + void WriteTickerProperties(const itemDef_s* item) const + { + if (item->type != ITEM_TYPE_NEWS_TICKER || item->typeData.ticker == nullptr) + return; + + const auto* newsTickerDef = item->typeData.ticker; + WriteIntProperty("spacing", newsTickerDef->spacing, 0); + WriteIntProperty("speed", newsTickerDef->speed, 0); + WriteIntProperty("newsfeed", newsTickerDef->feedId, 0); + } + + void WriteItemData(const itemDef_s* item) + { + WriteStringProperty("name", item->window.name); + WriteStringProperty("text", item->text); + WriteKeywordProperty("textsavegame", item->itemFlags & ITEM_FLAG_SAVE_GAME_INFO); + WriteKeywordProperty("textcinematicsubtitle", item->itemFlags & ITEM_FLAG_CINEMATIC_SUBTITLE); + WriteStringProperty("group", item->window.group); + WriteRectProperty("rect", item->window.rectClient); + WriteIntProperty("style", item->window.style, 0); + WriteKeywordProperty("decoration", item->window.staticFlags & WINDOW_FLAG_DECORATION); + WriteKeywordProperty("autowrapped", item->window.staticFlags & WINDOW_FLAG_AUTO_WRAPPED); + WriteKeywordProperty("horizontalscroll", item->window.staticFlags & WINDOW_FLAG_HORIZONTAL_SCROLL); + WriteIntProperty("type", item->type, ITEM_TYPE_TEXT); + WriteIntProperty("border", item->window.border, 0); + WriteFloatProperty("borderSize", item->window.borderSize, 0.0f); + + if (item->visibleExp) + WriteStatementProperty("visible", item->visibleExp, true); + else if (item->window.dynamicFlags[0] & WINDOW_FLAG_VISIBLE) + WriteIntProperty("visible", 1, 0); + + WriteStatementProperty("disabled", item->disabledExp, true); + WriteIntProperty("ownerdraw", item->window.ownerDraw, 0); + WriteFlagsProperty("ownerdrawFlag", item->window.ownerDrawFlags); + WriteIntProperty("align", item->alignment, 0); + WriteIntProperty("textalign", item->textAlignMode, 0); + WriteFloatProperty("textalignx", item->textalignx, 0.0f); + WriteFloatProperty("textaligny", item->textaligny, 0.0f); + WriteFloatProperty("textscale", item->textscale, 0.0f); + WriteIntProperty("textstyle", item->textStyle, 0); + WriteIntProperty("textfont", item->fontEnum, 0); + WriteColorProperty("backcolor", item->window.backColor, COLOR_0000); + WriteColorProperty("forecolor", item->window.foreColor, COLOR_1111); + WriteColorProperty("bordercolor", item->window.borderColor, COLOR_0000); + WriteColorProperty("outlinecolor", item->window.outlineColor, COLOR_0000); + WriteColorProperty("disablecolor", item->window.disableColor, COLOR_0000); + WriteColorProperty("glowcolor", item->glowColor, COLOR_0000); + WriteMaterialProperty("background", item->window.background); + WriteMenuEventHandlerSetProperty("onFocus", item->onFocus); + WriteMenuEventHandlerSetProperty("leaveFocus", item->leaveFocus); + WriteMenuEventHandlerSetProperty("mouseEnter", item->mouseEnter); + WriteMenuEventHandlerSetProperty("mouseExit", item->mouseExit); + WriteMenuEventHandlerSetProperty("mouseEnterText", item->mouseEnterText); + WriteMenuEventHandlerSetProperty("mouseExitText", item->mouseExitText); + WriteMenuEventHandlerSetProperty("action", item->action); + WriteMenuEventHandlerSetProperty("accept", item->accept); + // WriteFloatProperty("special", item->special, 0.0f); + WriteSoundAliasProperty("focusSound", item->focusSound); + WriteStringProperty("dvarTest", item->dvarTest); + + if (item->dvarFlags & ITEM_DVAR_FLAG_ENABLE) + WriteMultiTokenStringProperty("enableDvar", item->enableDvar); + else if (item->dvarFlags & ITEM_DVAR_FLAG_DISABLE) + WriteMultiTokenStringProperty("disableDvar", item->enableDvar); + else if (item->dvarFlags & ITEM_DVAR_FLAG_SHOW) + WriteMultiTokenStringProperty("showDvar", item->enableDvar); + else if (item->dvarFlags & ITEM_DVAR_FLAG_HIDE) + WriteMultiTokenStringProperty("hideDvar", item->enableDvar); + else if (item->dvarFlags & ITEM_DVAR_FLAG_FOCUS) + WriteMultiTokenStringProperty("focusDvar", item->enableDvar); + + WriteItemKeyHandlerProperty(item->onKey); + WriteStatementProperty("exp text", item->textExp, false); + WriteStatementProperty("exp material", item->materialExp, false); + WriteFloatExpressionsProperty(item->floatExpressions, item->floatExpressionCount); + WriteIntProperty("gamemsgwindowindex", item->gameMsgWindowIndex, 0); + WriteIntProperty("gamemsgwindowmode", item->gameMsgWindowMode, 0); + WriteDecodeEffectProperty("decodeEffect", item); + + WriteListBoxProperties(item); + WriteEditFieldProperties(item); + WriteMultiProperties(item); + WriteEnumDvarProperties(item); + WriteTickerProperties(item); + } + + void WriteItemDefs(const itemDef_s* const* itemDefs, size_t itemCount) + { + for (auto i = 0u; i < itemCount; i++) + { + StartItemDefScope(); + + WriteItemData(itemDefs[i]); + + EndScope(); + } + } + + void WriteMenuData(const menuDef_t* menu) + { + WriteStringProperty("name", menu->window.name); + WriteBoolProperty("fullscreen", menu->fullScreen, false); + WriteKeywordProperty("screenSpace", menu->window.staticFlags & WINDOW_FLAG_SCREEN_SPACE); + WriteKeywordProperty("decoration", menu->window.staticFlags & WINDOW_FLAG_DECORATION); + WriteRectProperty("rect", menu->window.rect); + WriteIntProperty("style", menu->window.style, 0); + WriteIntProperty("border", menu->window.border, 0); + WriteFloatProperty("borderSize", menu->window.borderSize, 0.0f); + WriteColorProperty("backcolor", menu->window.backColor, COLOR_0000); + WriteColorProperty("forecolor", menu->window.foreColor, COLOR_1111); + WriteColorProperty("bordercolor", menu->window.borderColor, COLOR_0000); + WriteColorProperty("focuscolor", menu->focusColor, COLOR_0000); + WriteColorProperty("outlinecolor", menu->window.outlineColor, COLOR_0000); + WriteMaterialProperty("background", menu->window.background); + WriteIntProperty("ownerdraw", menu->window.ownerDraw, 0); + WriteFlagsProperty("ownerdrawFlag", menu->window.ownerDrawFlags); + WriteKeywordProperty("outOfBoundsClick", menu->window.staticFlags & WINDOW_FLAG_OUT_OF_BOUNDS_CLICK); + WriteStringProperty("soundLoop", menu->soundName); + WriteKeywordProperty("popup", menu->window.staticFlags & WINDOW_FLAG_POPUP); + WriteFloatProperty("fadeClamp", menu->fadeClamp, 0.0f); + WriteIntProperty("fadeCycle", menu->fadeCycle, 0); + WriteFloatProperty("fadeAmount", menu->fadeAmount, 0.0f); + WriteFloatProperty("fadeInAmount", menu->fadeInAmount, 0.0f); + WriteFloatProperty("blurWorld", menu->blurRadius, 0.0f); + WriteKeywordProperty("legacySplitScreenScale", menu->window.staticFlags & WINDOW_FLAG_LEGACY_SPLIT_SCREEN_SCALE); + WriteKeywordProperty("hiddenDuringScope", menu->window.staticFlags & WINDOW_FLAG_HIDDEN_DURING_SCOPE); + WriteKeywordProperty("hiddenDuringFlashbang", menu->window.staticFlags & WINDOW_FLAG_HIDDEN_DURING_FLASH_BANG); + WriteKeywordProperty("hiddenDuringUI", menu->window.staticFlags & WINDOW_FLAG_HIDDEN_DURING_UI); + WriteStringProperty("allowedBinding", menu->allowedBinding); + WriteKeywordProperty("textOnlyFocus", menu->window.staticFlags & WINDOW_FLAG_TEXT_ONLY_FOCUS); + + if (menu->visibleExp) + WriteStatementProperty("visible", menu->visibleExp, true); + else if (menu->window.dynamicFlags[0] & WINDOW_FLAG_VISIBLE) + WriteIntProperty("visible", 1, 0); + + WriteStatementProperty("exp rect X", menu->rectXExp, false); + WriteStatementProperty("exp rect Y", menu->rectYExp, false); + WriteStatementProperty("exp rect W", menu->rectWExp, false); + WriteStatementProperty("exp rect H", menu->rectHExp, false); + WriteStatementProperty("exp openSound", menu->openSoundExp, false); + WriteStatementProperty("exp closeSound", menu->closeSoundExp, false); + WriteMenuEventHandlerSetProperty("onOpen", menu->onOpen); + WriteMenuEventHandlerSetProperty("onClose", menu->onClose); + WriteMenuEventHandlerSetProperty("onRequestClose", menu->onCloseRequest); + WriteMenuEventHandlerSetProperty("onESC", menu->onESC); + WriteItemKeyHandlerProperty(menu->onKey); + WriteItemDefs(menu->items, menu->itemCount); + } + }; +} // namespace + +namespace IW4::menu +{ + std::unique_ptr CreateMenuWriter(std::ostream& stream) + { + return std::make_unique(stream); + } +} // namespace IW4::menu diff --git a/src/ObjWriting/Game/IW4/Menu/MenuWriterIW4.h b/src/ObjWriting/Game/IW4/Menu/MenuWriterIW4.h new file mode 100644 index 00000000..5c198f80 --- /dev/null +++ b/src/ObjWriting/Game/IW4/Menu/MenuWriterIW4.h @@ -0,0 +1,19 @@ +#pragma once + +#include "Game/IW4/IW4.h" +#include "Menu/IMenuWriter.h" + +#include +#include + +namespace IW4::menu +{ + class IWriterIW4 : public ::menu::IWriter + { + public: + virtual void WriteFunctionDef(const std::string& functionName, const Statement_s* statement) = 0; + virtual void WriteMenu(const menuDef_t& menu) = 0; + }; + + std::unique_ptr CreateMenuWriter(std::ostream& stream); +} // namespace IW4::menu diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 6fbe38da..727ab8d8 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -9,8 +9,8 @@ #include "Localize/LocalizeDumperIW4.h" #include "Maps/AddonMapEntsDumperIW4.h" #include "Material/MaterialDecompilingDumperIW4.h" -#include "Menu/AssetDumperMenuDef.h" -#include "Menu/AssetDumperMenuList.h" +#include "Menu/MenuDumperIW4.h" +#include "Menu/MenuListDumperIW4.h" #include "ObjWriting.h" #include "PhysCollmap/AssetDumperPhysCollmap.h" #include "PhysPreset/PhysPresetInfoStringDumperIW4.h" @@ -63,8 +63,8 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD) DUMP_ASSET_POOL(light_def::Dumper, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF) // DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT) - DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST) - DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU) + DUMP_ASSET_POOL(menu::MenuListDumper, m_menu_list, ASSET_TYPE_MENULIST) + DUMP_ASSET_POOL(menu::MenuDumper, m_menu_def, ASSET_TYPE_MENU) DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) DUMP_ASSET_POOL(weapon::Dumper, m_weapon, ASSET_TYPE_WEAPON) // DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) diff --git a/src/ObjWriting/Game/IW5/Menu/AssetDumperMenuDef.cpp b/src/ObjWriting/Game/IW5/Menu/AssetDumperMenuDef.cpp deleted file mode 100644 index b14b5dbe..00000000 --- a/src/ObjWriting/Game/IW5/Menu/AssetDumperMenuDef.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "AssetDumperMenuDef.h" - -#include "Game/IW5/GameAssetPoolIW5.h" -#include "Game/IW5/Menu/MenuDumperIW5.h" -#include "Menu/AbstractMenuDumper.h" -#include "ObjWriting.h" - -#include -#include - -namespace fs = std::filesystem; - -using namespace IW5; - -const MenuList* AssetDumperMenuDef::GetParentMenuList(XAssetInfo* asset) -{ - const auto* menu = asset->Asset(); - const auto* gameAssetPool = dynamic_cast(asset->m_zone->m_pools.get()); - for (const auto* menuList : *gameAssetPool->m_menu_list) - { - const auto* menuListAsset = menuList->Asset(); - - for (auto menuIndex = 0; menuIndex < menuListAsset->menuCount; menuIndex++) - { - if (menuListAsset->menus[menuIndex] == menu) - return menuListAsset; - } - } - - return nullptr; -} - -std::string AssetDumperMenuDef::GetPathForMenu(XAssetInfo* asset) -{ - const auto* list = GetParentMenuList(asset); - - if (!list) - return "ui_mp/" + std::string(asset->Asset()->window.name) + ".menu"; - - const fs::path p(list->name); - std::string parentPath; - if (p.has_parent_path()) - parentPath = p.parent_path().string() + "/"; - - return parentPath + std::string(asset->Asset()->window.name) + ".menu"; -} - -bool AssetDumperMenuDef::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperMenuDef::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* menu = asset->Asset(); - const auto menuFilePath = GetPathForMenu(asset); - - if (ObjWriting::ShouldHandleAssetType(ASSET_TYPE_MENULIST)) - { - // Don't dump menu file separately if the name matches the menu list - const auto* menuListParent = GetParentMenuList(asset); - if (menuListParent && menuFilePath == menuListParent->name) - return; - } - - const auto assetFile = context.OpenAssetFile(menuFilePath); - - if (!assetFile) - return; - - MenuDumper menuDumper(*assetFile); - - menuDumper.Start(); - menuDumper.WriteMenu(menu); - menuDumper.End(); -} diff --git a/src/ObjWriting/Game/IW5/Menu/AssetDumperMenuDef.h b/src/ObjWriting/Game/IW5/Menu/AssetDumperMenuDef.h deleted file mode 100644 index 696da199..00000000 --- a/src/ObjWriting/Game/IW5/Menu/AssetDumperMenuDef.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/IW5/IW5.h" - -namespace IW5 -{ - class AssetDumperMenuDef final : public AbstractAssetDumper - { - static const MenuList* GetParentMenuList(XAssetInfo* asset); - static std::string GetPathForMenu(XAssetInfo* asset); - - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace IW5 diff --git a/src/ObjWriting/Game/IW5/Menu/AssetDumperMenuList.cpp b/src/ObjWriting/Game/IW5/Menu/AssetDumperMenuList.cpp deleted file mode 100644 index c3b9bb44..00000000 --- a/src/ObjWriting/Game/IW5/Menu/AssetDumperMenuList.cpp +++ /dev/null @@ -1,128 +0,0 @@ -#include "AssetDumperMenuList.h" - -#include "Game/IW5/Menu/MenuDumperIW5.h" -#include "Menu/AbstractMenuDumper.h" -#include "ObjWriting.h" - -#include -#include -#include -#include - -namespace fs = std::filesystem; - -using namespace IW5; - -std::vector AssetDumperMenuList::GetAllUniqueExpressionSupportingData(const MenuList* menuList) -{ - std::vector result; - std::set alreadyAddedSupportingData; - - if (menuList->menus == nullptr) - return result; - - for (auto i = 0; i < menuList->menuCount; i++) - { - if (menuList->menus[i] == nullptr) - continue; - - const auto* menu = menuList->menus[i]; - - if (menu->data == nullptr || menu->data->expressionData == nullptr) - continue; - - if (alreadyAddedSupportingData.find(menu->data->expressionData) == alreadyAddedSupportingData.end()) - { - result.push_back(menu->data->expressionData); - alreadyAddedSupportingData.emplace(menu->data->expressionData); - } - } - - return result; -} - -void AssetDumperMenuList::DumpFunctions(MenuDumper& menuDumper, const MenuList* menuList) -{ - const auto allSupportingData = GetAllUniqueExpressionSupportingData(menuList); - auto functionIndex = 0u; - - assert(allSupportingData.size() <= 1); - - for (const auto* supportingData : allSupportingData) - { - if (supportingData->uifunctions.functions == nullptr) - continue; - - for (auto i = 0; i < supportingData->uifunctions.totalFunctions; i++) - { - const auto* function = supportingData->uifunctions.functions[i]; - if (function == nullptr) - continue; - - std::stringstream ss; - ss << "FUNC_" << functionIndex; - - menuDumper.WriteFunctionDef(ss.str(), function); - - functionIndex++; - } - } -} - -void AssetDumperMenuList::DumpMenus(MenuDumper& menuDumper, const MenuList* menuList) -{ - const fs::path p(menuList->name); - - std::string parentPath; - if (p.has_parent_path()) - parentPath = p.parent_path().string() + "/"; - - for (auto menuNum = 0; menuNum < menuList->menuCount; menuNum++) - { - const auto* menu = menuList->menus[menuNum]; - const auto* menuAssetName = menu->window.name; - - bool isReference = false; - if (menuAssetName && menuAssetName[0] == ',') - { - menuAssetName = &menuAssetName[1]; - isReference = true; - } - - std::ostringstream ss; - ss << parentPath << menuAssetName << ".menu"; - - const auto menuName = ss.str(); - - // If the menu was embedded directly as menu list write its data in the menu list file - if (!isReference && menuName == menuList->name) - menuDumper.WriteMenu(menu); - else - menuDumper.IncludeMenu(ss.str()); - } -} - -bool AssetDumperMenuList::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperMenuList::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* menuList = asset->Asset(); - const auto assetFile = context.OpenAssetFile(asset->m_name); - - if (!assetFile) - return; - - MenuDumper menuDumper(*assetFile); - - menuDumper.Start(); - - if (!ObjWriting::Configuration.MenuLegacyMode) - DumpFunctions(menuDumper, menuList); - - DumpMenus(menuDumper, menuList); - - menuDumper.End(); -} diff --git a/src/ObjWriting/Game/IW5/Menu/AssetDumperMenuList.h b/src/ObjWriting/Game/IW5/Menu/AssetDumperMenuList.h deleted file mode 100644 index 58a83904..00000000 --- a/src/ObjWriting/Game/IW5/Menu/AssetDumperMenuList.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/IW5/IW5.h" -#include "Game/IW5/Menu/MenuDumperIW5.h" - -namespace IW5 -{ - class AssetDumperMenuList final : public AbstractAssetDumper - { - static std::vector GetAllUniqueExpressionSupportingData(const MenuList* menuList); - - static void DumpFunctions(MenuDumper& menuDumper, const MenuList* menuList); - static void DumpMenus(MenuDumper& menuDumper, const MenuList* menuList); - - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace IW5 diff --git a/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.cpp b/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.cpp index d96e3c0b..713006b4 100644 --- a/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.cpp @@ -1,920 +1,83 @@ #include "MenuDumperIW5.h" -#include "Game/IW5/MenuConstantsIW5.h" +#include "Game/IW5/GameAssetPoolIW5.h" +#include "Game/IW5/Menu/MenuDumperIW5.h" +#include "MenuWriterIW5.h" #include "ObjWriting.h" -#include -#include -#include +#include +#include +#include + +namespace fs = std::filesystem; using namespace IW5; -// Uncomment this macro to skip interpretative expression dumping -// #define DUMP_NAIVE - -#ifdef DUMP_NAIVE -#define DUMP_FUNC WriteStatementNaive -#else -#define DUMP_FUNC WriteStatementSkipInitialUnnecessaryParenthesis -#endif - -size_t MenuDumper::FindStatementClosingParenthesis(const Statement_s* statement, size_t openingParenthesisPosition) +namespace { - assert(statement->numEntries >= 0); - assert(openingParenthesisPosition < static_cast(statement->numEntries)); - - const auto statementEnd = static_cast(statement->numEntries); - - // The openingParenthesisPosition does not necessarily point to an actual opening parenthesis operator. That's fine though. - // We will pretend it does since the game does sometimes leave out opening parenthesis from the entries. - auto currentParenthesisDepth = 1; - for (auto currentSearchPosition = openingParenthesisPosition + 1; currentSearchPosition < statementEnd; currentSearchPosition++) + const MenuList* GetParentMenuList(XAssetInfo* asset) { - const auto& expEntry = statement->entries[currentSearchPosition]; - if (expEntry.type != EET_OPERATOR) - continue; - - // Any function means a "left out" left paren - if (expEntry.data.op == OP_LEFTPAREN || expEntry.data.op >= OP_COUNT) + const auto* menu = asset->Asset(); + const auto* gameAssetPool = dynamic_cast(asset->m_zone->m_pools.get()); + for (const auto* menuList : *gameAssetPool->m_menu_list) { - currentParenthesisDepth++; - } - else if (expEntry.data.op == OP_RIGHTPAREN) - { - if (currentParenthesisDepth > 0) - currentParenthesisDepth--; - if (currentParenthesisDepth == 0) - return currentSearchPosition; - } - } + const auto* menuListAsset = menuList->Asset(); - return statementEnd; -} - -void MenuDumper::WriteStatementOperator(const Statement_s* statement, size_t& currentPos, bool& spaceNext) const -{ - const auto& expEntry = statement->entries[currentPos]; - - if (spaceNext && expEntry.data.op != OP_COMMA) - m_stream << " "; - - if (expEntry.data.op == OP_LEFTPAREN) - { - const auto closingParenPos = FindStatementClosingParenthesis(statement, currentPos); - m_stream << "("; - WriteStatementEntryRange(statement, currentPos + 1, closingParenPos); - m_stream << ")"; - - currentPos = closingParenPos + 1; - spaceNext = true; - } - else if (expEntry.data.op >= EXP_FUNC_STATIC_DVAR_INT && expEntry.data.op <= EXP_FUNC_STATIC_DVAR_STRING) - { - switch (expEntry.data.op) - { - case EXP_FUNC_STATIC_DVAR_INT: - m_stream << "dvarint"; - break; - - case EXP_FUNC_STATIC_DVAR_BOOL: - m_stream << "dvarbool"; - break; - - case EXP_FUNC_STATIC_DVAR_FLOAT: - m_stream << "dvarfloat"; - break; - - case EXP_FUNC_STATIC_DVAR_STRING: - m_stream << "dvarstring"; - break; - - default: - break; - } - - // Functions do not have opening parenthesis in the entries. We can just pretend they do though - const auto closingParenPos = FindStatementClosingParenthesis(statement, currentPos); - m_stream << "("; - - if (closingParenPos - currentPos + 1 >= 1) - { - const auto& staticDvarEntry = statement->entries[currentPos + 1]; - if (staticDvarEntry.type == EET_OPERAND && staticDvarEntry.data.operand.dataType == VAL_INT) + for (auto menuIndex = 0; menuIndex < menuListAsset->menuCount; menuIndex++) { - if (statement->supportingData && statement->supportingData->staticDvarList.staticDvars && staticDvarEntry.data.operand.internals.intVal >= 0 - && staticDvarEntry.data.operand.internals.intVal < statement->supportingData->staticDvarList.numStaticDvars) - { - const auto* staticDvar = statement->supportingData->staticDvarList.staticDvars[staticDvarEntry.data.operand.internals.intVal]; - if (staticDvar && staticDvar->dvarName) - m_stream << staticDvar->dvarName; - } - else - { - m_stream << "#INVALID_DVAR_INDEX"; - } - } - else - { - m_stream << "#INVALID_DVAR_OPERAND"; + if (menuListAsset->menus[menuIndex] == menu) + return menuListAsset; } } - m_stream << ")"; - currentPos = closingParenPos + 1; - spaceNext = true; + return nullptr; } - else + + std::string GetPathForMenu(XAssetInfo* asset) { - if (expEntry.data.op >= 0 && static_cast(expEntry.data.op) < std::extent_v) - m_stream << g_expFunctionNames[expEntry.data.op]; + const auto* list = GetParentMenuList(asset); - if (expEntry.data.op >= OP_COUNT) - { - // Functions do not have opening parenthesis in the entries. We can just pretend they do though - const auto closingParenPos = FindStatementClosingParenthesis(statement, currentPos); - m_stream << "("; - WriteStatementEntryRange(statement, currentPos + 1, closingParenPos); - m_stream << ")"; - currentPos = closingParenPos + 1; - } - else - currentPos++; + if (!list) + return std::format("ui_mp/{}.menu", asset->Asset()->window.name); - spaceNext = expEntry.data.op != OP_NOT; + const fs::path p(list->name); + std::string parentPath; + if (p.has_parent_path()) + parentPath = p.parent_path().string() + "/"; + + return std::format("{}{}.menu", parentPath, asset->Asset()->window.name); } -} +} // namespace -void MenuDumper::WriteStatementOperandFunction(const Statement_s* statement, const size_t currentPos) const +namespace IW5::menu { - const auto& operand = statement->entries[currentPos].data.operand; - - if (operand.internals.function == nullptr) - return; - - if (!ObjWriting::Configuration.MenuLegacyMode) + bool MenuDumper::ShouldDump(XAssetInfo* asset) { - int functionIndex = -1; - if (statement->supportingData && statement->supportingData->uifunctions.functions) + return true; + } + + void MenuDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* menu = asset->Asset(); + const auto menuFilePath = GetPathForMenu(asset); + + if (ObjWriting::ShouldHandleAssetType(ASSET_TYPE_MENULIST)) { - for (auto supportingFunctionIndex = 0; supportingFunctionIndex < statement->supportingData->uifunctions.totalFunctions; supportingFunctionIndex++) - { - if (statement->supportingData->uifunctions.functions[supportingFunctionIndex] == operand.internals.function) - { - functionIndex = supportingFunctionIndex; - break; - } - } + // Don't dump menu file separately if the name matches the menu list + const auto* menuListParent = GetParentMenuList(asset); + if (menuListParent && menuFilePath == menuListParent->name) + return; } - if (functionIndex >= 0) - m_stream << "FUNC_" << functionIndex; - else - m_stream << "INVALID_FUNC"; - m_stream << "()"; + const auto assetFile = context.OpenAssetFile(menuFilePath); + + if (!assetFile) + return; + + auto menuWriter = CreateMenuWriter(*assetFile); + + menuWriter->Start(); + menuWriter->WriteMenu(*menu); + menuWriter->End(); } - else - { - m_stream << "("; - WriteStatementSkipInitialUnnecessaryParenthesis(operand.internals.function); - m_stream << ")"; - } -} - -void MenuDumper::WriteStatementOperand(const Statement_s* statement, size_t& currentPos, bool& spaceNext) const -{ - const auto& expEntry = statement->entries[currentPos]; - - if (spaceNext) - m_stream << " "; - - const auto& operand = expEntry.data.operand; - - switch (operand.dataType) - { - case VAL_FLOAT: - m_stream << operand.internals.floatVal; - break; - - case VAL_INT: - m_stream << operand.internals.intVal; - break; - - case VAL_STRING: - WriteEscapedString(operand.internals.stringVal.string); - break; - - case VAL_FUNCTION: - WriteStatementOperandFunction(statement, currentPos); - break; - - default: - break; - } - - currentPos++; - spaceNext = true; -} - -void MenuDumper::WriteStatementEntryRange(const Statement_s* statement, size_t startOffset, size_t endOffset) const -{ - assert(startOffset <= endOffset); - assert(endOffset <= static_cast(statement->numEntries)); - - auto currentPos = startOffset; - auto spaceNext = false; - while (currentPos < endOffset) - { - const auto& expEntry = statement->entries[currentPos]; - - if (expEntry.type == EET_OPERATOR) - { - WriteStatementOperator(statement, currentPos, spaceNext); - } - else - { - WriteStatementOperand(statement, currentPos, spaceNext); - } - } -} - -void MenuDumper::WriteStatementNaive(const Statement_s* statement) const -{ - const auto entryCount = static_cast(statement->numEntries); - for (auto i = 0uz; i < entryCount; i++) - { - const auto& entry = statement->entries[i]; - if (entry.type == EET_OPERAND) - { - size_t pos = i; - bool discard = false; - WriteStatementOperand(statement, pos, discard); - } - else if (entry.data.op >= EXP_FUNC_STATIC_DVAR_INT && entry.data.op <= EXP_FUNC_STATIC_DVAR_STRING) - { - switch (entry.data.op) - { - case EXP_FUNC_STATIC_DVAR_INT: - m_stream << "dvarint"; - break; - - case EXP_FUNC_STATIC_DVAR_BOOL: - m_stream << "dvarbool"; - break; - - case EXP_FUNC_STATIC_DVAR_FLOAT: - m_stream << "dvarfloat"; - break; - - case EXP_FUNC_STATIC_DVAR_STRING: - m_stream << "dvarstring"; - break; - - default: - break; - } - - // Functions do not have opening parenthesis in the entries. We can just pretend they do though - const auto closingParenPos = FindStatementClosingParenthesis(statement, i); - m_stream << "("; - - if (closingParenPos - i + 1u >= 1u) - { - const auto& staticDvarEntry = statement->entries[i + 1u]; - if (staticDvarEntry.type == EET_OPERAND && staticDvarEntry.data.operand.dataType == VAL_INT) - { - if (statement->supportingData && statement->supportingData->staticDvarList.staticDvars && staticDvarEntry.data.operand.internals.intVal >= 0 - && staticDvarEntry.data.operand.internals.intVal < statement->supportingData->staticDvarList.numStaticDvars) - { - const auto* staticDvar = statement->supportingData->staticDvarList.staticDvars[staticDvarEntry.data.operand.internals.intVal]; - if (staticDvar && staticDvar->dvarName) - m_stream << staticDvar->dvarName; - } - else - { - m_stream << "#INVALID_DVAR_INDEX"; - } - } - else - { - m_stream << "#INVALID_DVAR_OPERAND"; - } - } - - m_stream << ")"; - i = closingParenPos; - } - else - { - assert(entry.data.op >= 0 && static_cast(entry.data.op) < std::extent_v); - if (entry.data.op >= 0 && static_cast(entry.data.op) < std::extent_v) - m_stream << g_expFunctionNames[entry.data.op]; - if (entry.data.op >= OP_COUNT) - m_stream << "("; - } - } -} - -void MenuDumper::WriteStatement(const Statement_s* statement) const -{ - if (statement == nullptr || statement->numEntries < 0) - return; - - WriteStatementEntryRange(statement, 0, static_cast(statement->numEntries)); -} - -void MenuDumper::WriteStatementSkipInitialUnnecessaryParenthesis(const Statement_s* statementValue) const -{ - if (statementValue == nullptr || statementValue->numEntries < 0) - return; - - const auto statementEnd = static_cast(statementValue->numEntries); - - if (statementValue->numEntries >= 1 && statementValue->entries[0].type == EET_OPERATOR && statementValue->entries[0].data.op == OP_LEFTPAREN) - { - const auto parenthesisEnd = FindStatementClosingParenthesis(statementValue, 0); - - if (parenthesisEnd >= statementEnd) - WriteStatementEntryRange(statementValue, 1, statementEnd); - else if (parenthesisEnd == statementEnd - 1) - WriteStatementEntryRange(statementValue, 1, statementEnd - 1); - else - WriteStatementEntryRange(statementValue, 0, statementEnd); - } - else - { - WriteStatementEntryRange(statementValue, 0, statementEnd); - } -} - -void MenuDumper::WriteStatementProperty(const std::string& propertyKey, const Statement_s* statementValue, bool isBooleanStatement) const -{ - if (statementValue == nullptr || statementValue->numEntries < 0) - return; - - Indent(); - WriteKey(propertyKey); - - if (isBooleanStatement) - { - m_stream << "when("; - DUMP_FUNC(statementValue); - m_stream << ");\n"; - } - else - { - DUMP_FUNC(statementValue); - m_stream << ";\n"; - } -} - -void MenuDumper::WriteSetLocalVarData(const std::string& setFunction, const SetLocalVarData* setLocalVarData) const -{ - if (setLocalVarData == nullptr) - return; - - Indent(); - m_stream << setFunction << " " << setLocalVarData->localVarName << " "; - WriteStatement(setLocalVarData->expression); - m_stream << ";\n"; -} - -// #define WRITE_ORIGINAL_SCRIPT - -void MenuDumper::WriteUnconditionalScript(const char* script) const -{ -#ifdef WRITE_ORIGINAL_SCRIPT - Indent(); - m_stream << script << "\n"; - return; -#endif - - const auto tokenList = CreateScriptTokenList(script); - - auto isNewStatement = true; - for (const auto& token : tokenList) - { - if (isNewStatement) - { - if (token == ";") - continue; - - Indent(); - } - - if (token == ";") - { - m_stream << ";\n"; - isNewStatement = true; - continue; - } - - if (!isNewStatement) - m_stream << " "; - else - isNewStatement = false; - - if (DoesTokenNeedQuotationMarks(token)) - m_stream << "\"" << token << "\""; - else - m_stream << token; - } - - if (!isNewStatement) - m_stream << ";\n"; -} - -void MenuDumper::WriteMenuEventHandlerSet(const MenuEventHandlerSet* eventHandlerSet) -{ - Indent(); - m_stream << "{\n"; - IncIndent(); - - for (auto i = 0; i < eventHandlerSet->eventHandlerCount; i++) - { - const auto* eventHandler = eventHandlerSet->eventHandlers[i]; - if (eventHandler == nullptr) - continue; - - switch (eventHandler->eventType) - { - case EVENT_UNCONDITIONAL: - WriteUnconditionalScript(eventHandler->eventData.unconditionalScript); - break; - - case EVENT_IF: - if (eventHandler->eventData.conditionalScript == nullptr || eventHandler->eventData.conditionalScript->eventExpression == nullptr - || eventHandler->eventData.conditionalScript->eventHandlerSet == nullptr) - { - continue; - } - - Indent(); - m_stream << "if ("; - WriteStatementSkipInitialUnnecessaryParenthesis(eventHandler->eventData.conditionalScript->eventExpression); - m_stream << ")\n"; - WriteMenuEventHandlerSet(eventHandler->eventData.conditionalScript->eventHandlerSet); - break; - - case EVENT_ELSE: - if (eventHandler->eventData.elseScript == nullptr) - continue; - - Indent(); - m_stream << "else\n"; - WriteMenuEventHandlerSet(eventHandler->eventData.elseScript); - break; - - case EVENT_SET_LOCAL_VAR_BOOL: - WriteSetLocalVarData("setLocalVarBool", eventHandler->eventData.setLocalVarData); - break; - - case EVENT_SET_LOCAL_VAR_INT: - WriteSetLocalVarData("setLocalVarInt", eventHandler->eventData.setLocalVarData); - break; - - case EVENT_SET_LOCAL_VAR_FLOAT: - WriteSetLocalVarData("setLocalVarFloat", eventHandler->eventData.setLocalVarData); - break; - - case EVENT_SET_LOCAL_VAR_STRING: - WriteSetLocalVarData("setLocalVarString", eventHandler->eventData.setLocalVarData); - break; - - default: - break; - } - } - - DecIndent(); - Indent(); - m_stream << "}\n"; -} - -void MenuDumper::WriteMenuEventHandlerSetProperty(const std::string& propertyKey, const MenuEventHandlerSet* eventHandlerSetValue) -{ - if (eventHandlerSetValue == nullptr) - return; - - Indent(); - m_stream << propertyKey << "\n"; - WriteMenuEventHandlerSet(eventHandlerSetValue); -} - -void MenuDumper::WriteRectProperty(const std::string& propertyKey, const rectDef_s& rect) const -{ - Indent(); - WriteKey(propertyKey); - m_stream << rect.x << " " << rect.y << " " << rect.w << " " << rect.h << " " << static_cast(rect.horzAlign) << " " << static_cast(rect.vertAlign) - << "\n"; -} - -void MenuDumper::WriteMaterialProperty(const std::string& propertyKey, const Material* materialValue) const -{ - if (materialValue == nullptr || materialValue->info.name == nullptr) - return; - - if (materialValue->info.name[0] == ',') - WriteStringProperty(propertyKey, &materialValue->info.name[1]); - else - WriteStringProperty(propertyKey, materialValue->info.name); -} - -void MenuDumper::WriteSoundAliasProperty(const std::string& propertyKey, const snd_alias_list_t* soundAliasValue) const -{ - if (soundAliasValue == nullptr) - return; - - WriteStringProperty(propertyKey, soundAliasValue->aliasName); -} - -void MenuDumper::WriteDecodeEffectProperty(const std::string& propertyKey, const itemDef_s* item) const -{ - if (!item->decayActive) - return; - - Indent(); - WriteKey(propertyKey); - m_stream << item->fxLetterTime << " " << item->fxDecayStartTime << " " << item->fxDecayDuration << "\n"; -} - -void MenuDumper::WriteItemKeyHandlerProperty(const ItemKeyHandler* itemKeyHandlerValue) -{ - for (const auto* currentHandler = itemKeyHandlerValue; currentHandler; currentHandler = currentHandler->next) - { - if (currentHandler->key >= '!' && currentHandler->key <= '~' && currentHandler->key != '"') - { - std::ostringstream ss; - ss << "execKey \"" << static_cast(currentHandler->key) << "\""; - WriteMenuEventHandlerSetProperty(ss.str(), currentHandler->action); - } - else - { - std::ostringstream ss; - ss << "execKeyInt " << currentHandler->key; - WriteMenuEventHandlerSetProperty(ss.str(), currentHandler->action); - } - } -} - -void MenuDumper::WriteFloatExpressionsProperty(const ItemFloatExpression* floatExpressions, int floatExpressionCount) const -{ - if (!floatExpressions) - return; - - for (int i = 0; i < floatExpressionCount; i++) - { - const auto& floatExpression = floatExpressions[i]; - - if (floatExpression.target < 0 || floatExpression.target >= ITEM_FLOATEXP_TGT_COUNT) - continue; - - std::string propertyName = std::string("exp ") + floatExpressionTargetBindings[floatExpression.target].name + std::string(" ") - + floatExpressionTargetBindings[floatExpression.target].componentName; - - WriteStatementProperty(propertyName, floatExpression.expression, false); - } -} - -void MenuDumper::WriteMultiTokenStringProperty(const std::string& propertyKey, const char* value) const -{ - if (!value) - return; - - Indent(); - WriteKey(propertyKey); - - const auto tokenList = CreateScriptTokenList(value); - - auto firstToken = true; - m_stream << "{ "; - for (const auto& token : tokenList) - { - if (firstToken) - firstToken = false; - else - m_stream << ";"; - m_stream << "\"" << token << "\""; - } - if (!firstToken) - m_stream << " "; - m_stream << "}\n"; -} - -void MenuDumper::WriteColumnProperty(const std::string& propertyKey, const listBoxDef_s* listBox) const -{ - if (listBox->numColumns <= 0) - return; - - Indent(); - WriteKey(propertyKey); - m_stream << listBox->numColumns << "\n"; - - for (auto col = 0; col < listBox->numColumns; col++) - { - Indent(); - for (auto i = 0u; i < MENU_KEY_SPACING; i++) - m_stream << " "; - - m_stream << listBox->columnInfo[col].xpos << " " << listBox->columnInfo[col].ypos << " " << listBox->columnInfo[col].width << " " - << listBox->columnInfo[col].height << " " << listBox->columnInfo[col].maxChars << " " << listBox->columnInfo[col].alignment << "\n"; - } -} - -void MenuDumper::WriteListBoxProperties(const itemDef_s* item) -{ - if (item->type != ITEM_TYPE_LISTBOX || item->typeData.listBox == nullptr) - return; - - const auto* listBox = item->typeData.listBox; - WriteKeywordProperty("notselectable", listBox->notselectable != 0); - WriteKeywordProperty("noscrollbars", listBox->noScrollBars != 0); - WriteKeywordProperty("usepaging", listBox->usePaging != 0); - WriteFloatProperty("elementwidth", listBox->elementWidth, 0.0f); - WriteFloatProperty("elementheight", listBox->elementHeight, 0.0f); - WriteFloatProperty("feeder", item->special, 0.0f); - WriteIntProperty("elementtype", listBox->elementStyle, 0); - WriteColumnProperty("columns", listBox); - WriteMenuEventHandlerSetProperty("doubleclick", listBox->onDoubleClick); - WriteColorProperty("selectBorder", listBox->selectBorder, COLOR_0000); - WriteMaterialProperty("selectIcon", listBox->selectIcon); - WriteStatementProperty("exp elementheight", listBox->elementHeightExp, false); -} - -void MenuDumper::WriteDvarFloatProperty(const std::string& propertyKey, const itemDef_s* item, const editFieldDef_s* editField) const -{ - if (item->dvar == nullptr) - return; - - Indent(); - WriteKey(propertyKey); - m_stream << "\"" << item->dvar << "\" " << editField->stepVal << " " << editField->minVal << " " << editField->maxVal << "\n"; -} - -void MenuDumper::WriteEditFieldProperties(const itemDef_s* item) const -{ - switch (item->type) - { - case ITEM_TYPE_TEXT: - case ITEM_TYPE_EDITFIELD: - case ITEM_TYPE_NUMERICFIELD: - case ITEM_TYPE_SLIDER: - case ITEM_TYPE_YESNO: - case ITEM_TYPE_BIND: - case ITEM_TYPE_VALIDFILEFIELD: - case ITEM_TYPE_DECIMALFIELD: - case ITEM_TYPE_UPREDITFIELD: - case ITEM_TYPE_EMAILFIELD: - case ITEM_TYPE_PASSWORDFIELD: - break; - - default: - return; - } - - if (item->typeData.editField == nullptr) - return; - - const auto* editField = item->typeData.editField; - if (std::fabs(-1.0f - editField->stepVal) >= std::numeric_limits::epsilon() - || std::fabs(-1.0f - editField->minVal) >= std::numeric_limits::epsilon() - || std::fabs(-1.0f - editField->maxVal) >= std::numeric_limits::epsilon()) - { - WriteDvarFloatProperty("dvarFloat", item, editField); - } - else - { - WriteStringProperty("dvar", item->dvar); - } - WriteStringProperty("localvar", item->localVar); - WriteIntProperty("maxChars", editField->maxChars, 0); - WriteKeywordProperty("maxCharsGotoNext", editField->maxCharsGotoNext != 0); - WriteIntProperty("maxPaintChars", editField->maxPaintChars, 0); -} - -void MenuDumper::WriteMultiValueProperty(const multiDef_s* multiDef) const -{ - Indent(); - if (multiDef->strDef) - WriteKey("dvarStrList"); - else - WriteKey("dvarFloatList"); - - m_stream << "{"; - for (auto i = 0; i < multiDef->count; i++) - { - if (multiDef->dvarList[i] == nullptr || multiDef->strDef && multiDef->dvarStr[i] == nullptr) - continue; - - m_stream << " \"" << multiDef->dvarList[i] << "\""; - - if (multiDef->strDef) - m_stream << " \"" << multiDef->dvarStr[i] << "\""; - else - m_stream << " " << multiDef->dvarValue[i] << ""; - } - m_stream << " }\n"; -} - -void MenuDumper::WriteMultiProperties(const itemDef_s* item) const -{ - if (item->type != ITEM_TYPE_MULTI || item->typeData.multi == nullptr) - return; - - const auto* multiDef = item->typeData.multi; - - if (multiDef->count <= 0) - return; - - WriteStringProperty("dvar", item->dvar); - WriteStringProperty("localvar", item->localVar); - WriteMultiValueProperty(multiDef); -} - -void MenuDumper::WriteEnumDvarProperties(const itemDef_s* item) const -{ - if (item->type != ITEM_TYPE_DVARENUM) - return; - - WriteStringProperty("dvar", item->dvar); - WriteStringProperty("localvar", item->localVar); - WriteStringProperty("dvarEnumList", item->typeData.enumDvarName); -} - -void MenuDumper::WriteTickerProperties(const itemDef_s* item) const -{ - if (item->type != ITEM_TYPE_NEWS_TICKER || item->typeData.ticker == nullptr) - return; - - const auto* newsTickerDef = item->typeData.ticker; - WriteIntProperty("spacing", newsTickerDef->spacing, 0); - WriteIntProperty("speed", newsTickerDef->speed, 0); - WriteIntProperty("newsfeed", newsTickerDef->feedId, 0); -} - -void MenuDumper::WriteItemData(const itemDef_s* item) -{ - WriteStringProperty("name", item->window.name); - WriteStringProperty("text", item->text); - WriteKeywordProperty("textsavegame", item->itemFlags & ITEM_FLAG_SAVE_GAME_INFO); - WriteKeywordProperty("textcinematicsubtitle", item->itemFlags & ITEM_FLAG_CINEMATIC_SUBTITLE); - WriteStringProperty("group", item->window.group); - WriteRectProperty("rect", item->window.rectClient); - WriteIntProperty("style", item->window.style, 0); - WriteKeywordProperty("decoration", item->window.staticFlags & WINDOW_FLAG_DECORATION); - WriteKeywordProperty("autowrapped", item->window.staticFlags & WINDOW_FLAG_AUTO_WRAPPED); - WriteKeywordProperty("horizontalscroll", item->window.staticFlags & WINDOW_FLAG_HORIZONTAL_SCROLL); - WriteIntProperty("type", item->type, ITEM_TYPE_TEXT); - WriteIntProperty("border", item->window.border, 0); - WriteFloatProperty("borderSize", item->window.borderSize, 0.0f); - - if (item->visibleExp) - WriteStatementProperty("visible", item->visibleExp, true); - else if (item->window.dynamicFlags[0] & WINDOW_FLAG_VISIBLE) - WriteIntProperty("visible", 1, 0); - - WriteStatementProperty("disabled", item->disabledExp, true); - WriteIntProperty("ownerdraw", item->window.ownerDraw, 0); - WriteFlagsProperty("ownerdrawFlag", item->window.ownerDrawFlags); - WriteIntProperty("align", item->alignment, 0); - WriteIntProperty("textalign", item->textAlignMode, 0); - WriteFloatProperty("textalignx", item->textalignx, 0.0f); - WriteFloatProperty("textaligny", item->textaligny, 0.0f); - WriteFloatProperty("textscale", item->textscale, 0.0f); - WriteIntProperty("textstyle", item->textStyle, 0); - WriteIntProperty("textfont", item->fontEnum, 0); - WriteColorProperty("backcolor", item->window.backColor, COLOR_0000); - WriteColorProperty("forecolor", item->window.foreColor, COLOR_1111); - WriteColorProperty("bordercolor", item->window.borderColor, COLOR_0000); - WriteColorProperty("outlinecolor", item->window.outlineColor, COLOR_0000); - WriteColorProperty("disablecolor", item->window.disableColor, COLOR_0000); - WriteColorProperty("glowcolor", item->glowColor, COLOR_0000); - WriteMaterialProperty("background", item->window.background); - WriteMenuEventHandlerSetProperty("onFocus", item->onFocus); - WriteMenuEventHandlerSetProperty("hasFocus", item->hasFocus); - WriteMenuEventHandlerSetProperty("leaveFocus", item->leaveFocus); - WriteMenuEventHandlerSetProperty("mouseEnter", item->mouseEnter); - WriteMenuEventHandlerSetProperty("mouseExit", item->mouseExit); - WriteMenuEventHandlerSetProperty("mouseEnterText", item->mouseEnterText); - WriteMenuEventHandlerSetProperty("mouseExitText", item->mouseExitText); - WriteMenuEventHandlerSetProperty("action", item->action); - WriteMenuEventHandlerSetProperty("accept", item->accept); - // WriteFloatProperty("special", item->special, 0.0f); - WriteSoundAliasProperty("focusSound", item->focusSound); - WriteStringProperty("dvarTest", item->dvarTest); - - if (item->dvarFlags & ITEM_DVAR_FLAG_ENABLE) - WriteMultiTokenStringProperty("enableDvar", item->enableDvar); - else if (item->dvarFlags & ITEM_DVAR_FLAG_DISABLE) - WriteMultiTokenStringProperty("disableDvar", item->enableDvar); - else if (item->dvarFlags & ITEM_DVAR_FLAG_SHOW) - WriteMultiTokenStringProperty("showDvar", item->enableDvar); - else if (item->dvarFlags & ITEM_DVAR_FLAG_HIDE) - WriteMultiTokenStringProperty("hideDvar", item->enableDvar); - else if (item->dvarFlags & ITEM_DVAR_FLAG_FOCUS) - WriteMultiTokenStringProperty("focusDvar", item->enableDvar); - - WriteItemKeyHandlerProperty(item->onKey); - WriteStatementProperty("exp text", item->textExp, false); - WriteStatementProperty("exp textaligny", item->textAlignYExp, false); - WriteStatementProperty("exp material", item->materialExp, false); - WriteFloatExpressionsProperty(item->floatExpressions, item->floatExpressionCount); - WriteIntProperty("gamemsgwindowindex", item->gameMsgWindowIndex, 0); - WriteIntProperty("gamemsgwindowmode", item->gameMsgWindowMode, 0); - WriteDecodeEffectProperty("decodeEffect", item); - - WriteListBoxProperties(item); - WriteEditFieldProperties(item); - WriteMultiProperties(item); - WriteEnumDvarProperties(item); - WriteTickerProperties(item); -} - -void MenuDumper::WriteItemDefs(const itemDef_s* const* itemDefs, size_t itemCount) -{ - for (auto i = 0u; i < itemCount; i++) - { - StartItemDefScope(); - - WriteItemData(itemDefs[i]); - - EndScope(); - } -} - -void MenuDumper::WriteMenuData(const menuDef_t* menu) -{ - WriteStringProperty("name", menu->window.name); - WriteBoolProperty("fullscreen", menu->data->fullScreen, false); - WriteKeywordProperty("screenSpace", menu->window.staticFlags & WINDOW_FLAG_SCREEN_SPACE); - WriteKeywordProperty("decoration", menu->window.staticFlags & WINDOW_FLAG_DECORATION); - WriteRectProperty("rect", menu->window.rect); - WriteIntProperty("style", menu->window.style, 0); - WriteIntProperty("border", menu->window.border, 0); - WriteFloatProperty("borderSize", menu->window.borderSize, 0.0f); - WriteColorProperty("backcolor", menu->window.backColor, COLOR_0000); - WriteColorProperty("forecolor", menu->window.foreColor, COLOR_1111); - WriteColorProperty("bordercolor", menu->window.borderColor, COLOR_0000); - WriteColorProperty("focuscolor", menu->data->focusColor, COLOR_0000); - WriteColorProperty("outlinecolor", menu->window.outlineColor, COLOR_0000); - WriteMaterialProperty("background", menu->window.background); - WriteIntProperty("ownerdraw", menu->window.ownerDraw, 0); - WriteFlagsProperty("ownerdrawFlag", menu->window.ownerDrawFlags); - WriteKeywordProperty("outOfBoundsClick", menu->window.staticFlags & WINDOW_FLAG_OUT_OF_BOUNDS_CLICK); - WriteStringProperty("soundLoop", menu->data->soundName); - WriteKeywordProperty("popup", menu->window.staticFlags & WINDOW_FLAG_POPUP); - WriteFloatProperty("fadeClamp", menu->data->fadeClamp, 0.0f); - WriteIntProperty("fadeCycle", menu->data->fadeCycle, 0); - WriteFloatProperty("fadeAmount", menu->data->fadeAmount, 0.0f); - WriteFloatProperty("fadeInAmount", menu->data->fadeInAmount, 0.0f); - WriteFloatProperty("blurWorld", menu->data->blurRadius, 0.0f); - WriteKeywordProperty("legacySplitScreenScale", menu->window.staticFlags & WINDOW_FLAG_LEGACY_SPLIT_SCREEN_SCALE); - WriteKeywordProperty("hiddenDuringScope", menu->window.staticFlags & WINDOW_FLAG_HIDDEN_DURING_SCOPE); - WriteKeywordProperty("hiddenDuringFlashbang", menu->window.staticFlags & WINDOW_FLAG_HIDDEN_DURING_FLASH_BANG); - WriteKeywordProperty("hiddenDuringUI", menu->window.staticFlags & WINDOW_FLAG_HIDDEN_DURING_UI); - WriteStringProperty("allowedBinding", menu->data->allowedBinding); - WriteKeywordProperty("textOnlyFocus", menu->window.staticFlags & WINDOW_FLAG_TEXT_ONLY_FOCUS); - - if (menu->data->visibleExp) - WriteStatementProperty("visible", menu->data->visibleExp, true); - else if (menu->window.dynamicFlags[0] & WINDOW_FLAG_VISIBLE) - WriteIntProperty("visible", 1, 0); - - WriteStatementProperty("exp rect X", menu->data->rectXExp, false); - WriteStatementProperty("exp rect Y", menu->data->rectYExp, false); - WriteStatementProperty("exp rect W", menu->data->rectWExp, false); - WriteStatementProperty("exp rect H", menu->data->rectHExp, false); - WriteStatementProperty("exp openSound", menu->data->openSoundExp, false); - WriteStatementProperty("exp closeSound", menu->data->closeSoundExp, false); - WriteStatementProperty("exp soundLoop", menu->data->soundLoopExp, false); - WriteMenuEventHandlerSetProperty("onOpen", menu->data->onOpen); - WriteMenuEventHandlerSetProperty("onClose", menu->data->onClose); - WriteMenuEventHandlerSetProperty("onRequestClose", menu->data->onCloseRequest); - WriteMenuEventHandlerSetProperty("onESC", menu->data->onESC); - WriteMenuEventHandlerSetProperty("onFocusDueToClose", menu->data->onFocusDueToClose); - WriteItemKeyHandlerProperty(menu->data->onKey); - WriteItemDefs(menu->items, menu->itemCount); -} - -MenuDumper::MenuDumper(std::ostream& stream) - : AbstractMenuDumper(stream) -{ -} - -void MenuDumper::WriteFunctionDef(const std::string& functionName, const Statement_s* statement) -{ - StartFunctionDefScope(); - - WriteStringProperty("name", functionName); - WriteStatementProperty("value", statement, false); - - EndScope(); -} - -void MenuDumper::WriteMenu(const menuDef_t* menu) -{ - StartMenuDefScope(); - - WriteMenuData(menu); - - EndScope(); -} +} // namespace IW5::menu diff --git a/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.h b/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.h index 9e3e3000..e5bd12ad 100644 --- a/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.h @@ -1,57 +1,15 @@ #pragma once +#include "Dumping/AbstractAssetDumper.h" #include "Game/IW5/IW5.h" -#include "Menu/AbstractMenuDumper.h" +#include "Game/IW5/Menu/MenuDumperIW5.h" -#include - -namespace IW5 +namespace IW5::menu { - class MenuDumper : public AbstractMenuDumper + class MenuDumper final : public AbstractAssetDumper { - static size_t FindStatementClosingParenthesis(const Statement_s* statement, size_t openingParenthesisPosition); - - void WriteStatementNaive(const Statement_s* statement) const; - - void WriteStatementOperator(const Statement_s* statement, size_t& currentPos, bool& spaceNext) const; - void WriteStatementOperandFunction(const Statement_s* statement, size_t currentPos) const; - void WriteStatementOperand(const Statement_s* statement, size_t& currentPos, bool& spaceNext) const; - void WriteStatementEntryRange(const Statement_s* statement, size_t startOffset, size_t endOffset) const; - void WriteStatement(const Statement_s* statement) const; - void WriteStatementSkipInitialUnnecessaryParenthesis(const Statement_s* statementValue) const; - void WriteStatementProperty(const std::string& propertyKey, const Statement_s* statementValue, bool isBooleanStatement) const; - - void WriteSetLocalVarData(const std::string& setFunction, const SetLocalVarData* setLocalVarData) const; - void WriteUnconditionalScript(const char* script) const; - void WriteMenuEventHandlerSet(const MenuEventHandlerSet* eventHandlerSet); - void WriteMenuEventHandlerSetProperty(const std::string& propertyKey, const MenuEventHandlerSet* eventHandlerSetValue); - - void WriteRectProperty(const std::string& propertyKey, const rectDef_s& rect) const; - void WriteMaterialProperty(const std::string& propertyKey, const Material* materialValue) const; - void WriteSoundAliasProperty(const std::string& propertyKey, const snd_alias_list_t* soundAliasValue) const; - void WriteDecodeEffectProperty(const std::string& propertyKey, const itemDef_s* item) const; - void WriteItemKeyHandlerProperty(const ItemKeyHandler* itemKeyHandlerValue); - void WriteMultiTokenStringProperty(const std::string& propertyKey, const char* value) const; - void WriteFloatExpressionsProperty(const ItemFloatExpression* floatExpressions, int floatExpressionCount) const; - void WriteColumnProperty(const std::string& propertyKey, const listBoxDef_s* listBox) const; - - void WriteListBoxProperties(const itemDef_s* item); - void WriteDvarFloatProperty(const std::string& propertyKey, const itemDef_s* item, const editFieldDef_s* editField) const; - void WriteEditFieldProperties(const itemDef_s* item) const; - void WriteMultiValueProperty(const multiDef_s* multiDef) const; - void WriteMultiProperties(const itemDef_s* item) const; - void WriteEnumDvarProperties(const itemDef_s* item) const; - void WriteTickerProperties(const itemDef_s* item) const; - - void WriteItemData(const itemDef_s* item); - void WriteItemDefs(const itemDef_s* const* itemDefs, size_t itemCount); - - void WriteMenuData(const menuDef_t* menu); - - public: - explicit MenuDumper(std::ostream& stream); - - void WriteFunctionDef(const std::string& functionName, const Statement_s* statement); - void WriteMenu(const menuDef_t* menu); + protected: + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW5 +} // namespace IW5::menu diff --git a/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.cpp b/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.cpp new file mode 100644 index 00000000..8806de3b --- /dev/null +++ b/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.cpp @@ -0,0 +1,133 @@ +#include "MenuListDumperIW5.h" + +#include "Game/IW5/Menu/MenuWriterIW5.h" +#include "Menu/AbstractMenuWriter.h" +#include "MenuWriterIW5.h" +#include "ObjWriting.h" + +#include +#include +#include +#include +#include + +namespace fs = std::filesystem; + +using namespace IW5; + +namespace +{ + std::vector GetAllUniqueExpressionSupportingData(const MenuList* menuList) + { + std::vector result; + std::set alreadyAddedSupportingData; + + if (menuList->menus == nullptr) + return result; + + for (auto i = 0; i < menuList->menuCount; i++) + { + if (menuList->menus[i] == nullptr) + continue; + + const auto* menu = menuList->menus[i]; + + if (menu->data == nullptr || menu->data->expressionData == nullptr) + continue; + + if (alreadyAddedSupportingData.find(menu->data->expressionData) == alreadyAddedSupportingData.end()) + { + result.push_back(menu->data->expressionData); + alreadyAddedSupportingData.emplace(menu->data->expressionData); + } + } + + return result; + } + + void DumpFunctions(IW5::menu::IWriterIW5& menuDumper, const MenuList* menuList) + { + const auto allSupportingData = GetAllUniqueExpressionSupportingData(menuList); + auto functionIndex = 0u; + + assert(allSupportingData.size() <= 1); + + for (const auto* supportingData : allSupportingData) + { + if (supportingData->uifunctions.functions == nullptr) + continue; + + for (auto i = 0; i < supportingData->uifunctions.totalFunctions; i++) + { + const auto* function = supportingData->uifunctions.functions[i]; + if (function == nullptr) + continue; + + menuDumper.WriteFunctionDef(std::format("FUNC_{}", functionIndex), function); + + functionIndex++; + } + } + } + + void DumpMenus(IW5::menu::IWriterIW5& menuDumper, const MenuList* menuList) + { + const fs::path p(menuList->name); + + std::string parentPath; + if (p.has_parent_path()) + parentPath = p.parent_path().string() + "/"; + + for (auto menuNum = 0; menuNum < menuList->menuCount; menuNum++) + { + const auto* menu = menuList->menus[menuNum]; + const auto* menuAssetName = menu->window.name; + + bool isReference = false; + if (menuAssetName && menuAssetName[0] == ',') + { + menuAssetName = &menuAssetName[1]; + isReference = true; + } + + std::ostringstream ss; + ss << parentPath << menuAssetName << ".menu"; + + const auto menuName = ss.str(); + + // If the menu was embedded directly as menu list write its data in the menu list file + if (!isReference && menuName == menuList->name) + menuDumper.WriteMenu(*menu); + else + menuDumper.IncludeMenu(ss.str()); + } + } +} // namespace + +namespace IW5::menu +{ + bool MenuListDumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void MenuListDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* menuList = asset->Asset(); + const auto assetFile = context.OpenAssetFile(asset->m_name); + + if (!assetFile) + return; + + auto menuWriter = CreateMenuWriter(*assetFile); + + menuWriter->Start(); + + if (!ObjWriting::Configuration.MenuLegacyMode) + DumpFunctions(*menuWriter, menuList); + + DumpMenus(*menuWriter, menuList); + + menuWriter->End(); + } +} // namespace IW5::menu diff --git a/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.h b/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.h new file mode 100644 index 00000000..29daedb6 --- /dev/null +++ b/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.h @@ -0,0 +1,14 @@ +#pragma once + +#include "Dumping/AbstractAssetDumper.h" +#include "Game/IW5/IW5.h" + +namespace IW5::menu +{ + class MenuListDumper final : public AbstractAssetDumper + { + protected: + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + }; +} // namespace IW5::menu diff --git a/src/ObjWriting/Game/IW5/Menu/MenuWriterIW5.cpp b/src/ObjWriting/Game/IW5/Menu/MenuWriterIW5.cpp new file mode 100644 index 00000000..1ef3c4cb --- /dev/null +++ b/src/ObjWriting/Game/IW5/Menu/MenuWriterIW5.cpp @@ -0,0 +1,957 @@ +#include "MenuWriterIW5.h" + +#include "Game/IW5/MenuConstantsIW5.h" +#include "Menu/AbstractMenuWriter.h" +#include "ObjWriting.h" + +#include +#include +#include + +using namespace IW5; + +// Uncomment this macro to skip interpretative expression dumping +// #define DUMP_NAIVE + +#ifdef DUMP_NAIVE +#define DUMP_FUNC WriteStatementNaive +#else +#define DUMP_FUNC WriteStatementSkipInitialUnnecessaryParenthesis +#endif + +namespace +{ + size_t FindStatementClosingParenthesis(const Statement_s* statement, const size_t openingParenthesisPosition) + { + assert(statement->numEntries >= 0); + assert(openingParenthesisPosition < static_cast(statement->numEntries)); + + const auto statementEnd = static_cast(statement->numEntries); + + // The openingParenthesisPosition does not necessarily point to an actual opening parenthesis operator. That's fine though. + // We will pretend it does since the game does sometimes leave out opening parenthesis from the entries. + auto currentParenthesisDepth = 1; + for (auto currentSearchPosition = openingParenthesisPosition + 1; currentSearchPosition < statementEnd; currentSearchPosition++) + { + const auto& expEntry = statement->entries[currentSearchPosition]; + if (expEntry.type != EET_OPERATOR) + continue; + + // Any function means a "left out" left paren + if (expEntry.data.op == OP_LEFTPAREN || expEntry.data.op >= OP_COUNT) + { + currentParenthesisDepth++; + } + else if (expEntry.data.op == OP_RIGHTPAREN) + { + if (currentParenthesisDepth > 0) + currentParenthesisDepth--; + if (currentParenthesisDepth == 0) + return currentSearchPosition; + } + } + + return statementEnd; + } +} // namespace + +namespace +{ + class MenuWriter final : public ::menu::AbstractBaseWriter, public IW5::menu::IWriterIW5 + { + public: + explicit MenuWriter(std::ostream& stream) + : AbstractBaseWriter(stream) + { + } + + void WriteFunctionDef(const std::string& functionName, const Statement_s* statement) override + { + StartFunctionDefScope(); + + WriteStringProperty("name", functionName); + WriteStatementProperty("value", statement, false); + + EndScope(); + } + + void WriteMenu(const menuDef_t& menu) override + { + StartMenuDefScope(); + + WriteMenuData(&menu); + + EndScope(); + } + + void Start() override + { + AbstractBaseWriter::Start(); + } + + void End() override + { + AbstractBaseWriter::End(); + } + + void IncludeMenu(const std::string& menuPath) const override + { + AbstractBaseWriter::IncludeMenu(menuPath); + } + + private: + void WriteStatementNaive(const Statement_s* statement) const + { + const auto entryCount = static_cast(statement->numEntries); + for (auto i = 0uz; i < entryCount; i++) + { + const auto& entry = statement->entries[i]; + if (entry.type == EET_OPERAND) + { + size_t pos = i; + bool discard = false; + WriteStatementOperand(statement, pos, discard); + } + else if (entry.data.op >= EXP_FUNC_STATIC_DVAR_INT && entry.data.op <= EXP_FUNC_STATIC_DVAR_STRING) + { + switch (entry.data.op) + { + case EXP_FUNC_STATIC_DVAR_INT: + m_stream << "dvarint"; + break; + + case EXP_FUNC_STATIC_DVAR_BOOL: + m_stream << "dvarbool"; + break; + + case EXP_FUNC_STATIC_DVAR_FLOAT: + m_stream << "dvarfloat"; + break; + + case EXP_FUNC_STATIC_DVAR_STRING: + m_stream << "dvarstring"; + break; + + default: + break; + } + + // Functions do not have opening parenthesis in the entries. We can just pretend they do though + const auto closingParenPos = FindStatementClosingParenthesis(statement, i); + m_stream << "("; + + if (closingParenPos - i + 1u >= 1u) + { + const auto& staticDvarEntry = statement->entries[i + 1u]; + if (staticDvarEntry.type == EET_OPERAND && staticDvarEntry.data.operand.dataType == VAL_INT) + { + if (statement->supportingData && statement->supportingData->staticDvarList.staticDvars + && staticDvarEntry.data.operand.internals.intVal >= 0 + && staticDvarEntry.data.operand.internals.intVal < statement->supportingData->staticDvarList.numStaticDvars) + { + const auto* staticDvar = statement->supportingData->staticDvarList.staticDvars[staticDvarEntry.data.operand.internals.intVal]; + if (staticDvar && staticDvar->dvarName) + m_stream << staticDvar->dvarName; + } + else + { + m_stream << "#INVALID_DVAR_INDEX"; + } + } + else + { + m_stream << "#INVALID_DVAR_OPERAND"; + } + } + + m_stream << ")"; + i = closingParenPos; + } + else + { + assert(entry.data.op >= 0 && static_cast(entry.data.op) < std::extent_v); + if (entry.data.op >= 0 && static_cast(entry.data.op) < std::extent_v) + m_stream << g_expFunctionNames[entry.data.op]; + if (entry.data.op >= OP_COUNT) + m_stream << "("; + } + } + } + + void WriteStatementOperator(const Statement_s* statement, size_t& currentPos, bool& spaceNext) const + { + const auto& expEntry = statement->entries[currentPos]; + + if (spaceNext && expEntry.data.op != OP_COMMA) + m_stream << " "; + + if (expEntry.data.op == OP_LEFTPAREN) + { + const auto closingParenPos = FindStatementClosingParenthesis(statement, currentPos); + m_stream << "("; + WriteStatementEntryRange(statement, currentPos + 1, closingParenPos); + m_stream << ")"; + + currentPos = closingParenPos + 1; + spaceNext = true; + } + else if (expEntry.data.op >= EXP_FUNC_STATIC_DVAR_INT && expEntry.data.op <= EXP_FUNC_STATIC_DVAR_STRING) + { + switch (expEntry.data.op) + { + case EXP_FUNC_STATIC_DVAR_INT: + m_stream << "dvarint"; + break; + + case EXP_FUNC_STATIC_DVAR_BOOL: + m_stream << "dvarbool"; + break; + + case EXP_FUNC_STATIC_DVAR_FLOAT: + m_stream << "dvarfloat"; + break; + + case EXP_FUNC_STATIC_DVAR_STRING: + m_stream << "dvarstring"; + break; + + default: + break; + } + + // Functions do not have opening parenthesis in the entries. We can just pretend they do though + const auto closingParenPos = FindStatementClosingParenthesis(statement, currentPos); + m_stream << "("; + + if (closingParenPos - currentPos + 1 >= 1) + { + const auto& staticDvarEntry = statement->entries[currentPos + 1]; + if (staticDvarEntry.type == EET_OPERAND && staticDvarEntry.data.operand.dataType == VAL_INT) + { + if (statement->supportingData && statement->supportingData->staticDvarList.staticDvars + && staticDvarEntry.data.operand.internals.intVal >= 0 + && staticDvarEntry.data.operand.internals.intVal < statement->supportingData->staticDvarList.numStaticDvars) + { + const auto* staticDvar = statement->supportingData->staticDvarList.staticDvars[staticDvarEntry.data.operand.internals.intVal]; + if (staticDvar && staticDvar->dvarName) + m_stream << staticDvar->dvarName; + } + else + { + m_stream << "#INVALID_DVAR_INDEX"; + } + } + else + { + m_stream << "#INVALID_DVAR_OPERAND"; + } + } + + m_stream << ")"; + currentPos = closingParenPos + 1; + spaceNext = true; + } + else + { + if (expEntry.data.op >= 0 && static_cast(expEntry.data.op) < std::extent_v) + m_stream << g_expFunctionNames[expEntry.data.op]; + + if (expEntry.data.op >= OP_COUNT) + { + // Functions do not have opening parenthesis in the entries. We can just pretend they do though + const auto closingParenPos = FindStatementClosingParenthesis(statement, currentPos); + m_stream << "("; + WriteStatementEntryRange(statement, currentPos + 1, closingParenPos); + m_stream << ")"; + currentPos = closingParenPos + 1; + } + else + currentPos++; + + spaceNext = expEntry.data.op != OP_NOT; + } + } + + void WriteStatementOperandFunction(const Statement_s* statement, size_t currentPos) const + { + const auto& operand = statement->entries[currentPos].data.operand; + + if (operand.internals.function == nullptr) + return; + + if (!ObjWriting::Configuration.MenuLegacyMode) + { + int functionIndex = -1; + if (statement->supportingData && statement->supportingData->uifunctions.functions) + { + for (auto supportingFunctionIndex = 0; supportingFunctionIndex < statement->supportingData->uifunctions.totalFunctions; + supportingFunctionIndex++) + { + if (statement->supportingData->uifunctions.functions[supportingFunctionIndex] == operand.internals.function) + { + functionIndex = supportingFunctionIndex; + break; + } + } + } + + if (functionIndex >= 0) + m_stream << "FUNC_" << functionIndex; + else + m_stream << "INVALID_FUNC"; + m_stream << "()"; + } + else + { + m_stream << "("; + WriteStatementSkipInitialUnnecessaryParenthesis(operand.internals.function); + m_stream << ")"; + } + } + + void WriteStatementOperand(const Statement_s* statement, size_t& currentPos, bool& spaceNext) const + { + const auto& expEntry = statement->entries[currentPos]; + + if (spaceNext) + m_stream << " "; + + const auto& operand = expEntry.data.operand; + + switch (operand.dataType) + { + case VAL_FLOAT: + m_stream << operand.internals.floatVal; + break; + + case VAL_INT: + m_stream << operand.internals.intVal; + break; + + case VAL_STRING: + WriteEscapedString(operand.internals.stringVal.string); + break; + + case VAL_FUNCTION: + WriteStatementOperandFunction(statement, currentPos); + break; + + default: + break; + } + + currentPos++; + spaceNext = true; + } + + void WriteStatementEntryRange(const Statement_s* statement, size_t startOffset, size_t endOffset) const + { + assert(startOffset <= endOffset); + assert(endOffset <= static_cast(statement->numEntries)); + + auto currentPos = startOffset; + auto spaceNext = false; + while (currentPos < endOffset) + { + const auto& expEntry = statement->entries[currentPos]; + + if (expEntry.type == EET_OPERATOR) + { + WriteStatementOperator(statement, currentPos, spaceNext); + } + else + { + WriteStatementOperand(statement, currentPos, spaceNext); + } + } + } + + void WriteStatement(const Statement_s* statement) const + { + if (statement == nullptr || statement->numEntries < 0) + return; + + WriteStatementEntryRange(statement, 0, static_cast(statement->numEntries)); + } + + void WriteStatementSkipInitialUnnecessaryParenthesis(const Statement_s* statementValue) const + { + if (statementValue == nullptr || statementValue->numEntries < 0) + return; + + const auto statementEnd = static_cast(statementValue->numEntries); + + if (statementValue->numEntries >= 1 && statementValue->entries[0].type == EET_OPERATOR && statementValue->entries[0].data.op == OP_LEFTPAREN) + { + const auto parenthesisEnd = FindStatementClosingParenthesis(statementValue, 0); + + if (parenthesisEnd >= statementEnd) + WriteStatementEntryRange(statementValue, 1, statementEnd); + else if (parenthesisEnd == statementEnd - 1) + WriteStatementEntryRange(statementValue, 1, statementEnd - 1); + else + WriteStatementEntryRange(statementValue, 0, statementEnd); + } + else + { + WriteStatementEntryRange(statementValue, 0, statementEnd); + } + } + + void WriteStatementProperty(const std::string& propertyKey, const Statement_s* statementValue, bool isBooleanStatement) const + { + if (statementValue == nullptr || statementValue->numEntries < 0) + return; + + Indent(); + WriteKey(propertyKey); + + if (isBooleanStatement) + { + m_stream << "when("; + DUMP_FUNC(statementValue); + m_stream << ");\n"; + } + else + { + DUMP_FUNC(statementValue); + m_stream << ";\n"; + } + } + + void WriteSetLocalVarData(const std::string& setFunction, const SetLocalVarData* setLocalVarData) const + { + if (setLocalVarData == nullptr) + return; + + Indent(); + m_stream << setFunction << " " << setLocalVarData->localVarName << " "; + WriteStatement(setLocalVarData->expression); + m_stream << ";\n"; + } + + // #define WRITE_ORIGINAL_SCRIPT + void WriteUnconditionalScript(const char* script) const + { +#ifdef WRITE_ORIGINAL_SCRIPT + Indent(); + m_stream << script << "\n"; + return; +#endif + + const auto tokenList = CreateScriptTokenList(script); + + auto isNewStatement = true; + for (const auto& token : tokenList) + { + if (isNewStatement) + { + if (token == ";") + continue; + + Indent(); + } + + if (token == ";") + { + m_stream << ";\n"; + isNewStatement = true; + continue; + } + + if (!isNewStatement) + m_stream << " "; + else + isNewStatement = false; + + if (DoesTokenNeedQuotationMarks(token)) + m_stream << "\"" << token << "\""; + else + m_stream << token; + } + + if (!isNewStatement) + m_stream << ";\n"; + } + + void WriteMenuEventHandlerSet(const MenuEventHandlerSet* eventHandlerSet) + { + Indent(); + m_stream << "{\n"; + IncIndent(); + + for (auto i = 0; i < eventHandlerSet->eventHandlerCount; i++) + { + const auto* eventHandler = eventHandlerSet->eventHandlers[i]; + if (eventHandler == nullptr) + continue; + + switch (eventHandler->eventType) + { + case EVENT_UNCONDITIONAL: + WriteUnconditionalScript(eventHandler->eventData.unconditionalScript); + break; + + case EVENT_IF: + if (eventHandler->eventData.conditionalScript == nullptr || eventHandler->eventData.conditionalScript->eventExpression == nullptr + || eventHandler->eventData.conditionalScript->eventHandlerSet == nullptr) + { + continue; + } + + Indent(); + m_stream << "if ("; + WriteStatementSkipInitialUnnecessaryParenthesis(eventHandler->eventData.conditionalScript->eventExpression); + m_stream << ")\n"; + WriteMenuEventHandlerSet(eventHandler->eventData.conditionalScript->eventHandlerSet); + break; + + case EVENT_ELSE: + if (eventHandler->eventData.elseScript == nullptr) + continue; + + Indent(); + m_stream << "else\n"; + WriteMenuEventHandlerSet(eventHandler->eventData.elseScript); + break; + + case EVENT_SET_LOCAL_VAR_BOOL: + WriteSetLocalVarData("setLocalVarBool", eventHandler->eventData.setLocalVarData); + break; + + case EVENT_SET_LOCAL_VAR_INT: + WriteSetLocalVarData("setLocalVarInt", eventHandler->eventData.setLocalVarData); + break; + + case EVENT_SET_LOCAL_VAR_FLOAT: + WriteSetLocalVarData("setLocalVarFloat", eventHandler->eventData.setLocalVarData); + break; + + case EVENT_SET_LOCAL_VAR_STRING: + WriteSetLocalVarData("setLocalVarString", eventHandler->eventData.setLocalVarData); + break; + + default: + break; + } + } + + DecIndent(); + Indent(); + m_stream << "}\n"; + } + + void WriteMenuEventHandlerSetProperty(const std::string& propertyKey, const MenuEventHandlerSet* eventHandlerSetValue) + { + if (eventHandlerSetValue == nullptr) + return; + + Indent(); + m_stream << propertyKey << "\n"; + WriteMenuEventHandlerSet(eventHandlerSetValue); + } + + void WriteRectProperty(const std::string& propertyKey, const rectDef_s& rect) const + { + Indent(); + WriteKey(propertyKey); + m_stream << rect.x << " " << rect.y << " " << rect.w << " " << rect.h << " " << static_cast(rect.horzAlign) << " " + << static_cast(rect.vertAlign) << "\n"; + } + + void WriteMaterialProperty(const std::string& propertyKey, const Material* materialValue) const + { + if (materialValue == nullptr || materialValue->info.name == nullptr) + return; + + if (materialValue->info.name[0] == ',') + WriteStringProperty(propertyKey, &materialValue->info.name[1]); + else + WriteStringProperty(propertyKey, materialValue->info.name); + } + + void WriteSoundAliasProperty(const std::string& propertyKey, const snd_alias_list_t* soundAliasValue) const + { + if (soundAliasValue == nullptr) + return; + + WriteStringProperty(propertyKey, soundAliasValue->aliasName); + } + + void WriteDecodeEffectProperty(const std::string& propertyKey, const itemDef_s* item) const + { + if (!item->decayActive) + return; + + Indent(); + WriteKey(propertyKey); + m_stream << item->fxLetterTime << " " << item->fxDecayStartTime << " " << item->fxDecayDuration << "\n"; + } + + void WriteItemKeyHandlerProperty(const ItemKeyHandler* itemKeyHandlerValue) + { + for (const auto* currentHandler = itemKeyHandlerValue; currentHandler; currentHandler = currentHandler->next) + { + if (currentHandler->key >= '!' && currentHandler->key <= '~' && currentHandler->key != '"') + { + std::ostringstream ss; + ss << "execKey \"" << static_cast(currentHandler->key) << "\""; + WriteMenuEventHandlerSetProperty(ss.str(), currentHandler->action); + } + else + { + std::ostringstream ss; + ss << "execKeyInt " << currentHandler->key; + WriteMenuEventHandlerSetProperty(ss.str(), currentHandler->action); + } + } + } + + void WriteMultiTokenStringProperty(const std::string& propertyKey, const char* value) const + { + if (!value) + return; + + Indent(); + WriteKey(propertyKey); + + const auto tokenList = CreateScriptTokenList(value); + + auto firstToken = true; + m_stream << "{ "; + for (const auto& token : tokenList) + { + if (firstToken) + firstToken = false; + else + m_stream << ";"; + m_stream << "\"" << token << "\""; + } + if (!firstToken) + m_stream << " "; + m_stream << "}\n"; + } + + void WriteFloatExpressionsProperty(const ItemFloatExpression* floatExpressions, int floatExpressionCount) const + { + if (!floatExpressions) + return; + + for (int i = 0; i < floatExpressionCount; i++) + { + const auto& floatExpression = floatExpressions[i]; + + if (floatExpression.target < 0 || floatExpression.target >= ITEM_FLOATEXP_TGT_COUNT) + continue; + + std::string propertyName = std::string("exp ") + floatExpressionTargetBindings[floatExpression.target].name + std::string(" ") + + floatExpressionTargetBindings[floatExpression.target].componentName; + + WriteStatementProperty(propertyName, floatExpression.expression, false); + } + } + + void WriteColumnProperty(const std::string& propertyKey, const listBoxDef_s* listBox) const + { + if (listBox->numColumns <= 0) + return; + + Indent(); + WriteKey(propertyKey); + m_stream << listBox->numColumns << "\n"; + + for (auto col = 0; col < listBox->numColumns; col++) + { + Indent(); + for (auto i = 0u; i < MENU_KEY_SPACING; i++) + m_stream << " "; + + m_stream << listBox->columnInfo[col].xpos << " " << listBox->columnInfo[col].ypos << " " << listBox->columnInfo[col].width << " " + << listBox->columnInfo[col].height << " " << listBox->columnInfo[col].maxChars << " " << listBox->columnInfo[col].alignment << "\n"; + } + } + + void WriteListBoxProperties(const itemDef_s* item) + { + if (item->type != ITEM_TYPE_LISTBOX || item->typeData.listBox == nullptr) + return; + + const auto* listBox = item->typeData.listBox; + WriteKeywordProperty("notselectable", listBox->notselectable != 0); + WriteKeywordProperty("noscrollbars", listBox->noScrollBars != 0); + WriteKeywordProperty("usepaging", listBox->usePaging != 0); + WriteFloatProperty("elementwidth", listBox->elementWidth, 0.0f); + WriteFloatProperty("elementheight", listBox->elementHeight, 0.0f); + WriteFloatProperty("feeder", item->special, 0.0f); + WriteIntProperty("elementtype", listBox->elementStyle, 0); + WriteColumnProperty("columns", listBox); + WriteMenuEventHandlerSetProperty("doubleclick", listBox->onDoubleClick); + WriteColorProperty("selectBorder", listBox->selectBorder, COLOR_0000); + WriteMaterialProperty("selectIcon", listBox->selectIcon); + WriteStatementProperty("exp elementheight", listBox->elementHeightExp, false); + } + + void WriteDvarFloatProperty(const std::string& propertyKey, const itemDef_s* item, const editFieldDef_s* editField) const + { + if (item->dvar == nullptr) + return; + + Indent(); + WriteKey(propertyKey); + m_stream << "\"" << item->dvar << "\" " << editField->stepVal << " " << editField->minVal << " " << editField->maxVal << "\n"; + } + + void WriteEditFieldProperties(const itemDef_s* item) const + { + switch (item->type) + { + case ITEM_TYPE_TEXT: + case ITEM_TYPE_EDITFIELD: + case ITEM_TYPE_NUMERICFIELD: + case ITEM_TYPE_SLIDER: + case ITEM_TYPE_YESNO: + case ITEM_TYPE_BIND: + case ITEM_TYPE_VALIDFILEFIELD: + case ITEM_TYPE_DECIMALFIELD: + case ITEM_TYPE_UPREDITFIELD: + case ITEM_TYPE_EMAILFIELD: + case ITEM_TYPE_PASSWORDFIELD: + break; + + default: + return; + } + + if (item->typeData.editField == nullptr) + return; + + const auto* editField = item->typeData.editField; + if (std::fabs(-1.0f - editField->stepVal) >= std::numeric_limits::epsilon() + || std::fabs(-1.0f - editField->minVal) >= std::numeric_limits::epsilon() + || std::fabs(-1.0f - editField->maxVal) >= std::numeric_limits::epsilon()) + { + WriteDvarFloatProperty("dvarFloat", item, editField); + } + else + { + WriteStringProperty("dvar", item->dvar); + } + WriteStringProperty("localvar", item->localVar); + WriteIntProperty("maxChars", editField->maxChars, 0); + WriteKeywordProperty("maxCharsGotoNext", editField->maxCharsGotoNext != 0); + WriteIntProperty("maxPaintChars", editField->maxPaintChars, 0); + } + + void WriteMultiValueProperty(const multiDef_s* multiDef) const + { + Indent(); + if (multiDef->strDef) + WriteKey("dvarStrList"); + else + WriteKey("dvarFloatList"); + + m_stream << "{"; + for (auto i = 0; i < multiDef->count; i++) + { + if (multiDef->dvarList[i] == nullptr || multiDef->strDef && multiDef->dvarStr[i] == nullptr) + continue; + + m_stream << " \"" << multiDef->dvarList[i] << "\""; + + if (multiDef->strDef) + m_stream << " \"" << multiDef->dvarStr[i] << "\""; + else + m_stream << " " << multiDef->dvarValue[i] << ""; + } + m_stream << " }\n"; + } + + void WriteMultiProperties(const itemDef_s* item) const + { + if (item->type != ITEM_TYPE_MULTI || item->typeData.multi == nullptr) + return; + + const auto* multiDef = item->typeData.multi; + + if (multiDef->count <= 0) + return; + + WriteStringProperty("dvar", item->dvar); + WriteStringProperty("localvar", item->localVar); + WriteMultiValueProperty(multiDef); + } + + void WriteEnumDvarProperties(const itemDef_s* item) const + { + if (item->type != ITEM_TYPE_DVARENUM) + return; + + WriteStringProperty("dvar", item->dvar); + WriteStringProperty("localvar", item->localVar); + WriteStringProperty("dvarEnumList", item->typeData.enumDvarName); + } + + void WriteTickerProperties(const itemDef_s* item) const + { + if (item->type != ITEM_TYPE_NEWS_TICKER || item->typeData.ticker == nullptr) + return; + + const auto* newsTickerDef = item->typeData.ticker; + WriteIntProperty("spacing", newsTickerDef->spacing, 0); + WriteIntProperty("speed", newsTickerDef->speed, 0); + WriteIntProperty("newsfeed", newsTickerDef->feedId, 0); + } + + void WriteItemData(const itemDef_s* item) + { + WriteStringProperty("name", item->window.name); + WriteStringProperty("text", item->text); + WriteKeywordProperty("textsavegame", item->itemFlags & ITEM_FLAG_SAVE_GAME_INFO); + WriteKeywordProperty("textcinematicsubtitle", item->itemFlags & ITEM_FLAG_CINEMATIC_SUBTITLE); + WriteStringProperty("group", item->window.group); + WriteRectProperty("rect", item->window.rectClient); + WriteIntProperty("style", item->window.style, 0); + WriteKeywordProperty("decoration", item->window.staticFlags & WINDOW_FLAG_DECORATION); + WriteKeywordProperty("autowrapped", item->window.staticFlags & WINDOW_FLAG_AUTO_WRAPPED); + WriteKeywordProperty("horizontalscroll", item->window.staticFlags & WINDOW_FLAG_HORIZONTAL_SCROLL); + WriteIntProperty("type", item->type, ITEM_TYPE_TEXT); + WriteIntProperty("border", item->window.border, 0); + WriteFloatProperty("borderSize", item->window.borderSize, 0.0f); + + if (item->visibleExp) + WriteStatementProperty("visible", item->visibleExp, true); + else if (item->window.dynamicFlags[0] & WINDOW_FLAG_VISIBLE) + WriteIntProperty("visible", 1, 0); + + WriteStatementProperty("disabled", item->disabledExp, true); + WriteIntProperty("ownerdraw", item->window.ownerDraw, 0); + WriteFlagsProperty("ownerdrawFlag", item->window.ownerDrawFlags); + WriteIntProperty("align", item->alignment, 0); + WriteIntProperty("textalign", item->textAlignMode, 0); + WriteFloatProperty("textalignx", item->textalignx, 0.0f); + WriteFloatProperty("textaligny", item->textaligny, 0.0f); + WriteFloatProperty("textscale", item->textscale, 0.0f); + WriteIntProperty("textstyle", item->textStyle, 0); + WriteIntProperty("textfont", item->fontEnum, 0); + WriteColorProperty("backcolor", item->window.backColor, COLOR_0000); + WriteColorProperty("forecolor", item->window.foreColor, COLOR_1111); + WriteColorProperty("bordercolor", item->window.borderColor, COLOR_0000); + WriteColorProperty("outlinecolor", item->window.outlineColor, COLOR_0000); + WriteColorProperty("disablecolor", item->window.disableColor, COLOR_0000); + WriteColorProperty("glowcolor", item->glowColor, COLOR_0000); + WriteMaterialProperty("background", item->window.background); + WriteMenuEventHandlerSetProperty("onFocus", item->onFocus); + WriteMenuEventHandlerSetProperty("hasFocus", item->hasFocus); + WriteMenuEventHandlerSetProperty("leaveFocus", item->leaveFocus); + WriteMenuEventHandlerSetProperty("mouseEnter", item->mouseEnter); + WriteMenuEventHandlerSetProperty("mouseExit", item->mouseExit); + WriteMenuEventHandlerSetProperty("mouseEnterText", item->mouseEnterText); + WriteMenuEventHandlerSetProperty("mouseExitText", item->mouseExitText); + WriteMenuEventHandlerSetProperty("action", item->action); + WriteMenuEventHandlerSetProperty("accept", item->accept); + // WriteFloatProperty("special", item->special, 0.0f); + WriteSoundAliasProperty("focusSound", item->focusSound); + WriteStringProperty("dvarTest", item->dvarTest); + + if (item->dvarFlags & ITEM_DVAR_FLAG_ENABLE) + WriteMultiTokenStringProperty("enableDvar", item->enableDvar); + else if (item->dvarFlags & ITEM_DVAR_FLAG_DISABLE) + WriteMultiTokenStringProperty("disableDvar", item->enableDvar); + else if (item->dvarFlags & ITEM_DVAR_FLAG_SHOW) + WriteMultiTokenStringProperty("showDvar", item->enableDvar); + else if (item->dvarFlags & ITEM_DVAR_FLAG_HIDE) + WriteMultiTokenStringProperty("hideDvar", item->enableDvar); + else if (item->dvarFlags & ITEM_DVAR_FLAG_FOCUS) + WriteMultiTokenStringProperty("focusDvar", item->enableDvar); + + WriteItemKeyHandlerProperty(item->onKey); + WriteStatementProperty("exp text", item->textExp, false); + WriteStatementProperty("exp textaligny", item->textAlignYExp, false); + WriteStatementProperty("exp material", item->materialExp, false); + WriteFloatExpressionsProperty(item->floatExpressions, item->floatExpressionCount); + WriteIntProperty("gamemsgwindowindex", item->gameMsgWindowIndex, 0); + WriteIntProperty("gamemsgwindowmode", item->gameMsgWindowMode, 0); + WriteDecodeEffectProperty("decodeEffect", item); + + WriteListBoxProperties(item); + WriteEditFieldProperties(item); + WriteMultiProperties(item); + WriteEnumDvarProperties(item); + WriteTickerProperties(item); + } + + void WriteItemDefs(const itemDef_s* const* itemDefs, size_t itemCount) + { + for (auto i = 0u; i < itemCount; i++) + { + StartItemDefScope(); + + WriteItemData(itemDefs[i]); + + EndScope(); + } + } + + void WriteMenuData(const menuDef_t* menu) + { + WriteStringProperty("name", menu->window.name); + WriteBoolProperty("fullscreen", menu->data->fullScreen, false); + WriteKeywordProperty("screenSpace", menu->window.staticFlags & WINDOW_FLAG_SCREEN_SPACE); + WriteKeywordProperty("decoration", menu->window.staticFlags & WINDOW_FLAG_DECORATION); + WriteRectProperty("rect", menu->window.rect); + WriteIntProperty("style", menu->window.style, 0); + WriteIntProperty("border", menu->window.border, 0); + WriteFloatProperty("borderSize", menu->window.borderSize, 0.0f); + WriteColorProperty("backcolor", menu->window.backColor, COLOR_0000); + WriteColorProperty("forecolor", menu->window.foreColor, COLOR_1111); + WriteColorProperty("bordercolor", menu->window.borderColor, COLOR_0000); + WriteColorProperty("focuscolor", menu->data->focusColor, COLOR_0000); + WriteColorProperty("outlinecolor", menu->window.outlineColor, COLOR_0000); + WriteMaterialProperty("background", menu->window.background); + WriteIntProperty("ownerdraw", menu->window.ownerDraw, 0); + WriteFlagsProperty("ownerdrawFlag", menu->window.ownerDrawFlags); + WriteKeywordProperty("outOfBoundsClick", menu->window.staticFlags & WINDOW_FLAG_OUT_OF_BOUNDS_CLICK); + WriteStringProperty("soundLoop", menu->data->soundName); + WriteKeywordProperty("popup", menu->window.staticFlags & WINDOW_FLAG_POPUP); + WriteFloatProperty("fadeClamp", menu->data->fadeClamp, 0.0f); + WriteIntProperty("fadeCycle", menu->data->fadeCycle, 0); + WriteFloatProperty("fadeAmount", menu->data->fadeAmount, 0.0f); + WriteFloatProperty("fadeInAmount", menu->data->fadeInAmount, 0.0f); + WriteFloatProperty("blurWorld", menu->data->blurRadius, 0.0f); + WriteKeywordProperty("legacySplitScreenScale", menu->window.staticFlags & WINDOW_FLAG_LEGACY_SPLIT_SCREEN_SCALE); + WriteKeywordProperty("hiddenDuringScope", menu->window.staticFlags & WINDOW_FLAG_HIDDEN_DURING_SCOPE); + WriteKeywordProperty("hiddenDuringFlashbang", menu->window.staticFlags & WINDOW_FLAG_HIDDEN_DURING_FLASH_BANG); + WriteKeywordProperty("hiddenDuringUI", menu->window.staticFlags & WINDOW_FLAG_HIDDEN_DURING_UI); + WriteStringProperty("allowedBinding", menu->data->allowedBinding); + WriteKeywordProperty("textOnlyFocus", menu->window.staticFlags & WINDOW_FLAG_TEXT_ONLY_FOCUS); + + if (menu->data->visibleExp) + WriteStatementProperty("visible", menu->data->visibleExp, true); + else if (menu->window.dynamicFlags[0] & WINDOW_FLAG_VISIBLE) + WriteIntProperty("visible", 1, 0); + + WriteStatementProperty("exp rect X", menu->data->rectXExp, false); + WriteStatementProperty("exp rect Y", menu->data->rectYExp, false); + WriteStatementProperty("exp rect W", menu->data->rectWExp, false); + WriteStatementProperty("exp rect H", menu->data->rectHExp, false); + WriteStatementProperty("exp openSound", menu->data->openSoundExp, false); + WriteStatementProperty("exp closeSound", menu->data->closeSoundExp, false); + WriteStatementProperty("exp soundLoop", menu->data->soundLoopExp, false); + WriteMenuEventHandlerSetProperty("onOpen", menu->data->onOpen); + WriteMenuEventHandlerSetProperty("onClose", menu->data->onClose); + WriteMenuEventHandlerSetProperty("onRequestClose", menu->data->onCloseRequest); + WriteMenuEventHandlerSetProperty("onESC", menu->data->onESC); + WriteMenuEventHandlerSetProperty("onFocusDueToClose", menu->data->onFocusDueToClose); + WriteItemKeyHandlerProperty(menu->data->onKey); + WriteItemDefs(menu->items, menu->itemCount); + } + }; +} // namespace + +namespace IW5::menu +{ + std::unique_ptr CreateMenuWriter(std::ostream& stream) + { + return std::make_unique(stream); + } +} // namespace IW5::menu diff --git a/src/ObjWriting/Game/IW5/Menu/MenuWriterIW5.h b/src/ObjWriting/Game/IW5/Menu/MenuWriterIW5.h new file mode 100644 index 00000000..eb9fe690 --- /dev/null +++ b/src/ObjWriting/Game/IW5/Menu/MenuWriterIW5.h @@ -0,0 +1,19 @@ +#pragma once + +#include "Game/IW5/IW5.h" +#include "Menu/IMenuWriter.h" + +#include +#include + +namespace IW5::menu +{ + class IWriterIW5 : public ::menu::IWriter + { + public: + virtual void WriteFunctionDef(const std::string& functionName, const Statement_s* statement) = 0; + virtual void WriteMenu(const menuDef_t& menu) = 0; + }; + + std::unique_ptr CreateMenuWriter(std::ostream& stream); +} // namespace IW5::menu diff --git a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp index 28ea516a..536f7935 100644 --- a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp +++ b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp @@ -7,8 +7,8 @@ #include "Leaderboard/LeaderboardJsonDumperIW5.h" #include "Localize/LocalizeDumperIW5.h" #include "Maps/AddonMapEntsDumperIW5.h" -#include "Menu/AssetDumperMenuDef.h" -#include "Menu/AssetDumperMenuList.h" +#include "Menu/MenuDumperIW5.h" +#include "Menu/MenuListDumperIW5.h" #include "ObjWriting.h" #include "RawFile/RawFileDumperIW5.h" #include "Script/ScriptDumperIW5.h" @@ -53,8 +53,8 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD) // DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF) // DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT) - DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST) - DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU) + DUMP_ASSET_POOL(menu::MenuListDumper, m_menu_list, ASSET_TYPE_MENULIST) + DUMP_ASSET_POOL(menu::MenuDumper, m_menu_def, ASSET_TYPE_MENU) DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) DUMP_ASSET_POOL(attachment::JsonDumper, m_attachment, ASSET_TYPE_ATTACHMENT) DUMP_ASSET_POOL(weapon::Dumper, m_weapon, ASSET_TYPE_WEAPON) diff --git a/src/ObjWriting/Menu/AbstractMenuDumper.cpp b/src/ObjWriting/Menu/AbstractMenuDumper.cpp deleted file mode 100644 index 5b00b40b..00000000 --- a/src/ObjWriting/Menu/AbstractMenuDumper.cpp +++ /dev/null @@ -1,298 +0,0 @@ -#include "AbstractMenuDumper.h" - -#include "Parsing/Impl/ParserSingleInputStream.h" -#include "Parsing/Simple/SimpleLexer.h" - -#include -#include -#include - -AbstractMenuDumper::AbstractMenuDumper(std::ostream& stream) - : m_stream(stream), - m_indent(0u) -{ -} - -void AbstractMenuDumper::IncIndent() -{ - m_indent++; -} - -void AbstractMenuDumper::DecIndent() -{ - if (m_indent > 0) - m_indent--; -} - -void AbstractMenuDumper::Indent() const -{ - for (auto i = 0u; i < m_indent; i++) - m_stream << " "; -} - -void AbstractMenuDumper::StartScope(const std::string& scopeName) -{ - Indent(); - m_stream << scopeName << "\n"; - Indent(); - m_stream << "{\n"; - IncIndent(); -} - -void AbstractMenuDumper::StartMenuDefScope() -{ - StartScope("menuDef"); -} - -void AbstractMenuDumper::StartItemDefScope() -{ - StartScope("itemDef"); -} - -void AbstractMenuDumper::StartFunctionDefScope() -{ - StartScope("functionDef"); -} - -void AbstractMenuDumper::EndScope() -{ - DecIndent(); - Indent(); - m_stream << "}\n"; -} - -std::vector AbstractMenuDumper::CreateScriptTokenList(const char* script) -{ - const std::string scriptString(script); - std::istringstream stringStream(scriptString); - ParserSingleInputStream inputStream(stringStream, "MenuScript"); - - SimpleLexer::Config lexerConfig; - lexerConfig.m_emit_new_line_tokens = false; - lexerConfig.m_read_strings = true; - lexerConfig.m_string_escape_sequences = true; - lexerConfig.m_read_integer_numbers = false; - lexerConfig.m_read_floating_point_numbers = false; - SimpleLexer lexer(&inputStream, std::move(lexerConfig)); - - std::vector result; - auto hasLexerTokens = true; - while (hasLexerTokens) - { - const auto& token = lexer.GetToken(0); - switch (token.m_type) - { - case SimpleParserValueType::IDENTIFIER: - result.emplace_back(token.IdentifierValue()); - break; - - case SimpleParserValueType::STRING: - result.emplace_back(token.StringValue()); - break; - - case SimpleParserValueType::CHARACTER: - result.emplace_back(1, token.CharacterValue()); - break; - - case SimpleParserValueType::INVALID: - case SimpleParserValueType::END_OF_FILE: - hasLexerTokens = false; - break; - - default: - assert(false); - break; - } - - lexer.PopTokens(1); - } - - return result; -} - -bool AbstractMenuDumper::DoesTokenNeedQuotationMarks(const std::string& token) -{ - if (token.empty()) - return true; - - const auto hasAlNumCharacter = std::ranges::any_of(token, - [](const char& c) - { - return isalnum(c); - }); - - if (!hasAlNumCharacter) - return false; - - const auto hasNonIdentifierCharacter = std::ranges::any_of(token, - [](const char& c) - { - return !isalnum(c) && c != '_'; - }); - - return hasNonIdentifierCharacter; -} - -void AbstractMenuDumper::WriteEscapedString(const std::string_view& str) const -{ - m_stream << "\""; - - for (const auto& c : str) - { - switch (c) - { - case '\r': - m_stream << "\\r"; - break; - case '\n': - m_stream << "\\n"; - break; - case '\t': - m_stream << "\\t"; - break; - case '\f': - m_stream << "\\f"; - break; - case '"': - m_stream << "\\\""; - break; - default: - m_stream << c; - break; - } - } - - m_stream << "\""; -} - -const std::string& AbstractMenuDumper::BoolValue(const bool value) -{ - return value ? BOOL_VALUE_TRUE : BOOL_VALUE_FALSE; -} - -void AbstractMenuDumper::WriteKey(const std::string& keyName) const -{ - m_stream << keyName; - - if (keyName.size() < MENU_KEY_SPACING) - { - const auto spacingLength = MENU_KEY_SPACING - keyName.size(); - for (auto i = 0u; i < spacingLength; i++) - m_stream << " "; - } -} - -void AbstractMenuDumper::WriteStringProperty(const std::string& propertyKey, const std::string& propertyValue) const -{ - if (propertyValue.empty()) - return; - - Indent(); - WriteKey(propertyKey); - - WriteEscapedString(propertyValue); - m_stream << "\n"; -} - -void AbstractMenuDumper::WriteStringProperty(const std::string& propertyKey, const char* propertyValue) const -{ - if (propertyValue == nullptr || propertyValue[0] == '\0') - return; - - Indent(); - WriteKey(propertyKey); - - WriteEscapedString(propertyValue); - m_stream << "\n"; -} - -void AbstractMenuDumper::WriteBoolProperty(const std::string& propertyKey, const bool propertyValue, const bool defaultValue) const -{ - if (propertyValue == defaultValue) - return; - - Indent(); - WriteKey(propertyKey); - m_stream << BoolValue(propertyValue) << "\n"; -} - -void AbstractMenuDumper::WriteIntProperty(const std::string& propertyKey, const int propertyValue, const int defaultValue) const -{ - if (propertyValue == defaultValue) - return; - - Indent(); - WriteKey(propertyKey); - m_stream << propertyValue << "\n"; -} - -void AbstractMenuDumper::WriteFloatProperty(const std::string& propertyKey, const float propertyValue, const float defaultValue) const -{ - if (std::fabs(propertyValue - defaultValue) < std::numeric_limits::epsilon()) - return; - - Indent(); - WriteKey(propertyKey); - m_stream << propertyValue << "\n"; -} - -void AbstractMenuDumper::WriteColorProperty(const std::string& propertyKey, const float (&propertyValue)[4], const float (&defaultValue)[4]) const -{ - if (std::fabs(propertyValue[0] - defaultValue[0]) < std::numeric_limits::epsilon() - && std::fabs(propertyValue[1] - defaultValue[1]) < std::numeric_limits::epsilon() - && std::fabs(propertyValue[2] - defaultValue[2]) < std::numeric_limits::epsilon() - && std::fabs(propertyValue[3] - defaultValue[3]) < std::numeric_limits::epsilon()) - { - return; - } - - Indent(); - WriteKey(propertyKey); - m_stream << propertyValue[0] << " " << propertyValue[1] << " " << propertyValue[2] << " " << propertyValue[3] << "\n"; -} - -void AbstractMenuDumper::WriteKeywordProperty(const std::string& propertyKey, const bool shouldWrite) const -{ - if (!shouldWrite) - return; - - Indent(); - WriteKey(propertyKey); - m_stream << "\n"; -} - -void AbstractMenuDumper::WriteFlagsProperty(const std::string& propertyKey, const int flagsValue) const -{ - for (auto i = 0u; i < sizeof(flagsValue) * 8; i++) - { - if (flagsValue & (1 << i)) - { - Indent(); - WriteKey(propertyKey); - m_stream << i << "\n"; - } - } -} - -void AbstractMenuDumper::Start() -{ - Indent(); - m_stream << "{\n"; - IncIndent(); -} - -void AbstractMenuDumper::End() -{ - for (auto i = 0u; i < m_indent; i++) - { - DecIndent(); - Indent(); - m_stream << "}\n"; - } -} - -void AbstractMenuDumper::IncludeMenu(const std::string& menuPath) const -{ - Indent(); - m_stream << "loadMenu { \"" << menuPath << "\" }\n"; -} diff --git a/src/ObjWriting/Menu/AbstractMenuDumper.h b/src/ObjWriting/Menu/AbstractMenuDumper.h deleted file mode 100644 index 10494684..00000000 --- a/src/ObjWriting/Menu/AbstractMenuDumper.h +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -class AbstractMenuDumper -{ -protected: - static constexpr auto MENU_KEY_SPACING = 28u; - static const inline std::string BOOL_VALUE_TRUE = "1"; - static const inline std::string BOOL_VALUE_FALSE = "0"; - static constexpr inline float COLOR_0000[4]{0.0f, 0.0f, 0.0f, 0.0f}; - static constexpr inline float COLOR_1111[4]{1.0f, 1.0f, 1.0f, 1.0f}; - - std::ostream& m_stream; - size_t m_indent; - - void IncIndent(); - void DecIndent(); - void Indent() const; - - void StartScope(const std::string& scopeName); - void StartMenuDefScope(); - void StartItemDefScope(); - void StartFunctionDefScope(); - void EndScope(); - - static std::vector CreateScriptTokenList(const char* script); - static bool DoesTokenNeedQuotationMarks(const std::string& token); - - void WriteEscapedString(const std::string_view& str) const; - - static const std::string& BoolValue(bool value); - void WriteKey(const std::string& keyName) const; - void WriteStringProperty(const std::string& propertyKey, const std::string& propertyValue) const; - void WriteStringProperty(const std::string& propertyKey, const char* propertyValue) const; - void WriteBoolProperty(const std::string& propertyKey, bool propertyValue, bool defaultValue) const; - void WriteIntProperty(const std::string& propertyKey, int propertyValue, int defaultValue) const; - void WriteFloatProperty(const std::string& propertyKey, float propertyValue, float defaultValue) const; - void WriteColorProperty(const std::string& propertyKey, const float (&propertyValue)[4], const float (&defaultValue)[4]) const; - void WriteKeywordProperty(const std::string& propertyKey, bool shouldWrite) const; - void WriteFlagsProperty(const std::string& propertyKey, int flagsValue) const; - - explicit AbstractMenuDumper(std::ostream& stream); - -public: - void Start(); - void End(); - - void IncludeMenu(const std::string& menuPath) const; -}; diff --git a/src/ObjWriting/Menu/AbstractMenuWriter.cpp b/src/ObjWriting/Menu/AbstractMenuWriter.cpp new file mode 100644 index 00000000..34c1b567 --- /dev/null +++ b/src/ObjWriting/Menu/AbstractMenuWriter.cpp @@ -0,0 +1,301 @@ +#include "AbstractMenuWriter.h" + +#include "Parsing/Impl/ParserSingleInputStream.h" +#include "Parsing/Simple/SimpleLexer.h" + +#include +#include +#include + +namespace menu +{ + AbstractBaseWriter::AbstractBaseWriter(std::ostream& stream) + : m_stream(stream), + m_indent(0u) + { + } + + void AbstractBaseWriter::IncIndent() + { + m_indent++; + } + + void AbstractBaseWriter::DecIndent() + { + if (m_indent > 0) + m_indent--; + } + + void AbstractBaseWriter::Indent() const + { + for (auto i = 0u; i < m_indent; i++) + m_stream << " "; + } + + void AbstractBaseWriter::StartScope(const std::string& scopeName) + { + Indent(); + m_stream << scopeName << "\n"; + Indent(); + m_stream << "{\n"; + IncIndent(); + } + + void AbstractBaseWriter::StartMenuDefScope() + { + StartScope("menuDef"); + } + + void AbstractBaseWriter::StartItemDefScope() + { + StartScope("itemDef"); + } + + void AbstractBaseWriter::StartFunctionDefScope() + { + StartScope("functionDef"); + } + + void AbstractBaseWriter::EndScope() + { + DecIndent(); + Indent(); + m_stream << "}\n"; + } + + std::vector AbstractBaseWriter::CreateScriptTokenList(const char* script) + { + const std::string scriptString(script); + std::istringstream stringStream(scriptString); + ParserSingleInputStream inputStream(stringStream, "MenuScript"); + + SimpleLexer::Config lexerConfig; + lexerConfig.m_emit_new_line_tokens = false; + lexerConfig.m_read_strings = true; + lexerConfig.m_string_escape_sequences = true; + lexerConfig.m_read_integer_numbers = false; + lexerConfig.m_read_floating_point_numbers = false; + SimpleLexer lexer(&inputStream, std::move(lexerConfig)); + + std::vector result; + auto hasLexerTokens = true; + while (hasLexerTokens) + { + const auto& token = lexer.GetToken(0); + switch (token.m_type) + { + case SimpleParserValueType::IDENTIFIER: + result.emplace_back(token.IdentifierValue()); + break; + + case SimpleParserValueType::STRING: + result.emplace_back(token.StringValue()); + break; + + case SimpleParserValueType::CHARACTER: + result.emplace_back(1, token.CharacterValue()); + break; + + case SimpleParserValueType::INVALID: + case SimpleParserValueType::END_OF_FILE: + hasLexerTokens = false; + break; + + default: + assert(false); + break; + } + + lexer.PopTokens(1); + } + + return result; + } + + bool AbstractBaseWriter::DoesTokenNeedQuotationMarks(const std::string& token) + { + if (token.empty()) + return true; + + const auto hasAlNumCharacter = std::ranges::any_of(token, + [](const char& c) + { + return isalnum(c); + }); + + if (!hasAlNumCharacter) + return false; + + const auto hasNonIdentifierCharacter = std::ranges::any_of(token, + [](const char& c) + { + return !isalnum(c) && c != '_'; + }); + + return hasNonIdentifierCharacter; + } + + void AbstractBaseWriter::WriteEscapedString(const std::string_view& str) const + { + m_stream << "\""; + + for (const auto& c : str) + { + switch (c) + { + case '\r': + m_stream << "\\r"; + break; + case '\n': + m_stream << "\\n"; + break; + case '\t': + m_stream << "\\t"; + break; + case '\f': + m_stream << "\\f"; + break; + case '"': + m_stream << "\\\""; + break; + default: + m_stream << c; + break; + } + } + + m_stream << "\""; + } + + const std::string& AbstractBaseWriter::BoolValue(const bool value) + { + return value ? BOOL_VALUE_TRUE : BOOL_VALUE_FALSE; + } + + void AbstractBaseWriter::WriteKey(const std::string& keyName) const + { + m_stream << keyName; + + if (keyName.size() < MENU_KEY_SPACING) + { + const auto spacingLength = MENU_KEY_SPACING - keyName.size(); + for (auto i = 0u; i < spacingLength; i++) + m_stream << " "; + } + } + + void AbstractBaseWriter::WriteStringProperty(const std::string& propertyKey, const std::string& propertyValue) const + { + if (propertyValue.empty()) + return; + + Indent(); + WriteKey(propertyKey); + + WriteEscapedString(propertyValue); + m_stream << "\n"; + } + + void AbstractBaseWriter::WriteStringProperty(const std::string& propertyKey, const char* propertyValue) const + { + if (propertyValue == nullptr || propertyValue[0] == '\0') + return; + + Indent(); + WriteKey(propertyKey); + + WriteEscapedString(propertyValue); + m_stream << "\n"; + } + + void AbstractBaseWriter::WriteBoolProperty(const std::string& propertyKey, const bool propertyValue, const bool defaultValue) const + { + if (propertyValue == defaultValue) + return; + + Indent(); + WriteKey(propertyKey); + m_stream << BoolValue(propertyValue) << "\n"; + } + + void AbstractBaseWriter::WriteIntProperty(const std::string& propertyKey, const int propertyValue, const int defaultValue) const + { + if (propertyValue == defaultValue) + return; + + Indent(); + WriteKey(propertyKey); + m_stream << propertyValue << "\n"; + } + + void AbstractBaseWriter::WriteFloatProperty(const std::string& propertyKey, const float propertyValue, const float defaultValue) const + { + if (std::fabs(propertyValue - defaultValue) < std::numeric_limits::epsilon()) + return; + + Indent(); + WriteKey(propertyKey); + m_stream << propertyValue << "\n"; + } + + void AbstractBaseWriter::WriteColorProperty(const std::string& propertyKey, const float (&propertyValue)[4], const float (&defaultValue)[4]) const + { + if (std::fabs(propertyValue[0] - defaultValue[0]) < std::numeric_limits::epsilon() + && std::fabs(propertyValue[1] - defaultValue[1]) < std::numeric_limits::epsilon() + && std::fabs(propertyValue[2] - defaultValue[2]) < std::numeric_limits::epsilon() + && std::fabs(propertyValue[3] - defaultValue[3]) < std::numeric_limits::epsilon()) + { + return; + } + + Indent(); + WriteKey(propertyKey); + m_stream << propertyValue[0] << " " << propertyValue[1] << " " << propertyValue[2] << " " << propertyValue[3] << "\n"; + } + + void AbstractBaseWriter::WriteKeywordProperty(const std::string& propertyKey, const bool shouldWrite) const + { + if (!shouldWrite) + return; + + Indent(); + WriteKey(propertyKey); + m_stream << "\n"; + } + + void AbstractBaseWriter::WriteFlagsProperty(const std::string& propertyKey, const int flagsValue) const + { + for (auto i = 0u; i < sizeof(flagsValue) * 8; i++) + { + if (flagsValue & (1 << i)) + { + Indent(); + WriteKey(propertyKey); + m_stream << i << "\n"; + } + } + } + + void AbstractBaseWriter::Start() + { + Indent(); + m_stream << "{\n"; + IncIndent(); + } + + void AbstractBaseWriter::End() + { + for (auto i = 0u; i < m_indent; i++) + { + DecIndent(); + Indent(); + m_stream << "}\n"; + } + } + + void AbstractBaseWriter::IncludeMenu(const std::string& menuPath) const + { + Indent(); + m_stream << "loadMenu { \"" << menuPath << "\" }\n"; + } +} // namespace menu diff --git a/src/ObjWriting/Menu/AbstractMenuWriter.h b/src/ObjWriting/Menu/AbstractMenuWriter.h new file mode 100644 index 00000000..3127a3e8 --- /dev/null +++ b/src/ObjWriting/Menu/AbstractMenuWriter.h @@ -0,0 +1,59 @@ +#pragma once + +#include "IMenuWriter.h" + +#include +#include +#include +#include + +namespace menu +{ + class AbstractBaseWriter : public IWriter + { + protected: + static constexpr auto MENU_KEY_SPACING = 28u; + static const inline std::string BOOL_VALUE_TRUE = "1"; + static const inline std::string BOOL_VALUE_FALSE = "0"; + static constexpr inline float COLOR_0000[4]{0.0f, 0.0f, 0.0f, 0.0f}; + static constexpr inline float COLOR_1111[4]{1.0f, 1.0f, 1.0f, 1.0f}; + + public: + void Start() override; + void End() override; + + void IncludeMenu(const std::string& menuPath) const override; + + protected: + explicit AbstractBaseWriter(std::ostream& stream); + + void IncIndent(); + void DecIndent(); + void Indent() const; + + void StartScope(const std::string& scopeName); + void StartMenuDefScope(); + void StartItemDefScope(); + void StartFunctionDefScope(); + void EndScope(); + + static std::vector CreateScriptTokenList(const char* script); + static bool DoesTokenNeedQuotationMarks(const std::string& token); + + void WriteEscapedString(const std::string_view& str) const; + + static const std::string& BoolValue(bool value); + void WriteKey(const std::string& keyName) const; + void WriteStringProperty(const std::string& propertyKey, const std::string& propertyValue) const; + void WriteStringProperty(const std::string& propertyKey, const char* propertyValue) const; + void WriteBoolProperty(const std::string& propertyKey, bool propertyValue, bool defaultValue) const; + void WriteIntProperty(const std::string& propertyKey, int propertyValue, int defaultValue) const; + void WriteFloatProperty(const std::string& propertyKey, float propertyValue, float defaultValue) const; + void WriteColorProperty(const std::string& propertyKey, const float (&propertyValue)[4], const float (&defaultValue)[4]) const; + void WriteKeywordProperty(const std::string& propertyKey, bool shouldWrite) const; + void WriteFlagsProperty(const std::string& propertyKey, int flagsValue) const; + + std::ostream& m_stream; + size_t m_indent; + }; +} // namespace menu diff --git a/src/ObjWriting/Menu/IMenuWriter.h b/src/ObjWriting/Menu/IMenuWriter.h new file mode 100644 index 00000000..393fc33f --- /dev/null +++ b/src/ObjWriting/Menu/IMenuWriter.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +namespace menu +{ + class IWriter + { + public: + IWriter() = default; + virtual ~IWriter() = default; + + virtual void Start() = 0; + virtual void End() = 0; + + virtual void IncludeMenu(const std::string& menuPath) const = 0; + }; +} // namespace menu From 93691a24f4b82435b80f68c6bf4a4efa2aab3a55 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Sun, 3 Aug 2025 21:29:06 +0200 Subject: [PATCH 24/35] refactor: streamline physcollmap dumping --- .../PhysCollmap/PhysCollmapCommon.cpp | 11 +++ src/ObjCommon/PhysCollmap/PhysCollmapCommon.h | 8 ++ src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 4 +- .../PhysCollmap/AssetDumperPhysCollmap.cpp | 87 ------------------- .../IW4/PhysCollmap/PhysCollmapDumperIW4.cpp | 83 ++++++++++++++++++ ...erPhysCollmap.h => PhysCollmapDumperIW4.h} | 8 +- 6 files changed, 107 insertions(+), 94 deletions(-) create mode 100644 src/ObjCommon/PhysCollmap/PhysCollmapCommon.cpp create mode 100644 src/ObjCommon/PhysCollmap/PhysCollmapCommon.h delete mode 100644 src/ObjWriting/Game/IW4/PhysCollmap/AssetDumperPhysCollmap.cpp create mode 100644 src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.cpp rename src/ObjWriting/Game/IW4/PhysCollmap/{AssetDumperPhysCollmap.h => PhysCollmapDumperIW4.h} (59%) diff --git a/src/ObjCommon/PhysCollmap/PhysCollmapCommon.cpp b/src/ObjCommon/PhysCollmap/PhysCollmapCommon.cpp new file mode 100644 index 00000000..7414207e --- /dev/null +++ b/src/ObjCommon/PhysCollmap/PhysCollmapCommon.cpp @@ -0,0 +1,11 @@ +#include "PhysCollmapCommon.h" + +#include + +namespace phys_collmap +{ + std::string GetFileNameForAssetName(const std::string& assetName) + { + return std::format("phys_collmaps/{}.map", assetName); + } +} // namespace phys_collmap diff --git a/src/ObjCommon/PhysCollmap/PhysCollmapCommon.h b/src/ObjCommon/PhysCollmap/PhysCollmapCommon.h new file mode 100644 index 00000000..eaf0877e --- /dev/null +++ b/src/ObjCommon/PhysCollmap/PhysCollmapCommon.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace phys_collmap +{ + std::string GetFileNameForAssetName(const std::string& assetName); +} diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 727ab8d8..a7874a66 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -12,7 +12,7 @@ #include "Menu/MenuDumperIW4.h" #include "Menu/MenuListDumperIW4.h" #include "ObjWriting.h" -#include "PhysCollmap/AssetDumperPhysCollmap.h" +#include "PhysCollmap/PhysCollmapDumperIW4.h" #include "PhysPreset/PhysPresetInfoStringDumperIW4.h" #include "RawFile/RawFileDumperIW4.h" #include "Shader/AssetDumperPixelShader.h" @@ -40,7 +40,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const const auto* assetPools = dynamic_cast(context.m_zone.m_pools.get()); DUMP_ASSET_POOL(phys_preset::InfoStringDumper, m_phys_preset, ASSET_TYPE_PHYSPRESET) - DUMP_ASSET_POOL(AssetDumperPhysCollmap, m_phys_collmap, ASSET_TYPE_PHYSCOLLMAP) + DUMP_ASSET_POOL(phys_collmap::Dumper, m_phys_collmap, ASSET_TYPE_PHYSCOLLMAP) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) DUMP_ASSET_POOL(xmodel::Dumper, m_xmodel, ASSET_TYPE_XMODEL) DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) diff --git a/src/ObjWriting/Game/IW4/PhysCollmap/AssetDumperPhysCollmap.cpp b/src/ObjWriting/Game/IW4/PhysCollmap/AssetDumperPhysCollmap.cpp deleted file mode 100644 index 7055e8aa..00000000 --- a/src/ObjWriting/Game/IW4/PhysCollmap/AssetDumperPhysCollmap.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include "AssetDumperPhysCollmap.h" - -#include "Dumping/MapFile/MapFileDumper.h" - -#include -#include - -using namespace IW4; - -std::string AssetDumperPhysCollmap::GetAssetFilename(const std::string& assetName) -{ - std::ostringstream ss; - - ss << "phys_collmaps/" << assetName << ".map"; - - return ss.str(); -} - -bool AssetDumperPhysCollmap::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperPhysCollmap::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* physCollmap = asset->Asset(); - const auto assetFile = context.OpenAssetFile(GetAssetFilename(asset->m_name)); - - if (!assetFile) - return; - - MapFileDumper mapFileDumper(*assetFile); - mapFileDumper.Init(); - - if (physCollmap->count <= 0 || physCollmap->geoms == nullptr) - return; - - mapFileDumper.BeginEntity(); - - mapFileDumper.WriteKeyValue("classname", "worldspawn"); - - for (auto i = 0u; i < physCollmap->count; i++) - { - const auto& geom = physCollmap->geoms[i]; - mapFileDumper.BeginBrush(); - - switch (geom.type) - { - case PHYS_GEOM_NONE: - // TODO: Dump BrushWrapper (probably GJK related) - mapFileDumper.WriteComment("TODO: Brush data"); - break; - case PHYS_GEOM_BOX: - mapFileDumper.WritePhysicsBox({ - {geom.bounds.midPoint.v[0], geom.bounds.midPoint.v[1], geom.bounds.midPoint.v[2]}, - {geom.bounds.halfSize.v[0], geom.bounds.halfSize.v[1], geom.bounds.halfSize.v[2]}, - {geom.orientation[0][0], geom.orientation[0][1], geom.orientation[0][2] }, - {geom.orientation[1][0], geom.orientation[1][1], geom.orientation[1][2] }, - {geom.orientation[2][0], geom.orientation[2][1], geom.orientation[2][2] } - }); - break; - - case PHYS_GEOM_CYLINDER: - mapFileDumper.WritePhysicsCylinder({ - {geom.bounds.midPoint.v[0], geom.bounds.midPoint.v[1], geom.bounds.midPoint.v[2]}, - geom.bounds.halfSize.v[0], - geom.bounds.halfSize.v[2] * 2, - {geom.orientation[0][0], geom.orientation[0][1], geom.orientation[0][2] } - }); - break; - - case PHYS_GEOM_BRUSHMODEL: - case PHYS_GEOM_BRUSH: - case PHYS_GEOM_COLLMAP: - case PHYS_GEOM_CAPSULE: - case PHYS_GEOM_GLASS: - default: - // These do not seem to appear inside any collmap assets - assert(false); - break; - } - - mapFileDumper.EndBrush(); - } - - mapFileDumper.EndEntity(); -} diff --git a/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.cpp b/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.cpp new file mode 100644 index 00000000..046a9c5e --- /dev/null +++ b/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.cpp @@ -0,0 +1,83 @@ +#include "PhysCollmapDumperIW4.h" + +#include "Dumping/MapFile/MapFileDumper.h" +#include "PhysCollmap/PhysCollmapCommon.h" + +#include +#include + +using namespace IW4; +using namespace ::phys_collmap; + +namespace IW4::phys_collmap +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* physCollmap = asset->Asset(); + const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name)); + + if (!assetFile) + return; + + MapFileDumper mapFileDumper(*assetFile); + mapFileDumper.Init(); + + if (physCollmap->count <= 0 || physCollmap->geoms == nullptr) + return; + + mapFileDumper.BeginEntity(); + + mapFileDumper.WriteKeyValue("classname", "worldspawn"); + + for (auto i = 0u; i < physCollmap->count; i++) + { + const auto& geom = physCollmap->geoms[i]; + mapFileDumper.BeginBrush(); + + switch (geom.type) + { + case PHYS_GEOM_NONE: + // TODO: Dump BrushWrapper (probably GJK related) + mapFileDumper.WriteComment("TODO: Brush data"); + break; + case PHYS_GEOM_BOX: + mapFileDumper.WritePhysicsBox({ + {geom.bounds.midPoint.v[0], geom.bounds.midPoint.v[1], geom.bounds.midPoint.v[2]}, + {geom.bounds.halfSize.v[0], geom.bounds.halfSize.v[1], geom.bounds.halfSize.v[2]}, + {geom.orientation[0][0], geom.orientation[0][1], geom.orientation[0][2] }, + {geom.orientation[1][0], geom.orientation[1][1], geom.orientation[1][2] }, + {geom.orientation[2][0], geom.orientation[2][1], geom.orientation[2][2] } + }); + break; + + case PHYS_GEOM_CYLINDER: + mapFileDumper.WritePhysicsCylinder({ + {geom.bounds.midPoint.v[0], geom.bounds.midPoint.v[1], geom.bounds.midPoint.v[2]}, + geom.bounds.halfSize.v[0], + geom.bounds.halfSize.v[2] * 2, + {geom.orientation[0][0], geom.orientation[0][1], geom.orientation[0][2] } + }); + break; + + case PHYS_GEOM_BRUSHMODEL: + case PHYS_GEOM_BRUSH: + case PHYS_GEOM_COLLMAP: + case PHYS_GEOM_CAPSULE: + case PHYS_GEOM_GLASS: + default: + // These do not seem to appear inside any collmap assets + assert(false); + break; + } + + mapFileDumper.EndBrush(); + } + + mapFileDumper.EndEntity(); + } +} // namespace IW4::phys_collmap diff --git a/src/ObjWriting/Game/IW4/PhysCollmap/AssetDumperPhysCollmap.h b/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.h similarity index 59% rename from src/ObjWriting/Game/IW4/PhysCollmap/AssetDumperPhysCollmap.h rename to src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.h index 213f1ce1..2407233e 100644 --- a/src/ObjWriting/Game/IW4/PhysCollmap/AssetDumperPhysCollmap.h +++ b/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.h @@ -3,14 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4 +namespace IW4::phys_collmap { - class AssetDumperPhysCollmap final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { - static std::string GetAssetFilename(const std::string& assetName); - protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4 +} // namespace IW4::phys_collmap From e9a7f43348099fe66cb23a18b7987e7f80c09e6a Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Sun, 3 Aug 2025 21:35:44 +0200 Subject: [PATCH 25/35] fix: formatting --- src/ObjCommon/Shader/ShaderCommon.cpp | 2 +- src/ObjCommon/Techset/TechsetCommon.cpp | 2 +- src/ObjCommon/Techset/TechsetCommon.h | 2 +- src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.cpp | 1 - src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.cpp | 2 +- src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.h | 2 +- src/ObjWriting/Game/IW3/Image/ImageDumperIW3.cpp | 1 - src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.h | 2 +- src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.h | 2 +- .../Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.h | 2 +- src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.h | 2 +- src/ObjWriting/Game/IW5/Image/ImageDumperIW5.cpp | 1 - src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.h | 2 +- 13 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/ObjCommon/Shader/ShaderCommon.cpp b/src/ObjCommon/Shader/ShaderCommon.cpp index e7cb5994..7dc6c7bb 100644 --- a/src/ObjCommon/Shader/ShaderCommon.cpp +++ b/src/ObjCommon/Shader/ShaderCommon.cpp @@ -13,4 +13,4 @@ namespace shader { return std::format("shader_bin/vs_{}.cso", assetName); } -} // namespace phys_constraints +} // namespace shader diff --git a/src/ObjCommon/Techset/TechsetCommon.cpp b/src/ObjCommon/Techset/TechsetCommon.cpp index 0deff7f2..f8e75ea5 100644 --- a/src/ObjCommon/Techset/TechsetCommon.cpp +++ b/src/ObjCommon/Techset/TechsetCommon.cpp @@ -13,4 +13,4 @@ namespace techset { return std::format("techsets/{}.techset", assetName); } -} // namespace phys_constraints +} // namespace techset diff --git a/src/ObjCommon/Techset/TechsetCommon.h b/src/ObjCommon/Techset/TechsetCommon.h index 61e467c0..510b9122 100644 --- a/src/ObjCommon/Techset/TechsetCommon.h +++ b/src/ObjCommon/Techset/TechsetCommon.h @@ -6,4 +6,4 @@ namespace techset { std::string GetFileNameForTechniqueName(const std::string& assetName); std::string GetFileNameForTechsetName(const std::string& assetName); -} +} // namespace techset diff --git a/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.cpp b/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.cpp index abf4bf0b..8c610411 100644 --- a/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.cpp +++ b/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.cpp @@ -7,7 +7,6 @@ #include #include - using namespace IW4; using namespace ::light_def; diff --git a/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.cpp b/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.cpp index eac377d0..2d772c67 100644 --- a/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.cpp +++ b/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.cpp @@ -1085,4 +1085,4 @@ namespace T6::sound { return std::make_unique(memory, searchPath); } -} // namespace T6 +} // namespace T6::sound diff --git a/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.h b/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.h index 6bc4a5df..c4d1af75 100644 --- a/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.h +++ b/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.h @@ -10,4 +10,4 @@ namespace T6::sound { std::unique_ptr> CreateSoundBankLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6 +} // namespace T6::sound diff --git a/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.cpp b/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.cpp index 0e8c9873..5459adcf 100644 --- a/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.cpp +++ b/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.cpp @@ -14,7 +14,6 @@ #include #include - using namespace IW3; using namespace ::image; diff --git a/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.h b/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.h index dcdbec06..c010dd89 100644 --- a/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.h +++ b/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.h @@ -11,4 +11,4 @@ namespace IW3::string_table bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW3 +} // namespace IW3::string_table diff --git a/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.h b/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.h index 9b8003c9..f80236df 100644 --- a/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.h +++ b/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.h @@ -11,4 +11,4 @@ namespace IW4::light_def bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4 +} // namespace IW4::light_def diff --git a/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.h b/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.h index 98b6a366..22998751 100644 --- a/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.h +++ b/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.h @@ -12,4 +12,4 @@ namespace IW4::phys_preset bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4 +} // namespace IW4::phys_preset diff --git a/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.h b/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.h index b141a586..5beb2809 100644 --- a/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.h @@ -12,4 +12,4 @@ namespace IW4::tracer bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4 +} // namespace IW4::tracer diff --git a/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.cpp b/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.cpp index 5bc59c92..cbb596c1 100644 --- a/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.cpp @@ -11,7 +11,6 @@ #include #include - using namespace IW5; using namespace ::image; diff --git a/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.h b/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.h index b784a1f2..6544e974 100644 --- a/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.h +++ b/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.h @@ -11,4 +11,4 @@ namespace T6::raw_file bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6 +} // namespace T6::raw_file From 408746c54a0996afcce4cd41e3b89809db99a0a8 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Mon, 4 Aug 2025 21:24:45 +0200 Subject: [PATCH 26/35] refactor: streamline structured data def dumping --- src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 4 +- .../AssetDumperStructuredDataDefSet.cpp | 206 ----------------- .../AssetDumperStructuredDataDefSet.h | 28 --- .../StructuredDataDefDumperIW4.cpp | 208 ++++++++++++++++++ .../StructuredDataDefDumperIW4.h | 17 ++ 5 files changed, 227 insertions(+), 236 deletions(-) delete mode 100644 src/ObjWriting/Game/IW4/StructuredDataDef/AssetDumperStructuredDataDefSet.cpp delete mode 100644 src/ObjWriting/Game/IW4/StructuredDataDef/AssetDumperStructuredDataDefSet.h create mode 100644 src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.cpp create mode 100644 src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.h diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index a7874a66..fbfca499 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -20,7 +20,7 @@ #include "Sound/LoadedSoundDumperIW4.h" #include "Sound/SndCurveDumperIW4.h" #include "StringTable/StringTableDumperIW4.h" -#include "StructuredDataDef/AssetDumperStructuredDataDefSet.h" +#include "StructuredDataDef/StructuredDataDefDumperIW4.h" #include "Techset/TechsetDumperIW4.h" #include "Tracer/TracerDumperIW4.h" #include "Vehicle/VehicleDumperIW4.h" @@ -73,7 +73,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE) DUMP_ASSET_POOL(string_table::Dumper, m_string_table, ASSET_TYPE_STRINGTABLE) DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD) - DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF) + DUMP_ASSET_POOL(structured_data_def::Dumper, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF) DUMP_ASSET_POOL(tracer::Dumper, m_tracer, ASSET_TYPE_TRACER) DUMP_ASSET_POOL(vehicle::Dumper, m_vehicle, ASSET_TYPE_VEHICLE) DUMP_ASSET_POOL(addon_map_ents::Dumper, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS) diff --git a/src/ObjWriting/Game/IW4/StructuredDataDef/AssetDumperStructuredDataDefSet.cpp b/src/ObjWriting/Game/IW4/StructuredDataDef/AssetDumperStructuredDataDefSet.cpp deleted file mode 100644 index f25c6bf4..00000000 --- a/src/ObjWriting/Game/IW4/StructuredDataDef/AssetDumperStructuredDataDefSet.cpp +++ /dev/null @@ -1,206 +0,0 @@ -#include "AssetDumperStructuredDataDefSet.h" - -#include "StructuredDataDef/StructuredDataDefDumper.h" - -#include -#include -#include - -using namespace IW4; -using namespace std::string_literals; - -CommonStructuredDataType AssetDumperStructuredDataDefSet::ConvertType(const CommonStructuredDataDef* def, const StructuredDataType in) -{ - CommonStructuredDataType out; - - switch (in.type) - { - case DATA_INT: - out.m_category = CommonStructuredDataTypeCategory::INT; - break; - case DATA_BYTE: - out.m_category = CommonStructuredDataTypeCategory::BYTE; - break; - case DATA_BOOL: - out.m_category = CommonStructuredDataTypeCategory::BOOL; - break; - case DATA_FLOAT: - out.m_category = CommonStructuredDataTypeCategory::FLOAT; - break; - case DATA_SHORT: - out.m_category = CommonStructuredDataTypeCategory::SHORT; - break; - case DATA_STRING: - out.m_category = CommonStructuredDataTypeCategory::STRING; - out.m_info.string_length = in.u.stringDataLength; - break; - case DATA_ENUM: - assert(!def->m_enums.empty()); - out.m_category = CommonStructuredDataTypeCategory::ENUM; - out.m_info.type_index = std::max(std::min(static_cast(in.u.enumIndex), def->m_enums.size() - 1uz), 0uz); - break; - case DATA_STRUCT: - assert(!def->m_structs.empty()); - out.m_category = CommonStructuredDataTypeCategory::STRUCT; - out.m_info.type_index = std::max(std::min(static_cast(in.u.structIndex), def->m_structs.size() - 1uz), 0uz); - break; - case DATA_INDEXED_ARRAY: - assert(!def->m_indexed_arrays.empty()); - out.m_category = CommonStructuredDataTypeCategory::INDEXED_ARRAY; - out.m_info.type_index = std::max(std::min(static_cast(in.u.indexedArrayIndex), def->m_indexed_arrays.size() - 1uz), 0uz); - break; - case DATA_ENUM_ARRAY: - assert(!def->m_enumed_arrays.empty()); - out.m_category = CommonStructuredDataTypeCategory::ENUM_ARRAY; - out.m_info.type_index = std::max(std::min(static_cast(in.u.enumedArrayIndex), def->m_enumed_arrays.size() - 1uz), 0uz); - break; - case DATA_COUNT: - default: - assert(false); - break; - } - - return out; -} - -void AssetDumperStructuredDataDefSet::ConvertEnum(CommonStructuredDataEnum* out, const StructuredDataEnum* in, const size_t enumIndex) -{ - out->m_name = "ENUM_" + std::to_string(enumIndex); - - if (in->reservedEntryCount > 0 && in->reservedEntryCount != in->entryCount) - out->m_reserved_entry_count = std::max(in->reservedEntryCount, 0); - else - out->m_reserved_entry_count = -1; - - out->m_entries.resize(static_cast(std::max(in->entryCount, 0))); - for (auto i = 0u; i < out->m_entries.size(); i++) - { - auto& outEntry = out->m_entries[i]; - const auto& inEntry = in->entries[i]; - - outEntry.m_name = std::string(inEntry.string); - outEntry.m_value = inEntry.index; - } - - out->SortEntriesByOffset(); -} - -void AssetDumperStructuredDataDefSet::ConvertStruct(const CommonStructuredDataDef* def, - const StructuredDataDef* gameDef, - CommonStructuredDataStruct* out, - const StructuredDataStruct* in, - const size_t structIndex) -{ - if (gameDef->rootType.type == DATA_STRUCT && structIndex == static_cast(gameDef->rootType.u.structIndex)) - { - out->m_name = "root"; - out->m_size_in_byte = gameDef->size; - } - else - { - out->m_name = "STRUCT_" + std::to_string(structIndex); - out->m_size_in_byte = static_cast(std::max(in->size, 0)); - } - - out->m_bit_offset = in->bitOffset; - - out->m_properties.resize(static_cast(std::max(in->propertyCount, 0))); - for (auto i = 0u; i < out->m_properties.size(); i++) - { - auto& outProperty = out->m_properties[i]; - const auto& inProperty = in->properties[i]; - - outProperty.m_name = std::string(inProperty.name); - outProperty.m_type = ConvertType(def, inProperty.type); - - if (inProperty.type.type == DATA_BOOL) - outProperty.m_offset_in_bits = inProperty.offset; - else - outProperty.m_offset_in_bits = inProperty.offset * 8; - } - - out->SortPropertiesByOffset(); -} - -void AssetDumperStructuredDataDefSet::ConvertIndexedArray(const CommonStructuredDataDef* def, - CommonStructuredDataIndexedArray* out, - const StructuredDataIndexedArray* in) -{ - out->m_element_count = static_cast(std::max(in->arraySize, 0)); - out->m_element_size_in_bits = in->elementType.type == DATA_BOOL ? 1 : in->elementSize * 8; - out->m_array_type = ConvertType(def, in->elementType); -} - -void AssetDumperStructuredDataDefSet::ConvertEnumedArray(const CommonStructuredDataDef* def, - CommonStructuredDataEnumedArray* out, - const StructuredDataEnumedArray* in) -{ - assert(!def->m_enums.empty()); - out->m_element_size_in_bits = in->elementType.type == DATA_BOOL ? 1 : in->elementSize * 8; - out->m_array_type = ConvertType(def, in->elementType); - out->m_enum_index = std::max(std::min(static_cast(in->enumIndex), def->m_enums.size() - 1uz), 0uz); - - if (def->m_enums.empty()) - { - assert(false); - return; - } - - out->m_element_count = def->m_enums[out->m_enum_index]->ElementCount(); -} - -std::unique_ptr AssetDumperStructuredDataDefSet::ConvertDef(const StructuredDataDef* in) -{ - auto out = std::make_unique(); - - out->m_version = in->version; - out->m_checksum = in->formatChecksum; - out->m_size_in_byte = in->size; - - out->m_enums.resize(static_cast(std::max(in->enumCount, 0))); - out->m_structs.resize(static_cast(std::max(in->structCount, 0))); - out->m_indexed_arrays.resize(static_cast(std::max(in->indexedArrayCount, 0))); - out->m_enumed_arrays.resize(static_cast(std::max(in->enumedArrayCount, 0))); - - for (auto i = 0u; i < out->m_enums.size(); i++) - { - auto _enum = std::make_unique(); - ConvertEnum(_enum.get(), &in->enums[i], i); - out->m_enums[i] = std::move(_enum); - } - for (auto i = 0u; i < out->m_structs.size(); i++) - { - auto _struct = std::make_unique(); - ConvertStruct(out.get(), in, _struct.get(), &in->structs[i], i); - out->m_structs[i] = std::move(_struct); - } - for (auto i = 0u; i < out->m_indexed_arrays.size(); i++) - ConvertIndexedArray(out.get(), &out->m_indexed_arrays[i], &in->indexedArrays[i]); - for (auto i = 0u; i < out->m_enumed_arrays.size(); i++) - ConvertEnumedArray(out.get(), &out->m_enumed_arrays[i], &in->enumedArrays[i]); - - out->m_root_type = ConvertType(out.get(), in->rootType); - - return out; -} - -bool AssetDumperStructuredDataDefSet::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperStructuredDataDefSet::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* set = asset->Asset(); - const auto assetFile = context.OpenAssetFile(asset->m_name); - - if (!assetFile || set->defs == nullptr) - return; - - StructuredDataDefDumper dumper(*assetFile); - for (auto i = 0u; i < set->defCount; i++) - { - const auto def = ConvertDef(&set->defs[i]); - dumper.DumpDef(*def); - } -} diff --git a/src/ObjWriting/Game/IW4/StructuredDataDef/AssetDumperStructuredDataDefSet.h b/src/ObjWriting/Game/IW4/StructuredDataDef/AssetDumperStructuredDataDefSet.h deleted file mode 100644 index 7859af57..00000000 --- a/src/ObjWriting/Game/IW4/StructuredDataDef/AssetDumperStructuredDataDefSet.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#include "Dumping/AbstractAssetDumper.h" -#include "Game/IW4/IW4.h" -#include "StructuredDataDef/CommonStructuredDataDef.h" - -#include - -namespace IW4 -{ - class AssetDumperStructuredDataDefSet final : public AbstractAssetDumper - { - static CommonStructuredDataType ConvertType(const CommonStructuredDataDef* def, StructuredDataType in); - static void ConvertEnum(CommonStructuredDataEnum* out, const StructuredDataEnum* in, size_t enumIndex); - static void ConvertStruct(const CommonStructuredDataDef* def, - const StructuredDataDef* gameDef, - CommonStructuredDataStruct* out, - const StructuredDataStruct* in, - size_t structIndex); - static void ConvertIndexedArray(const CommonStructuredDataDef* def, CommonStructuredDataIndexedArray* out, const StructuredDataIndexedArray* in); - static void ConvertEnumedArray(const CommonStructuredDataDef* def, CommonStructuredDataEnumedArray* out, const StructuredDataEnumedArray* in); - static std::unique_ptr ConvertDef(const StructuredDataDef* in); - - protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; - }; -} // namespace IW4 diff --git a/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.cpp b/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.cpp new file mode 100644 index 00000000..22177b7e --- /dev/null +++ b/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.cpp @@ -0,0 +1,208 @@ +#include "StructuredDataDefDumperIW4.h" + +#include "StructuredDataDef/StructuredDataDefDumper.h" + +#include +#include +#include + +using namespace IW4; +using namespace std::string_literals; + +namespace +{ + CommonStructuredDataType ConvertType(const CommonStructuredDataDef* def, const StructuredDataType in) + { + CommonStructuredDataType out; + + switch (in.type) + { + case DATA_INT: + out.m_category = CommonStructuredDataTypeCategory::INT; + break; + case DATA_BYTE: + out.m_category = CommonStructuredDataTypeCategory::BYTE; + break; + case DATA_BOOL: + out.m_category = CommonStructuredDataTypeCategory::BOOL; + break; + case DATA_FLOAT: + out.m_category = CommonStructuredDataTypeCategory::FLOAT; + break; + case DATA_SHORT: + out.m_category = CommonStructuredDataTypeCategory::SHORT; + break; + case DATA_STRING: + out.m_category = CommonStructuredDataTypeCategory::STRING; + out.m_info.string_length = in.u.stringDataLength; + break; + case DATA_ENUM: + assert(!def->m_enums.empty()); + out.m_category = CommonStructuredDataTypeCategory::ENUM; + out.m_info.type_index = std::max(std::min(static_cast(in.u.enumIndex), def->m_enums.size() - 1uz), 0uz); + break; + case DATA_STRUCT: + assert(!def->m_structs.empty()); + out.m_category = CommonStructuredDataTypeCategory::STRUCT; + out.m_info.type_index = std::max(std::min(static_cast(in.u.structIndex), def->m_structs.size() - 1uz), 0uz); + break; + case DATA_INDEXED_ARRAY: + assert(!def->m_indexed_arrays.empty()); + out.m_category = CommonStructuredDataTypeCategory::INDEXED_ARRAY; + out.m_info.type_index = std::max(std::min(static_cast(in.u.indexedArrayIndex), def->m_indexed_arrays.size() - 1uz), 0uz); + break; + case DATA_ENUM_ARRAY: + assert(!def->m_enumed_arrays.empty()); + out.m_category = CommonStructuredDataTypeCategory::ENUM_ARRAY; + out.m_info.type_index = std::max(std::min(static_cast(in.u.enumedArrayIndex), def->m_enumed_arrays.size() - 1uz), 0uz); + break; + case DATA_COUNT: + default: + assert(false); + break; + } + + return out; + } + + void ConvertEnum(CommonStructuredDataEnum* out, const StructuredDataEnum* in, const size_t enumIndex) + { + out->m_name = "ENUM_" + std::to_string(enumIndex); + + if (in->reservedEntryCount > 0 && in->reservedEntryCount != in->entryCount) + out->m_reserved_entry_count = std::max(in->reservedEntryCount, 0); + else + out->m_reserved_entry_count = -1; + + out->m_entries.resize(static_cast(std::max(in->entryCount, 0))); + for (auto i = 0u; i < out->m_entries.size(); i++) + { + auto& outEntry = out->m_entries[i]; + const auto& inEntry = in->entries[i]; + + outEntry.m_name = std::string(inEntry.string); + outEntry.m_value = inEntry.index; + } + + out->SortEntriesByOffset(); + } + + void ConvertStruct(const CommonStructuredDataDef* def, + const StructuredDataDef* gameDef, + CommonStructuredDataStruct* out, + const StructuredDataStruct* in, + const size_t structIndex) + { + if (gameDef->rootType.type == DATA_STRUCT && structIndex == static_cast(gameDef->rootType.u.structIndex)) + { + out->m_name = "root"; + out->m_size_in_byte = gameDef->size; + } + else + { + out->m_name = "STRUCT_" + std::to_string(structIndex); + out->m_size_in_byte = static_cast(std::max(in->size, 0)); + } + + out->m_bit_offset = in->bitOffset; + + out->m_properties.resize(static_cast(std::max(in->propertyCount, 0))); + for (auto i = 0u; i < out->m_properties.size(); i++) + { + auto& outProperty = out->m_properties[i]; + const auto& inProperty = in->properties[i]; + + outProperty.m_name = std::string(inProperty.name); + outProperty.m_type = ConvertType(def, inProperty.type); + + if (inProperty.type.type == DATA_BOOL) + outProperty.m_offset_in_bits = inProperty.offset; + else + outProperty.m_offset_in_bits = inProperty.offset * 8; + } + + out->SortPropertiesByOffset(); + } + + void ConvertIndexedArray(const CommonStructuredDataDef* def, CommonStructuredDataIndexedArray* out, const StructuredDataIndexedArray* in) + { + out->m_element_count = static_cast(std::max(in->arraySize, 0)); + out->m_element_size_in_bits = in->elementType.type == DATA_BOOL ? 1 : in->elementSize * 8; + out->m_array_type = ConvertType(def, in->elementType); + } + + void ConvertEnumedArray(const CommonStructuredDataDef* def, CommonStructuredDataEnumedArray* out, const StructuredDataEnumedArray* in) + { + assert(!def->m_enums.empty()); + out->m_element_size_in_bits = in->elementType.type == DATA_BOOL ? 1 : in->elementSize * 8; + out->m_array_type = ConvertType(def, in->elementType); + out->m_enum_index = std::max(std::min(static_cast(in->enumIndex), def->m_enums.size() - 1uz), 0uz); + + if (def->m_enums.empty()) + { + assert(false); + return; + } + + out->m_element_count = def->m_enums[out->m_enum_index]->ElementCount(); + } + + std::unique_ptr ConvertDef(const StructuredDataDef* in) + { + auto out = std::make_unique(); + + out->m_version = in->version; + out->m_checksum = in->formatChecksum; + out->m_size_in_byte = in->size; + + out->m_enums.resize(static_cast(std::max(in->enumCount, 0))); + out->m_structs.resize(static_cast(std::max(in->structCount, 0))); + out->m_indexed_arrays.resize(static_cast(std::max(in->indexedArrayCount, 0))); + out->m_enumed_arrays.resize(static_cast(std::max(in->enumedArrayCount, 0))); + + for (auto i = 0u; i < out->m_enums.size(); i++) + { + auto _enum = std::make_unique(); + ConvertEnum(_enum.get(), &in->enums[i], i); + out->m_enums[i] = std::move(_enum); + } + for (auto i = 0u; i < out->m_structs.size(); i++) + { + auto _struct = std::make_unique(); + ConvertStruct(out.get(), in, _struct.get(), &in->structs[i], i); + out->m_structs[i] = std::move(_struct); + } + for (auto i = 0u; i < out->m_indexed_arrays.size(); i++) + ConvertIndexedArray(out.get(), &out->m_indexed_arrays[i], &in->indexedArrays[i]); + for (auto i = 0u; i < out->m_enumed_arrays.size(); i++) + ConvertEnumedArray(out.get(), &out->m_enumed_arrays[i], &in->enumedArrays[i]); + + out->m_root_type = ConvertType(out.get(), in->rootType); + + return out; + } +} // namespace + +namespace IW4::structured_data_def +{ + bool Dumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* set = asset->Asset(); + const auto assetFile = context.OpenAssetFile(asset->m_name); + + if (!assetFile || set->defs == nullptr) + return; + + StructuredDataDefDumper dumper(*assetFile); + for (auto i = 0u; i < set->defCount; i++) + { + const auto def = ConvertDef(&set->defs[i]); + dumper.DumpDef(*def); + } + } +} // namespace IW4::structured_data_def diff --git a/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.h b/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.h new file mode 100644 index 00000000..da36a645 --- /dev/null +++ b/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.h @@ -0,0 +1,17 @@ +#pragma once + +#include "Dumping/AbstractAssetDumper.h" +#include "Game/IW4/IW4.h" +#include "StructuredDataDef/CommonStructuredDataDef.h" + +#include + +namespace IW4::structured_data_def +{ + class Dumper final : public AbstractAssetDumper + { + protected: + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + }; +} // namespace IW4::structured_data_def From 472e59991fa2423f977e03c8d7d3f81535033107 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Mon, 4 Aug 2025 21:36:47 +0200 Subject: [PATCH 27/35] refactor: streamline shader dumping --- src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 8 +++--- .../IW4/Shader/AssetDumperPixelShader.cpp | 26 ------------------- .../IW4/Shader/AssetDumperVertexShader.cpp | 26 ------------------- .../Game/IW4/Shader/PixelShaderDumperIW4.cpp | 26 +++++++++++++++++++ ...erPixelShader.h => PixelShaderDumperIW4.h} | 6 ++--- .../Game/IW4/Shader/VertexShaderDumperIW4.cpp | 26 +++++++++++++++++++ ...VertexShader.h => VertexShaderDumperIW4.h} | 6 ++--- 7 files changed, 62 insertions(+), 62 deletions(-) delete mode 100644 src/ObjWriting/Game/IW4/Shader/AssetDumperPixelShader.cpp delete mode 100644 src/ObjWriting/Game/IW4/Shader/AssetDumperVertexShader.cpp create mode 100644 src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.cpp rename src/ObjWriting/Game/IW4/Shader/{AssetDumperPixelShader.h => PixelShaderDumperIW4.h} (68%) create mode 100644 src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.cpp rename src/ObjWriting/Game/IW4/Shader/{AssetDumperVertexShader.h => VertexShaderDumperIW4.h} (68%) diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index fbfca499..75d93683 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -15,8 +15,8 @@ #include "PhysCollmap/PhysCollmapDumperIW4.h" #include "PhysPreset/PhysPresetInfoStringDumperIW4.h" #include "RawFile/RawFileDumperIW4.h" -#include "Shader/AssetDumperPixelShader.h" -#include "Shader/AssetDumperVertexShader.h" +#include "Shader/PixelShaderDumperIW4.h" +#include "Shader/VertexShaderDumperIW4.h" #include "Sound/LoadedSoundDumperIW4.h" #include "Sound/SndCurveDumperIW4.h" #include "StringTable/StringTableDumperIW4.h" @@ -47,8 +47,8 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const #ifdef EXPERIMENTAL_MATERIAL_COMPILATION DUMP_ASSET_POOL(material::DecompilingGdtDumper, m_material, ASSET_TYPE_MATERIAL) #endif - DUMP_ASSET_POOL(AssetDumperPixelShader, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER) - DUMP_ASSET_POOL(AssetDumperVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER) + DUMP_ASSET_POOL(shader::PixelShaderDumper, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER) + DUMP_ASSET_POOL(shader::VertexShaderDumper, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER) DUMP_ASSET_POOL(techset::Dumper, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) // DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND) diff --git a/src/ObjWriting/Game/IW4/Shader/AssetDumperPixelShader.cpp b/src/ObjWriting/Game/IW4/Shader/AssetDumperPixelShader.cpp deleted file mode 100644 index 40bb4089..00000000 --- a/src/ObjWriting/Game/IW4/Shader/AssetDumperPixelShader.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "AssetDumperPixelShader.h" - -#include - -using namespace IW4; - -bool AssetDumperPixelShader::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperPixelShader::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* pixelShader = asset->Asset(); - - std::ostringstream ss; - ss << "shader_bin/ps_" << pixelShader->name << ".cso"; - - const auto shaderFile = context.OpenAssetFile(ss.str()); - - if (!shaderFile) - return; - - shaderFile->write(reinterpret_cast(pixelShader->prog.loadDef.program), - static_cast(pixelShader->prog.loadDef.programSize) * 4u); -} diff --git a/src/ObjWriting/Game/IW4/Shader/AssetDumperVertexShader.cpp b/src/ObjWriting/Game/IW4/Shader/AssetDumperVertexShader.cpp deleted file mode 100644 index 6bc12d7a..00000000 --- a/src/ObjWriting/Game/IW4/Shader/AssetDumperVertexShader.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "AssetDumperVertexShader.h" - -#include - -using namespace IW4; - -bool AssetDumperVertexShader::ShouldDump(XAssetInfo* asset) -{ - return true; -} - -void AssetDumperVertexShader::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) -{ - const auto* vertexShader = asset->Asset(); - - std::ostringstream ss; - ss << "shader_bin/vs_" << vertexShader->name << ".cso"; - - const auto shaderFile = context.OpenAssetFile(ss.str()); - - if (!shaderFile) - return; - - shaderFile->write(reinterpret_cast(vertexShader->prog.loadDef.program), - static_cast(vertexShader->prog.loadDef.programSize) * 4u); -} diff --git a/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.cpp b/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.cpp new file mode 100644 index 00000000..bbd382fa --- /dev/null +++ b/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.cpp @@ -0,0 +1,26 @@ +#include "PixelShaderDumperIW4.h" + +#include "Shader/ShaderCommon.h" + +using namespace IW4; +using namespace ::shader; + +namespace IW4::shader +{ + bool PixelShaderDumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void PixelShaderDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* pixelShader = asset->Asset(); + const auto shaderFile = context.OpenAssetFile(GetFileNameForPixelShaderAssetName(asset->m_name)); + + if (!shaderFile) + return; + + shaderFile->write(reinterpret_cast(pixelShader->prog.loadDef.program), + static_cast(pixelShader->prog.loadDef.programSize) * 4u); + } +} // namespace IW4::shader diff --git a/src/ObjWriting/Game/IW4/Shader/AssetDumperPixelShader.h b/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.h similarity index 68% rename from src/ObjWriting/Game/IW4/Shader/AssetDumperPixelShader.h rename to src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.h index 925e80f9..875576ca 100644 --- a/src/ObjWriting/Game/IW4/Shader/AssetDumperPixelShader.h +++ b/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4 +namespace IW4::shader { - class AssetDumperPixelShader final : public AbstractAssetDumper + class PixelShaderDumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4 +} // namespace IW4::shader diff --git a/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.cpp b/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.cpp new file mode 100644 index 00000000..3dacbc04 --- /dev/null +++ b/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.cpp @@ -0,0 +1,26 @@ +#include "VertexShaderDumperIW4.h" + +#include "Shader/ShaderCommon.h" + +using namespace IW4; +using namespace ::shader; + +namespace IW4::shader +{ + bool VertexShaderDumper::ShouldDump(XAssetInfo* asset) + { + return true; + } + + void VertexShaderDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + { + const auto* vertexShader = asset->Asset(); + const auto shaderFile = context.OpenAssetFile(GetFileNameForVertexShaderAssetName(asset->m_name)); + + if (!shaderFile) + return; + + shaderFile->write(reinterpret_cast(vertexShader->prog.loadDef.program), + static_cast(vertexShader->prog.loadDef.programSize) * 4u); + } +} // namespace IW4::shader diff --git a/src/ObjWriting/Game/IW4/Shader/AssetDumperVertexShader.h b/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.h similarity index 68% rename from src/ObjWriting/Game/IW4/Shader/AssetDumperVertexShader.h rename to src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.h index a9d631ef..6f24fce7 100644 --- a/src/ObjWriting/Game/IW4/Shader/AssetDumperVertexShader.h +++ b/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4 +namespace IW4::shader { - class AssetDumperVertexShader final : public AbstractAssetDumper + class VertexShaderDumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4 +} // namespace IW4::shader From a5024d40b09878e16dc2e4556ee884f879d173a0 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Mon, 4 Aug 2025 23:48:30 +0200 Subject: [PATCH 28/35] refactor: streamline T6 asset loading --- .../Game/T6/FontIcon/CsvLoaderFontIconT6.cpp | 6 +- .../Game/T6/FontIcon/CsvLoaderFontIconT6.h | 6 +- .../Game/T6/FontIcon/JsonLoaderFontIconT6.cpp | 6 +- .../Game/T6/FontIcon/JsonLoaderFontIconT6.h | 6 +- .../Game/T6/Image/LoaderImageT6.cpp | 10 ++-- src/ObjLoading/Game/T6/Image/LoaderImageT6.h | 6 +- .../T6/Leaderboard/JsonLeaderboardDefLoader.h | 11 ---- ...Loader.cpp => JsonLoaderLeaderboardT6.cpp} | 48 ++++++++++++++-- .../T6/Leaderboard/JsonLoaderLeaderboardT6.h | 13 +++++ .../T6/Leaderboard/LoaderLeaderboardT6.cpp | 54 ------------------ .../Game/T6/Leaderboard/LoaderLeaderboardT6.h | 13 ----- ...derLocalizeT6.cpp => LocalizeLoaderT6.cpp} | 8 +-- ...{LoaderLocalizeT6.h => LocalizeLoaderT6.h} | 6 +- .../Game/T6/Material/LoaderMaterialT6.cpp | 9 +-- .../Game/T6/Material/LoaderMaterialT6.h | 6 +- src/ObjLoading/Game/T6/ObjLoaderT6.cpp | 42 +++++++------- .../GdtLoaderPhysConstraintsT6.cpp | 9 ++- .../GdtLoaderPhysConstraintsT6.h | 7 +-- .../InfoStringLoaderPhysConstraintsT6.cpp | 57 ++++++++++--------- .../InfoStringLoaderPhysConstraintsT6.h | 8 +-- .../RawLoaderPhysConstraintsT6.cpp | 11 ++-- .../RawLoaderPhysConstraintsT6.h | 6 +- .../T6/PhysPreset/GdtLoaderPhysPresetT6.cpp | 16 +++--- .../T6/PhysPreset/GdtLoaderPhysPresetT6.h | 6 +- .../InfoStringLoaderPhysPresetT6.cpp | 54 ++++++++++-------- .../PhysPreset/InfoStringLoaderPhysPresetT6.h | 9 ++- .../T6/PhysPreset/RawLoaderPhysPresetT6.cpp | 13 +++-- .../T6/PhysPreset/RawLoaderPhysPresetT6.h | 6 +- src/ObjLoading/Game/T6/Qdb/LoaderQdbT6.cpp | 6 +- src/ObjLoading/Game/T6/Qdb/LoaderQdbT6.h | 6 +- .../Game/T6/RawFile/LoaderRawFileT6.cpp | 6 +- .../Game/T6/RawFile/LoaderRawFileT6.h | 6 +- .../Game/T6/Script/LoaderScriptT6.cpp | 6 +- .../Game/T6/Script/LoaderScriptT6.h | 6 +- src/ObjLoading/Game/T6/Slug/LoaderSlugT6.cpp | 6 +- src/ObjLoading/Game/T6/Slug/LoaderSlugT6.h | 6 +- .../T6/StringTable/LoaderStringTableT6.cpp | 9 +-- .../Game/T6/StringTable/LoaderStringTableT6.h | 6 +- .../Game/T6/Tracer/GdtLoaderTracerT6.cpp | 8 +-- .../Game/T6/Tracer/GdtLoaderTracerT6.h | 6 +- .../T6/Tracer/InfoStringLoaderTracerT6.cpp | 46 ++++++++------- .../Game/T6/Tracer/InfoStringLoaderTracerT6.h | 8 +-- .../Game/T6/Tracer/RawLoaderTracerT6.cpp | 8 +-- .../Game/T6/Tracer/RawLoaderTracerT6.h | 6 +- .../Game/T6/Vehicle/GdtLoaderVehicleT6.cpp | 8 +-- .../Game/T6/Vehicle/GdtLoaderVehicleT6.h | 6 +- .../T6/Vehicle/InfoStringLoaderVehicleT6.cpp | 43 +++++++------- .../T6/Vehicle/InfoStringLoaderVehicleT6.h | 8 +-- .../Game/T6/Vehicle/RawLoaderVehicleT6.cpp | 8 +-- .../Game/T6/Vehicle/RawLoaderVehicleT6.h | 6 +- .../Game/T6/ZBarrier/GdtLoaderZBarrierT6.cpp | 8 +-- .../Game/T6/ZBarrier/GdtLoaderZBarrierT6.h | 6 +- .../ZBarrier/InfoStringLoaderZBarrierT6.cpp | 45 ++++++++------- .../T6/ZBarrier/InfoStringLoaderZBarrierT6.h | 8 +-- .../Game/T6/ZBarrier/RawLoaderZBarrierT6.cpp | 8 +-- .../Game/T6/ZBarrier/RawLoaderZBarrierT6.h | 6 +- .../AssetLoaders/LoaderStringTableT6Test.cpp | 2 +- .../T6/FontIcon/JsonLoaderFontIconT6Test.cpp | 2 +- .../Game/T6/Material/LoaderMaterialT6Test.cpp | 2 +- 59 files changed, 380 insertions(+), 383 deletions(-) delete mode 100644 src/ObjLoading/Game/T6/Leaderboard/JsonLeaderboardDefLoader.h rename src/ObjLoading/Game/T6/Leaderboard/{JsonLeaderboardDefLoader.cpp => JsonLoaderLeaderboardT6.cpp} (72%) create mode 100644 src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.h delete mode 100644 src/ObjLoading/Game/T6/Leaderboard/LoaderLeaderboardT6.cpp delete mode 100644 src/ObjLoading/Game/T6/Leaderboard/LoaderLeaderboardT6.h rename src/ObjLoading/Game/T6/Localize/{LoaderLocalizeT6.cpp => LocalizeLoaderT6.cpp} (85%) rename src/ObjLoading/Game/T6/Localize/{LoaderLocalizeT6.h => LocalizeLoaderT6.h} (51%) diff --git a/src/ObjLoading/Game/T6/FontIcon/CsvLoaderFontIconT6.cpp b/src/ObjLoading/Game/T6/FontIcon/CsvLoaderFontIconT6.cpp index ca53435b..047b1c39 100644 --- a/src/ObjLoading/Game/T6/FontIcon/CsvLoaderFontIconT6.cpp +++ b/src/ObjLoading/Game/T6/FontIcon/CsvLoaderFontIconT6.cpp @@ -282,10 +282,10 @@ namespace }; } // namespace -namespace T6 +namespace T6::font_icon { - std::unique_ptr> CreateCsvFontIconLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateCsvLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6 +} // namespace T6::font_icon diff --git a/src/ObjLoading/Game/T6/FontIcon/CsvLoaderFontIconT6.h b/src/ObjLoading/Game/T6/FontIcon/CsvLoaderFontIconT6.h index 7bb1e58f..76e623ea 100644 --- a/src/ObjLoading/Game/T6/FontIcon/CsvLoaderFontIconT6.h +++ b/src/ObjLoading/Game/T6/FontIcon/CsvLoaderFontIconT6.h @@ -7,7 +7,7 @@ #include -namespace T6 +namespace T6::font_icon { - std::unique_ptr> CreateCsvFontIconLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6 + std::unique_ptr> CreateCsvLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace T6::font_icon diff --git a/src/ObjLoading/Game/T6/FontIcon/JsonLoaderFontIconT6.cpp b/src/ObjLoading/Game/T6/FontIcon/JsonLoaderFontIconT6.cpp index 002e778c..5ff32a18 100644 --- a/src/ObjLoading/Game/T6/FontIcon/JsonLoaderFontIconT6.cpp +++ b/src/ObjLoading/Game/T6/FontIcon/JsonLoaderFontIconT6.cpp @@ -141,10 +141,10 @@ namespace }; } // namespace -namespace T6 +namespace T6::font_icon { - std::unique_ptr> CreateJsonFontIconLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateJsonLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6 +} // namespace T6::font_icon diff --git a/src/ObjLoading/Game/T6/FontIcon/JsonLoaderFontIconT6.h b/src/ObjLoading/Game/T6/FontIcon/JsonLoaderFontIconT6.h index 7938827a..e770f0d4 100644 --- a/src/ObjLoading/Game/T6/FontIcon/JsonLoaderFontIconT6.h +++ b/src/ObjLoading/Game/T6/FontIcon/JsonLoaderFontIconT6.h @@ -7,7 +7,7 @@ #include -namespace T6 +namespace T6::font_icon { - std::unique_ptr> CreateJsonFontIconLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6 + std::unique_ptr> CreateJsonLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace T6::font_icon diff --git a/src/ObjLoading/Game/T6/Image/LoaderImageT6.cpp b/src/ObjLoading/Game/T6/Image/LoaderImageT6.cpp index 5c26a32d..1b41701a 100644 --- a/src/ObjLoading/Game/T6/Image/LoaderImageT6.cpp +++ b/src/ObjLoading/Game/T6/Image/LoaderImageT6.cpp @@ -2,6 +2,7 @@ #include "Game/T6/CommonT6.h" #include "Game/T6/T6.h" +#include "Image/ImageCommon.h" #include "Image/IwiLoader.h" #include @@ -11,6 +12,7 @@ #include using namespace T6; +using namespace ::image; namespace { @@ -25,7 +27,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = std::format("images/{}.iwi", assetName); + const auto fileName = GetFileNameForAsset(assetName, ".iwi"); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -68,10 +70,10 @@ namespace }; } // namespace -namespace T6 +namespace T6::image { - std::unique_ptr> CreateImageLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6 +} // namespace T6::image diff --git a/src/ObjLoading/Game/T6/Image/LoaderImageT6.h b/src/ObjLoading/Game/T6/Image/LoaderImageT6.h index 6c1bfb1f..e77f4591 100644 --- a/src/ObjLoading/Game/T6/Image/LoaderImageT6.h +++ b/src/ObjLoading/Game/T6/Image/LoaderImageT6.h @@ -7,7 +7,7 @@ #include -namespace T6 +namespace T6::image { - std::unique_ptr> CreateImageLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace T6::image diff --git a/src/ObjLoading/Game/T6/Leaderboard/JsonLeaderboardDefLoader.h b/src/ObjLoading/Game/T6/Leaderboard/JsonLeaderboardDefLoader.h deleted file mode 100644 index 6145d04d..00000000 --- a/src/ObjLoading/Game/T6/Leaderboard/JsonLeaderboardDefLoader.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "Game/T6/T6.h" -#include "Utils/MemoryManager.h" - -#include - -namespace T6 -{ - bool LoadLeaderboardAsJson(std::istream& stream, LeaderboardDef& leaderboard, MemoryManager& memory); -} // namespace T6 diff --git a/src/ObjLoading/Game/T6/Leaderboard/JsonLeaderboardDefLoader.cpp b/src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.cpp similarity index 72% rename from src/ObjLoading/Game/T6/Leaderboard/JsonLeaderboardDefLoader.cpp rename to src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.cpp index b4f7823f..ffbb5e0b 100644 --- a/src/ObjLoading/Game/T6/Leaderboard/JsonLeaderboardDefLoader.cpp +++ b/src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.cpp @@ -1,14 +1,18 @@ -#include "JsonLeaderboardDefLoader.h" +#include "JsonLoaderLeaderboardT6.h" #include "Game/T6/CommonT6.h" #include "Game/T6/Leaderboard/JsonLeaderboardDef.h" +#include "Game/T6/T6.h" +#include "Leaderboard/LeaderboardCommon.h" +#include #include #include #include using namespace nlohmann; using namespace T6; +using namespace ::leaderboard; namespace { @@ -124,13 +128,45 @@ namespace std::istream& m_stream; MemoryManager& m_memory; }; + + class LeaderboardLoader final : public AssetCreator + { + public: + LeaderboardLoader(MemoryManager& memory, ISearchPath& searchPath) + : m_memory(memory), + m_search_path(searchPath) + { + } + + AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override + { + const auto file = m_search_path.Open(GetJsonFileNameForAsset(assetName)); + if (!file.IsOpen()) + return AssetCreationResult::NoAction(); + + auto* leaderboardDef = m_memory.Alloc(); + leaderboardDef->name = m_memory.Dup(assetName.c_str()); + + const JsonLoader loader(*file.m_stream, m_memory); + if (!loader.Load(*leaderboardDef)) + { + std::cerr << std::format("Failed to load leaderboard \"{}\"\n", assetName); + return AssetCreationResult::Failure(); + } + + return AssetCreationResult::Success(context.AddAsset(assetName, leaderboardDef)); + } + + private: + MemoryManager& m_memory; + ISearchPath& m_search_path; + }; } // namespace -namespace T6 +namespace T6::leaderboard { - bool LoadLeaderboardAsJson(std::istream& stream, LeaderboardDef& leaderboard, MemoryManager& memory) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { - const JsonLoader loader(stream, memory); - return loader.Load(leaderboard); + return std::make_unique(memory, searchPath); } -} // namespace T6 +} // namespace T6::leaderboard diff --git a/src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.h b/src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.h new file mode 100644 index 00000000..24865730 --- /dev/null +++ b/src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.h @@ -0,0 +1,13 @@ +#pragma once + +#include "Asset/IAssetCreator.h" +#include "Game/T6/T6.h" +#include "SearchPath/ISearchPath.h" +#include "Utils/MemoryManager.h" + +#include + +namespace T6::leaderboard +{ + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace T6::leaderboard diff --git a/src/ObjLoading/Game/T6/Leaderboard/LoaderLeaderboardT6.cpp b/src/ObjLoading/Game/T6/Leaderboard/LoaderLeaderboardT6.cpp deleted file mode 100644 index ae08c020..00000000 --- a/src/ObjLoading/Game/T6/Leaderboard/LoaderLeaderboardT6.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "LoaderLeaderboardT6.h" - -#include "Game/T6/CommonT6.h" -#include "Game/T6/T6.h" -#include "JsonLeaderboardDefLoader.h" - -#include -#include -#include - -using namespace T6; - -namespace -{ - class LeaderboardLoader final : public AssetCreator - { - public: - LeaderboardLoader(MemoryManager& memory, ISearchPath& searchPath) - : m_memory(memory), - m_search_path(searchPath) - { - } - - AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override - { - const auto file = m_search_path.Open(std::format("leaderboards/{}.json", assetName)); - if (!file.IsOpen()) - return AssetCreationResult::NoAction(); - - auto* leaderboardDef = m_memory.Alloc(); - leaderboardDef->name = m_memory.Dup(assetName.c_str()); - - if (!LoadLeaderboardAsJson(*file.m_stream, *leaderboardDef, m_memory)) - { - std::cerr << std::format("Failed to load leaderboard \"{}\"\n", assetName); - return AssetCreationResult::Failure(); - } - - return AssetCreationResult::Success(context.AddAsset(assetName, leaderboardDef)); - } - - private: - MemoryManager& m_memory; - ISearchPath& m_search_path; - }; -} // namespace - -namespace T6 -{ - std::unique_ptr> CreateLeaderboardLoader(MemoryManager& memory, ISearchPath& searchPath) - { - return std::make_unique(memory, searchPath); - } -} // namespace T6 diff --git a/src/ObjLoading/Game/T6/Leaderboard/LoaderLeaderboardT6.h b/src/ObjLoading/Game/T6/Leaderboard/LoaderLeaderboardT6.h deleted file mode 100644 index df060b90..00000000 --- a/src/ObjLoading/Game/T6/Leaderboard/LoaderLeaderboardT6.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "Asset/IAssetCreator.h" -#include "Game/T6/T6.h" -#include "SearchPath/ISearchPath.h" -#include "Utils/MemoryManager.h" - -#include - -namespace T6 -{ - std::unique_ptr> CreateLeaderboardLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6 diff --git a/src/ObjLoading/Game/T6/Localize/LoaderLocalizeT6.cpp b/src/ObjLoading/Game/T6/Localize/LocalizeLoaderT6.cpp similarity index 85% rename from src/ObjLoading/Game/T6/Localize/LoaderLocalizeT6.cpp rename to src/ObjLoading/Game/T6/Localize/LocalizeLoaderT6.cpp index c4a3b77d..f28fa7d0 100644 --- a/src/ObjLoading/Game/T6/Localize/LoaderLocalizeT6.cpp +++ b/src/ObjLoading/Game/T6/Localize/LocalizeLoaderT6.cpp @@ -1,4 +1,4 @@ -#include "LoaderLocalizeT6.h" +#include "LocalizeLoaderT6.h" #include "Localize/CommonLocalizeLoader.h" @@ -35,10 +35,10 @@ namespace }; } // namespace -namespace T6 +namespace T6::localize { - std::unique_ptr> CreateLocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace T6 +} // namespace T6::localize diff --git a/src/ObjLoading/Game/T6/Localize/LoaderLocalizeT6.h b/src/ObjLoading/Game/T6/Localize/LocalizeLoaderT6.h similarity index 51% rename from src/ObjLoading/Game/T6/Localize/LoaderLocalizeT6.h rename to src/ObjLoading/Game/T6/Localize/LocalizeLoaderT6.h index 991f53b1..0aecaa98 100644 --- a/src/ObjLoading/Game/T6/Localize/LoaderLocalizeT6.h +++ b/src/ObjLoading/Game/T6/Localize/LocalizeLoaderT6.h @@ -8,7 +8,7 @@ #include -namespace T6 +namespace T6::localize { - std::unique_ptr> CreateLocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace T6 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace T6::localize diff --git a/src/ObjLoading/Game/T6/Material/LoaderMaterialT6.cpp b/src/ObjLoading/Game/T6/Material/LoaderMaterialT6.cpp index 5458b96e..eeb7b7fa 100644 --- a/src/ObjLoading/Game/T6/Material/LoaderMaterialT6.cpp +++ b/src/ObjLoading/Game/T6/Material/LoaderMaterialT6.cpp @@ -8,6 +8,7 @@ #include using namespace T6; +using namespace ::material; namespace { @@ -22,7 +23,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto file = m_search_path.Open(material::GetFileNameForAssetName(assetName)); + const auto file = m_search_path.Open(GetFileNameForAssetName(assetName)); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -45,10 +46,10 @@ namespace }; } // namespace -namespace T6 +namespace T6::material { - std::unique_ptr> CreateMaterialLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6 +} // namespace T6::material diff --git a/src/ObjLoading/Game/T6/Material/LoaderMaterialT6.h b/src/ObjLoading/Game/T6/Material/LoaderMaterialT6.h index 22cd78dc..d0dcc461 100644 --- a/src/ObjLoading/Game/T6/Material/LoaderMaterialT6.h +++ b/src/ObjLoading/Game/T6/Material/LoaderMaterialT6.h @@ -7,7 +7,7 @@ #include -namespace T6 +namespace T6::material { - std::unique_ptr> CreateMaterialLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace T6::material diff --git a/src/ObjLoading/Game/T6/ObjLoaderT6.cpp b/src/ObjLoading/Game/T6/ObjLoaderT6.cpp index 6aa2d966..3e02b7f6 100644 --- a/src/ObjLoading/Game/T6/ObjLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/ObjLoaderT6.cpp @@ -13,8 +13,8 @@ #include "Image/IwiTypes.h" #include "Image/LoaderImageT6.h" #include "Image/Texture.h" -#include "Leaderboard/LoaderLeaderboardT6.h" -#include "Localize/LoaderLocalizeT6.h" +#include "Leaderboard/JsonLoaderLeaderboardT6.h" +#include "Localize/LocalizeLoaderT6.h" #include "Material/LoaderMaterialT6.h" #include "ObjContainer/IPak/IPak.h" #include "ObjLoading.h" @@ -393,16 +393,16 @@ namespace T6 { auto& memory = zone.Memory(); - collection.AddAssetCreator(CreateRawPhysPresetLoader(memory, searchPath, zone)); - collection.AddAssetCreator(CreateGdtPhysPresetLoader(memory, searchPath, gdt, zone)); - collection.AddAssetCreator(CreateRawPhysConstraintsLoader(memory, searchPath, zone)); - collection.AddAssetCreator(CreateGdtPhysConstraintsLoader(memory, searchPath, gdt, zone)); + collection.AddAssetCreator(phys_preset::CreateRawLoader(memory, searchPath, zone)); + collection.AddAssetCreator(phys_preset::CreateGdtLoader(memory, gdt, zone)); + collection.AddAssetCreator(phys_constraints::CreateRawLoader(memory, searchPath, zone)); + collection.AddAssetCreator(phys_constraints::CreateGdtLoader(memory, searchPath, gdt, zone)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); collection.AddAssetCreator(xmodel::CreateXModelLoader(memory, searchPath, zone)); - collection.AddAssetCreator(CreateMaterialLoader(memory, searchPath)); + collection.AddAssetCreator(material::CreateLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateImageLoader(memory, searchPath)); + collection.AddAssetCreator(image::CreateLoader(memory, searchPath)); collection.AddAssetCreator(sound::CreateSoundBankLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); @@ -413,11 +413,11 @@ namespace T6 // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateCsvFontIconLoader(memory, searchPath)); - collection.AddAssetCreator(CreateJsonFontIconLoader(memory, searchPath)); + collection.AddAssetCreator(font_icon::CreateCsvLoader(memory, searchPath)); + collection.AddAssetCreator(font_icon::CreateJsonLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateLocalizeLoader(memory, searchPath, zone)); + collection.AddAssetCreator(localize::CreateLoader(memory, searchPath, zone)); collection.AddAssetCreator(weapon::CreateRawLoader(memory, searchPath, zone)); collection.AddAssetCreator(weapon::CreateGdtLoader(memory, searchPath, gdt, zone)); collection.AddAssetCreator(attachment::CreateRawLoader(memory, searchPath, zone)); @@ -428,26 +428,26 @@ namespace T6 // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateRawFileLoader(memory, searchPath)); - collection.AddAssetCreator(CreateStringTableLoader(memory, searchPath)); - collection.AddAssetCreator(CreateLeaderboardLoader(memory, searchPath)); + collection.AddAssetCreator(raw_file::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(string_table::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(leaderboard::CreateLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateScriptLoader(memory, searchPath)); - collection.AddAssetCreator(CreateRawVehicleLoader(memory, searchPath, zone)); - collection.AddAssetCreator(CreateGdtVehicleLoader(memory, searchPath, gdt, zone)); + collection.AddAssetCreator(script::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(vehicle::CreateRawLoader(memory, searchPath, zone)); + collection.AddAssetCreator(vehicle::CreateGdtLoader(memory, searchPath, gdt, zone)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateQdbLoader(memory, searchPath)); - collection.AddAssetCreator(CreateSlugLoader(memory, searchPath)); + collection.AddAssetCreator(qdb::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(slug::CreateLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateRawZBarrierLoader(memory, searchPath, zone)); - collection.AddAssetCreator(CreateGdtZBarrierLoader(memory, searchPath, gdt, zone)); + collection.AddAssetCreator(z_barrier::CreateRawLoader(memory, searchPath, zone)); + collection.AddAssetCreator(z_barrier::CreateGdtLoader(memory, searchPath, gdt, zone)); } } // namespace diff --git a/src/ObjLoading/Game/T6/PhysConstraints/GdtLoaderPhysConstraintsT6.cpp b/src/ObjLoading/Game/T6/PhysConstraints/GdtLoaderPhysConstraintsT6.cpp index d6c35c5d..fae17b92 100644 --- a/src/ObjLoading/Game/T6/PhysConstraints/GdtLoaderPhysConstraintsT6.cpp +++ b/src/ObjLoading/Game/T6/PhysConstraints/GdtLoaderPhysConstraintsT6.cpp @@ -40,15 +40,14 @@ namespace private: IGdtQueryable& m_gdt; - InfoStringLoaderPhysConstraints m_info_string_loader; + T6::phys_constraints::InfoStringLoader m_info_string_loader; }; } // namespace -namespace T6 +namespace T6::phys_constraints { - std::unique_ptr> - CreateGdtPhysConstraintsLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) { return std::make_unique(memory, searchPath, gdt, zone); } -} // namespace T6 +} // namespace T6::phys_constraints diff --git a/src/ObjLoading/Game/T6/PhysConstraints/GdtLoaderPhysConstraintsT6.h b/src/ObjLoading/Game/T6/PhysConstraints/GdtLoaderPhysConstraintsT6.h index 45b70188..c55f8e1a 100644 --- a/src/ObjLoading/Game/T6/PhysConstraints/GdtLoaderPhysConstraintsT6.h +++ b/src/ObjLoading/Game/T6/PhysConstraints/GdtLoaderPhysConstraintsT6.h @@ -8,8 +8,7 @@ #include -namespace T6 +namespace T6::phys_constraints { - std::unique_ptr> - CreateGdtPhysConstraintsLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); -} // namespace T6 + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); +} // namespace T6::phys_constraints diff --git a/src/ObjLoading/Game/T6/PhysConstraints/InfoStringLoaderPhysConstraintsT6.cpp b/src/ObjLoading/Game/T6/PhysConstraints/InfoStringLoaderPhysConstraintsT6.cpp index ab29df7e..1242dfe0 100644 --- a/src/ObjLoading/Game/T6/PhysConstraints/InfoStringLoaderPhysConstraintsT6.cpp +++ b/src/ObjLoading/Game/T6/PhysConstraints/InfoStringLoaderPhysConstraintsT6.cpp @@ -76,35 +76,38 @@ namespace } } // namespace -InfoStringLoaderPhysConstraints::InfoStringLoaderPhysConstraints(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) - : m_memory(memory), - m_search_path(searchPath), - m_zone(zone) +namespace T6::phys_constraints { -} - -AssetCreationResult InfoStringLoaderPhysConstraints::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) -{ - auto* physConstraints = m_memory.Alloc(); - physConstraints->name = m_memory.Dup(assetName.c_str()); - - AssetRegistration registration(assetName, physConstraints); - InfoStringToPhysConstraintsConverter converter(infoString, - *physConstraints, - m_zone.m_script_strings, - m_memory, - context, - registration, - phys_constraints_fields, - std::extent_v); - if (!converter.Convert()) + InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + : m_memory(memory), + m_search_path(searchPath), + m_zone(zone) { - std::cerr << std::format("Failed to parse phys constraints: \"{}\"\n", assetName); - return AssetCreationResult::Failure(); } - CalculatePhysConstraintsFields(*physConstraints, m_zone.m_script_strings); - registration.AddScriptString(m_zone.m_script_strings.AddOrGetScriptString("")); + AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) + { + auto* physConstraints = m_memory.Alloc(); + physConstraints->name = m_memory.Dup(assetName.c_str()); - return AssetCreationResult::Success(context.AddAsset(std::move(registration))); -} + AssetRegistration registration(assetName, physConstraints); + InfoStringToPhysConstraintsConverter converter(infoString, + *physConstraints, + m_zone.m_script_strings, + m_memory, + context, + registration, + phys_constraints_fields, + std::extent_v); + if (!converter.Convert()) + { + std::cerr << std::format("Failed to parse phys constraints: \"{}\"\n", assetName); + return AssetCreationResult::Failure(); + } + + CalculatePhysConstraintsFields(*physConstraints, m_zone.m_script_strings); + registration.AddScriptString(m_zone.m_script_strings.AddOrGetScriptString("")); + + return AssetCreationResult::Success(context.AddAsset(std::move(registration))); + } +} // namespace T6::phys_constraints diff --git a/src/ObjLoading/Game/T6/PhysConstraints/InfoStringLoaderPhysConstraintsT6.h b/src/ObjLoading/Game/T6/PhysConstraints/InfoStringLoaderPhysConstraintsT6.h index dbebb186..14bf7512 100644 --- a/src/ObjLoading/Game/T6/PhysConstraints/InfoStringLoaderPhysConstraintsT6.h +++ b/src/ObjLoading/Game/T6/PhysConstraints/InfoStringLoaderPhysConstraintsT6.h @@ -4,12 +4,12 @@ #include "Asset/AssetCreationResult.h" #include "InfoString/InfoString.h" -namespace T6 +namespace T6::phys_constraints { - class InfoStringLoaderPhysConstraints + class InfoStringLoader { public: - InfoStringLoaderPhysConstraints(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); + InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context); @@ -18,4 +18,4 @@ namespace T6 ISearchPath& m_search_path; Zone& m_zone; }; -} // namespace T6 +} // namespace T6::phys_constraints diff --git a/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.cpp b/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.cpp index 0555c180..8a85fe93 100644 --- a/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.cpp +++ b/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.cpp @@ -11,6 +11,7 @@ #include using namespace T6; +using namespace ::phys_constraints; namespace { @@ -25,7 +26,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = phys_constraints::GetFileNameForAssetName(assetName); + const auto fileName = GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -42,14 +43,14 @@ namespace private: ISearchPath& m_search_path; - InfoStringLoaderPhysConstraints m_info_string_loader; + T6::phys_constraints::InfoStringLoader m_info_string_loader; }; } // namespace -namespace T6 +namespace T6::phys_constraints { - std::unique_ptr> CreateRawPhysConstraintsLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace T6 +} // namespace T6::phys_constraints diff --git a/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.h b/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.h index dc88bc45..e347be28 100644 --- a/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.h +++ b/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.h @@ -7,7 +7,7 @@ #include -namespace T6 +namespace T6::phys_constraints { - std::unique_ptr> CreateRawPhysConstraintsLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace T6 + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace T6::phys_constraints diff --git a/src/ObjLoading/Game/T6/PhysPreset/GdtLoaderPhysPresetT6.cpp b/src/ObjLoading/Game/T6/PhysPreset/GdtLoaderPhysPresetT6.cpp index 9d7f179f..ed681d4f 100644 --- a/src/ObjLoading/Game/T6/PhysPreset/GdtLoaderPhysPresetT6.cpp +++ b/src/ObjLoading/Game/T6/PhysPreset/GdtLoaderPhysPresetT6.cpp @@ -16,15 +16,15 @@ namespace class GdtLoaderPhysPreset final : public AssetCreator { public: - GdtLoaderPhysPreset(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) + GdtLoaderPhysPreset(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone) : m_gdt(gdt), - m_info_string_loader(memory, searchPath, zone) + m_info_string_loader(memory, zone) { } AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto* gdtEntry = m_gdt.GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_WEAPON, assetName); + const auto* gdtEntry = m_gdt.GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_PHYS_PRESET, assetName); if (gdtEntry == nullptr) return AssetCreationResult::NoAction(); @@ -40,14 +40,14 @@ namespace private: IGdtQueryable& m_gdt; - InfoStringLoaderPhysPreset m_info_string_loader; + T6::phys_preset::InfoStringLoader m_info_string_loader; }; } // namespace -namespace T6 +namespace T6::phys_preset { - std::unique_ptr> CreateGdtPhysPresetLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone) { - return std::make_unique(memory, searchPath, gdt, zone); + return std::make_unique(memory, gdt, zone); } -} // namespace T6 +} // namespace T6::phys_preset diff --git a/src/ObjLoading/Game/T6/PhysPreset/GdtLoaderPhysPresetT6.h b/src/ObjLoading/Game/T6/PhysPreset/GdtLoaderPhysPresetT6.h index c2fdbe8d..c832e2a7 100644 --- a/src/ObjLoading/Game/T6/PhysPreset/GdtLoaderPhysPresetT6.h +++ b/src/ObjLoading/Game/T6/PhysPreset/GdtLoaderPhysPresetT6.h @@ -8,7 +8,7 @@ #include -namespace T6 +namespace T6::phys_preset { - std::unique_ptr> CreateGdtPhysPresetLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); -} // namespace T6 + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone); +} // namespace T6::phys_preset diff --git a/src/ObjLoading/Game/T6/PhysPreset/InfoStringLoaderPhysPresetT6.cpp b/src/ObjLoading/Game/T6/PhysPreset/InfoStringLoaderPhysPresetT6.cpp index fbd2b9d2..88e86f90 100644 --- a/src/ObjLoading/Game/T6/PhysPreset/InfoStringLoaderPhysPresetT6.cpp +++ b/src/ObjLoading/Game/T6/PhysPreset/InfoStringLoaderPhysPresetT6.cpp @@ -60,31 +60,39 @@ namespace } } // namespace -InfoStringLoaderPhysPreset::InfoStringLoaderPhysPreset(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) - : m_memory(memory), - m_search_path(searchPath), - m_zone(zone) +namespace T6::phys_preset { -} - -AssetCreationResult InfoStringLoaderPhysPreset::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) -{ - auto* physPreset = m_memory.Alloc(); - physPreset->name = m_memory.Dup(assetName.c_str()); - - AssetRegistration registration(assetName, physPreset); - - PhysPresetInfo physPresetInfo; - memset(&physPresetInfo, 0, sizeof(physPresetInfo)); - InfoStringToPhysPresetConverter converter( - infoString, physPresetInfo, m_zone.m_script_strings, m_memory, context, registration, phys_preset_fields, std::extent_v); - if (!converter.Convert()) + InfoStringLoader::InfoStringLoader(MemoryManager& memory, Zone& zone) + : m_memory(memory), + m_zone(zone) { - std::cerr << std::format("Failed to parse phys preset: \"{}\"\n", assetName); - return AssetCreationResult::Failure(); } - CopyFromPhysPresetInfo(physPresetInfo, *physPreset); + AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) + { + auto* physPreset = m_memory.Alloc(); + physPreset->name = m_memory.Dup(assetName.c_str()); - return AssetCreationResult::Success(context.AddAsset(std::move(registration))); -} + AssetRegistration registration(assetName, physPreset); + + PhysPresetInfo physPresetInfo; + memset(&physPresetInfo, 0, sizeof(physPresetInfo)); + InfoStringToPhysPresetConverter converter(infoString, + physPresetInfo, + m_zone.m_script_strings, + m_memory, + context, + registration, + phys_preset_fields, + std::extent_v); + if (!converter.Convert()) + { + std::cerr << std::format("Failed to parse phys preset: \"{}\"\n", assetName); + return AssetCreationResult::Failure(); + } + + CopyFromPhysPresetInfo(physPresetInfo, *physPreset); + + return AssetCreationResult::Success(context.AddAsset(std::move(registration))); + } +} // namespace T6::phys_preset diff --git a/src/ObjLoading/Game/T6/PhysPreset/InfoStringLoaderPhysPresetT6.h b/src/ObjLoading/Game/T6/PhysPreset/InfoStringLoaderPhysPresetT6.h index 3e214d60..99d0d1f5 100644 --- a/src/ObjLoading/Game/T6/PhysPreset/InfoStringLoaderPhysPresetT6.h +++ b/src/ObjLoading/Game/T6/PhysPreset/InfoStringLoaderPhysPresetT6.h @@ -4,18 +4,17 @@ #include "Asset/AssetCreationResult.h" #include "InfoString/InfoString.h" -namespace T6 +namespace T6::phys_preset { - class InfoStringLoaderPhysPreset + class InfoStringLoader { public: - InfoStringLoaderPhysPreset(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); + InfoStringLoader(MemoryManager& memory, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context); private: MemoryManager& m_memory; - ISearchPath& m_search_path; Zone& m_zone; }; -} // namespace T6 +} // namespace T6::phys_preset diff --git a/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.cpp b/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.cpp index 237ccbc8..034f11a7 100644 --- a/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.cpp +++ b/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.cpp @@ -11,6 +11,7 @@ #include using namespace T6; +using namespace ::phys_preset; namespace { @@ -19,13 +20,13 @@ namespace public: RawLoaderPhysPreset(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) : m_search_path(searchPath), - m_info_string_loader(memory, searchPath, zone) + m_info_string_loader(memory, zone) { } AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = phys_preset::GetFileNameForAssetName(assetName); + const auto fileName = GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -42,14 +43,14 @@ namespace private: ISearchPath& m_search_path; - InfoStringLoaderPhysPreset m_info_string_loader; + T6::phys_preset::InfoStringLoader m_info_string_loader; }; } // namespace -namespace T6 +namespace T6::phys_preset { - std::unique_ptr> CreateRawPhysPresetLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace T6 +} // namespace T6::phys_preset diff --git a/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.h b/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.h index 44070d9b..ecc7fa40 100644 --- a/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.h +++ b/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.h @@ -7,7 +7,7 @@ #include -namespace T6 +namespace T6::phys_preset { - std::unique_ptr> CreateRawPhysPresetLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace T6 + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace T6::phys_preset diff --git a/src/ObjLoading/Game/T6/Qdb/LoaderQdbT6.cpp b/src/ObjLoading/Game/T6/Qdb/LoaderQdbT6.cpp index e00e88ac..7c2bed1b 100644 --- a/src/ObjLoading/Game/T6/Qdb/LoaderQdbT6.cpp +++ b/src/ObjLoading/Game/T6/Qdb/LoaderQdbT6.cpp @@ -44,10 +44,10 @@ namespace }; } // namespace -namespace T6 +namespace T6::qdb { - std::unique_ptr> CreateQdbLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6 +} // namespace T6::qdb diff --git a/src/ObjLoading/Game/T6/Qdb/LoaderQdbT6.h b/src/ObjLoading/Game/T6/Qdb/LoaderQdbT6.h index a8d5f9c9..f769cc85 100644 --- a/src/ObjLoading/Game/T6/Qdb/LoaderQdbT6.h +++ b/src/ObjLoading/Game/T6/Qdb/LoaderQdbT6.h @@ -7,7 +7,7 @@ #include -namespace T6 +namespace T6::qdb { - std::unique_ptr> CreateQdbLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace T6::qdb diff --git a/src/ObjLoading/Game/T6/RawFile/LoaderRawFileT6.cpp b/src/ObjLoading/Game/T6/RawFile/LoaderRawFileT6.cpp index f3352243..f4644e8c 100644 --- a/src/ObjLoading/Game/T6/RawFile/LoaderRawFileT6.cpp +++ b/src/ObjLoading/Game/T6/RawFile/LoaderRawFileT6.cpp @@ -114,10 +114,10 @@ namespace }; } // namespace -namespace T6 +namespace T6::raw_file { - std::unique_ptr> CreateRawFileLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6 +} // namespace T6::raw_file diff --git a/src/ObjLoading/Game/T6/RawFile/LoaderRawFileT6.h b/src/ObjLoading/Game/T6/RawFile/LoaderRawFileT6.h index db44f9a5..1af4421b 100644 --- a/src/ObjLoading/Game/T6/RawFile/LoaderRawFileT6.h +++ b/src/ObjLoading/Game/T6/RawFile/LoaderRawFileT6.h @@ -7,7 +7,7 @@ #include -namespace T6 +namespace T6::raw_file { - std::unique_ptr> CreateRawFileLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace T6::raw_file diff --git a/src/ObjLoading/Game/T6/Script/LoaderScriptT6.cpp b/src/ObjLoading/Game/T6/Script/LoaderScriptT6.cpp index 5d30b473..e1b98e8e 100644 --- a/src/ObjLoading/Game/T6/Script/LoaderScriptT6.cpp +++ b/src/ObjLoading/Game/T6/Script/LoaderScriptT6.cpp @@ -44,10 +44,10 @@ namespace }; } // namespace -namespace T6 +namespace T6::script { - std::unique_ptr> CreateScriptLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6 +} // namespace T6::script diff --git a/src/ObjLoading/Game/T6/Script/LoaderScriptT6.h b/src/ObjLoading/Game/T6/Script/LoaderScriptT6.h index 754da2ec..88c90948 100644 --- a/src/ObjLoading/Game/T6/Script/LoaderScriptT6.h +++ b/src/ObjLoading/Game/T6/Script/LoaderScriptT6.h @@ -7,7 +7,7 @@ #include -namespace T6 +namespace T6::script { - std::unique_ptr> CreateScriptLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace T6::script diff --git a/src/ObjLoading/Game/T6/Slug/LoaderSlugT6.cpp b/src/ObjLoading/Game/T6/Slug/LoaderSlugT6.cpp index f527a521..407d0fb7 100644 --- a/src/ObjLoading/Game/T6/Slug/LoaderSlugT6.cpp +++ b/src/ObjLoading/Game/T6/Slug/LoaderSlugT6.cpp @@ -44,10 +44,10 @@ namespace }; } // namespace -namespace T6 +namespace T6::slug { - std::unique_ptr> CreateSlugLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6 +} // namespace T6::slug diff --git a/src/ObjLoading/Game/T6/Slug/LoaderSlugT6.h b/src/ObjLoading/Game/T6/Slug/LoaderSlugT6.h index 49da9e84..bcf50625 100644 --- a/src/ObjLoading/Game/T6/Slug/LoaderSlugT6.h +++ b/src/ObjLoading/Game/T6/Slug/LoaderSlugT6.h @@ -7,7 +7,7 @@ #include -namespace T6 +namespace T6::slug { - std::unique_ptr> CreateSlugLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace T6::slug diff --git a/src/ObjLoading/Game/T6/StringTable/LoaderStringTableT6.cpp b/src/ObjLoading/Game/T6/StringTable/LoaderStringTableT6.cpp index d9560241..a07301e6 100644 --- a/src/ObjLoading/Game/T6/StringTable/LoaderStringTableT6.cpp +++ b/src/ObjLoading/Game/T6/StringTable/LoaderStringTableT6.cpp @@ -8,6 +8,7 @@ #include using namespace T6; +using namespace ::string_table; namespace { @@ -26,7 +27,7 @@ namespace if (!file.IsOpen()) return AssetCreationResult::NoAction(); - string_table::StringTableLoaderV3 loader; + StringTableLoaderV3 loader; auto* stringTable = loader.LoadFromStream(assetName, m_memory, *file.m_stream); return AssetCreationResult::Success(context.AddAsset(assetName, stringTable)); @@ -38,10 +39,10 @@ namespace }; } // namespace -namespace T6 +namespace T6::string_table { - std::unique_ptr> CreateStringTableLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6 +} // namespace T6::string_table diff --git a/src/ObjLoading/Game/T6/StringTable/LoaderStringTableT6.h b/src/ObjLoading/Game/T6/StringTable/LoaderStringTableT6.h index 7db144c6..448c15b8 100644 --- a/src/ObjLoading/Game/T6/StringTable/LoaderStringTableT6.h +++ b/src/ObjLoading/Game/T6/StringTable/LoaderStringTableT6.h @@ -7,7 +7,7 @@ #include -namespace T6 +namespace T6::string_table { - std::unique_ptr> CreateStringTableLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace T6::string_table diff --git a/src/ObjLoading/Game/T6/Tracer/GdtLoaderTracerT6.cpp b/src/ObjLoading/Game/T6/Tracer/GdtLoaderTracerT6.cpp index ee7376ed..84a2dc3b 100644 --- a/src/ObjLoading/Game/T6/Tracer/GdtLoaderTracerT6.cpp +++ b/src/ObjLoading/Game/T6/Tracer/GdtLoaderTracerT6.cpp @@ -40,14 +40,14 @@ namespace private: IGdtQueryable& m_gdt; - InfoStringLoaderTracer m_info_string_loader; + T6::tracer::InfoStringLoader m_info_string_loader; }; } // namespace -namespace T6 +namespace T6::tracer { - std::unique_ptr> CreateGdtTracerLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) { return std::make_unique(memory, searchPath, gdt, zone); } -} // namespace T6 +} // namespace T6::tracer diff --git a/src/ObjLoading/Game/T6/Tracer/GdtLoaderTracerT6.h b/src/ObjLoading/Game/T6/Tracer/GdtLoaderTracerT6.h index d3059ce3..57108194 100644 --- a/src/ObjLoading/Game/T6/Tracer/GdtLoaderTracerT6.h +++ b/src/ObjLoading/Game/T6/Tracer/GdtLoaderTracerT6.h @@ -8,7 +8,7 @@ #include -namespace T6 +namespace T6::tracer { - std::unique_ptr> CreateGdtTracerLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); -} // namespace T6 + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); +} // namespace T6::tracer diff --git a/src/ObjLoading/Game/T6/Tracer/InfoStringLoaderTracerT6.cpp b/src/ObjLoading/Game/T6/Tracer/InfoStringLoaderTracerT6.cpp index 00c21757..03f3a29c 100644 --- a/src/ObjLoading/Game/T6/Tracer/InfoStringLoaderTracerT6.cpp +++ b/src/ObjLoading/Game/T6/Tracer/InfoStringLoaderTracerT6.cpp @@ -3,6 +3,7 @@ #include "Game/T6/InfoString/InfoStringToStructConverter.h" #include "Game/T6/T6.h" #include "Game/T6/Tracer/TracerFields.h" +#include "Tracer/TracerCommon.h" #include #include @@ -11,6 +12,7 @@ #include using namespace T6; +using namespace ::tracer; namespace { @@ -46,27 +48,31 @@ namespace }; } // namespace -InfoStringLoaderTracer::InfoStringLoaderTracer(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) - : m_memory(memory), - m_search_path(searchPath), - m_zone(zone) +namespace T6::tracer { -} - -AssetCreationResult InfoStringLoaderTracer::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) -{ - auto* tracer = m_memory.Alloc(); - tracer->name = m_memory.Dup(assetName.c_str()); - - AssetRegistration registration(assetName, tracer); - - InfoStringToTracerConverter converter( - infoString, *tracer, m_zone.m_script_strings, m_memory, context, registration, tracer_fields, std::extent_v); - if (!converter.Convert()) + InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + : m_memory(memory), + m_search_path(searchPath), + m_zone(zone) { - std::cerr << std::format("Failed to parse tracer: \"{}\"\n", assetName); - return AssetCreationResult::Failure(); } - return AssetCreationResult::Success(context.AddAsset(std::move(registration))); -} + AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) + { + auto* tracer = m_memory.Alloc(); + tracer->name = m_memory.Dup(assetName.c_str()); + + AssetRegistration registration(assetName, tracer); + + InfoStringToTracerConverter converter( + infoString, *tracer, m_zone.m_script_strings, m_memory, context, registration, tracer_fields, std::extent_v); + if (!converter.Convert()) + { + std::cerr << std::format("Failed to parse tracer: \"{}\"\n", assetName); + return AssetCreationResult::Failure(); + } + + return AssetCreationResult::Success(context.AddAsset(std::move(registration))); + } + +} // namespace T6::tracer diff --git a/src/ObjLoading/Game/T6/Tracer/InfoStringLoaderTracerT6.h b/src/ObjLoading/Game/T6/Tracer/InfoStringLoaderTracerT6.h index 141c8216..2f3c029d 100644 --- a/src/ObjLoading/Game/T6/Tracer/InfoStringLoaderTracerT6.h +++ b/src/ObjLoading/Game/T6/Tracer/InfoStringLoaderTracerT6.h @@ -4,12 +4,12 @@ #include "Asset/AssetCreationResult.h" #include "InfoString/InfoString.h" -namespace T6 +namespace T6::tracer { - class InfoStringLoaderTracer + class InfoStringLoader { public: - InfoStringLoaderTracer(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); + InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context); @@ -18,4 +18,4 @@ namespace T6 ISearchPath& m_search_path; Zone& m_zone; }; -} // namespace T6 +} // namespace T6::tracer diff --git a/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.cpp b/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.cpp index 2361a4ed..162253b2 100644 --- a/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.cpp +++ b/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.cpp @@ -43,14 +43,14 @@ namespace private: ISearchPath& m_search_path; - InfoStringLoaderTracer m_info_string_loader; + T6::tracer::InfoStringLoader m_info_string_loader; }; } // namespace -namespace T6 +namespace T6::tracer { - std::unique_ptr> CreateRawTracerLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace T6 +} // namespace T6::tracer diff --git a/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.h b/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.h index a41e74c2..500c992d 100644 --- a/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.h +++ b/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.h @@ -7,7 +7,7 @@ #include -namespace T6 +namespace T6::tracer { - std::unique_ptr> CreateRawTracerLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace T6 + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace T6::tracer diff --git a/src/ObjLoading/Game/T6/Vehicle/GdtLoaderVehicleT6.cpp b/src/ObjLoading/Game/T6/Vehicle/GdtLoaderVehicleT6.cpp index 7b224773..932bc544 100644 --- a/src/ObjLoading/Game/T6/Vehicle/GdtLoaderVehicleT6.cpp +++ b/src/ObjLoading/Game/T6/Vehicle/GdtLoaderVehicleT6.cpp @@ -40,14 +40,14 @@ namespace private: IGdtQueryable& m_gdt; - InfoStringLoaderVehicle m_info_string_loader; + T6::vehicle::InfoStringLoader m_info_string_loader; }; } // namespace -namespace T6 +namespace T6::vehicle { - std::unique_ptr> CreateGdtVehicleLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) { return std::make_unique(memory, searchPath, gdt, zone); } -} // namespace T6 +} // namespace T6::vehicle diff --git a/src/ObjLoading/Game/T6/Vehicle/GdtLoaderVehicleT6.h b/src/ObjLoading/Game/T6/Vehicle/GdtLoaderVehicleT6.h index fee2a56d..b24400df 100644 --- a/src/ObjLoading/Game/T6/Vehicle/GdtLoaderVehicleT6.h +++ b/src/ObjLoading/Game/T6/Vehicle/GdtLoaderVehicleT6.h @@ -8,7 +8,7 @@ #include -namespace T6 +namespace T6::vehicle { - std::unique_ptr> CreateGdtVehicleLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); -} // namespace T6 + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); +} // namespace T6::vehicle diff --git a/src/ObjLoading/Game/T6/Vehicle/InfoStringLoaderVehicleT6.cpp b/src/ObjLoading/Game/T6/Vehicle/InfoStringLoaderVehicleT6.cpp index 4999f0bb..b0a6150b 100644 --- a/src/ObjLoading/Game/T6/Vehicle/InfoStringLoaderVehicleT6.cpp +++ b/src/ObjLoading/Game/T6/Vehicle/InfoStringLoaderVehicleT6.cpp @@ -107,27 +107,30 @@ namespace }; } // namespace -InfoStringLoaderVehicle::InfoStringLoaderVehicle(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) - : m_memory(memory), - m_search_path(searchPath), - m_zone(zone) +namespace T6::vehicle { -} - -AssetCreationResult InfoStringLoaderVehicle::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) -{ - auto* vehicleDef = m_memory.Alloc(); - vehicleDef->name = m_memory.Dup(assetName.c_str()); - - AssetRegistration registration(assetName, vehicleDef); - - InfoStringToVehicleConverter converter( - infoString, *vehicleDef, m_zone.m_script_strings, m_memory, context, registration, vehicle_fields, std::extent_v); - if (!converter.Convert()) + InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + : m_memory(memory), + m_search_path(searchPath), + m_zone(zone) { - std::cerr << std::format("Failed to parse vehicle: \"{}\"\n", assetName); - return AssetCreationResult::Failure(); } - return AssetCreationResult::Success(context.AddAsset(std::move(registration))); -} + AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) + { + auto* vehicleDef = m_memory.Alloc(); + vehicleDef->name = m_memory.Dup(assetName.c_str()); + + AssetRegistration registration(assetName, vehicleDef); + + InfoStringToVehicleConverter converter( + infoString, *vehicleDef, m_zone.m_script_strings, m_memory, context, registration, vehicle_fields, std::extent_v); + if (!converter.Convert()) + { + std::cerr << std::format("Failed to parse vehicle: \"{}\"\n", assetName); + return AssetCreationResult::Failure(); + } + + return AssetCreationResult::Success(context.AddAsset(std::move(registration))); + } +} // namespace T6::vehicle diff --git a/src/ObjLoading/Game/T6/Vehicle/InfoStringLoaderVehicleT6.h b/src/ObjLoading/Game/T6/Vehicle/InfoStringLoaderVehicleT6.h index 9aed730e..f8cacd00 100644 --- a/src/ObjLoading/Game/T6/Vehicle/InfoStringLoaderVehicleT6.h +++ b/src/ObjLoading/Game/T6/Vehicle/InfoStringLoaderVehicleT6.h @@ -4,12 +4,12 @@ #include "Asset/AssetCreationResult.h" #include "InfoString/InfoString.h" -namespace T6 +namespace T6::vehicle { - class InfoStringLoaderVehicle + class InfoStringLoader { public: - InfoStringLoaderVehicle(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); + InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context); @@ -18,4 +18,4 @@ namespace T6 ISearchPath& m_search_path; Zone& m_zone; }; -} // namespace T6 +} // namespace T6::vehicle diff --git a/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.cpp b/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.cpp index 154a9da3..5e829b85 100644 --- a/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.cpp +++ b/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.cpp @@ -43,14 +43,14 @@ namespace private: ISearchPath& m_search_path; - InfoStringLoaderVehicle m_info_string_loader; + T6::vehicle::InfoStringLoader m_info_string_loader; }; } // namespace -namespace T6 +namespace T6::vehicle { - std::unique_ptr> CreateRawVehicleLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace T6 +} // namespace T6::vehicle diff --git a/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.h b/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.h index e88d6909..37a709d6 100644 --- a/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.h +++ b/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.h @@ -7,7 +7,7 @@ #include -namespace T6 +namespace T6::vehicle { - std::unique_ptr> CreateRawVehicleLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace T6 + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace T6::vehicle diff --git a/src/ObjLoading/Game/T6/ZBarrier/GdtLoaderZBarrierT6.cpp b/src/ObjLoading/Game/T6/ZBarrier/GdtLoaderZBarrierT6.cpp index cba149e6..0f8d5d22 100644 --- a/src/ObjLoading/Game/T6/ZBarrier/GdtLoaderZBarrierT6.cpp +++ b/src/ObjLoading/Game/T6/ZBarrier/GdtLoaderZBarrierT6.cpp @@ -40,14 +40,14 @@ namespace private: IGdtQueryable& m_gdt; - InfoStringLoaderZBarrier m_info_string_loader; + T6::z_barrier::InfoStringLoader m_info_string_loader; }; } // namespace -namespace T6 +namespace T6::z_barrier { - std::unique_ptr> CreateGdtZBarrierLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) { return std::make_unique(memory, searchPath, gdt, zone); } -} // namespace T6 +} // namespace T6::z_barrier diff --git a/src/ObjLoading/Game/T6/ZBarrier/GdtLoaderZBarrierT6.h b/src/ObjLoading/Game/T6/ZBarrier/GdtLoaderZBarrierT6.h index af3796b9..7631005e 100644 --- a/src/ObjLoading/Game/T6/ZBarrier/GdtLoaderZBarrierT6.h +++ b/src/ObjLoading/Game/T6/ZBarrier/GdtLoaderZBarrierT6.h @@ -8,7 +8,7 @@ #include -namespace T6 +namespace T6::z_barrier { - std::unique_ptr> CreateGdtZBarrierLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); -} // namespace T6 + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); +} // namespace T6::z_barrier diff --git a/src/ObjLoading/Game/T6/ZBarrier/InfoStringLoaderZBarrierT6.cpp b/src/ObjLoading/Game/T6/ZBarrier/InfoStringLoaderZBarrierT6.cpp index 23c460b9..43d93ab3 100644 --- a/src/ObjLoading/Game/T6/ZBarrier/InfoStringLoaderZBarrierT6.cpp +++ b/src/ObjLoading/Game/T6/ZBarrier/InfoStringLoaderZBarrierT6.cpp @@ -55,29 +55,32 @@ namespace } } // namespace -InfoStringLoaderZBarrier::InfoStringLoaderZBarrier(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) - : m_memory(memory), - m_search_path(searchPath), - m_zone(zone) +namespace T6::z_barrier { -} - -AssetCreationResult InfoStringLoaderZBarrier::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) -{ - auto* zbarrier = m_memory.Alloc(); - zbarrier->name = m_memory.Dup(assetName.c_str()); - - AssetRegistration registration(assetName, zbarrier); - - InfoStringToZBarrierConverter converter( - infoString, *zbarrier, m_zone.m_script_strings, m_memory, context, registration, zbarrier_fields, std::extent_v); - if (!converter.Convert()) + InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + : m_memory(memory), + m_search_path(searchPath), + m_zone(zone) { - std::cerr << std::format("Failed to parse zbarrier: \"{}\"\n", assetName); - return AssetCreationResult::Failure(); } - CalculateZBarrierFields(*zbarrier); + AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) + { + auto* zbarrier = m_memory.Alloc(); + zbarrier->name = m_memory.Dup(assetName.c_str()); - return AssetCreationResult::Success(context.AddAsset(std::move(registration))); -} + AssetRegistration registration(assetName, zbarrier); + + InfoStringToZBarrierConverter converter( + infoString, *zbarrier, m_zone.m_script_strings, m_memory, context, registration, zbarrier_fields, std::extent_v); + if (!converter.Convert()) + { + std::cerr << std::format("Failed to parse zbarrier: \"{}\"\n", assetName); + return AssetCreationResult::Failure(); + } + + CalculateZBarrierFields(*zbarrier); + + return AssetCreationResult::Success(context.AddAsset(std::move(registration))); + } +} // namespace T6::z_barrier diff --git a/src/ObjLoading/Game/T6/ZBarrier/InfoStringLoaderZBarrierT6.h b/src/ObjLoading/Game/T6/ZBarrier/InfoStringLoaderZBarrierT6.h index 5a70ec28..efba4096 100644 --- a/src/ObjLoading/Game/T6/ZBarrier/InfoStringLoaderZBarrierT6.h +++ b/src/ObjLoading/Game/T6/ZBarrier/InfoStringLoaderZBarrierT6.h @@ -4,12 +4,12 @@ #include "Asset/AssetCreationResult.h" #include "InfoString/InfoString.h" -namespace T6 +namespace T6::z_barrier { - class InfoStringLoaderZBarrier + class InfoStringLoader { public: - InfoStringLoaderZBarrier(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); + InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context); @@ -18,4 +18,4 @@ namespace T6 ISearchPath& m_search_path; Zone& m_zone; }; -} // namespace T6 +} // namespace T6::z_barrier diff --git a/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.cpp b/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.cpp index 0d51eca5..9f0b3349 100644 --- a/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.cpp +++ b/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.cpp @@ -43,14 +43,14 @@ namespace private: ISearchPath& m_search_path; - InfoStringLoaderZBarrier m_info_string_loader; + T6::z_barrier::InfoStringLoader m_info_string_loader; }; } // namespace -namespace T6 +namespace T6::z_barrier { - std::unique_ptr> CreateRawZBarrierLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace T6 +} // namespace T6::z_barrier diff --git a/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.h b/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.h index 007b2306..0ae04d30 100644 --- a/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.h +++ b/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.h @@ -7,7 +7,7 @@ #include -namespace T6 +namespace T6::z_barrier { - std::unique_ptr> CreateRawZBarrierLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace T6 + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace T6::z_barrier diff --git a/test/ObjLoadingTests/Game/T6/AssetLoaders/LoaderStringTableT6Test.cpp b/test/ObjLoadingTests/Game/T6/AssetLoaders/LoaderStringTableT6Test.cpp index 87004412..163a4575 100644 --- a/test/ObjLoadingTests/Game/T6/AssetLoaders/LoaderStringTableT6Test.cpp +++ b/test/ObjLoadingTests/Game/T6/AssetLoaders/LoaderStringTableT6Test.cpp @@ -26,7 +26,7 @@ namespace IgnoredAssetLookup ignoredAssetLookup; AssetCreationContext context(zone, &creatorCollection, &ignoredAssetLookup); - auto loader = CreateStringTableLoader(memory, searchPath); + auto loader = string_table::CreateLoader(memory, searchPath); auto result = loader->CreateAsset("mp/cooltable.csv", context); REQUIRE(result.HasBeenSuccessful()); diff --git a/test/ObjLoadingTests/Game/T6/FontIcon/JsonLoaderFontIconT6Test.cpp b/test/ObjLoadingTests/Game/T6/FontIcon/JsonLoaderFontIconT6Test.cpp index f99d761f..d61e4096 100644 --- a/test/ObjLoadingTests/Game/T6/FontIcon/JsonLoaderFontIconT6Test.cpp +++ b/test/ObjLoadingTests/Game/T6/FontIcon/JsonLoaderFontIconT6Test.cpp @@ -90,7 +90,7 @@ namespace GivenMaterial("ui_button_xenon_lstick_anim_d", context, memory); GivenMaterial("xenonbutton_ls", context, memory); - auto loader = CreateJsonFontIconLoader(memory, searchPath); + auto loader = font_icon::CreateJsonLoader(memory, searchPath); auto result = loader->CreateAsset("fonticon/test.csv", context); REQUIRE(result.HasBeenSuccessful()); diff --git a/test/ObjLoadingTests/Game/T6/Material/LoaderMaterialT6Test.cpp b/test/ObjLoadingTests/Game/T6/Material/LoaderMaterialT6Test.cpp index 454054a6..609c5200 100644 --- a/test/ObjLoadingTests/Game/T6/Material/LoaderMaterialT6Test.cpp +++ b/test/ObjLoadingTests/Game/T6/Material/LoaderMaterialT6Test.cpp @@ -253,7 +253,7 @@ namespace GivenImage("~-gmetal_ac_duct_c", context, memory); GivenTechset("wpc_lit_sm_r0c0n0s0_1zzj1138", context, memory); - auto loader = CreateMaterialLoader(memory, searchPath); + auto loader = material::CreateLoader(memory, searchPath); auto result = loader->CreateAsset("wpc/metal_ac_duct", context); REQUIRE(result.HasBeenSuccessful()); From b5c9567389aedc73ab60ab358bd67a5185ba22a3 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Mon, 4 Aug 2025 23:53:51 +0200 Subject: [PATCH 29/35] refactor: streamline T5 asset loading --- src/ObjLoading/Game/T5/Localize/LoaderLocalizeT5.cpp | 6 +++--- src/ObjLoading/Game/T5/Localize/LoaderLocalizeT5.h | 6 +++--- src/ObjLoading/Game/T5/Material/LoaderMaterialT5.cpp | 9 +++++---- src/ObjLoading/Game/T5/Material/LoaderMaterialT5.h | 6 +++--- src/ObjLoading/Game/T5/ObjLoaderT5.cpp | 8 ++++---- src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.cpp | 6 +++--- src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.h | 6 +++--- .../Game/T5/StringTable/LoaderStringTableT5.cpp | 9 +++++---- src/ObjLoading/Game/T5/StringTable/LoaderStringTableT5.h | 6 +++--- .../Game/T5/AssetLoaders/LoaderStringTableT5Test.cpp | 2 +- .../Game/T5/Material/LoaderMaterialT5Test.cpp | 2 +- 11 files changed, 34 insertions(+), 32 deletions(-) diff --git a/src/ObjLoading/Game/T5/Localize/LoaderLocalizeT5.cpp b/src/ObjLoading/Game/T5/Localize/LoaderLocalizeT5.cpp index 175b71fb..fefc44d3 100644 --- a/src/ObjLoading/Game/T5/Localize/LoaderLocalizeT5.cpp +++ b/src/ObjLoading/Game/T5/Localize/LoaderLocalizeT5.cpp @@ -35,10 +35,10 @@ namespace }; } // namespace -namespace T5 +namespace T5::localize { - std::unique_ptr> CreateLocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace T5 +} // namespace T5::localize diff --git a/src/ObjLoading/Game/T5/Localize/LoaderLocalizeT5.h b/src/ObjLoading/Game/T5/Localize/LoaderLocalizeT5.h index fd71deb5..c4d2a787 100644 --- a/src/ObjLoading/Game/T5/Localize/LoaderLocalizeT5.h +++ b/src/ObjLoading/Game/T5/Localize/LoaderLocalizeT5.h @@ -8,7 +8,7 @@ #include -namespace T5 +namespace T5::localize { - std::unique_ptr> CreateLocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace T5 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace T5::localize diff --git a/src/ObjLoading/Game/T5/Material/LoaderMaterialT5.cpp b/src/ObjLoading/Game/T5/Material/LoaderMaterialT5.cpp index a362e728..f0218e1b 100644 --- a/src/ObjLoading/Game/T5/Material/LoaderMaterialT5.cpp +++ b/src/ObjLoading/Game/T5/Material/LoaderMaterialT5.cpp @@ -8,6 +8,7 @@ #include using namespace T5; +using namespace ::material; namespace { @@ -22,7 +23,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto file = m_search_path.Open(material::GetFileNameForAssetName(assetName)); + const auto file = m_search_path.Open(GetFileNameForAssetName(assetName)); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -45,10 +46,10 @@ namespace }; } // namespace -namespace T5 +namespace T5::material { - std::unique_ptr> CreateMaterialLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T5 +} // namespace T5::material diff --git a/src/ObjLoading/Game/T5/Material/LoaderMaterialT5.h b/src/ObjLoading/Game/T5/Material/LoaderMaterialT5.h index 22c337ff..1dfee2d2 100644 --- a/src/ObjLoading/Game/T5/Material/LoaderMaterialT5.h +++ b/src/ObjLoading/Game/T5/Material/LoaderMaterialT5.h @@ -6,7 +6,7 @@ #include "SearchPath/ISearchPath.h" #include "Utils/MemoryManager.h" -namespace T5 +namespace T5::material { - std::unique_ptr> CreateMaterialLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T5 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace T5::material diff --git a/src/ObjLoading/Game/T5/ObjLoaderT5.cpp b/src/ObjLoading/Game/T5/ObjLoaderT5.cpp index 83238561..67cbccc6 100644 --- a/src/ObjLoading/Game/T5/ObjLoaderT5.cpp +++ b/src/ObjLoading/Game/T5/ObjLoaderT5.cpp @@ -105,7 +105,7 @@ namespace // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); collection.AddAssetCreator(xmodel::CreateXModelLoader(memory, searchPath, zone)); - collection.AddAssetCreator(CreateMaterialLoader(memory, searchPath)); + collection.AddAssetCreator(material::CreateLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); @@ -120,13 +120,13 @@ namespace // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateLocalizeLoader(memory, searchPath, zone)); + collection.AddAssetCreator(localize::CreateLoader(memory, searchPath, zone)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateRawFileLoader(memory, searchPath)); - collection.AddAssetCreator(CreateStringTableLoader(memory, searchPath)); + collection.AddAssetCreator(raw_file::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(string_table::CreateLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); diff --git a/src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.cpp b/src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.cpp index ec7ec152..9b3eb7e8 100644 --- a/src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.cpp +++ b/src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.cpp @@ -114,10 +114,10 @@ namespace }; } // namespace -namespace T5 +namespace T5::raw_file { - std::unique_ptr> CreateRawFileLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T5 +} // namespace T5::raw_file diff --git a/src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.h b/src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.h index 42e83ed3..d0308037 100644 --- a/src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.h +++ b/src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.h @@ -7,7 +7,7 @@ #include -namespace T5 +namespace T5::raw_file { - std::unique_ptr> CreateRawFileLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T5 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace T5::raw_file diff --git a/src/ObjLoading/Game/T5/StringTable/LoaderStringTableT5.cpp b/src/ObjLoading/Game/T5/StringTable/LoaderStringTableT5.cpp index f50b423a..4408fa37 100644 --- a/src/ObjLoading/Game/T5/StringTable/LoaderStringTableT5.cpp +++ b/src/ObjLoading/Game/T5/StringTable/LoaderStringTableT5.cpp @@ -7,6 +7,7 @@ #include using namespace T5; +using namespace ::string_table; namespace { @@ -25,7 +26,7 @@ namespace if (!file.IsOpen()) return AssetCreationResult::NoAction(); - string_table::StringTableLoaderV3 loader; + StringTableLoaderV3 loader; auto* stringTable = loader.LoadFromStream(assetName, m_memory, *file.m_stream); return AssetCreationResult::Success(context.AddAsset(assetName, stringTable)); @@ -37,10 +38,10 @@ namespace }; } // namespace -namespace T5 +namespace T5::string_table { - std::unique_ptr> CreateStringTableLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T5 +} // namespace T5::string_table diff --git a/src/ObjLoading/Game/T5/StringTable/LoaderStringTableT5.h b/src/ObjLoading/Game/T5/StringTable/LoaderStringTableT5.h index 3479639b..3c661793 100644 --- a/src/ObjLoading/Game/T5/StringTable/LoaderStringTableT5.h +++ b/src/ObjLoading/Game/T5/StringTable/LoaderStringTableT5.h @@ -7,7 +7,7 @@ #include -namespace T5 +namespace T5::string_table { - std::unique_ptr> CreateStringTableLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T5 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace T5::string_table diff --git a/test/ObjLoadingTests/Game/T5/AssetLoaders/LoaderStringTableT5Test.cpp b/test/ObjLoadingTests/Game/T5/AssetLoaders/LoaderStringTableT5Test.cpp index 8dca092f..ca346aa3 100644 --- a/test/ObjLoadingTests/Game/T5/AssetLoaders/LoaderStringTableT5Test.cpp +++ b/test/ObjLoadingTests/Game/T5/AssetLoaders/LoaderStringTableT5Test.cpp @@ -26,7 +26,7 @@ namespace IgnoredAssetLookup ignoredAssetLookup; AssetCreationContext context(zone, &creatorCollection, &ignoredAssetLookup); - auto loader = CreateStringTableLoader(memory, searchPath); + auto loader = string_table::CreateLoader(memory, searchPath); auto result = loader->CreateAsset("mp/cooltable.csv", context); REQUIRE(result.HasBeenSuccessful()); diff --git a/test/ObjLoadingTests/Game/T5/Material/LoaderMaterialT5Test.cpp b/test/ObjLoadingTests/Game/T5/Material/LoaderMaterialT5Test.cpp index 90f8283d..e2aaedcb 100644 --- a/test/ObjLoadingTests/Game/T5/Material/LoaderMaterialT5Test.cpp +++ b/test/ObjLoadingTests/Game/T5/Material/LoaderMaterialT5Test.cpp @@ -370,7 +370,7 @@ namespace GivenImage("~-gjun_art_brick_foundation_c", context, memory); GivenTechset("mc_l_sm_r0c0n0s0", context, memory); - auto loader = CreateMaterialLoader(memory, searchPath); + auto loader = material::CreateLoader(memory, searchPath); auto result = loader->CreateAsset("mc/jun_art_brick_foundation", context); REQUIRE(result.HasBeenSuccessful()); From 81a67151b529690cf7801d2656419d04ec450074 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Tue, 5 Aug 2025 00:23:06 +0200 Subject: [PATCH 30/35] refactor: streamline IW5 asset loading --- .../Game/IW5/Image/LoaderImageIW5.cpp | 10 +- .../Game/IW5/Image/LoaderImageIW5.h | 6 +- .../Leaderboard/JsonLeaderboardDefLoader.cpp | 131 ---- .../Leaderboard/JsonLeaderboardDefLoader.h | 11 - .../IW5/Leaderboard/LoaderLeaderboardIW5.cpp | 124 +++- .../IW5/Leaderboard/LoaderLeaderboardIW5.h | 6 +- .../Game/IW5/Localize/LoaderLocalizeIW5.cpp | 6 +- .../Game/IW5/Localize/LoaderLocalizeIW5.h | 6 +- .../Game/IW5/Material/LoaderMaterialIW5.cpp | 9 +- .../Game/IW5/Material/LoaderMaterialIW5.h | 6 +- .../Game/IW5/Menu/LoaderMenuListIW5.cpp | 18 +- .../Game/IW5/Menu/LoaderMenuListIW5.h | 4 +- .../Game/IW5/Menu/MenuConverterIW5.h | 2 +- src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp | 22 +- .../Game/IW5/RawFile/LoaderRawFileIW5.cpp | 6 +- .../Game/IW5/RawFile/LoaderRawFileIW5.h | 6 +- .../Game/IW5/Script/LoaderScriptFileIW5.cpp | 6 +- .../Game/IW5/Script/LoaderScriptFileIW5.h | 6 +- .../IW5/StringTable/LoaderStringTableIW5.cpp | 9 +- .../IW5/StringTable/LoaderStringTableIW5.h | 6 +- .../Game/IW5/Weapon/GdtLoaderWeaponIW5.cpp | 8 +- .../Game/IW5/Weapon/GdtLoaderWeaponIW5.h | 6 +- .../IW5/Weapon/InfoStringLoaderWeaponIW5.cpp | 51 +- .../IW5/Weapon/InfoStringLoaderWeaponIW5.h | 8 +- .../IW5/Weapon/JsonWeaponAttachmentLoader.cpp | 645 ------------------ .../IW5/Weapon/JsonWeaponAttachmentLoader.h | 17 - .../Game/IW5/Weapon/LoaderAttachmentIW5.cpp | 634 ++++++++++++++++- .../Game/IW5/Weapon/LoaderAttachmentIW5.h | 6 +- .../Game/IW5/Weapon/RawLoaderWeaponIW5.cpp | 12 +- .../Game/IW5/Weapon/RawLoaderWeaponIW5.h | 6 +- .../AssetLoaders/LoaderStringTableIW5Test.cpp | 2 +- .../IW5/Material/LoaderMaterialIW5Test.cpp | 2 +- 32 files changed, 868 insertions(+), 929 deletions(-) delete mode 100644 src/ObjLoading/Game/IW5/Leaderboard/JsonLeaderboardDefLoader.cpp delete mode 100644 src/ObjLoading/Game/IW5/Leaderboard/JsonLeaderboardDefLoader.h delete mode 100644 src/ObjLoading/Game/IW5/Weapon/JsonWeaponAttachmentLoader.cpp delete mode 100644 src/ObjLoading/Game/IW5/Weapon/JsonWeaponAttachmentLoader.h diff --git a/src/ObjLoading/Game/IW5/Image/LoaderImageIW5.cpp b/src/ObjLoading/Game/IW5/Image/LoaderImageIW5.cpp index f30d27e4..09bb4046 100644 --- a/src/ObjLoading/Game/IW5/Image/LoaderImageIW5.cpp +++ b/src/ObjLoading/Game/IW5/Image/LoaderImageIW5.cpp @@ -1,6 +1,7 @@ #include "LoaderImageIW5.h" #include "Game/IW5/IW5.h" +#include "Image/ImageCommon.h" #include "Image/IwiLoader.h" #include @@ -9,6 +10,7 @@ #include using namespace IW5; +using namespace ::image; namespace { @@ -25,7 +27,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = std::format("images/{}.iwi", assetName); + const auto fileName = GetFileNameForAsset(assetName, ".iwi"); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -60,10 +62,10 @@ namespace }; } // namespace -namespace IW5 +namespace IW5::image { - std::unique_ptr> CreateImageLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW5 +} // namespace IW5::image diff --git a/src/ObjLoading/Game/IW5/Image/LoaderImageIW5.h b/src/ObjLoading/Game/IW5/Image/LoaderImageIW5.h index 66609137..120897b0 100644 --- a/src/ObjLoading/Game/IW5/Image/LoaderImageIW5.h +++ b/src/ObjLoading/Game/IW5/Image/LoaderImageIW5.h @@ -7,7 +7,7 @@ #include -namespace IW5 +namespace IW5::image { - std::unique_ptr> CreateImageLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW5 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace IW5::image diff --git a/src/ObjLoading/Game/IW5/Leaderboard/JsonLeaderboardDefLoader.cpp b/src/ObjLoading/Game/IW5/Leaderboard/JsonLeaderboardDefLoader.cpp deleted file mode 100644 index df4d9625..00000000 --- a/src/ObjLoading/Game/IW5/Leaderboard/JsonLeaderboardDefLoader.cpp +++ /dev/null @@ -1,131 +0,0 @@ -#include "JsonLeaderboardDefLoader.h" - -#include "Game/IW5/CommonIW5.h" -#include "Game/IW5/Leaderboard/JsonLeaderboardDef.h" - -#include -#include -#include - -using namespace nlohmann; -using namespace IW5; - -namespace -{ - class JsonLoader - { - public: - JsonLoader(std::istream& stream, MemoryManager& memory) - : m_stream(stream), - m_memory(memory) - { - } - - bool Load(LeaderboardDef& leaderboardDef) const - { - try - { - const auto jRoot = json::parse(m_stream); - std::string type; - unsigned version; - - jRoot.at("_type").get_to(type); - jRoot.at("_version").get_to(version); - - if (type != "leaderboard" || version != 1u) - { - std::cerr << std::format("Tried to load leaderboard \"{}\" but did not find expected type leaderboard of version 1\n", leaderboardDef.name); - return false; - } - - const auto jLeaderboard = jRoot.get(); - return CreateLeaderboardFromJson(jLeaderboard, leaderboardDef); - } - catch (const json::exception& e) - { - std::cerr << std::format("Failed to parse json of leaderboard: {}\n", e.what()); - } - - return false; - } - - private: - static bool CreateTrackTypeFlagsFromJson(const JsonLeaderboardDef& jLeaderboardDef, int& trackTypeFlags) - { - for (const auto trackType : jLeaderboardDef.trackTypes) - trackTypeFlags |= 1 << trackType; - - return true; - } - - bool CreateColumnDefFromJson(const JsonColumnDef& jColumn, LbColumnDef& lbColumnDef, LeaderboardDef& leaderboardDef) const - { - lbColumnDef.name = m_memory.Dup(jColumn.name.c_str()); - - lbColumnDef.id = jColumn.colId; - lbColumnDef.propertyId = jColumn.propertyId.value_or(0); - lbColumnDef.hidden = jColumn.hidden.value_or(false); - - if (jColumn.statName) - lbColumnDef.statName = m_memory.Dup(jColumn.statName->c_str()); - else - lbColumnDef.statName = nullptr; - - lbColumnDef.type = jColumn.type; - - lbColumnDef.precision = jColumn.precision.value_or(0); - - lbColumnDef.agg = jColumn.aggregationFunction; - - lbColumnDef.uiCalColX = jColumn.uiCalColX.value_or(0); - lbColumnDef.uiCalColY = jColumn.uiCalColY.value_or(0); - - return true; - } - - bool CreateLeaderboardFromJson(const JsonLeaderboardDef& jLeaderboardDef, LeaderboardDef& leaderboardDef) const - { - leaderboardDef.id = jLeaderboardDef.id; - - leaderboardDef.xpColId = jLeaderboardDef.xpColId.value_or(-1); - leaderboardDef.prestigeColId = jLeaderboardDef.prestigeColId.value_or(-1); - - if (!jLeaderboardDef.columns.empty()) - { - leaderboardDef.columnCount = static_cast(jLeaderboardDef.columns.size()); - leaderboardDef.columns = m_memory.Alloc(leaderboardDef.columnCount); - - for (auto i = 0; i < leaderboardDef.columnCount; i++) - { - if (!CreateColumnDefFromJson(jLeaderboardDef.columns[i], leaderboardDef.columns[i], leaderboardDef)) - return false; - } - } - else - { - leaderboardDef.columnCount = 0; - leaderboardDef.columns = nullptr; - } - - leaderboardDef.updateType = jLeaderboardDef.updateType; - - if (!CreateTrackTypeFlagsFromJson(jLeaderboardDef, leaderboardDef.trackTypes)) - return false; - - return true; - } - - std::istream& m_stream; - MemoryManager& m_memory; - }; -} // namespace - -namespace IW5 -{ - bool LoadLeaderboardAsJson(std::istream& stream, LeaderboardDef& leaderboard, MemoryManager& memory) - { - const JsonLoader loader(stream, memory); - - return loader.Load(leaderboard); - } -} // namespace IW5 diff --git a/src/ObjLoading/Game/IW5/Leaderboard/JsonLeaderboardDefLoader.h b/src/ObjLoading/Game/IW5/Leaderboard/JsonLeaderboardDefLoader.h deleted file mode 100644 index 753a5db3..00000000 --- a/src/ObjLoading/Game/IW5/Leaderboard/JsonLeaderboardDefLoader.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "Game/IW5/IW5.h" -#include "Utils/MemoryManager.h" - -#include - -namespace IW5 -{ - bool LoadLeaderboardAsJson(std::istream& stream, LeaderboardDef& leaderboard, MemoryManager& memory); -} // namespace IW5 diff --git a/src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.cpp b/src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.cpp index c18ed86b..4ec9f420 100644 --- a/src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.cpp +++ b/src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.cpp @@ -1,16 +1,127 @@ #include "LoaderLeaderboardIW5.h" #include "Game/IW5/IW5.h" -#include "JsonLeaderboardDefLoader.h" +#include "Game/IW5/Leaderboard/JsonLeaderboardDef.h" +#include "Leaderboard/LeaderboardCommon.h" #include #include #include +#include +using namespace nlohmann; using namespace IW5; +using namespace ::leaderboard; namespace { + class JsonLoader + { + public: + JsonLoader(std::istream& stream, MemoryManager& memory) + : m_stream(stream), + m_memory(memory) + { + } + + bool Load(LeaderboardDef& leaderboardDef) const + { + try + { + const auto jRoot = json::parse(m_stream); + std::string type; + unsigned version; + + jRoot.at("_type").get_to(type); + jRoot.at("_version").get_to(version); + + if (type != "leaderboard" || version != 1u) + { + std::cerr << std::format("Tried to load leaderboard \"{}\" but did not find expected type leaderboard of version 1\n", leaderboardDef.name); + return false; + } + + const auto jLeaderboard = jRoot.get(); + return CreateLeaderboardFromJson(jLeaderboard, leaderboardDef); + } + catch (const json::exception& e) + { + std::cerr << std::format("Failed to parse json of leaderboard: {}\n", e.what()); + } + + return false; + } + + private: + static bool CreateTrackTypeFlagsFromJson(const JsonLeaderboardDef& jLeaderboardDef, int& trackTypeFlags) + { + for (const auto trackType : jLeaderboardDef.trackTypes) + trackTypeFlags |= 1 << trackType; + + return true; + } + + bool CreateColumnDefFromJson(const JsonColumnDef& jColumn, LbColumnDef& lbColumnDef, LeaderboardDef& leaderboardDef) const + { + lbColumnDef.name = m_memory.Dup(jColumn.name.c_str()); + + lbColumnDef.id = jColumn.colId; + lbColumnDef.propertyId = jColumn.propertyId.value_or(0); + lbColumnDef.hidden = jColumn.hidden.value_or(false); + + if (jColumn.statName) + lbColumnDef.statName = m_memory.Dup(jColumn.statName->c_str()); + else + lbColumnDef.statName = nullptr; + + lbColumnDef.type = jColumn.type; + + lbColumnDef.precision = jColumn.precision.value_or(0); + + lbColumnDef.agg = jColumn.aggregationFunction; + + lbColumnDef.uiCalColX = jColumn.uiCalColX.value_or(0); + lbColumnDef.uiCalColY = jColumn.uiCalColY.value_or(0); + + return true; + } + + bool CreateLeaderboardFromJson(const JsonLeaderboardDef& jLeaderboardDef, LeaderboardDef& leaderboardDef) const + { + leaderboardDef.id = jLeaderboardDef.id; + + leaderboardDef.xpColId = jLeaderboardDef.xpColId.value_or(-1); + leaderboardDef.prestigeColId = jLeaderboardDef.prestigeColId.value_or(-1); + + if (!jLeaderboardDef.columns.empty()) + { + leaderboardDef.columnCount = static_cast(jLeaderboardDef.columns.size()); + leaderboardDef.columns = m_memory.Alloc(leaderboardDef.columnCount); + + for (auto i = 0; i < leaderboardDef.columnCount; i++) + { + if (!CreateColumnDefFromJson(jLeaderboardDef.columns[i], leaderboardDef.columns[i], leaderboardDef)) + return false; + } + } + else + { + leaderboardDef.columnCount = 0; + leaderboardDef.columns = nullptr; + } + + leaderboardDef.updateType = jLeaderboardDef.updateType; + + if (!CreateTrackTypeFlagsFromJson(jLeaderboardDef, leaderboardDef.trackTypes)) + return false; + + return true; + } + + std::istream& m_stream; + MemoryManager& m_memory; + }; + class LeaderboardLoader final : public AssetCreator { public: @@ -22,14 +133,15 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto file = m_search_path.Open(std::format("leaderboards/{}.json", assetName)); + const auto file = m_search_path.Open(GetJsonFileNameForAsset(assetName)); if (!file.IsOpen()) return AssetCreationResult::NoAction(); auto* leaderboardDef = m_memory.Alloc(); leaderboardDef->name = m_memory.Dup(assetName.c_str()); - if (!LoadLeaderboardAsJson(*file.m_stream, *leaderboardDef, m_memory)) + const JsonLoader loader(*file.m_stream, m_memory); + if (!loader.Load(*leaderboardDef)) { std::cerr << std::format("Failed to load leaderboard \"{}\"\n", assetName); return AssetCreationResult::Failure(); @@ -44,10 +156,10 @@ namespace }; } // namespace -namespace IW5 +namespace IW5::leaderboard { - std::unique_ptr> CreateLeaderboardLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW5 +} // namespace IW5::leaderboard diff --git a/src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.h b/src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.h index 6c144840..d074b9b3 100644 --- a/src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.h +++ b/src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.h @@ -7,7 +7,7 @@ #include -namespace IW5 +namespace IW5::leaderboard { - std::unique_ptr> CreateLeaderboardLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW5 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace IW5::leaderboard diff --git a/src/ObjLoading/Game/IW5/Localize/LoaderLocalizeIW5.cpp b/src/ObjLoading/Game/IW5/Localize/LoaderLocalizeIW5.cpp index a531c42f..218e9aab 100644 --- a/src/ObjLoading/Game/IW5/Localize/LoaderLocalizeIW5.cpp +++ b/src/ObjLoading/Game/IW5/Localize/LoaderLocalizeIW5.cpp @@ -35,10 +35,10 @@ namespace }; } // namespace -namespace IW5 +namespace IW5::localize { - std::unique_ptr> CreateLocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace IW5 +} // namespace IW5::localize diff --git a/src/ObjLoading/Game/IW5/Localize/LoaderLocalizeIW5.h b/src/ObjLoading/Game/IW5/Localize/LoaderLocalizeIW5.h index 6c47a8d1..9588b800 100644 --- a/src/ObjLoading/Game/IW5/Localize/LoaderLocalizeIW5.h +++ b/src/ObjLoading/Game/IW5/Localize/LoaderLocalizeIW5.h @@ -8,7 +8,7 @@ #include -namespace IW5 +namespace IW5::localize { - std::unique_ptr> CreateLocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace IW5 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace IW5::localize diff --git a/src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.cpp b/src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.cpp index 189e368f..9ed987d1 100644 --- a/src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.cpp +++ b/src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.cpp @@ -8,6 +8,7 @@ #include using namespace IW5; +using namespace ::material; namespace { @@ -22,7 +23,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto file = m_search_path.Open(material::GetFileNameForAssetName(assetName)); + const auto file = m_search_path.Open(GetFileNameForAssetName(assetName)); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -45,10 +46,10 @@ namespace }; } // namespace -namespace IW5 +namespace IW5::material { - std::unique_ptr> CreateMaterialLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW5 +} // namespace IW5::material diff --git a/src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.h b/src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.h index 5488c1a7..1f0d7690 100644 --- a/src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.h +++ b/src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.h @@ -7,7 +7,7 @@ #include -namespace IW5 +namespace IW5::material { - std::unique_ptr> CreateMaterialLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW5 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace IW5::material diff --git a/src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.cpp b/src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.cpp index 46e6938c..f68b8dd4 100644 --- a/src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.cpp +++ b/src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.cpp @@ -11,6 +11,7 @@ #include using namespace IW5; +using namespace ::menu; namespace { @@ -28,7 +29,7 @@ namespace std::vector menus; AssetRegistration registration(assetName); - auto& zoneState = context.GetZoneAssetCreationState(); + auto& zoneState = context.GetZoneAssetCreationState(); auto& conversionState = context.GetZoneAssetCreationState(); std::deque menuLoadQueue; @@ -80,7 +81,7 @@ namespace private: bool LoadMenuFileFromQueue(const std::string& menuFilePath, AssetCreationContext& context, - menu::MenuAssetZoneState& zoneState, + MenuAssetZoneState& zoneState, MenuConversionZoneState& conversionState, std::vector& menus, AssetRegistration& registration) const @@ -121,8 +122,8 @@ namespace bool ProcessParsedResults(const std::string& fileName, AssetCreationContext& context, - menu::ParsingResult& parsingResult, - menu::MenuAssetZoneState& zoneState, + ParsingResult& parsingResult, + MenuAssetZoneState& zoneState, MenuConversionZoneState& conversionState, std::vector& menus, AssetRegistration& registration) const @@ -196,10 +197,9 @@ namespace menuList.menus = nullptr; } - std::unique_ptr - ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState& zoneState) const + std::unique_ptr ParseMenuFile(std::istream& stream, const std::string& menuFileName, const MenuAssetZoneState& zoneState) const { - menu::MenuFileReader reader(stream, menuFileName, menu::FeatureLevel::IW5, m_search_path); + MenuFileReader reader(stream, menuFileName, FeatureLevel::IW5, m_search_path); reader.IncludeZoneState(zoneState); reader.SetPermissiveMode(ObjLoading::Configuration.MenuPermissiveParsing); @@ -212,10 +212,10 @@ namespace }; } // namespace -namespace IW5 +namespace IW5::menu { std::unique_ptr> CreateMenuListLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW5 +} // namespace IW5::menu diff --git a/src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.h b/src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.h index 823161b8..a323e807 100644 --- a/src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.h +++ b/src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.h @@ -7,7 +7,7 @@ #include -namespace IW5 +namespace IW5::menu { std::unique_ptr> CreateMenuListLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW5 +} // namespace IW5::menu diff --git a/src/ObjLoading/Game/IW5/Menu/MenuConverterIW5.h b/src/ObjLoading/Game/IW5/Menu/MenuConverterIW5.h index 2f112270..c0b03845 100644 --- a/src/ObjLoading/Game/IW5/Menu/MenuConverterIW5.h +++ b/src/ObjLoading/Game/IW5/Menu/MenuConverterIW5.h @@ -14,7 +14,7 @@ namespace IW5 IMenuConverter() = default; virtual ~IMenuConverter() = default; - virtual void ConvertMenu(const menu::CommonMenuDef& commonMenu, menuDef_t& menu, AssetRegistration& registration) = 0; + virtual void ConvertMenu(const ::menu::CommonMenuDef& commonMenu, menuDef_t& menu, AssetRegistration& registration) = 0; static std::unique_ptr Create(bool disableOptimizations, ISearchPath& searchPath, MemoryManager& memory, AssetCreationContext& context); }; diff --git a/src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp b/src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp index 5f254899..b331a795 100644 --- a/src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp +++ b/src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp @@ -126,12 +126,12 @@ namespace // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); collection.AddAssetCreator(xmodel::CreateXModelLoader(memory, searchPath, zone)); - collection.AddAssetCreator(CreateMaterialLoader(memory, searchPath)); + collection.AddAssetCreator(material::CreateLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateImageLoader(memory, searchPath)); + collection.AddAssetCreator(image::CreateLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); @@ -145,19 +145,19 @@ namespace // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateMenuListLoader(memory, searchPath)); + collection.AddAssetCreator(menu::CreateMenuListLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateLocalizeLoader(memory, searchPath, zone)); - collection.AddAssetCreator(CreateAttachmentLoader(memory, searchPath)); - collection.AddAssetCreator(CreateRawWeaponLoader(memory, searchPath, zone)); - collection.AddAssetCreator(CreateGdtWeaponLoader(memory, searchPath, gdt, zone)); + collection.AddAssetCreator(localize::CreateLoader(memory, searchPath, zone)); + collection.AddAssetCreator(attachment::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(weapon::CreateRawLoader(memory, searchPath, zone)); + collection.AddAssetCreator(weapon::CreateGdtLoader(memory, searchPath, gdt, zone)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateRawFileLoader(memory, searchPath)); - collection.AddAssetCreator(CreateScriptLoader(memory, searchPath)); - collection.AddAssetCreator(CreateStringTableLoader(memory, searchPath)); - collection.AddAssetCreator(CreateLeaderboardLoader(memory, searchPath)); + collection.AddAssetCreator(raw_file::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(script::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(string_table::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(leaderboard::CreateLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); diff --git a/src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.cpp b/src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.cpp index 139e9ad3..9692a6f9 100644 --- a/src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.cpp +++ b/src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.cpp @@ -81,10 +81,10 @@ namespace }; } // namespace -namespace IW5 +namespace IW5::raw_file { - std::unique_ptr> CreateRawFileLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW5 +} // namespace IW5::raw_file diff --git a/src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.h b/src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.h index 3099146e..e8c96461 100644 --- a/src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.h +++ b/src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.h @@ -7,7 +7,7 @@ #include -namespace IW5 +namespace IW5::raw_file { - std::unique_ptr> CreateRawFileLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW5 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace IW5::raw_file diff --git a/src/ObjLoading/Game/IW5/Script/LoaderScriptFileIW5.cpp b/src/ObjLoading/Game/IW5/Script/LoaderScriptFileIW5.cpp index 5ae68da9..cfbf8125 100644 --- a/src/ObjLoading/Game/IW5/Script/LoaderScriptFileIW5.cpp +++ b/src/ObjLoading/Game/IW5/Script/LoaderScriptFileIW5.cpp @@ -79,10 +79,10 @@ namespace }; } // namespace -namespace IW5 +namespace IW5::script { - std::unique_ptr> CreateScriptLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW5 +} // namespace IW5::script diff --git a/src/ObjLoading/Game/IW5/Script/LoaderScriptFileIW5.h b/src/ObjLoading/Game/IW5/Script/LoaderScriptFileIW5.h index 457a0957..1380a837 100644 --- a/src/ObjLoading/Game/IW5/Script/LoaderScriptFileIW5.h +++ b/src/ObjLoading/Game/IW5/Script/LoaderScriptFileIW5.h @@ -7,7 +7,7 @@ #include -namespace IW5 +namespace IW5::script { - std::unique_ptr> CreateScriptLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW5 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace IW5::script diff --git a/src/ObjLoading/Game/IW5/StringTable/LoaderStringTableIW5.cpp b/src/ObjLoading/Game/IW5/StringTable/LoaderStringTableIW5.cpp index 2ca18723..4f56de03 100644 --- a/src/ObjLoading/Game/IW5/StringTable/LoaderStringTableIW5.cpp +++ b/src/ObjLoading/Game/IW5/StringTable/LoaderStringTableIW5.cpp @@ -10,6 +10,7 @@ #include using namespace IW5; +using namespace ::string_table; namespace { @@ -28,7 +29,7 @@ namespace if (!file.IsOpen()) return AssetCreationResult::NoAction(); - string_table::StringTableLoaderV2 loader; + StringTableLoaderV2 loader; auto* stringTable = loader.LoadFromStream(assetName, m_memory, *file.m_stream); return AssetCreationResult::Success(context.AddAsset(assetName, stringTable)); @@ -40,10 +41,10 @@ namespace }; } // namespace -namespace IW5 +namespace IW5::string_table { - std::unique_ptr> CreateStringTableLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW5 +} // namespace IW5::string_table diff --git a/src/ObjLoading/Game/IW5/StringTable/LoaderStringTableIW5.h b/src/ObjLoading/Game/IW5/StringTable/LoaderStringTableIW5.h index e07bf9c7..804b8444 100644 --- a/src/ObjLoading/Game/IW5/StringTable/LoaderStringTableIW5.h +++ b/src/ObjLoading/Game/IW5/StringTable/LoaderStringTableIW5.h @@ -7,7 +7,7 @@ #include -namespace IW5 +namespace IW5::string_table { - std::unique_ptr> CreateStringTableLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW5 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace IW5::string_table diff --git a/src/ObjLoading/Game/IW5/Weapon/GdtLoaderWeaponIW5.cpp b/src/ObjLoading/Game/IW5/Weapon/GdtLoaderWeaponIW5.cpp index 03897a0d..02d8d733 100644 --- a/src/ObjLoading/Game/IW5/Weapon/GdtLoaderWeaponIW5.cpp +++ b/src/ObjLoading/Game/IW5/Weapon/GdtLoaderWeaponIW5.cpp @@ -40,14 +40,14 @@ namespace private: IGdtQueryable& m_gdt; - InfoStringLoaderWeapon m_info_string_loader; + IW5::weapon::InfoStringLoader m_info_string_loader; }; } // namespace -namespace IW5 +namespace IW5::weapon { - std::unique_ptr> CreateGdtWeaponLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) { return std::make_unique(memory, searchPath, gdt, zone); } -} // namespace IW5 +} // namespace IW5::weapon diff --git a/src/ObjLoading/Game/IW5/Weapon/GdtLoaderWeaponIW5.h b/src/ObjLoading/Game/IW5/Weapon/GdtLoaderWeaponIW5.h index 0e86b336..2bccdb9c 100644 --- a/src/ObjLoading/Game/IW5/Weapon/GdtLoaderWeaponIW5.h +++ b/src/ObjLoading/Game/IW5/Weapon/GdtLoaderWeaponIW5.h @@ -8,7 +8,7 @@ #include -namespace IW5 +namespace IW5::weapon { - std::unique_ptr> CreateGdtWeaponLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); -} // namespace IW5 + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); +} // namespace IW5::weapon diff --git a/src/ObjLoading/Game/IW5/Weapon/InfoStringLoaderWeaponIW5.cpp b/src/ObjLoading/Game/IW5/Weapon/InfoStringLoaderWeaponIW5.cpp index 93f82995..cc9f1f3e 100644 --- a/src/ObjLoading/Game/IW5/Weapon/InfoStringLoaderWeaponIW5.cpp +++ b/src/ObjLoading/Game/IW5/Weapon/InfoStringLoaderWeaponIW5.cpp @@ -856,33 +856,36 @@ namespace } } // namespace -InfoStringLoaderWeapon::InfoStringLoaderWeapon(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) - : m_memory(memory), - m_search_path(searchPath), - m_zone(zone) +namespace IW5::weapon { -} - -AssetCreationResult InfoStringLoaderWeapon::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) const -{ - auto* weaponFullDef = m_memory.Alloc(); - - InitWeaponFullDef(*weaponFullDef); - weaponFullDef->weapCompleteDef.szInternalName = m_memory.Dup(assetName.c_str()); - - AssetRegistration registration(assetName, &weaponFullDef->weapCompleteDef); - - InfoStringToWeaponConverter converter( - infoString, *weaponFullDef, m_zone.m_script_strings, m_memory, context, registration, weapon_fields, std::extent_v); - if (!converter.Convert()) + InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + : m_memory(memory), + m_search_path(searchPath), + m_zone(zone) { - std::cerr << std::format("Failed to parse weapon: \"{}\"\n", assetName); - return AssetCreationResult::Failure(); } - CalculateWeaponFields(*weaponFullDef, m_memory); + AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) const + { + auto* weaponFullDef = m_memory.Alloc(); - LoadAccuracyGraphs(*weaponFullDef, m_memory, m_search_path, context); + InitWeaponFullDef(*weaponFullDef); + weaponFullDef->weapCompleteDef.szInternalName = m_memory.Dup(assetName.c_str()); - return AssetCreationResult::Success(context.AddAsset(std::move(registration))); -} + AssetRegistration registration(assetName, &weaponFullDef->weapCompleteDef); + + InfoStringToWeaponConverter converter( + infoString, *weaponFullDef, m_zone.m_script_strings, m_memory, context, registration, weapon_fields, std::extent_v); + if (!converter.Convert()) + { + std::cerr << std::format("Failed to parse weapon: \"{}\"\n", assetName); + return AssetCreationResult::Failure(); + } + + CalculateWeaponFields(*weaponFullDef, m_memory); + + LoadAccuracyGraphs(*weaponFullDef, m_memory, m_search_path, context); + + return AssetCreationResult::Success(context.AddAsset(std::move(registration))); + } +} // namespace IW5::weapon diff --git a/src/ObjLoading/Game/IW5/Weapon/InfoStringLoaderWeaponIW5.h b/src/ObjLoading/Game/IW5/Weapon/InfoStringLoaderWeaponIW5.h index 40f14367..e34dbde8 100644 --- a/src/ObjLoading/Game/IW5/Weapon/InfoStringLoaderWeaponIW5.h +++ b/src/ObjLoading/Game/IW5/Weapon/InfoStringLoaderWeaponIW5.h @@ -4,12 +4,12 @@ #include "Asset/AssetCreationResult.h" #include "InfoString/InfoString.h" -namespace IW5 +namespace IW5::weapon { - class InfoStringLoaderWeapon + class InfoStringLoader { public: - InfoStringLoaderWeapon(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); + InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) const; @@ -18,4 +18,4 @@ namespace IW5 ISearchPath& m_search_path; Zone& m_zone; }; -} // namespace IW5 +} // namespace IW5::weapon diff --git a/src/ObjLoading/Game/IW5/Weapon/JsonWeaponAttachmentLoader.cpp b/src/ObjLoading/Game/IW5/Weapon/JsonWeaponAttachmentLoader.cpp deleted file mode 100644 index 44d1bf68..00000000 --- a/src/ObjLoading/Game/IW5/Weapon/JsonWeaponAttachmentLoader.cpp +++ /dev/null @@ -1,645 +0,0 @@ -#include "JsonWeaponAttachmentLoader.h" - -#include "Game/IW5/CommonIW5.h" -#include "Game/IW5/Weapon/JsonWeaponAttachment.h" - -#include -#include -#include - -using namespace nlohmann; -using namespace IW5; - -namespace -{ - class JsonLoader - { - public: - JsonLoader(std::istream& stream, MemoryManager& memory, AssetCreationContext& context, AssetRegistration& registration) - : m_stream(stream), - m_memory(memory), - m_context(context), - m_registration(registration) - - { - } - - bool Load(WeaponAttachment& attachment) const - { - try - { - const auto jRoot = json::parse(m_stream); - std::string type; - unsigned version; - - jRoot.at("_type").get_to(type); - jRoot.at("_version").get_to(version); - - if (type != "attachment" || version != 1u) - { - std::cerr << "Tried to load attachment \"" << attachment.szInternalName << "\" but did not find expected type attachment of version 1\n"; - return false; - } - - const auto jAttachment = jRoot.get(); - return CreateWeaponAttachmentFromJson(jAttachment, attachment); - } - catch (const json::exception& e) - { - std::cerr << std::format("Failed to parse json of attachment: {}\n", e.what()); - } - - return false; - } - - private: - static void PrintError(const WeaponAttachment& attachment, const std::string& message) - { - std::cerr << "Cannot load attachment \"" << attachment.szInternalName << "\": " << message << "\n"; - } - - bool CreateWeaponAttachmentFromJson(const JsonWeaponAttachment& jAttachment, WeaponAttachment& attachment) const - { -#define CONVERT_XMODEL_ARRAY(propertyName, count) \ - CreateXModelArrayFromJson(jAttachment.propertyName, attachment.propertyName, #propertyName, count, attachment); - -#define CONVERT_ATTRIBUTE(attributeClass, attributeName) \ - if (jAttachment.attributeName) \ - { \ - using AttributeType = std::remove_pointer_t; \ - attachment.attributeName = m_memory.Alloc(); \ - if (!Create##attributeClass##FromJson(jAttachment.attributeName.value(), *attachment.attributeName, attachment)) \ - return false; \ - } \ - else \ - attachment.attributeName = nullptr; - - attachment.szDisplayName = m_memory.Dup(jAttachment.displayName.c_str()); - attachment.type = jAttachment.type; - attachment.weaponType = jAttachment.weaponType; - attachment.weapClass = jAttachment.weapClass; - - CONVERT_XMODEL_ARRAY(worldModels, ATTACHMENT_WORLD_MODEL_COUNT) - CONVERT_XMODEL_ARRAY(viewModels, ATTACHMENT_VIEW_MODEL_COUNT) - CONVERT_XMODEL_ARRAY(reticleViewModels, ATTACHMENT_RETICLE_VIEW_MODEL_COUNT) - - CONVERT_ATTRIBUTE(AttAmmoGeneral, ammoGeneral) - CONVERT_ATTRIBUTE(AttSight, sight) - CONVERT_ATTRIBUTE(AttReload, reload) - CONVERT_ATTRIBUTE(AttAddOns, addOns) - CONVERT_ATTRIBUTE(AttGeneral, general) - CONVERT_ATTRIBUTE(AttAimAssist, aimAssist) - CONVERT_ATTRIBUTE(AttAmmunition, ammunition) - CONVERT_ATTRIBUTE(AttDamage, damage) - CONVERT_ATTRIBUTE(AttLocationDamage, locationDamage) - CONVERT_ATTRIBUTE(AttIdleSettings, idleSettings) - CONVERT_ATTRIBUTE(AttADSSettings, adsSettings) - CONVERT_ATTRIBUTE(AttADSSettings, adsSettingsMain) - CONVERT_ATTRIBUTE(AttHipSpread, hipSpread) - CONVERT_ATTRIBUTE(AttGunKick, gunKick) - CONVERT_ATTRIBUTE(AttViewKick, viewKick) - CONVERT_ATTRIBUTE(AttADSOverlay, adsOverlay) - CONVERT_ATTRIBUTE(AttUI, ui) - CONVERT_ATTRIBUTE(AttRumbles, rumbles) - CONVERT_ATTRIBUTE(AttProjectile, projectile) - - attachment.ammunitionScale = jAttachment.ammunitionScale; - attachment.damageScale = jAttachment.damageScale; - attachment.damageScaleMin = jAttachment.damageScaleMin; - attachment.stateTimersScale = jAttachment.stateTimersScale; - attachment.fireTimersScale = jAttachment.fireTimersScale; - attachment.idleSettingsScale = jAttachment.idleSettingsScale; - attachment.adsSettingsScale = jAttachment.adsSettingsScale; - attachment.adsSettingsScaleMain = jAttachment.adsSettingsScaleMain; - attachment.hipSpreadScale = jAttachment.hipSpreadScale; - attachment.gunKickScale = jAttachment.gunKickScale; - attachment.viewKickScale = jAttachment.viewKickScale; - attachment.viewCenterScale = jAttachment.viewCenterScale; - attachment.loadIndex = jAttachment.loadIndex; - attachment.hideIronSightsWithThisAttachment = jAttachment.hideIronSightsWithThisAttachment; - attachment.shareAmmoWithAlt = jAttachment.shareAmmoWithAlt; - - return true; - } - - bool CreateTracerFromJson(const std::string& assetName, TracerDef*& tracerPtr, const WeaponAttachment& attachment) const - { - auto* tracer = m_context.LoadDependency(assetName); - if (!tracer) - { - PrintError(attachment, std::format("Could not find tracer {}", assetName)); - return false; - } - m_registration.AddDependency(tracer); - tracerPtr = tracer->Asset(); - - return true; - } - - bool CreateMaterialFromJson(const std::string& assetName, Material*& materialPtr, const WeaponAttachment& attachment) const - { - auto* material = m_context.LoadDependency(assetName); - if (!material) - { - PrintError(attachment, std::format("Could not find material {}", assetName)); - return false; - } - m_registration.AddDependency(material); - materialPtr = material->Asset(); - - return true; - } - - bool CreateFxFromJson(const std::string& assetName, FxEffectDef*& fxPtr, const WeaponAttachment& attachment) const - { - auto* fx = m_context.LoadDependency(assetName); - if (!fx) - { - PrintError(attachment, std::format("Could not find fx {}", assetName)); - return false; - } - m_registration.AddDependency(fx); - fxPtr = fx->Asset(); - - return true; - } - - bool CreateSoundFromJson(const std::string& assetName, SndAliasCustom& sndAliasCustom, const WeaponAttachment& attachment) const - { - m_registration.AddIndirectAssetReference(m_context.LoadIndirectAssetReference(assetName)); - sndAliasCustom.name = m_memory.Alloc(); - sndAliasCustom.name->soundName = m_memory.Dup(assetName.c_str()); - - return true; - } - - bool CreateXModelFromJson(const std::string& assetName, XModel*& xmodelPtr, const WeaponAttachment& attachment) const - { - auto* xmodel = m_context.LoadDependency(assetName); - if (!xmodel) - { - PrintError(attachment, std::format("Could not find xmodel {}", assetName)); - return false; - } - m_registration.AddDependency(xmodel); - xmodelPtr = xmodel->Asset(); - - return true; - } - - bool CreateXModelArrayFromJson(const std::vector& jXmodelArray, - XModel**& xmodelArray, - const char* propertyName, - size_t propertyCount, - const WeaponAttachment& attachment) const - { - if (!jXmodelArray.empty()) - { - const auto arraySize = jXmodelArray.size(); - if (arraySize > propertyCount) - { - PrintError(attachment, std::format("{} size cannot exceed {}", propertyName, propertyCount)); - return false; - } - xmodelArray = m_memory.Alloc(propertyCount); - memset(xmodelArray, 0, sizeof(void*) * propertyCount); - - for (auto i = 0u; i < arraySize; i++) - { - if (!CreateXModelFromJson(jXmodelArray[i], xmodelArray[i], attachment)) - return false; - } - } - else - { - xmodelArray = nullptr; - } - - return true; - } - - bool CreateAttAmmoGeneralFromJson(const JsonAttAmmoGeneral& jAmmoGeneral, AttAmmoGeneral& ammoGeneral, const WeaponAttachment& attachment) const - { - ammoGeneral.penetrateType = jAmmoGeneral.penetrateType; - ammoGeneral.penetrateMultiplier = jAmmoGeneral.penetrateMultiplier; - ammoGeneral.impactType = jAmmoGeneral.impactType; - ammoGeneral.fireType = jAmmoGeneral.fireType; - - if (jAmmoGeneral.tracerType) - { - if (!CreateTracerFromJson(jAmmoGeneral.tracerType.value(), ammoGeneral.tracerType, attachment)) - return false; - } - else - ammoGeneral.tracerType = nullptr; - - ammoGeneral.rifleBullet = jAmmoGeneral.rifleBullet; - ammoGeneral.armorPiercing = jAmmoGeneral.armorPiercing; - - return true; - } - - static bool CreateAttSightFromJson(const JsonAttSight& jSight, AttSight& sight, const WeaponAttachment& attachment) - { - sight.aimDownSight = jSight.aimDownSight; - sight.adsFire = jSight.adsFire; - sight.rechamberWhileAds = jSight.rechamberWhileAds; - sight.noAdsWhenMagEmpty = jSight.noAdsWhenMagEmpty; - sight.canHoldBreath = jSight.canHoldBreath; - sight.canVariableZoom = jSight.canVariableZoom; - sight.hideRailWithThisScope = jSight.hideRailWithThisScope; - - return true; - } - - static bool CreateAttReloadFromJson(const JsonAttReload& jReload, AttReload& reload, const WeaponAttachment& attachment) - { - reload.noPartialReload = jReload.noPartialReload; - reload.segmentedReload = jReload.segmentedReload; - - return true; - } - - static bool CreateAttAddOnsFromJson(const JsonAttAddOns& jAddOns, AttAddOns& addOns, const WeaponAttachment& attachment) - { - addOns.motionTracker = jAddOns.motionTracker; - addOns.silenced = jAddOns.silenced; - - return true; - } - - bool CreateAttGeneralFromJson(const JsonAttGeneral& jGeneral, AttGeneral& general, const WeaponAttachment& attachment) const - { - general.boltAction = jGeneral.boltAction; - general.inheritsPerks = jGeneral.inheritsPerks; - general.enemyCrosshairRange = jGeneral.enemyCrosshairRange; - - if (jGeneral.reticleCenter) - { - if (!CreateMaterialFromJson(jGeneral.reticleCenter.value(), general.reticleCenter, attachment)) - return false; - } - else - general.reticleCenter = nullptr; - - if (jGeneral.reticleSide) - { - if (!CreateMaterialFromJson(jGeneral.reticleSide.value(), general.reticleSide, attachment)) - return false; - } - else - general.reticleSide = nullptr; - - general.reticleCenterSize = jGeneral.reticleCenterSize; - general.reticleSideSize = jGeneral.reticleSideSize; - general.moveSpeedScale = jGeneral.moveSpeedScale; - general.adsMoveSpeedScale = jGeneral.adsMoveSpeedScale; - - return true; - } - - static bool CreateAttAimAssistFromJson(const JsonAttAimAssist& jAimAssist, AttAimAssist& aimAssist, const WeaponAttachment& attachment) - { - aimAssist.autoAimRange = jAimAssist.autoAimRange; - aimAssist.aimAssistRange = jAimAssist.aimAssistRange; - aimAssist.aimAssistRangeAds = jAimAssist.aimAssistRangeAds; - - return true; - } - - static bool CreateAttAmmunitionFromJson(const JsonAttAmmunition& jAmmunition, AttAmmunition& ammunition, const WeaponAttachment& attachment) - { - ammunition.maxAmmo = jAmmunition.maxAmmo; - ammunition.startAmmo = jAmmunition.startAmmo; - ammunition.clipSize = jAmmunition.clipSize; - ammunition.shotCount = jAmmunition.shotCount; - ammunition.reloadAmmoAdd = jAmmunition.reloadAmmoAdd; - ammunition.reloadStartAdd = jAmmunition.reloadStartAdd; - - return true; - } - - static bool CreateAttDamageFromJson(const JsonAttDamage& jDamage, AttDamage& damage, const WeaponAttachment& attachment) - { - damage.damage = jDamage.damage; - damage.minDamage = jDamage.minDamage; - damage.meleeDamage = jDamage.meleeDamage; - damage.maxDamageRange = jDamage.maxDamageRange; - damage.minDamageRange = jDamage.minDamageRange; - damage.playerDamage = jDamage.playerDamage; - damage.minPlayerDamage = jDamage.minPlayerDamage; - - return true; - } - - static bool - CreateAttLocationDamageFromJson(const JsonAttLocationDamage& jLocationDamage, AttLocationDamage& locationDamage, const WeaponAttachment& attachment) - { - locationDamage.locNone = jLocationDamage.locNone; - locationDamage.locHelmet = jLocationDamage.locHelmet; - locationDamage.locHead = jLocationDamage.locHead; - locationDamage.locNeck = jLocationDamage.locNeck; - locationDamage.locTorsoUpper = jLocationDamage.locTorsoUpper; - locationDamage.locTorsoLower = jLocationDamage.locTorsoLower; - locationDamage.locRightArmUpper = jLocationDamage.locRightArmUpper; - locationDamage.locRightArmLower = jLocationDamage.locRightArmLower; - locationDamage.locRightHand = jLocationDamage.locRightHand; - locationDamage.locLeftArmUpper = jLocationDamage.locLeftArmUpper; - locationDamage.locLeftArmLower = jLocationDamage.locLeftArmLower; - locationDamage.locLeftHand = jLocationDamage.locLeftHand; - locationDamage.locRightLegUpper = jLocationDamage.locRightLegUpper; - locationDamage.locRightLegLower = jLocationDamage.locRightLegLower; - locationDamage.locRightFoot = jLocationDamage.locRightFoot; - locationDamage.locLeftLegUpper = jLocationDamage.locLeftLegUpper; - locationDamage.locLeftLegLower = jLocationDamage.locLeftLegLower; - locationDamage.locLeftFoot = jLocationDamage.locLeftFoot; - locationDamage.locGun = jLocationDamage.locGun; - - return true; - } - - static bool CreateAttIdleSettingsFromJson(const JsonAttIdleSettings& jIdleSettings, AttIdleSettings& idleSettings, const WeaponAttachment& attachment) - { - idleSettings.hipIdleAmount = jIdleSettings.hipIdleAmount; - idleSettings.hipIdleSpeed = jIdleSettings.hipIdleSpeed; - idleSettings.idleCrouchFactor = jIdleSettings.idleCrouchFactor; - idleSettings.idleProneFactor = jIdleSettings.idleProneFactor; - idleSettings.adsIdleLerpStartTime = jIdleSettings.adsIdleLerpStartTime; - idleSettings.adsIdleLerpTime = jIdleSettings.adsIdleLerpTime; - - return true; - } - - static bool CreateAttADSSettingsFromJson(const JsonAttADSSettings& jAdsSettings, AttADSSettings& adsSettings, const WeaponAttachment& attachment) - { - adsSettings.adsSpread = jAdsSettings.adsSpread; - adsSettings.adsAimPitch = jAdsSettings.adsAimPitch; - adsSettings.adsTransInTime = jAdsSettings.adsTransInTime; - adsSettings.adsTransOutTime = jAdsSettings.adsTransOutTime; - adsSettings.adsReloadTransTime = jAdsSettings.adsReloadTransTime; - adsSettings.adsCrosshairInFrac = jAdsSettings.adsCrosshairInFrac; - adsSettings.adsCrosshairOutFrac = jAdsSettings.adsCrosshairOutFrac; - adsSettings.adsZoomFov = jAdsSettings.adsZoomFov; - adsSettings.adsZoomInFrac = jAdsSettings.adsZoomInFrac; - adsSettings.adsZoomOutFrac = jAdsSettings.adsZoomOutFrac; - adsSettings.adsBobFactor = jAdsSettings.adsBobFactor; - adsSettings.adsViewBobMult = jAdsSettings.adsViewBobMult; - adsSettings.adsViewErrorMin = jAdsSettings.adsViewErrorMin; - adsSettings.adsViewErrorMax = jAdsSettings.adsViewErrorMax; - - return true; - } - - static bool CreateAttHipSpreadFromJson(const JsonAttHipSpread& jHipSpread, AttHipSpread& hipSpread, const WeaponAttachment& attachment) - { - hipSpread.hipSpreadStandMin = jHipSpread.hipSpreadStandMin; - hipSpread.hipSpreadDuckedMin = jHipSpread.hipSpreadDuckedMin; - hipSpread.hipSpreadProneMin = jHipSpread.hipSpreadProneMin; - hipSpread.hipSpreadMax = jHipSpread.hipSpreadMax; - hipSpread.hipSpreadDuckedMax = jHipSpread.hipSpreadDuckedMax; - hipSpread.hipSpreadProneMax = jHipSpread.hipSpreadProneMax; - hipSpread.hipSpreadFireAdd = jHipSpread.hipSpreadFireAdd; - hipSpread.hipSpreadTurnAdd = jHipSpread.hipSpreadTurnAdd; - hipSpread.hipSpreadMoveAdd = jHipSpread.hipSpreadMoveAdd; - hipSpread.hipSpreadDecayRate = jHipSpread.hipSpreadDecayRate; - hipSpread.hipSpreadDuckedDecay = jHipSpread.hipSpreadDuckedDecay; - hipSpread.hipSpreadProneDecay = jHipSpread.hipSpreadProneDecay; - - return true; - } - - static bool CreateAttGunKickFromJson(const JsonAttGunKick& jGunKick, AttGunKick& gunKick, const WeaponAttachment& attachment) - { - gunKick.hipGunKickReducedKickBullets = jGunKick.hipGunKickReducedKickBullets; - gunKick.hipGunKickReducedKickPercent = jGunKick.hipGunKickReducedKickPercent; - gunKick.hipGunKickPitchMin = jGunKick.hipGunKickPitchMin; - gunKick.hipGunKickPitchMax = jGunKick.hipGunKickPitchMax; - gunKick.hipGunKickYawMin = jGunKick.hipGunKickYawMin; - gunKick.hipGunKickYawMax = jGunKick.hipGunKickYawMax; - gunKick.hipGunKickAccel = jGunKick.hipGunKickAccel; - gunKick.hipGunKickSpeedMax = jGunKick.hipGunKickSpeedMax; - gunKick.hipGunKickSpeedDecay = jGunKick.hipGunKickSpeedDecay; - gunKick.hipGunKickStaticDecay = jGunKick.hipGunKickStaticDecay; - gunKick.adsGunKickReducedKickBullets = jGunKick.adsGunKickReducedKickBullets; - gunKick.adsGunKickReducedKickPercent = jGunKick.adsGunKickReducedKickPercent; - gunKick.adsGunKickPitchMin = jGunKick.adsGunKickPitchMin; - gunKick.adsGunKickPitchMax = jGunKick.adsGunKickPitchMax; - gunKick.adsGunKickYawMin = jGunKick.adsGunKickYawMin; - gunKick.adsGunKickYawMax = jGunKick.adsGunKickYawMax; - gunKick.adsGunKickAccel = jGunKick.adsGunKickAccel; - gunKick.adsGunKickSpeedMax = jGunKick.adsGunKickSpeedMax; - gunKick.adsGunKickSpeedDecay = jGunKick.adsGunKickSpeedDecay; - gunKick.adsGunKickStaticDecay = jGunKick.adsGunKickStaticDecay; - - return true; - } - - static bool CreateAttViewKickFromJson(const JsonAttViewKick& jViewKick, AttViewKick& viewKick, const WeaponAttachment& attachment) - { - viewKick.hipViewKickPitchMin = jViewKick.hipViewKickPitchMin; - viewKick.hipViewKickPitchMax = jViewKick.hipViewKickPitchMax; - viewKick.hipViewKickYawMin = jViewKick.hipViewKickYawMin; - viewKick.hipViewKickYawMax = jViewKick.hipViewKickYawMax; - viewKick.hipViewKickCenterSpeed = jViewKick.hipViewKickCenterSpeed; - viewKick.adsViewKickPitchMin = jViewKick.adsViewKickPitchMin; - viewKick.adsViewKickPitchMax = jViewKick.adsViewKickPitchMax; - viewKick.adsViewKickYawMin = jViewKick.adsViewKickYawMin; - viewKick.adsViewKickYawMax = jViewKick.adsViewKickYawMax; - viewKick.adsViewKickCenterSpeed = jViewKick.adsViewKickCenterSpeed; - - return true; - } - - bool CreateAttADSOverlayFromJson(const JsonAttADSOverlay& jAdsOverlay, AttADSOverlay& adsOverlay, const WeaponAttachment& attachment) const - { - if (jAdsOverlay.shader) - { - if (!CreateMaterialFromJson(jAdsOverlay.shader.value(), adsOverlay.overlay.shader, attachment)) - return false; - } - else - adsOverlay.overlay.shader = nullptr; - - if (jAdsOverlay.shaderLowRes) - { - if (!CreateMaterialFromJson(jAdsOverlay.shaderLowRes.value(), adsOverlay.overlay.shaderLowRes, attachment)) - return false; - } - else - adsOverlay.overlay.shaderLowRes = nullptr; - - if (jAdsOverlay.shaderEMP) - { - if (!CreateMaterialFromJson(jAdsOverlay.shaderEMP.value(), adsOverlay.overlay.shaderEMP, attachment)) - return false; - } - else - adsOverlay.overlay.shaderEMP = nullptr; - - if (jAdsOverlay.shaderEMPLowRes) - { - if (!CreateMaterialFromJson(jAdsOverlay.shaderEMPLowRes.value(), adsOverlay.overlay.shaderEMPLowRes, attachment)) - return false; - } - else - adsOverlay.overlay.shaderEMPLowRes = nullptr; - - adsOverlay.overlay.reticle = jAdsOverlay.reticle; - adsOverlay.overlay.width = jAdsOverlay.width; - adsOverlay.overlay.height = jAdsOverlay.height; - adsOverlay.overlay.widthSplitscreen = jAdsOverlay.widthSplitscreen; - adsOverlay.overlay.heightSplitscreen = jAdsOverlay.heightSplitscreen; - adsOverlay.thermalScope = jAdsOverlay.thermalScope; - - return true; - } - - bool CreateAttUIFromJson(const JsonAttUI& jUi, AttUI& ui, const WeaponAttachment& attachment) const - { - if (jUi.dpadIcon) - { - if (!CreateMaterialFromJson(jUi.dpadIcon.value(), ui.dpadIcon, attachment)) - return false; - } - else - ui.dpadIcon = nullptr; - - if (jUi.ammoCounterIcon) - { - if (!CreateMaterialFromJson(jUi.ammoCounterIcon.value(), ui.ammoCounterIcon, attachment)) - return false; - } - else - ui.ammoCounterIcon = nullptr; - - ui.dpadIconRatio = jUi.dpadIconRatio; - ui.ammoCounterIconRatio = jUi.ammoCounterIconRatio; - ui.ammoCounterClip = jUi.ammoCounterClip; - - return true; - } - - bool CreateAttRumblesFromJson(const JsonAttRumbles& jRumbles, AttRumbles& rumbles, const WeaponAttachment& attachment) const - { - if (jRumbles.fireRumble) - rumbles.fireRumble = m_memory.Dup(jRumbles.fireRumble.value().c_str()); - else - rumbles.fireRumble = nullptr; - - if (jRumbles.meleeImpactRumble) - rumbles.meleeImpactRumble = m_memory.Dup(jRumbles.meleeImpactRumble.value().c_str()); - else - rumbles.meleeImpactRumble = nullptr; - - return true; - } - - bool CreateAttProjectileFromJson(const JsonAttProjectile& jProjectile, AttProjectile& projectile, const WeaponAttachment& attachment) const - { - projectile.explosionRadius = jProjectile.explosionRadius; - projectile.explosionInnerDamage = jProjectile.explosionInnerDamage; - projectile.explosionOuterDamage = jProjectile.explosionOuterDamage; - projectile.damageConeAngle = jProjectile.damageConeAngle; - projectile.projectileSpeed = jProjectile.projectileSpeed; - projectile.projectileSpeedUp = jProjectile.projectileSpeedUp; - projectile.projectileActivateDist = jProjectile.projectileActivateDist; - projectile.projectileLifetime = jProjectile.projectileLifetime; - - if (jProjectile.projectileModel) - { - if (!CreateXModelFromJson(jProjectile.projectileModel.value(), projectile.projectileModel, attachment)) - return false; - } - else - projectile.projectileModel = nullptr; - - projectile.projExplosionType = jProjectile.projExplosionType; - - if (jProjectile.projExplosionEffect) - { - if (!CreateFxFromJson(jProjectile.projExplosionEffect.value(), projectile.projExplosionEffect, attachment)) - return false; - } - else - projectile.projExplosionEffect = nullptr; - - projectile.projExplosionEffectForceNormalUp = jProjectile.projExplosionEffectForceNormalUp; - - if (jProjectile.projExplosionSound) - { - if (!CreateSoundFromJson(jProjectile.projExplosionSound.value(), projectile.projExplosionSound, attachment)) - return false; - } - else - projectile.projExplosionSound.name = nullptr; - - if (jProjectile.projDudEffect) - { - if (!CreateFxFromJson(jProjectile.projDudEffect.value(), projectile.projDudEffect, attachment)) - return false; - } - else - projectile.projDudEffect = nullptr; - - if (jProjectile.projDudSound) - { - if (!CreateSoundFromJson(jProjectile.projDudSound.value(), projectile.projDudSound, attachment)) - return false; - } - else - projectile.projDudSound.name = nullptr; - - projectile.projImpactExplode = jProjectile.projImpactExplode; - projectile.destabilizationRateTime = jProjectile.destabilizationRateTime; - projectile.destabilizationCurvatureMax = jProjectile.destabilizationCurvatureMax; - projectile.destabilizeDistance = jProjectile.destabilizeDistance; - - if (jProjectile.projTrailEffect) - { - if (!CreateFxFromJson(jProjectile.projTrailEffect.value(), projectile.projTrailEffect, attachment)) - return false; - } - else - projectile.projTrailEffect = nullptr; - - projectile.projIgnitionDelay = jProjectile.projIgnitionDelay; - - if (jProjectile.projIgnitionEffect) - { - if (!CreateFxFromJson(jProjectile.projIgnitionEffect.value(), projectile.projIgnitionEffect, attachment)) - return false; - } - else - projectile.projIgnitionEffect = nullptr; - - if (jProjectile.projIgnitionSound) - { - if (!CreateSoundFromJson(jProjectile.projIgnitionSound.value(), projectile.projIgnitionSound, attachment)) - return false; - } - else - projectile.projIgnitionSound.name = nullptr; - - return true; - } - - std::istream& m_stream; - MemoryManager& m_memory; - AssetCreationContext& m_context; - AssetRegistration& m_registration; - }; -} // namespace - -namespace IW5 -{ - bool LoadWeaponAttachmentAsJson(std::istream& stream, - WeaponAttachment& attachment, - MemoryManager& memory, - AssetCreationContext& context, - AssetRegistration& registration) - { - const JsonLoader loader(stream, memory, context, registration); - - return loader.Load(attachment); - } -} // namespace IW5 diff --git a/src/ObjLoading/Game/IW5/Weapon/JsonWeaponAttachmentLoader.h b/src/ObjLoading/Game/IW5/Weapon/JsonWeaponAttachmentLoader.h deleted file mode 100644 index 5b9d7b06..00000000 --- a/src/ObjLoading/Game/IW5/Weapon/JsonWeaponAttachmentLoader.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Asset/AssetCreationContext.h" -#include "Asset/AssetRegistration.h" -#include "Game/IW5/IW5.h" -#include "Utils/MemoryManager.h" - -#include - -namespace IW5 -{ - bool LoadWeaponAttachmentAsJson(std::istream& stream, - WeaponAttachment& attachment, - MemoryManager& memory, - AssetCreationContext& context, - AssetRegistration& registration); -} // namespace IW5 diff --git a/src/ObjLoading/Game/IW5/Weapon/LoaderAttachmentIW5.cpp b/src/ObjLoading/Game/IW5/Weapon/LoaderAttachmentIW5.cpp index ac7197c1..9d261f8e 100644 --- a/src/ObjLoading/Game/IW5/Weapon/LoaderAttachmentIW5.cpp +++ b/src/ObjLoading/Game/IW5/Weapon/LoaderAttachmentIW5.cpp @@ -1,16 +1,637 @@ #include "LoaderAttachmentIW5.h" #include "Game/IW5/IW5.h" -#include "JsonWeaponAttachmentLoader.h" +#include "Game/IW5/Weapon/JsonWeaponAttachment.h" +#include "Weapon/AttachmentCommon.h" #include #include #include +#include +using namespace nlohmann; using namespace IW5; +using namespace ::attachment; namespace { + class JsonLoader + { + public: + JsonLoader(std::istream& stream, MemoryManager& memory, AssetCreationContext& context, AssetRegistration& registration) + : m_stream(stream), + m_memory(memory), + m_context(context), + m_registration(registration) + + { + } + + bool Load(WeaponAttachment& attachment) const + { + try + { + const auto jRoot = json::parse(m_stream); + std::string type; + unsigned version; + + jRoot.at("_type").get_to(type); + jRoot.at("_version").get_to(version); + + if (type != "attachment" || version != 1u) + { + std::cerr << "Tried to load attachment \"" << attachment.szInternalName << "\" but did not find expected type attachment of version 1\n"; + return false; + } + + const auto jAttachment = jRoot.get(); + return CreateWeaponAttachmentFromJson(jAttachment, attachment); + } + catch (const json::exception& e) + { + std::cerr << std::format("Failed to parse json of attachment: {}\n", e.what()); + } + + return false; + } + + private: + static void PrintError(const WeaponAttachment& attachment, const std::string& message) + { + std::cerr << "Cannot load attachment \"" << attachment.szInternalName << "\": " << message << "\n"; + } + + bool CreateWeaponAttachmentFromJson(const JsonWeaponAttachment& jAttachment, WeaponAttachment& attachment) const + { +#define CONVERT_XMODEL_ARRAY(propertyName, count) \ + CreateXModelArrayFromJson(jAttachment.propertyName, attachment.propertyName, #propertyName, count, attachment); + +#define CONVERT_ATTRIBUTE(attributeClass, attributeName) \ + if (jAttachment.attributeName) \ + { \ + using AttributeType = std::remove_pointer_t; \ + attachment.attributeName = m_memory.Alloc(); \ + if (!Create##attributeClass##FromJson(jAttachment.attributeName.value(), *attachment.attributeName, attachment)) \ + return false; \ + } \ + else \ + attachment.attributeName = nullptr; + + attachment.szDisplayName = m_memory.Dup(jAttachment.displayName.c_str()); + attachment.type = jAttachment.type; + attachment.weaponType = jAttachment.weaponType; + attachment.weapClass = jAttachment.weapClass; + + CONVERT_XMODEL_ARRAY(worldModels, ATTACHMENT_WORLD_MODEL_COUNT) + CONVERT_XMODEL_ARRAY(viewModels, ATTACHMENT_VIEW_MODEL_COUNT) + CONVERT_XMODEL_ARRAY(reticleViewModels, ATTACHMENT_RETICLE_VIEW_MODEL_COUNT) + + CONVERT_ATTRIBUTE(AttAmmoGeneral, ammoGeneral) + CONVERT_ATTRIBUTE(AttSight, sight) + CONVERT_ATTRIBUTE(AttReload, reload) + CONVERT_ATTRIBUTE(AttAddOns, addOns) + CONVERT_ATTRIBUTE(AttGeneral, general) + CONVERT_ATTRIBUTE(AttAimAssist, aimAssist) + CONVERT_ATTRIBUTE(AttAmmunition, ammunition) + CONVERT_ATTRIBUTE(AttDamage, damage) + CONVERT_ATTRIBUTE(AttLocationDamage, locationDamage) + CONVERT_ATTRIBUTE(AttIdleSettings, idleSettings) + CONVERT_ATTRIBUTE(AttADSSettings, adsSettings) + CONVERT_ATTRIBUTE(AttADSSettings, adsSettingsMain) + CONVERT_ATTRIBUTE(AttHipSpread, hipSpread) + CONVERT_ATTRIBUTE(AttGunKick, gunKick) + CONVERT_ATTRIBUTE(AttViewKick, viewKick) + CONVERT_ATTRIBUTE(AttADSOverlay, adsOverlay) + CONVERT_ATTRIBUTE(AttUI, ui) + CONVERT_ATTRIBUTE(AttRumbles, rumbles) + CONVERT_ATTRIBUTE(AttProjectile, projectile) + + attachment.ammunitionScale = jAttachment.ammunitionScale; + attachment.damageScale = jAttachment.damageScale; + attachment.damageScaleMin = jAttachment.damageScaleMin; + attachment.stateTimersScale = jAttachment.stateTimersScale; + attachment.fireTimersScale = jAttachment.fireTimersScale; + attachment.idleSettingsScale = jAttachment.idleSettingsScale; + attachment.adsSettingsScale = jAttachment.adsSettingsScale; + attachment.adsSettingsScaleMain = jAttachment.adsSettingsScaleMain; + attachment.hipSpreadScale = jAttachment.hipSpreadScale; + attachment.gunKickScale = jAttachment.gunKickScale; + attachment.viewKickScale = jAttachment.viewKickScale; + attachment.viewCenterScale = jAttachment.viewCenterScale; + attachment.loadIndex = jAttachment.loadIndex; + attachment.hideIronSightsWithThisAttachment = jAttachment.hideIronSightsWithThisAttachment; + attachment.shareAmmoWithAlt = jAttachment.shareAmmoWithAlt; + + return true; + } + + bool CreateTracerFromJson(const std::string& assetName, TracerDef*& tracerPtr, const WeaponAttachment& attachment) const + { + auto* tracer = m_context.LoadDependency(assetName); + if (!tracer) + { + PrintError(attachment, std::format("Could not find tracer {}", assetName)); + return false; + } + m_registration.AddDependency(tracer); + tracerPtr = tracer->Asset(); + + return true; + } + + bool CreateMaterialFromJson(const std::string& assetName, Material*& materialPtr, const WeaponAttachment& attachment) const + { + auto* material = m_context.LoadDependency(assetName); + if (!material) + { + PrintError(attachment, std::format("Could not find material {}", assetName)); + return false; + } + m_registration.AddDependency(material); + materialPtr = material->Asset(); + + return true; + } + + bool CreateFxFromJson(const std::string& assetName, FxEffectDef*& fxPtr, const WeaponAttachment& attachment) const + { + auto* fx = m_context.LoadDependency(assetName); + if (!fx) + { + PrintError(attachment, std::format("Could not find fx {}", assetName)); + return false; + } + m_registration.AddDependency(fx); + fxPtr = fx->Asset(); + + return true; + } + + bool CreateSoundFromJson(const std::string& assetName, SndAliasCustom& sndAliasCustom, const WeaponAttachment& attachment) const + { + m_registration.AddIndirectAssetReference(m_context.LoadIndirectAssetReference(assetName)); + sndAliasCustom.name = m_memory.Alloc(); + sndAliasCustom.name->soundName = m_memory.Dup(assetName.c_str()); + + return true; + } + + bool CreateXModelFromJson(const std::string& assetName, XModel*& xmodelPtr, const WeaponAttachment& attachment) const + { + auto* xmodel = m_context.LoadDependency(assetName); + if (!xmodel) + { + PrintError(attachment, std::format("Could not find xmodel {}", assetName)); + return false; + } + m_registration.AddDependency(xmodel); + xmodelPtr = xmodel->Asset(); + + return true; + } + + bool CreateXModelArrayFromJson(const std::vector& jXmodelArray, + XModel**& xmodelArray, + const char* propertyName, + size_t propertyCount, + const WeaponAttachment& attachment) const + { + if (!jXmodelArray.empty()) + { + const auto arraySize = jXmodelArray.size(); + if (arraySize > propertyCount) + { + PrintError(attachment, std::format("{} size cannot exceed {}", propertyName, propertyCount)); + return false; + } + xmodelArray = m_memory.Alloc(propertyCount); + memset(xmodelArray, 0, sizeof(void*) * propertyCount); + + for (auto i = 0u; i < arraySize; i++) + { + if (!CreateXModelFromJson(jXmodelArray[i], xmodelArray[i], attachment)) + return false; + } + } + else + { + xmodelArray = nullptr; + } + + return true; + } + + bool CreateAttAmmoGeneralFromJson(const JsonAttAmmoGeneral& jAmmoGeneral, AttAmmoGeneral& ammoGeneral, const WeaponAttachment& attachment) const + { + ammoGeneral.penetrateType = jAmmoGeneral.penetrateType; + ammoGeneral.penetrateMultiplier = jAmmoGeneral.penetrateMultiplier; + ammoGeneral.impactType = jAmmoGeneral.impactType; + ammoGeneral.fireType = jAmmoGeneral.fireType; + + if (jAmmoGeneral.tracerType) + { + if (!CreateTracerFromJson(jAmmoGeneral.tracerType.value(), ammoGeneral.tracerType, attachment)) + return false; + } + else + ammoGeneral.tracerType = nullptr; + + ammoGeneral.rifleBullet = jAmmoGeneral.rifleBullet; + ammoGeneral.armorPiercing = jAmmoGeneral.armorPiercing; + + return true; + } + + static bool CreateAttSightFromJson(const JsonAttSight& jSight, AttSight& sight, const WeaponAttachment& attachment) + { + sight.aimDownSight = jSight.aimDownSight; + sight.adsFire = jSight.adsFire; + sight.rechamberWhileAds = jSight.rechamberWhileAds; + sight.noAdsWhenMagEmpty = jSight.noAdsWhenMagEmpty; + sight.canHoldBreath = jSight.canHoldBreath; + sight.canVariableZoom = jSight.canVariableZoom; + sight.hideRailWithThisScope = jSight.hideRailWithThisScope; + + return true; + } + + static bool CreateAttReloadFromJson(const JsonAttReload& jReload, AttReload& reload, const WeaponAttachment& attachment) + { + reload.noPartialReload = jReload.noPartialReload; + reload.segmentedReload = jReload.segmentedReload; + + return true; + } + + static bool CreateAttAddOnsFromJson(const JsonAttAddOns& jAddOns, AttAddOns& addOns, const WeaponAttachment& attachment) + { + addOns.motionTracker = jAddOns.motionTracker; + addOns.silenced = jAddOns.silenced; + + return true; + } + + bool CreateAttGeneralFromJson(const JsonAttGeneral& jGeneral, AttGeneral& general, const WeaponAttachment& attachment) const + { + general.boltAction = jGeneral.boltAction; + general.inheritsPerks = jGeneral.inheritsPerks; + general.enemyCrosshairRange = jGeneral.enemyCrosshairRange; + + if (jGeneral.reticleCenter) + { + if (!CreateMaterialFromJson(jGeneral.reticleCenter.value(), general.reticleCenter, attachment)) + return false; + } + else + general.reticleCenter = nullptr; + + if (jGeneral.reticleSide) + { + if (!CreateMaterialFromJson(jGeneral.reticleSide.value(), general.reticleSide, attachment)) + return false; + } + else + general.reticleSide = nullptr; + + general.reticleCenterSize = jGeneral.reticleCenterSize; + general.reticleSideSize = jGeneral.reticleSideSize; + general.moveSpeedScale = jGeneral.moveSpeedScale; + general.adsMoveSpeedScale = jGeneral.adsMoveSpeedScale; + + return true; + } + + static bool CreateAttAimAssistFromJson(const JsonAttAimAssist& jAimAssist, AttAimAssist& aimAssist, const WeaponAttachment& attachment) + { + aimAssist.autoAimRange = jAimAssist.autoAimRange; + aimAssist.aimAssistRange = jAimAssist.aimAssistRange; + aimAssist.aimAssistRangeAds = jAimAssist.aimAssistRangeAds; + + return true; + } + + static bool CreateAttAmmunitionFromJson(const JsonAttAmmunition& jAmmunition, AttAmmunition& ammunition, const WeaponAttachment& attachment) + { + ammunition.maxAmmo = jAmmunition.maxAmmo; + ammunition.startAmmo = jAmmunition.startAmmo; + ammunition.clipSize = jAmmunition.clipSize; + ammunition.shotCount = jAmmunition.shotCount; + ammunition.reloadAmmoAdd = jAmmunition.reloadAmmoAdd; + ammunition.reloadStartAdd = jAmmunition.reloadStartAdd; + + return true; + } + + static bool CreateAttDamageFromJson(const JsonAttDamage& jDamage, AttDamage& damage, const WeaponAttachment& attachment) + { + damage.damage = jDamage.damage; + damage.minDamage = jDamage.minDamage; + damage.meleeDamage = jDamage.meleeDamage; + damage.maxDamageRange = jDamage.maxDamageRange; + damage.minDamageRange = jDamage.minDamageRange; + damage.playerDamage = jDamage.playerDamage; + damage.minPlayerDamage = jDamage.minPlayerDamage; + + return true; + } + + static bool + CreateAttLocationDamageFromJson(const JsonAttLocationDamage& jLocationDamage, AttLocationDamage& locationDamage, const WeaponAttachment& attachment) + { + locationDamage.locNone = jLocationDamage.locNone; + locationDamage.locHelmet = jLocationDamage.locHelmet; + locationDamage.locHead = jLocationDamage.locHead; + locationDamage.locNeck = jLocationDamage.locNeck; + locationDamage.locTorsoUpper = jLocationDamage.locTorsoUpper; + locationDamage.locTorsoLower = jLocationDamage.locTorsoLower; + locationDamage.locRightArmUpper = jLocationDamage.locRightArmUpper; + locationDamage.locRightArmLower = jLocationDamage.locRightArmLower; + locationDamage.locRightHand = jLocationDamage.locRightHand; + locationDamage.locLeftArmUpper = jLocationDamage.locLeftArmUpper; + locationDamage.locLeftArmLower = jLocationDamage.locLeftArmLower; + locationDamage.locLeftHand = jLocationDamage.locLeftHand; + locationDamage.locRightLegUpper = jLocationDamage.locRightLegUpper; + locationDamage.locRightLegLower = jLocationDamage.locRightLegLower; + locationDamage.locRightFoot = jLocationDamage.locRightFoot; + locationDamage.locLeftLegUpper = jLocationDamage.locLeftLegUpper; + locationDamage.locLeftLegLower = jLocationDamage.locLeftLegLower; + locationDamage.locLeftFoot = jLocationDamage.locLeftFoot; + locationDamage.locGun = jLocationDamage.locGun; + + return true; + } + + static bool CreateAttIdleSettingsFromJson(const JsonAttIdleSettings& jIdleSettings, AttIdleSettings& idleSettings, const WeaponAttachment& attachment) + { + idleSettings.hipIdleAmount = jIdleSettings.hipIdleAmount; + idleSettings.hipIdleSpeed = jIdleSettings.hipIdleSpeed; + idleSettings.idleCrouchFactor = jIdleSettings.idleCrouchFactor; + idleSettings.idleProneFactor = jIdleSettings.idleProneFactor; + idleSettings.adsIdleLerpStartTime = jIdleSettings.adsIdleLerpStartTime; + idleSettings.adsIdleLerpTime = jIdleSettings.adsIdleLerpTime; + + return true; + } + + static bool CreateAttADSSettingsFromJson(const JsonAttADSSettings& jAdsSettings, AttADSSettings& adsSettings, const WeaponAttachment& attachment) + { + adsSettings.adsSpread = jAdsSettings.adsSpread; + adsSettings.adsAimPitch = jAdsSettings.adsAimPitch; + adsSettings.adsTransInTime = jAdsSettings.adsTransInTime; + adsSettings.adsTransOutTime = jAdsSettings.adsTransOutTime; + adsSettings.adsReloadTransTime = jAdsSettings.adsReloadTransTime; + adsSettings.adsCrosshairInFrac = jAdsSettings.adsCrosshairInFrac; + adsSettings.adsCrosshairOutFrac = jAdsSettings.adsCrosshairOutFrac; + adsSettings.adsZoomFov = jAdsSettings.adsZoomFov; + adsSettings.adsZoomInFrac = jAdsSettings.adsZoomInFrac; + adsSettings.adsZoomOutFrac = jAdsSettings.adsZoomOutFrac; + adsSettings.adsBobFactor = jAdsSettings.adsBobFactor; + adsSettings.adsViewBobMult = jAdsSettings.adsViewBobMult; + adsSettings.adsViewErrorMin = jAdsSettings.adsViewErrorMin; + adsSettings.adsViewErrorMax = jAdsSettings.adsViewErrorMax; + + return true; + } + + static bool CreateAttHipSpreadFromJson(const JsonAttHipSpread& jHipSpread, AttHipSpread& hipSpread, const WeaponAttachment& attachment) + { + hipSpread.hipSpreadStandMin = jHipSpread.hipSpreadStandMin; + hipSpread.hipSpreadDuckedMin = jHipSpread.hipSpreadDuckedMin; + hipSpread.hipSpreadProneMin = jHipSpread.hipSpreadProneMin; + hipSpread.hipSpreadMax = jHipSpread.hipSpreadMax; + hipSpread.hipSpreadDuckedMax = jHipSpread.hipSpreadDuckedMax; + hipSpread.hipSpreadProneMax = jHipSpread.hipSpreadProneMax; + hipSpread.hipSpreadFireAdd = jHipSpread.hipSpreadFireAdd; + hipSpread.hipSpreadTurnAdd = jHipSpread.hipSpreadTurnAdd; + hipSpread.hipSpreadMoveAdd = jHipSpread.hipSpreadMoveAdd; + hipSpread.hipSpreadDecayRate = jHipSpread.hipSpreadDecayRate; + hipSpread.hipSpreadDuckedDecay = jHipSpread.hipSpreadDuckedDecay; + hipSpread.hipSpreadProneDecay = jHipSpread.hipSpreadProneDecay; + + return true; + } + + static bool CreateAttGunKickFromJson(const JsonAttGunKick& jGunKick, AttGunKick& gunKick, const WeaponAttachment& attachment) + { + gunKick.hipGunKickReducedKickBullets = jGunKick.hipGunKickReducedKickBullets; + gunKick.hipGunKickReducedKickPercent = jGunKick.hipGunKickReducedKickPercent; + gunKick.hipGunKickPitchMin = jGunKick.hipGunKickPitchMin; + gunKick.hipGunKickPitchMax = jGunKick.hipGunKickPitchMax; + gunKick.hipGunKickYawMin = jGunKick.hipGunKickYawMin; + gunKick.hipGunKickYawMax = jGunKick.hipGunKickYawMax; + gunKick.hipGunKickAccel = jGunKick.hipGunKickAccel; + gunKick.hipGunKickSpeedMax = jGunKick.hipGunKickSpeedMax; + gunKick.hipGunKickSpeedDecay = jGunKick.hipGunKickSpeedDecay; + gunKick.hipGunKickStaticDecay = jGunKick.hipGunKickStaticDecay; + gunKick.adsGunKickReducedKickBullets = jGunKick.adsGunKickReducedKickBullets; + gunKick.adsGunKickReducedKickPercent = jGunKick.adsGunKickReducedKickPercent; + gunKick.adsGunKickPitchMin = jGunKick.adsGunKickPitchMin; + gunKick.adsGunKickPitchMax = jGunKick.adsGunKickPitchMax; + gunKick.adsGunKickYawMin = jGunKick.adsGunKickYawMin; + gunKick.adsGunKickYawMax = jGunKick.adsGunKickYawMax; + gunKick.adsGunKickAccel = jGunKick.adsGunKickAccel; + gunKick.adsGunKickSpeedMax = jGunKick.adsGunKickSpeedMax; + gunKick.adsGunKickSpeedDecay = jGunKick.adsGunKickSpeedDecay; + gunKick.adsGunKickStaticDecay = jGunKick.adsGunKickStaticDecay; + + return true; + } + + static bool CreateAttViewKickFromJson(const JsonAttViewKick& jViewKick, AttViewKick& viewKick, const WeaponAttachment& attachment) + { + viewKick.hipViewKickPitchMin = jViewKick.hipViewKickPitchMin; + viewKick.hipViewKickPitchMax = jViewKick.hipViewKickPitchMax; + viewKick.hipViewKickYawMin = jViewKick.hipViewKickYawMin; + viewKick.hipViewKickYawMax = jViewKick.hipViewKickYawMax; + viewKick.hipViewKickCenterSpeed = jViewKick.hipViewKickCenterSpeed; + viewKick.adsViewKickPitchMin = jViewKick.adsViewKickPitchMin; + viewKick.adsViewKickPitchMax = jViewKick.adsViewKickPitchMax; + viewKick.adsViewKickYawMin = jViewKick.adsViewKickYawMin; + viewKick.adsViewKickYawMax = jViewKick.adsViewKickYawMax; + viewKick.adsViewKickCenterSpeed = jViewKick.adsViewKickCenterSpeed; + + return true; + } + + bool CreateAttADSOverlayFromJson(const JsonAttADSOverlay& jAdsOverlay, AttADSOverlay& adsOverlay, const WeaponAttachment& attachment) const + { + if (jAdsOverlay.shader) + { + if (!CreateMaterialFromJson(jAdsOverlay.shader.value(), adsOverlay.overlay.shader, attachment)) + return false; + } + else + adsOverlay.overlay.shader = nullptr; + + if (jAdsOverlay.shaderLowRes) + { + if (!CreateMaterialFromJson(jAdsOverlay.shaderLowRes.value(), adsOverlay.overlay.shaderLowRes, attachment)) + return false; + } + else + adsOverlay.overlay.shaderLowRes = nullptr; + + if (jAdsOverlay.shaderEMP) + { + if (!CreateMaterialFromJson(jAdsOverlay.shaderEMP.value(), adsOverlay.overlay.shaderEMP, attachment)) + return false; + } + else + adsOverlay.overlay.shaderEMP = nullptr; + + if (jAdsOverlay.shaderEMPLowRes) + { + if (!CreateMaterialFromJson(jAdsOverlay.shaderEMPLowRes.value(), adsOverlay.overlay.shaderEMPLowRes, attachment)) + return false; + } + else + adsOverlay.overlay.shaderEMPLowRes = nullptr; + + adsOverlay.overlay.reticle = jAdsOverlay.reticle; + adsOverlay.overlay.width = jAdsOverlay.width; + adsOverlay.overlay.height = jAdsOverlay.height; + adsOverlay.overlay.widthSplitscreen = jAdsOverlay.widthSplitscreen; + adsOverlay.overlay.heightSplitscreen = jAdsOverlay.heightSplitscreen; + adsOverlay.thermalScope = jAdsOverlay.thermalScope; + + return true; + } + + bool CreateAttUIFromJson(const JsonAttUI& jUi, AttUI& ui, const WeaponAttachment& attachment) const + { + if (jUi.dpadIcon) + { + if (!CreateMaterialFromJson(jUi.dpadIcon.value(), ui.dpadIcon, attachment)) + return false; + } + else + ui.dpadIcon = nullptr; + + if (jUi.ammoCounterIcon) + { + if (!CreateMaterialFromJson(jUi.ammoCounterIcon.value(), ui.ammoCounterIcon, attachment)) + return false; + } + else + ui.ammoCounterIcon = nullptr; + + ui.dpadIconRatio = jUi.dpadIconRatio; + ui.ammoCounterIconRatio = jUi.ammoCounterIconRatio; + ui.ammoCounterClip = jUi.ammoCounterClip; + + return true; + } + + bool CreateAttRumblesFromJson(const JsonAttRumbles& jRumbles, AttRumbles& rumbles, const WeaponAttachment& attachment) const + { + if (jRumbles.fireRumble) + rumbles.fireRumble = m_memory.Dup(jRumbles.fireRumble.value().c_str()); + else + rumbles.fireRumble = nullptr; + + if (jRumbles.meleeImpactRumble) + rumbles.meleeImpactRumble = m_memory.Dup(jRumbles.meleeImpactRumble.value().c_str()); + else + rumbles.meleeImpactRumble = nullptr; + + return true; + } + + bool CreateAttProjectileFromJson(const JsonAttProjectile& jProjectile, AttProjectile& projectile, const WeaponAttachment& attachment) const + { + projectile.explosionRadius = jProjectile.explosionRadius; + projectile.explosionInnerDamage = jProjectile.explosionInnerDamage; + projectile.explosionOuterDamage = jProjectile.explosionOuterDamage; + projectile.damageConeAngle = jProjectile.damageConeAngle; + projectile.projectileSpeed = jProjectile.projectileSpeed; + projectile.projectileSpeedUp = jProjectile.projectileSpeedUp; + projectile.projectileActivateDist = jProjectile.projectileActivateDist; + projectile.projectileLifetime = jProjectile.projectileLifetime; + + if (jProjectile.projectileModel) + { + if (!CreateXModelFromJson(jProjectile.projectileModel.value(), projectile.projectileModel, attachment)) + return false; + } + else + projectile.projectileModel = nullptr; + + projectile.projExplosionType = jProjectile.projExplosionType; + + if (jProjectile.projExplosionEffect) + { + if (!CreateFxFromJson(jProjectile.projExplosionEffect.value(), projectile.projExplosionEffect, attachment)) + return false; + } + else + projectile.projExplosionEffect = nullptr; + + projectile.projExplosionEffectForceNormalUp = jProjectile.projExplosionEffectForceNormalUp; + + if (jProjectile.projExplosionSound) + { + if (!CreateSoundFromJson(jProjectile.projExplosionSound.value(), projectile.projExplosionSound, attachment)) + return false; + } + else + projectile.projExplosionSound.name = nullptr; + + if (jProjectile.projDudEffect) + { + if (!CreateFxFromJson(jProjectile.projDudEffect.value(), projectile.projDudEffect, attachment)) + return false; + } + else + projectile.projDudEffect = nullptr; + + if (jProjectile.projDudSound) + { + if (!CreateSoundFromJson(jProjectile.projDudSound.value(), projectile.projDudSound, attachment)) + return false; + } + else + projectile.projDudSound.name = nullptr; + + projectile.projImpactExplode = jProjectile.projImpactExplode; + projectile.destabilizationRateTime = jProjectile.destabilizationRateTime; + projectile.destabilizationCurvatureMax = jProjectile.destabilizationCurvatureMax; + projectile.destabilizeDistance = jProjectile.destabilizeDistance; + + if (jProjectile.projTrailEffect) + { + if (!CreateFxFromJson(jProjectile.projTrailEffect.value(), projectile.projTrailEffect, attachment)) + return false; + } + else + projectile.projTrailEffect = nullptr; + + projectile.projIgnitionDelay = jProjectile.projIgnitionDelay; + + if (jProjectile.projIgnitionEffect) + { + if (!CreateFxFromJson(jProjectile.projIgnitionEffect.value(), projectile.projIgnitionEffect, attachment)) + return false; + } + else + projectile.projIgnitionEffect = nullptr; + + if (jProjectile.projIgnitionSound) + { + if (!CreateSoundFromJson(jProjectile.projIgnitionSound.value(), projectile.projIgnitionSound, attachment)) + return false; + } + else + projectile.projIgnitionSound.name = nullptr; + + return true; + } + + std::istream& m_stream; + MemoryManager& m_memory; + AssetCreationContext& m_context; + AssetRegistration& m_registration; + }; + class AttachmentLoader final : public AssetCreator { public: @@ -22,7 +643,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto file = m_search_path.Open(std::format("attachment/{}.json", assetName)); + const auto file = m_search_path.Open(GetJsonFileNameForAssetName(assetName)); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -30,7 +651,8 @@ namespace attachment->szInternalName = m_memory.Dup(assetName.c_str()); AssetRegistration registration(assetName, attachment); - if (!LoadWeaponAttachmentAsJson(*file.m_stream, *attachment, m_memory, context, registration)) + const JsonLoader loader(*file.m_stream, m_memory, context, registration); + if (!loader.Load(*attachment)) { std::cerr << std::format("Failed to load attachment \"{}\"\n", assetName); return AssetCreationResult::Failure(); @@ -45,10 +667,10 @@ namespace }; } // namespace -namespace IW5 +namespace IW5::attachment { - std::unique_ptr> CreateAttachmentLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW5 +} // namespace IW5::attachment diff --git a/src/ObjLoading/Game/IW5/Weapon/LoaderAttachmentIW5.h b/src/ObjLoading/Game/IW5/Weapon/LoaderAttachmentIW5.h index ec43ff96..cf793afa 100644 --- a/src/ObjLoading/Game/IW5/Weapon/LoaderAttachmentIW5.h +++ b/src/ObjLoading/Game/IW5/Weapon/LoaderAttachmentIW5.h @@ -7,7 +7,7 @@ #include -namespace IW5 +namespace IW5::attachment { - std::unique_ptr> CreateAttachmentLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW5 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace IW5::attachment diff --git a/src/ObjLoading/Game/IW5/Weapon/RawLoaderWeaponIW5.cpp b/src/ObjLoading/Game/IW5/Weapon/RawLoaderWeaponIW5.cpp index 642efa2e..2d487ae8 100644 --- a/src/ObjLoading/Game/IW5/Weapon/RawLoaderWeaponIW5.cpp +++ b/src/ObjLoading/Game/IW5/Weapon/RawLoaderWeaponIW5.cpp @@ -4,12 +4,14 @@ #include "Game/IW5/ObjConstantsIW5.h" #include "InfoString/InfoString.h" #include "InfoStringLoaderWeaponIW5.h" +#include "Weapon/WeaponCommon.h" #include #include #include using namespace IW5; +using namespace ::weapon; namespace { @@ -24,7 +26,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = std::format("weapons/{}", assetName); + const auto fileName = GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -41,14 +43,14 @@ namespace private: ISearchPath& m_search_path; - InfoStringLoaderWeapon m_info_string_loader; + IW5::weapon::InfoStringLoader m_info_string_loader; }; } // namespace -namespace IW5 +namespace IW5::weapon { - std::unique_ptr> CreateRawWeaponLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace IW5 +} // namespace IW5::weapon diff --git a/src/ObjLoading/Game/IW5/Weapon/RawLoaderWeaponIW5.h b/src/ObjLoading/Game/IW5/Weapon/RawLoaderWeaponIW5.h index d5df5fcf..ceba2d77 100644 --- a/src/ObjLoading/Game/IW5/Weapon/RawLoaderWeaponIW5.h +++ b/src/ObjLoading/Game/IW5/Weapon/RawLoaderWeaponIW5.h @@ -7,7 +7,7 @@ #include -namespace IW5 +namespace IW5::weapon { - std::unique_ptr> CreateRawWeaponLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace IW5 + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace IW5::weapon diff --git a/test/ObjLoadingTests/Game/IW5/AssetLoaders/LoaderStringTableIW5Test.cpp b/test/ObjLoadingTests/Game/IW5/AssetLoaders/LoaderStringTableIW5Test.cpp index ab5ac734..08a7b464 100644 --- a/test/ObjLoadingTests/Game/IW5/AssetLoaders/LoaderStringTableIW5Test.cpp +++ b/test/ObjLoadingTests/Game/IW5/AssetLoaders/LoaderStringTableIW5Test.cpp @@ -26,7 +26,7 @@ namespace IgnoredAssetLookup ignoredAssetLookup; AssetCreationContext context(zone, &creatorCollection, &ignoredAssetLookup); - auto loader = CreateStringTableLoader(memory, searchPath); + auto loader = string_table::CreateLoader(memory, searchPath); auto result = loader->CreateAsset("mp/cooltable.csv", context); REQUIRE(result.HasBeenSuccessful()); diff --git a/test/ObjLoadingTests/Game/IW5/Material/LoaderMaterialIW5Test.cpp b/test/ObjLoadingTests/Game/IW5/Material/LoaderMaterialIW5Test.cpp index 5de6912b..960f119d 100644 --- a/test/ObjLoadingTests/Game/IW5/Material/LoaderMaterialIW5Test.cpp +++ b/test/ObjLoadingTests/Game/IW5/Material/LoaderMaterialIW5Test.cpp @@ -313,7 +313,7 @@ namespace GivenImage("me_metal_rusty02_col", context, memory); GivenTechset("wc_l_sm_r0c0n0s0", context, memory); - auto loader = CreateMaterialLoader(memory, searchPath); + auto loader = material::CreateLoader(memory, searchPath); auto result = loader->CreateAsset("wc/me_metal_rust_02", context); REQUIRE(result.HasBeenSuccessful()); From 6806337f46ee73b7dc015c2e29811049134206d6 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Tue, 5 Aug 2025 01:13:58 +0200 Subject: [PATCH 31/35] refactor: streamline IW4 asset loading --- src/ObjCommon/Sound/SoundCurveCommon.cpp | 11 ++ src/ObjCommon/Sound/SoundCurveCommon.h | 8 ++ .../Game/IW4/Techset/CompilerTechsetIW4.cpp | 7 +- .../Leaderboard/JsonLeaderboardDefLoader.cpp | 114 ------------------ .../Leaderboard/JsonLeaderboardDefLoader.h | 11 -- .../IW4/Leaderboard/LoaderLeaderboardIW4.cpp | 106 +++++++++++++++- .../IW4/Leaderboard/LoaderLeaderboardIW4.h | 6 +- .../Game/IW4/LightDef/LightDefLoaderIW4.cpp | 6 +- .../Game/IW4/LightDef/LightDefLoaderIW4.h | 6 +- .../Game/IW4/Localize/LoaderLocalizeIW4.cpp | 6 +- .../Game/IW4/Localize/LoaderLocalizeIW4.h | 6 +- .../Game/IW4/Material/LoaderMaterialIW4.cpp | 9 +- .../Game/IW4/Material/LoaderMaterialIW4.h | 6 +- .../Game/IW4/Menu/LoaderMenuListIW4.cpp | 18 +-- .../Game/IW4/Menu/LoaderMenuListIW4.h | 4 +- .../Game/IW4/Menu/MenuConverterIW4.h | 2 +- src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp | 30 ++--- .../IW4/PhysPreset/GdtLoaderPhysPresetIW4.cpp | 57 ++++++--- .../IW4/PhysPreset/GdtLoaderPhysPresetIW4.h | 20 +-- .../InfoStringLoaderPhysPresetIW4.cpp | 47 ++++---- .../InfoStringLoaderPhysPresetIW4.h | 8 +- .../IW4/PhysPreset/RawLoaderPhysPresetIW4.cpp | 60 +++++---- .../IW4/PhysPreset/RawLoaderPhysPresetIW4.h | 19 +-- .../Game/IW4/RawFile/LoaderRawFileIW4.cpp | 6 +- .../Game/IW4/RawFile/LoaderRawFileIW4.h | 6 +- .../Game/IW4/Shader/LoaderPixelShaderIW4.cpp | 13 +- .../Game/IW4/Shader/LoaderPixelShaderIW4.h | 6 +- .../Game/IW4/Shader/LoaderVertexShaderIW4.cpp | 13 +- .../Game/IW4/Shader/LoaderVertexShaderIW4.h | 6 +- .../Game/IW4/Sound/LoaderSoundCurveIW4.cpp | 10 +- .../Game/IW4/Sound/LoaderSoundCurveIW4.h | 6 +- .../IW4/StringTable/LoaderStringTableIW4.cpp | 9 +- .../IW4/StringTable/LoaderStringTableIW4.h | 6 +- .../LoaderStructuredDataDefIW4.cpp | 6 +- .../LoaderStructuredDataDefIW4.h | 6 +- .../Game/IW4/Weapon/GdtLoaderWeaponIW4.cpp | 8 +- .../Game/IW4/Weapon/GdtLoaderWeaponIW4.h | 6 +- .../IW4/Weapon/InfoStringLoaderWeaponIW4.cpp | 51 ++++---- .../IW4/Weapon/InfoStringLoaderWeaponIW4.h | 8 +- .../Game/IW4/Weapon/RawLoaderWeaponIW4.cpp | 12 +- .../Game/IW4/Weapon/RawLoaderWeaponIW4.h | 6 +- src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 2 +- .../Game/IW4/Sound/SndCurveDumperIW4.cpp | 28 ++--- .../Game/IW4/Sound/SndCurveDumperIW4.h | 6 +- .../SndCurve => Sound}/SndCurveDumper.cpp | 0 .../SndCurve => Sound}/SndCurveDumper.h | 0 .../AssetLoaders/LoaderStringTableIW4Test.cpp | 2 +- .../IW4/Material/LoaderMaterialIW4Test.cpp | 2 +- .../Game/IW4/Menu/LoaderMenuListIW4Test.cpp | 4 +- 49 files changed, 398 insertions(+), 397 deletions(-) create mode 100644 src/ObjCommon/Sound/SoundCurveCommon.cpp create mode 100644 src/ObjCommon/Sound/SoundCurveCommon.h delete mode 100644 src/ObjLoading/Game/IW4/Leaderboard/JsonLeaderboardDefLoader.cpp delete mode 100644 src/ObjLoading/Game/IW4/Leaderboard/JsonLeaderboardDefLoader.h rename src/ObjWriting/{Dumping/SndCurve => Sound}/SndCurveDumper.cpp (100%) rename src/ObjWriting/{Dumping/SndCurve => Sound}/SndCurveDumper.h (100%) diff --git a/src/ObjCommon/Sound/SoundCurveCommon.cpp b/src/ObjCommon/Sound/SoundCurveCommon.cpp new file mode 100644 index 00000000..461a3f08 --- /dev/null +++ b/src/ObjCommon/Sound/SoundCurveCommon.cpp @@ -0,0 +1,11 @@ +#include "SoundCurveCommon.h" + +#include + +namespace sound_curve +{ + std::string GetFileNameForAssetName(const std::string& assetName) + { + return std::format("soundaliases/{}.vfcurve", assetName); + } +} // namespace sound_curve diff --git a/src/ObjCommon/Sound/SoundCurveCommon.h b/src/ObjCommon/Sound/SoundCurveCommon.h new file mode 100644 index 00000000..8ac96a84 --- /dev/null +++ b/src/ObjCommon/Sound/SoundCurveCommon.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +namespace sound_curve +{ + std::string GetFileNameForAssetName(const std::string& assetName); +} diff --git a/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.cpp b/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.cpp index bb53a3d5..321d3297 100644 --- a/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.cpp +++ b/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.cpp @@ -5,6 +5,7 @@ #include "Game/IW4/Shader/LoaderVertexShaderIW4.h" #include "Game/IW4/TechsetConstantsIW4.h" #include "Shader/D3D9ShaderAnalyser.h" +#include "Shader/ShaderCommon.h" #include "StateMap/StateMapReader.h" #include "Techset/TechniqueFileReader.h" #include "Techset/TechniqueStateMapCache.h" @@ -460,7 +461,8 @@ namespace if (pass.m_vertex_shader->Asset()->name && pass.m_vertex_shader->Asset()->name[0] == ',') { - pass.m_vertex_shader_info = m_shader_info_cache.LoadShaderInfoFromDisk(m_search_path, GetVertexShaderFileName(vertexShaderName)); + pass.m_vertex_shader_info = + m_shader_info_cache.LoadShaderInfoFromDisk(m_search_path, ::shader::GetFileNameForVertexShaderAssetName(vertexShaderName)); } else { @@ -495,7 +497,8 @@ namespace if (pass.m_pixel_shader->Asset()->name && pass.m_pixel_shader->Asset()->name[0] == ',') { - pass.m_pixel_shader_info = m_shader_info_cache.LoadShaderInfoFromDisk(m_search_path, GetPixelShaderFileName(pixelShaderName)); + pass.m_pixel_shader_info = + m_shader_info_cache.LoadShaderInfoFromDisk(m_search_path, ::shader::GetFileNameForPixelShaderAssetName(pixelShaderName)); } else { diff --git a/src/ObjLoading/Game/IW4/Leaderboard/JsonLeaderboardDefLoader.cpp b/src/ObjLoading/Game/IW4/Leaderboard/JsonLeaderboardDefLoader.cpp deleted file mode 100644 index 35c64c27..00000000 --- a/src/ObjLoading/Game/IW4/Leaderboard/JsonLeaderboardDefLoader.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include "JsonLeaderboardDefLoader.h" - -#include "Game/IW4/CommonIW4.h" -#include "Game/IW4/Leaderboard/JsonLeaderboardDef.h" - -#include -#include -#include - -using namespace nlohmann; -using namespace IW4; - -namespace -{ - class JsonLoader - { - public: - JsonLoader(std::istream& stream, MemoryManager& memory) - : m_stream(stream), - m_memory(memory) - { - } - - bool Load(LeaderboardDef& leaderboardDef) const - { - try - { - const auto jRoot = json::parse(m_stream); - std::string type; - unsigned version; - - jRoot.at("_type").get_to(type); - jRoot.at("_version").get_to(version); - - if (type != "leaderboard" || version != 1u) - { - std::cerr << std::format("Tried to load leaderboard \"{}\" but did not find expected type leaderboard of version 1\n", leaderboardDef.name); - return false; - } - - const auto jLeaderboard = jRoot.get(); - return CreateLeaderboardFromJson(jLeaderboard, leaderboardDef); - } - catch (const json::exception& e) - { - std::cerr << std::format("Failed to parse json of leaderboard: {}\n", e.what()); - } - - return false; - } - - private: - bool CreateColumnDefFromJson(const JsonColumnDef& jColumn, LbColumnDef& lbColumnDef, LeaderboardDef& leaderboardDef) const - { - lbColumnDef.name = m_memory.Dup(jColumn.name.c_str()); - - lbColumnDef.id = jColumn.colId; - lbColumnDef.propertyId = jColumn.propertyId.value_or(0); - lbColumnDef.hidden = jColumn.hidden.value_or(false); - - if (jColumn.statName) - lbColumnDef.statName = m_memory.Dup(jColumn.statName->c_str()); - else - lbColumnDef.statName = nullptr; - - lbColumnDef.type = jColumn.type; - - lbColumnDef.precision = jColumn.precision.value_or(0); - lbColumnDef.agg = jColumn.aggregationFunction; - - return true; - } - - bool CreateLeaderboardFromJson(const JsonLeaderboardDef& jLeaderboardDef, LeaderboardDef& leaderboardDef) const - { - leaderboardDef.id = jLeaderboardDef.id; - - leaderboardDef.xpColId = jLeaderboardDef.xpColId.value_or(-1); - leaderboardDef.prestigeColId = jLeaderboardDef.prestigeColId.value_or(-1); - - if (!jLeaderboardDef.columns.empty()) - { - leaderboardDef.columnCount = static_cast(jLeaderboardDef.columns.size()); - leaderboardDef.columns = m_memory.Alloc(leaderboardDef.columnCount); - - for (auto i = 0; i < leaderboardDef.columnCount; i++) - { - if (!CreateColumnDefFromJson(jLeaderboardDef.columns[i], leaderboardDef.columns[i], leaderboardDef)) - return false; - } - } - else - { - leaderboardDef.columnCount = 0; - leaderboardDef.columns = nullptr; - } - - return true; - } - - std::istream& m_stream; - MemoryManager& m_memory; - }; -} // namespace - -namespace IW4 -{ - bool LoadLeaderboardAsJson(std::istream& stream, LeaderboardDef& leaderboard, MemoryManager* memory) - { - const JsonLoader loader(stream, *memory); - - return loader.Load(leaderboard); - } -} // namespace IW4 diff --git a/src/ObjLoading/Game/IW4/Leaderboard/JsonLeaderboardDefLoader.h b/src/ObjLoading/Game/IW4/Leaderboard/JsonLeaderboardDefLoader.h deleted file mode 100644 index 22f85756..00000000 --- a/src/ObjLoading/Game/IW4/Leaderboard/JsonLeaderboardDefLoader.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "Game/IW4/IW4.h" -#include "Utils/MemoryManager.h" - -#include - -namespace IW4 -{ - bool LoadLeaderboardAsJson(std::istream& stream, LeaderboardDef& leaderboard, MemoryManager* memory); -} // namespace IW4 diff --git a/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.cpp b/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.cpp index 60f4418e..3a8b7b12 100644 --- a/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.cpp +++ b/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.cpp @@ -1,17 +1,110 @@ #include "LoaderLeaderboardIW4.h" #include "Game/IW4/IW4.h" -#include "JsonLeaderboardDefLoader.h" +#include "Game/IW4/Leaderboard/JsonLeaderboardDef.h" #include "Leaderboard/LeaderboardCommon.h" #include #include #include +#include +using namespace nlohmann; using namespace IW4; +using namespace ::leaderboard; namespace { + class JsonLoader + { + public: + JsonLoader(std::istream& stream, MemoryManager& memory) + : m_stream(stream), + m_memory(memory) + { + } + + bool Load(LeaderboardDef& leaderboardDef) const + { + try + { + const auto jRoot = json::parse(m_stream); + std::string type; + unsigned version; + + jRoot.at("_type").get_to(type); + jRoot.at("_version").get_to(version); + + if (type != "leaderboard" || version != 1u) + { + std::cerr << std::format("Tried to load leaderboard \"{}\" but did not find expected type leaderboard of version 1\n", leaderboardDef.name); + return false; + } + + const auto jLeaderboard = jRoot.get(); + return CreateLeaderboardFromJson(jLeaderboard, leaderboardDef); + } + catch (const json::exception& e) + { + std::cerr << std::format("Failed to parse json of leaderboard: {}\n", e.what()); + } + + return false; + } + + private: + bool CreateColumnDefFromJson(const JsonColumnDef& jColumn, LbColumnDef& lbColumnDef, LeaderboardDef& leaderboardDef) const + { + lbColumnDef.name = m_memory.Dup(jColumn.name.c_str()); + + lbColumnDef.id = jColumn.colId; + lbColumnDef.propertyId = jColumn.propertyId.value_or(0); + lbColumnDef.hidden = jColumn.hidden.value_or(false); + + if (jColumn.statName) + lbColumnDef.statName = m_memory.Dup(jColumn.statName->c_str()); + else + lbColumnDef.statName = nullptr; + + lbColumnDef.type = jColumn.type; + + lbColumnDef.precision = jColumn.precision.value_or(0); + lbColumnDef.agg = jColumn.aggregationFunction; + + return true; + } + + bool CreateLeaderboardFromJson(const JsonLeaderboardDef& jLeaderboardDef, LeaderboardDef& leaderboardDef) const + { + leaderboardDef.id = jLeaderboardDef.id; + + leaderboardDef.xpColId = jLeaderboardDef.xpColId.value_or(-1); + leaderboardDef.prestigeColId = jLeaderboardDef.prestigeColId.value_or(-1); + + if (!jLeaderboardDef.columns.empty()) + { + leaderboardDef.columnCount = static_cast(jLeaderboardDef.columns.size()); + leaderboardDef.columns = m_memory.Alloc(leaderboardDef.columnCount); + + for (auto i = 0; i < leaderboardDef.columnCount; i++) + { + if (!CreateColumnDefFromJson(jLeaderboardDef.columns[i], leaderboardDef.columns[i], leaderboardDef)) + return false; + } + } + else + { + leaderboardDef.columnCount = 0; + leaderboardDef.columns = nullptr; + } + + return true; + } + + std::istream& m_stream; + MemoryManager& m_memory; + }; + class LeaderboardLoader final : public AssetCreator { public: @@ -23,14 +116,15 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto file = m_search_path.Open(leaderboard::GetJsonFileNameForAsset(assetName)); + const auto file = m_search_path.Open(GetJsonFileNameForAsset(assetName)); if (!file.IsOpen()) return AssetCreationResult::NoAction(); auto* leaderboardDef = m_memory.Alloc(); leaderboardDef->name = m_memory.Dup(assetName.c_str()); - if (!LoadLeaderboardAsJson(*file.m_stream, *leaderboardDef, &m_memory)) + const JsonLoader loader(*file.m_stream, m_memory); + if (!loader.Load(*leaderboardDef)) { std::cerr << std::format("Failed to load leaderboard \"{}\"\n", assetName); return AssetCreationResult::Failure(); @@ -45,10 +139,10 @@ namespace }; } // namespace -namespace IW4 +namespace IW4::leaderboard { - std::unique_ptr> CreateLeaderboardLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4 +} // namespace IW4::leaderboard diff --git a/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.h b/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.h index 3f0a86ce..832d6b94 100644 --- a/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.h +++ b/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4 +namespace IW4::leaderboard { - std::unique_ptr> CreateLeaderboardLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace IW4::leaderboard diff --git a/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.cpp b/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.cpp index 8c610411..dacdf3d1 100644 --- a/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.cpp +++ b/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.cpp @@ -68,10 +68,10 @@ namespace }; } // namespace -namespace IW4 +namespace IW4::light_def { - std::unique_ptr> CreateLightDefLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4 +} // namespace IW4::light_def diff --git a/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.h b/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.h index 92eec1bb..96d93357 100644 --- a/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.h +++ b/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4 +namespace IW4::light_def { - std::unique_ptr> CreateLightDefLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace IW4::light_def diff --git a/src/ObjLoading/Game/IW4/Localize/LoaderLocalizeIW4.cpp b/src/ObjLoading/Game/IW4/Localize/LoaderLocalizeIW4.cpp index 795939ed..a7dc2c42 100644 --- a/src/ObjLoading/Game/IW4/Localize/LoaderLocalizeIW4.cpp +++ b/src/ObjLoading/Game/IW4/Localize/LoaderLocalizeIW4.cpp @@ -35,10 +35,10 @@ namespace }; } // namespace -namespace IW4 +namespace IW4::localize { - std::unique_ptr> CreateLocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace IW4 +} // namespace IW4::localize diff --git a/src/ObjLoading/Game/IW4/Localize/LoaderLocalizeIW4.h b/src/ObjLoading/Game/IW4/Localize/LoaderLocalizeIW4.h index c7ae0d9d..032e02d6 100644 --- a/src/ObjLoading/Game/IW4/Localize/LoaderLocalizeIW4.h +++ b/src/ObjLoading/Game/IW4/Localize/LoaderLocalizeIW4.h @@ -8,7 +8,7 @@ #include -namespace IW4 +namespace IW4::localize { - std::unique_ptr> CreateLocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace IW4 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace IW4::localize diff --git a/src/ObjLoading/Game/IW4/Material/LoaderMaterialIW4.cpp b/src/ObjLoading/Game/IW4/Material/LoaderMaterialIW4.cpp index be3bf8b0..5a37af7d 100644 --- a/src/ObjLoading/Game/IW4/Material/LoaderMaterialIW4.cpp +++ b/src/ObjLoading/Game/IW4/Material/LoaderMaterialIW4.cpp @@ -8,6 +8,7 @@ #include using namespace IW4; +using namespace ::material; namespace { @@ -22,7 +23,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto file = m_search_path.Open(material::GetFileNameForAssetName(assetName)); + const auto file = m_search_path.Open(GetFileNameForAssetName(assetName)); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -45,10 +46,10 @@ namespace }; } // namespace -namespace IW4 +namespace IW4::material { - std::unique_ptr> CreateMaterialLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4 +} // namespace IW4::material diff --git a/src/ObjLoading/Game/IW4/Material/LoaderMaterialIW4.h b/src/ObjLoading/Game/IW4/Material/LoaderMaterialIW4.h index efd0a610..8f634c0c 100644 --- a/src/ObjLoading/Game/IW4/Material/LoaderMaterialIW4.h +++ b/src/ObjLoading/Game/IW4/Material/LoaderMaterialIW4.h @@ -6,7 +6,7 @@ #include "SearchPath/ISearchPath.h" #include "Utils/MemoryManager.h" -namespace IW4 +namespace IW4::material { - std::unique_ptr> CreateMaterialLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace IW4::material diff --git a/src/ObjLoading/Game/IW4/Menu/LoaderMenuListIW4.cpp b/src/ObjLoading/Game/IW4/Menu/LoaderMenuListIW4.cpp index 52e00c74..e6e8843f 100644 --- a/src/ObjLoading/Game/IW4/Menu/LoaderMenuListIW4.cpp +++ b/src/ObjLoading/Game/IW4/Menu/LoaderMenuListIW4.cpp @@ -11,6 +11,7 @@ #include using namespace IW4; +using namespace ::menu; namespace { @@ -28,7 +29,7 @@ namespace std::vector menus; AssetRegistration registration(assetName); - auto& zoneState = context.GetZoneAssetCreationState(); + auto& zoneState = context.GetZoneAssetCreationState(); auto& conversionState = context.GetZoneAssetCreationState(); std::deque menuLoadQueue; @@ -80,7 +81,7 @@ namespace private: bool LoadMenuFileFromQueue(const std::string& menuFilePath, AssetCreationContext& context, - menu::MenuAssetZoneState& zoneState, + MenuAssetZoneState& zoneState, MenuConversionZoneState& conversionState, std::vector& menus, AssetRegistration& registration) const @@ -121,8 +122,8 @@ namespace bool ProcessParsedResults(const std::string& fileName, AssetCreationContext& context, - menu::ParsingResult& parsingResult, - menu::MenuAssetZoneState& zoneState, + ParsingResult& parsingResult, + MenuAssetZoneState& zoneState, MenuConversionZoneState& conversionState, std::vector& menus, AssetRegistration& registration) const @@ -196,10 +197,9 @@ namespace menuList.menus = nullptr; } - std::unique_ptr - ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState& zoneState) const + std::unique_ptr ParseMenuFile(std::istream& stream, const std::string& menuFileName, const MenuAssetZoneState& zoneState) const { - menu::MenuFileReader reader(stream, menuFileName, menu::FeatureLevel::IW4, m_search_path); + MenuFileReader reader(stream, menuFileName, FeatureLevel::IW4, m_search_path); reader.IncludeZoneState(zoneState); reader.SetPermissiveMode(ObjLoading::Configuration.MenuPermissiveParsing); @@ -212,10 +212,10 @@ namespace }; } // namespace -namespace IW4 +namespace IW4::menu { std::unique_ptr> CreateMenuListLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4 +} // namespace IW4::menu diff --git a/src/ObjLoading/Game/IW4/Menu/LoaderMenuListIW4.h b/src/ObjLoading/Game/IW4/Menu/LoaderMenuListIW4.h index 6a1d0499..2cb21bb3 100644 --- a/src/ObjLoading/Game/IW4/Menu/LoaderMenuListIW4.h +++ b/src/ObjLoading/Game/IW4/Menu/LoaderMenuListIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4 +namespace IW4::menu { std::unique_ptr> CreateMenuListLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4 +} // namespace IW4::menu diff --git a/src/ObjLoading/Game/IW4/Menu/MenuConverterIW4.h b/src/ObjLoading/Game/IW4/Menu/MenuConverterIW4.h index 234cedb5..8b32e98b 100644 --- a/src/ObjLoading/Game/IW4/Menu/MenuConverterIW4.h +++ b/src/ObjLoading/Game/IW4/Menu/MenuConverterIW4.h @@ -14,7 +14,7 @@ namespace IW4 IMenuConverter() = default; virtual ~IMenuConverter() = default; - virtual void ConvertMenu(const menu::CommonMenuDef& commonMenu, menuDef_t& menu, AssetRegistration& registration) = 0; + virtual void ConvertMenu(const ::menu::CommonMenuDef& commonMenu, menuDef_t& menu, AssetRegistration& registration) = 0; static std::unique_ptr Create(bool disableOptimizations, ISearchPath& searchPath, MemoryManager& memory, AssetCreationContext& context); }; diff --git a/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp b/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp index 118861ab..7e0811f6 100644 --- a/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp +++ b/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp @@ -119,19 +119,19 @@ namespace { auto& memory = zone.Memory(); - collection.AddAssetCreator(std::make_unique(memory, searchPath, zone)); - collection.AddAssetCreator(std::make_unique(memory, gdt, zone)); + collection.AddAssetCreator(phys_preset::CreateRawLoader(memory, searchPath, zone)); + collection.AddAssetCreator(phys_preset::CreateGdtLoader(memory, gdt, zone)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); collection.AddAssetCreator(xmodel::CreateXModelLoader(memory, searchPath, zone)); - collection.AddAssetCreator(CreateMaterialLoader(memory, searchPath)); - collection.AddAssetCreator(CreatePixelShaderLoader(memory, searchPath)); - collection.AddAssetCreator(CreateVertexShaderLoader(memory, searchPath)); + collection.AddAssetCreator(material::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(shader::CreatePixelShaderLoader(memory, searchPath)); + collection.AddAssetCreator(shader::CreateVertexShaderLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateSoundCurveLoader(memory, searchPath)); + collection.AddAssetCreator(sound_curve::CreateLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); @@ -140,19 +140,19 @@ namespace // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateLightDefLoader(memory, searchPath)); + collection.AddAssetCreator(light_def::CreateLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateMenuListLoader(memory, searchPath)); + collection.AddAssetCreator(menu::CreateMenuListLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateLocalizeLoader(memory, searchPath, zone)); - collection.AddAssetCreator(CreateRawWeaponLoader(memory, searchPath, zone)); - collection.AddAssetCreator(CreateGdtWeaponLoader(memory, searchPath, gdt, zone)); + collection.AddAssetCreator(localize::CreateLoader(memory, searchPath, zone)); + collection.AddAssetCreator(weapon::CreateRawLoader(memory, searchPath, zone)); + collection.AddAssetCreator(weapon::CreateGdtLoader(memory, searchPath, gdt, zone)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateRawFileLoader(memory, searchPath)); - collection.AddAssetCreator(CreateStringTableLoader(memory, searchPath)); - collection.AddAssetCreator(CreateLeaderboardLoader(memory, searchPath)); - collection.AddAssetCreator(CreateStructuredDataDefLoader(memory, searchPath)); + collection.AddAssetCreator(raw_file::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(string_table::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(leaderboard::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(structured_data_def::CreateLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); diff --git a/src/ObjLoading/Game/IW4/PhysPreset/GdtLoaderPhysPresetIW4.cpp b/src/ObjLoading/Game/IW4/PhysPreset/GdtLoaderPhysPresetIW4.cpp index afd65d70..4532e91e 100644 --- a/src/ObjLoading/Game/IW4/PhysPreset/GdtLoaderPhysPresetIW4.cpp +++ b/src/ObjLoading/Game/IW4/PhysPreset/GdtLoaderPhysPresetIW4.cpp @@ -10,26 +10,43 @@ using namespace IW4; -GdtLoaderPhysPreset::GdtLoaderPhysPreset(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone) - : m_memory(memory), - m_gdt(gdt), - m_zone(zone) +namespace { -} - -AssetCreationResult GdtLoaderPhysPreset::CreateAsset(const std::string& assetName, AssetCreationContext& context) -{ - auto* gdtEntry = m_gdt.GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_PHYS_PRESET, assetName); - if (gdtEntry == nullptr) - return AssetCreationResult::NoAction(); - - InfoString infoString; - if (!infoString.FromGdtProperties(*gdtEntry)) + class GdtLoaderPhysPreset final : public AssetCreator { - std::cerr << std::format("Failed to read phys preset gdt entry: \"{}\"\n", assetName); - return AssetCreationResult::Failure(); - } + public: + GdtLoaderPhysPreset(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone) + : m_gdt(gdt), + m_info_string_loader(memory, zone) + { + } - InfoStringLoaderPhysPreset infoStringLoader(m_memory, m_zone); - return infoStringLoader.CreateAsset(assetName, infoString, context); -} + AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override + { + const auto* gdtEntry = m_gdt.GetGdtEntryByGdfAndName(ObjConstants::GDF_FILENAME_PHYS_PRESET, assetName); + if (gdtEntry == nullptr) + return AssetCreationResult::NoAction(); + + InfoString infoString; + if (!infoString.FromGdtProperties(*gdtEntry)) + { + std::cerr << std::format("Failed to read phys preset gdt entry: \"{}\"\n", assetName); + return AssetCreationResult::Failure(); + } + + return m_info_string_loader.CreateAsset(assetName, infoString, context); + } + + private: + IGdtQueryable& m_gdt; + IW4::phys_preset::InfoStringLoader m_info_string_loader; + }; +} // namespace + +namespace IW4::phys_preset +{ + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone) + { + return std::make_unique(memory, gdt, zone); + } +} // namespace IW4::phys_preset diff --git a/src/ObjLoading/Game/IW4/PhysPreset/GdtLoaderPhysPresetIW4.h b/src/ObjLoading/Game/IW4/PhysPreset/GdtLoaderPhysPresetIW4.h index 59b65bc1..c51f29db 100644 --- a/src/ObjLoading/Game/IW4/PhysPreset/GdtLoaderPhysPresetIW4.h +++ b/src/ObjLoading/Game/IW4/PhysPreset/GdtLoaderPhysPresetIW4.h @@ -3,20 +3,12 @@ #include "Asset/IAssetCreator.h" #include "Game/IW4/IW4.h" #include "Gdt/IGdtQueryable.h" +#include "SearchPath/ISearchPath.h" #include "Utils/MemoryManager.h" -namespace IW4 +#include + +namespace IW4::phys_preset { - class GdtLoaderPhysPreset final : public AssetCreator - { - public: - GdtLoaderPhysPreset(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone); - - AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override; - - private: - MemoryManager& m_memory; - IGdtQueryable& m_gdt; - Zone& m_zone; - }; -} // namespace IW4 + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone); +} // namespace IW4::phys_preset diff --git a/src/ObjLoading/Game/IW4/PhysPreset/InfoStringLoaderPhysPresetIW4.cpp b/src/ObjLoading/Game/IW4/PhysPreset/InfoStringLoaderPhysPresetIW4.cpp index 25c8cc89..dc83cca1 100644 --- a/src/ObjLoading/Game/IW4/PhysPreset/InfoStringLoaderPhysPresetIW4.cpp +++ b/src/ObjLoading/Game/IW4/PhysPreset/InfoStringLoaderPhysPresetIW4.cpp @@ -58,30 +58,33 @@ namespace } } // namespace -InfoStringLoaderPhysPreset::InfoStringLoaderPhysPreset(MemoryManager& memory, Zone& zone) - : m_memory(memory), - m_zone(zone) +namespace IW4::phys_preset { -} - -AssetCreationResult InfoStringLoaderPhysPreset::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) -{ - PhysPresetInfo presetInfo; - std::memset(&presetInfo, 0, sizeof(presetInfo)); - - auto* physPreset = m_memory.Alloc(); - AssetRegistration registration(assetName, physPreset); - - InfoStringToPhysPresetConverter converter( - infoString, &presetInfo, m_zone.m_script_strings, m_memory, context, registration, phys_preset_fields, std::extent_v); - if (!converter.Convert()) + InfoStringLoader::InfoStringLoader(MemoryManager& memory, Zone& zone) + : m_memory(memory), + m_zone(zone) { - std::cerr << std::format("Failed to parse phys preset: \"{}\"\n", assetName); - return AssetCreationResult::Failure(); } - CopyFromPhysPresetInfo(presetInfo, *physPreset); - physPreset->name = m_memory.Dup(assetName.c_str()); + AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) + { + PhysPresetInfo presetInfo; + std::memset(&presetInfo, 0, sizeof(presetInfo)); - return AssetCreationResult::Success(context.AddAsset(std::move(registration))); -} + auto* physPreset = m_memory.Alloc(); + AssetRegistration registration(assetName, physPreset); + + InfoStringToPhysPresetConverter converter( + infoString, &presetInfo, m_zone.m_script_strings, m_memory, context, registration, phys_preset_fields, std::extent_v); + if (!converter.Convert()) + { + std::cerr << std::format("Failed to parse phys preset: \"{}\"\n", assetName); + return AssetCreationResult::Failure(); + } + + CopyFromPhysPresetInfo(presetInfo, *physPreset); + physPreset->name = m_memory.Dup(assetName.c_str()); + + return AssetCreationResult::Success(context.AddAsset(std::move(registration))); + } +} // namespace IW4::phys_preset diff --git a/src/ObjLoading/Game/IW4/PhysPreset/InfoStringLoaderPhysPresetIW4.h b/src/ObjLoading/Game/IW4/PhysPreset/InfoStringLoaderPhysPresetIW4.h index 0ca1cede..c864ca3e 100644 --- a/src/ObjLoading/Game/IW4/PhysPreset/InfoStringLoaderPhysPresetIW4.h +++ b/src/ObjLoading/Game/IW4/PhysPreset/InfoStringLoaderPhysPresetIW4.h @@ -4,12 +4,12 @@ #include "Asset/AssetCreationResult.h" #include "InfoString/InfoString.h" -namespace IW4 +namespace IW4::phys_preset { - class InfoStringLoaderPhysPreset + class InfoStringLoader { public: - InfoStringLoaderPhysPreset(MemoryManager& memory, Zone& zone); + InfoStringLoader(MemoryManager& memory, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context); @@ -17,4 +17,4 @@ namespace IW4 MemoryManager& m_memory; Zone& m_zone; }; -} // namespace IW4 +} // namespace IW4::phys_preset diff --git a/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.cpp b/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.cpp index 11bd6813..aa9b88a5 100644 --- a/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.cpp +++ b/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.cpp @@ -10,28 +10,46 @@ #include using namespace IW4; +using namespace ::phys_preset; -RawLoaderPhysPreset::RawLoaderPhysPreset(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) - : m_memory(memory), - m_search_path(searchPath), - m_zone(zone) +namespace { -} - -AssetCreationResult RawLoaderPhysPreset::CreateAsset(const std::string& assetName, AssetCreationContext& context) -{ - const auto fileName = phys_preset::GetFileNameForAssetName(assetName); - const auto file = m_search_path.Open(fileName); - if (!file.IsOpen()) - return AssetCreationResult::NoAction(); - - InfoString infoString; - if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_PHYS_PRESET, *file.m_stream)) + class RawLoaderPhysPreset final : public AssetCreator { - std::cerr << std::format("Could not parse as info string file: \"{}\"\n", fileName); - return AssetCreationResult::Failure(); - } + public: + RawLoaderPhysPreset(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + : m_search_path(searchPath), + m_info_string_loader(memory, zone) + { + } - InfoStringLoaderPhysPreset infoStringLoader(m_memory, m_zone); - return infoStringLoader.CreateAsset(assetName, infoString, context); -} + AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override + { + const auto fileName = GetFileNameForAssetName(assetName); + const auto file = m_search_path.Open(fileName); + if (!file.IsOpen()) + return AssetCreationResult::NoAction(); + + InfoString infoString; + if (!infoString.FromStream(ObjConstants::INFO_STRING_PREFIX_PHYS_PRESET, *file.m_stream)) + { + std::cerr << std::format("Could not parse as info string file: \"{}\"\n", fileName); + return AssetCreationResult::Failure(); + } + + return m_info_string_loader.CreateAsset(assetName, infoString, context); + } + + private: + ISearchPath& m_search_path; + IW4::phys_preset::InfoStringLoader m_info_string_loader; + }; +} // namespace + +namespace IW4::phys_preset +{ + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + { + return std::make_unique(memory, searchPath, zone); + } +} // namespace IW4::phys_preset diff --git a/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.h b/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.h index 1c3dd841..a711c13c 100644 --- a/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.h +++ b/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.h @@ -5,18 +5,9 @@ #include "SearchPath/ISearchPath.h" #include "Utils/MemoryManager.h" -namespace IW4 +#include + +namespace IW4::phys_preset { - class RawLoaderPhysPreset final : public AssetCreator - { - public: - RawLoaderPhysPreset(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); - - AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override; - - private: - MemoryManager& m_memory; - ISearchPath& m_search_path; - Zone& m_zone; - }; -} // namespace IW4 + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace IW4::phys_preset diff --git a/src/ObjLoading/Game/IW4/RawFile/LoaderRawFileIW4.cpp b/src/ObjLoading/Game/IW4/RawFile/LoaderRawFileIW4.cpp index 5d708aa9..381d7b16 100644 --- a/src/ObjLoading/Game/IW4/RawFile/LoaderRawFileIW4.cpp +++ b/src/ObjLoading/Game/IW4/RawFile/LoaderRawFileIW4.cpp @@ -82,10 +82,10 @@ namespace }; } // namespace -namespace IW4 +namespace IW4::raw_file { - std::unique_ptr> CreateRawFileLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4 +} // namespace IW4::raw_file diff --git a/src/ObjLoading/Game/IW4/RawFile/LoaderRawFileIW4.h b/src/ObjLoading/Game/IW4/RawFile/LoaderRawFileIW4.h index e8163342..1d483736 100644 --- a/src/ObjLoading/Game/IW4/RawFile/LoaderRawFileIW4.h +++ b/src/ObjLoading/Game/IW4/RawFile/LoaderRawFileIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4 +namespace IW4::raw_file { - std::unique_ptr> CreateRawFileLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace IW4::raw_file diff --git a/src/ObjLoading/Game/IW4/Shader/LoaderPixelShaderIW4.cpp b/src/ObjLoading/Game/IW4/Shader/LoaderPixelShaderIW4.cpp index 670e6879..6e13a9e0 100644 --- a/src/ObjLoading/Game/IW4/Shader/LoaderPixelShaderIW4.cpp +++ b/src/ObjLoading/Game/IW4/Shader/LoaderPixelShaderIW4.cpp @@ -1,12 +1,14 @@ #include "LoaderPixelShaderIW4.h" #include "Game/IW4/IW4.h" +#include "Shader/ShaderCommon.h" #include #include #include using namespace IW4; +using namespace ::shader; namespace { @@ -21,7 +23,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = GetPixelShaderFileName(assetName); + const auto fileName = GetFileNameForPixelShaderAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -53,15 +55,10 @@ namespace }; } // namespace -namespace IW4 +namespace IW4::shader { - std::string GetPixelShaderFileName(const std::string& pixelShaderAssetName) - { - return std::format("shader_bin/ps_{}.cso", pixelShaderAssetName); - } - std::unique_ptr> CreatePixelShaderLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4 +} // namespace IW4::shader diff --git a/src/ObjLoading/Game/IW4/Shader/LoaderPixelShaderIW4.h b/src/ObjLoading/Game/IW4/Shader/LoaderPixelShaderIW4.h index d29d29ba..3ea15f98 100644 --- a/src/ObjLoading/Game/IW4/Shader/LoaderPixelShaderIW4.h +++ b/src/ObjLoading/Game/IW4/Shader/LoaderPixelShaderIW4.h @@ -7,9 +7,7 @@ #include -namespace IW4 +namespace IW4::shader { - [[nodiscard]] std::string GetPixelShaderFileName(const std::string& pixelShaderAssetName); - std::unique_ptr> CreatePixelShaderLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4 +} // namespace IW4::shader diff --git a/src/ObjLoading/Game/IW4/Shader/LoaderVertexShaderIW4.cpp b/src/ObjLoading/Game/IW4/Shader/LoaderVertexShaderIW4.cpp index 6c1dd5bb..b47069f0 100644 --- a/src/ObjLoading/Game/IW4/Shader/LoaderVertexShaderIW4.cpp +++ b/src/ObjLoading/Game/IW4/Shader/LoaderVertexShaderIW4.cpp @@ -1,12 +1,14 @@ #include "LoaderVertexShaderIW4.h" #include "Game/IW4/IW4.h" +#include "Shader/ShaderCommon.h" #include #include #include using namespace IW4; +using namespace ::shader; namespace { @@ -21,7 +23,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = GetVertexShaderFileName(assetName); + const auto fileName = GetFileNameForVertexShaderAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -53,15 +55,10 @@ namespace }; } // namespace -namespace IW4 +namespace IW4::shader { - std::string GetVertexShaderFileName(const std::string& vertexShaderAssetName) - { - return std::format("shader_bin/vs_{}.cso", vertexShaderAssetName); - } - std::unique_ptr> CreateVertexShaderLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4 +} // namespace IW4::shader diff --git a/src/ObjLoading/Game/IW4/Shader/LoaderVertexShaderIW4.h b/src/ObjLoading/Game/IW4/Shader/LoaderVertexShaderIW4.h index e8139af0..7cc7e600 100644 --- a/src/ObjLoading/Game/IW4/Shader/LoaderVertexShaderIW4.h +++ b/src/ObjLoading/Game/IW4/Shader/LoaderVertexShaderIW4.h @@ -7,9 +7,7 @@ #include -namespace IW4 +namespace IW4::shader { - [[nodiscard]] std::string GetVertexShaderFileName(const std::string& vertexShaderAssetName); - std::unique_ptr> CreateVertexShaderLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4 +} // namespace IW4::shader diff --git a/src/ObjLoading/Game/IW4/Sound/LoaderSoundCurveIW4.cpp b/src/ObjLoading/Game/IW4/Sound/LoaderSoundCurveIW4.cpp index 5f760754..84a88655 100644 --- a/src/ObjLoading/Game/IW4/Sound/LoaderSoundCurveIW4.cpp +++ b/src/ObjLoading/Game/IW4/Sound/LoaderSoundCurveIW4.cpp @@ -4,6 +4,7 @@ #include "ObjLoading.h" #include "Parsing/Graph2D/Graph2DReader.h" #include "Pool/GlobalAssetPool.h" +#include "Sound/SoundCurveCommon.h" #include #include @@ -11,6 +12,7 @@ #include using namespace IW4; +using namespace ::sound_curve; namespace { @@ -25,7 +27,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = std::format("soundaliases/{}.vfcurve", assetName); + const auto fileName = GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -69,10 +71,10 @@ namespace }; } // namespace -namespace IW4 +namespace IW4::sound_curve { - std::unique_ptr> CreateSoundCurveLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4 +} // namespace IW4::sound_curve diff --git a/src/ObjLoading/Game/IW4/Sound/LoaderSoundCurveIW4.h b/src/ObjLoading/Game/IW4/Sound/LoaderSoundCurveIW4.h index 19f1bb3c..808cc0e1 100644 --- a/src/ObjLoading/Game/IW4/Sound/LoaderSoundCurveIW4.h +++ b/src/ObjLoading/Game/IW4/Sound/LoaderSoundCurveIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4 +namespace IW4::sound_curve { - std::unique_ptr> CreateSoundCurveLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace IW4::sound_curve diff --git a/src/ObjLoading/Game/IW4/StringTable/LoaderStringTableIW4.cpp b/src/ObjLoading/Game/IW4/StringTable/LoaderStringTableIW4.cpp index d4530772..d19d32d1 100644 --- a/src/ObjLoading/Game/IW4/StringTable/LoaderStringTableIW4.cpp +++ b/src/ObjLoading/Game/IW4/StringTable/LoaderStringTableIW4.cpp @@ -6,6 +6,7 @@ #include "StringTable/StringTableLoader.h" using namespace IW4; +using namespace ::string_table; namespace { @@ -24,7 +25,7 @@ namespace if (!file.IsOpen()) return AssetCreationResult::NoAction(); - string_table::StringTableLoaderV2 loader; + StringTableLoaderV2 loader; auto* stringTable = loader.LoadFromStream(assetName, m_memory, *file.m_stream); if (!stringTable) return AssetCreationResult::Failure(); @@ -38,10 +39,10 @@ namespace }; } // namespace -namespace IW4 +namespace IW4::string_table { - std::unique_ptr> CreateStringTableLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4 +} // namespace IW4::string_table diff --git a/src/ObjLoading/Game/IW4/StringTable/LoaderStringTableIW4.h b/src/ObjLoading/Game/IW4/StringTable/LoaderStringTableIW4.h index c9cbd55f..5bba65f4 100644 --- a/src/ObjLoading/Game/IW4/StringTable/LoaderStringTableIW4.h +++ b/src/ObjLoading/Game/IW4/StringTable/LoaderStringTableIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4 +namespace IW4::string_table { - std::unique_ptr> CreateStringTableLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace IW4::string_table diff --git a/src/ObjLoading/Game/IW4/StructuredDataDef/LoaderStructuredDataDefIW4.cpp b/src/ObjLoading/Game/IW4/StructuredDataDef/LoaderStructuredDataDefIW4.cpp index 6f662ab2..8dad6ce2 100644 --- a/src/ObjLoading/Game/IW4/StructuredDataDef/LoaderStructuredDataDefIW4.cpp +++ b/src/ObjLoading/Game/IW4/StructuredDataDef/LoaderStructuredDataDefIW4.cpp @@ -207,10 +207,10 @@ namespace }; } // namespace -namespace IW4 +namespace IW4::structured_data_def { - std::unique_ptr> CreateStructuredDataDefLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4 +} // namespace IW4::structured_data_def diff --git a/src/ObjLoading/Game/IW4/StructuredDataDef/LoaderStructuredDataDefIW4.h b/src/ObjLoading/Game/IW4/StructuredDataDef/LoaderStructuredDataDefIW4.h index 22d40f09..c3670e25 100644 --- a/src/ObjLoading/Game/IW4/StructuredDataDef/LoaderStructuredDataDefIW4.h +++ b/src/ObjLoading/Game/IW4/StructuredDataDef/LoaderStructuredDataDefIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4 +namespace IW4::structured_data_def { - std::unique_ptr> CreateStructuredDataDefLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace IW4::structured_data_def diff --git a/src/ObjLoading/Game/IW4/Weapon/GdtLoaderWeaponIW4.cpp b/src/ObjLoading/Game/IW4/Weapon/GdtLoaderWeaponIW4.cpp index 9b585add..ecd7f59a 100644 --- a/src/ObjLoading/Game/IW4/Weapon/GdtLoaderWeaponIW4.cpp +++ b/src/ObjLoading/Game/IW4/Weapon/GdtLoaderWeaponIW4.cpp @@ -40,14 +40,14 @@ namespace private: IGdtQueryable& m_gdt; - InfoStringLoaderWeapon m_info_string_loader; + IW4::weapon::InfoStringLoader m_info_string_loader; }; } // namespace -namespace IW4 +namespace IW4::weapon { - std::unique_ptr> CreateGdtWeaponLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) { return std::make_unique(memory, searchPath, gdt, zone); } -} // namespace IW4 +} // namespace IW4::weapon diff --git a/src/ObjLoading/Game/IW4/Weapon/GdtLoaderWeaponIW4.h b/src/ObjLoading/Game/IW4/Weapon/GdtLoaderWeaponIW4.h index 44a699b8..ce66f584 100644 --- a/src/ObjLoading/Game/IW4/Weapon/GdtLoaderWeaponIW4.h +++ b/src/ObjLoading/Game/IW4/Weapon/GdtLoaderWeaponIW4.h @@ -8,7 +8,7 @@ #include -namespace IW4 +namespace IW4::weapon { - std::unique_ptr> CreateGdtWeaponLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); -} // namespace IW4 + std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); +} // namespace IW4::weapon diff --git a/src/ObjLoading/Game/IW4/Weapon/InfoStringLoaderWeaponIW4.cpp b/src/ObjLoading/Game/IW4/Weapon/InfoStringLoaderWeaponIW4.cpp index e44ef3c2..bd38e04a 100644 --- a/src/ObjLoading/Game/IW4/Weapon/InfoStringLoaderWeaponIW4.cpp +++ b/src/ObjLoading/Game/IW4/Weapon/InfoStringLoaderWeaponIW4.cpp @@ -426,33 +426,36 @@ namespace } } // namespace -InfoStringLoaderWeapon::InfoStringLoaderWeapon(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) - : m_memory(memory), - m_search_path(searchPath), - m_zone(zone) +namespace IW4::weapon { -} - -AssetCreationResult InfoStringLoaderWeapon::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) -{ - auto* weaponFullDef = m_memory.Alloc(); - - InitWeaponFullDef(*weaponFullDef); - weaponFullDef->weapCompleteDef.szInternalName = m_memory.Dup(assetName.c_str()); - - AssetRegistration registration(assetName, &weaponFullDef->weapCompleteDef); - - InfoStringToWeaponConverter converter( - infoString, *weaponFullDef, m_zone.m_script_strings, m_memory, context, registration, weapon_fields, std::extent_v); - if (!converter.Convert()) + InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + : m_memory(memory), + m_search_path(searchPath), + m_zone(zone) { - std::cerr << std::format("Failed to parse weapon: \"{}\"\n", assetName); - return AssetCreationResult::Failure(); } - CalculateWeaponFields(*weaponFullDef, m_memory); + AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) + { + auto* weaponFullDef = m_memory.Alloc(); - LoadAccuracyGraphs(*weaponFullDef, m_memory, m_search_path, context); + InitWeaponFullDef(*weaponFullDef); + weaponFullDef->weapCompleteDef.szInternalName = m_memory.Dup(assetName.c_str()); - return AssetCreationResult::Success(context.AddAsset(std::move(registration))); -} + AssetRegistration registration(assetName, &weaponFullDef->weapCompleteDef); + + InfoStringToWeaponConverter converter( + infoString, *weaponFullDef, m_zone.m_script_strings, m_memory, context, registration, weapon_fields, std::extent_v); + if (!converter.Convert()) + { + std::cerr << std::format("Failed to parse weapon: \"{}\"\n", assetName); + return AssetCreationResult::Failure(); + } + + CalculateWeaponFields(*weaponFullDef, m_memory); + + LoadAccuracyGraphs(*weaponFullDef, m_memory, m_search_path, context); + + return AssetCreationResult::Success(context.AddAsset(std::move(registration))); + } +} // namespace IW4::weapon diff --git a/src/ObjLoading/Game/IW4/Weapon/InfoStringLoaderWeaponIW4.h b/src/ObjLoading/Game/IW4/Weapon/InfoStringLoaderWeaponIW4.h index 59204d85..d1ba5d80 100644 --- a/src/ObjLoading/Game/IW4/Weapon/InfoStringLoaderWeaponIW4.h +++ b/src/ObjLoading/Game/IW4/Weapon/InfoStringLoaderWeaponIW4.h @@ -4,12 +4,12 @@ #include "Asset/AssetCreationResult.h" #include "InfoString/InfoString.h" -namespace IW4 +namespace IW4::weapon { - class InfoStringLoaderWeapon + class InfoStringLoader { public: - InfoStringLoaderWeapon(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); + InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context); @@ -18,4 +18,4 @@ namespace IW4 ISearchPath& m_search_path; Zone& m_zone; }; -} // namespace IW4 +} // namespace IW4::weapon diff --git a/src/ObjLoading/Game/IW4/Weapon/RawLoaderWeaponIW4.cpp b/src/ObjLoading/Game/IW4/Weapon/RawLoaderWeaponIW4.cpp index a1b7b656..2b4b4283 100644 --- a/src/ObjLoading/Game/IW4/Weapon/RawLoaderWeaponIW4.cpp +++ b/src/ObjLoading/Game/IW4/Weapon/RawLoaderWeaponIW4.cpp @@ -4,12 +4,14 @@ #include "Game/IW4/ObjConstantsIW4.h" #include "InfoString/InfoString.h" #include "InfoStringLoaderWeaponIW4.h" +#include "Weapon/WeaponCommon.h" #include #include #include using namespace IW4; +using namespace ::weapon; namespace { @@ -24,7 +26,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = std::format("weapons/{}", assetName); + const auto fileName = GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -41,14 +43,14 @@ namespace private: ISearchPath& m_search_path; - InfoStringLoaderWeapon m_info_string_loader; + IW4::weapon::InfoStringLoader m_info_string_loader; }; } // namespace -namespace IW4 +namespace IW4::weapon { - std::unique_ptr> CreateRawWeaponLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace IW4 +} // namespace IW4::weapon diff --git a/src/ObjLoading/Game/IW4/Weapon/RawLoaderWeaponIW4.h b/src/ObjLoading/Game/IW4/Weapon/RawLoaderWeaponIW4.h index 786d7ce3..e8995ac3 100644 --- a/src/ObjLoading/Game/IW4/Weapon/RawLoaderWeaponIW4.h +++ b/src/ObjLoading/Game/IW4/Weapon/RawLoaderWeaponIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4 +namespace IW4::weapon { - std::unique_ptr> CreateRawWeaponLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace IW4 + std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace IW4::weapon diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 75d93683..0a39cf0e 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -52,7 +52,7 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const DUMP_ASSET_POOL(techset::Dumper, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) // DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND) - DUMP_ASSET_POOL(sound::SndCurveDumper, m_sound_curve, ASSET_TYPE_SOUND_CURVE) + DUMP_ASSET_POOL(sound_curve::Dumper, m_sound_curve, ASSET_TYPE_SOUND_CURVE) DUMP_ASSET_POOL(sound::LoadedSoundDumper, m_loaded_sound, ASSET_TYPE_LOADED_SOUND) // DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_MP) // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD) diff --git a/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.cpp b/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.cpp index f5a38e94..69b51223 100644 --- a/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.cpp @@ -1,40 +1,30 @@ #include "SndCurveDumperIW4.h" -#include "Dumping/SndCurve/SndCurveDumper.h" +#include "Sound/SndCurveDumper.h" +#include "Sound/SoundCurveCommon.h" #include using namespace IW4; +using namespace ::sound_curve; -namespace +namespace IW4::sound_curve { - std::string GetAssetFilename(const std::string& assetName) - { - std::ostringstream ss; - - ss << "soundaliases/" << assetName << ".vfcurve"; - - return ss.str(); - } -} // namespace - -namespace IW4::sound -{ - bool SndCurveDumper::ShouldDump(XAssetInfo* asset) + bool Dumper::ShouldDump(XAssetInfo* asset) { return true; } - void SndCurveDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* sndCurve = asset->Asset(); - const auto assetFile = context.OpenAssetFile(GetAssetFilename(sndCurve->filename)); + const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(sndCurve->filename)); if (!assetFile) return; - ::SndCurveDumper dumper(*assetFile); + SndCurveDumper dumper(*assetFile); const auto knotCount = std::min(static_cast(sndCurve->knotCount), std::extent_v); dumper.Init(knotCount); @@ -42,4 +32,4 @@ namespace IW4::sound for (auto i = 0u; i < knotCount; i++) dumper.WriteKnot(sndCurve->knots[i][0], sndCurve->knots[i][1]); } -} // namespace IW4::sound +} // namespace IW4::sound_curve diff --git a/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.h b/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.h index 18cc1264..85ff48a1 100644 --- a/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4::sound +namespace IW4::sound_curve { - class SndCurveDumper final : public AbstractAssetDumper + class Dumper final : public AbstractAssetDumper { protected: bool ShouldDump(XAssetInfo* asset) override; void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4::sound +} // namespace IW4::sound_curve diff --git a/src/ObjWriting/Dumping/SndCurve/SndCurveDumper.cpp b/src/ObjWriting/Sound/SndCurveDumper.cpp similarity index 100% rename from src/ObjWriting/Dumping/SndCurve/SndCurveDumper.cpp rename to src/ObjWriting/Sound/SndCurveDumper.cpp diff --git a/src/ObjWriting/Dumping/SndCurve/SndCurveDumper.h b/src/ObjWriting/Sound/SndCurveDumper.h similarity index 100% rename from src/ObjWriting/Dumping/SndCurve/SndCurveDumper.h rename to src/ObjWriting/Sound/SndCurveDumper.h diff --git a/test/ObjLoadingTests/Game/IW4/AssetLoaders/LoaderStringTableIW4Test.cpp b/test/ObjLoadingTests/Game/IW4/AssetLoaders/LoaderStringTableIW4Test.cpp index 88fbe000..ff4c5c56 100644 --- a/test/ObjLoadingTests/Game/IW4/AssetLoaders/LoaderStringTableIW4Test.cpp +++ b/test/ObjLoadingTests/Game/IW4/AssetLoaders/LoaderStringTableIW4Test.cpp @@ -27,7 +27,7 @@ namespace IgnoredAssetLookup ignoredAssetLookup; AssetCreationContext context(zone, &creatorCollection, &ignoredAssetLookup); - auto loader = CreateStringTableLoader(memory, searchPath); + auto loader = string_table::CreateLoader(memory, searchPath); auto result = loader->CreateAsset("mp/cooltable.csv", context); REQUIRE(result.HasBeenSuccessful()); diff --git a/test/ObjLoadingTests/Game/IW4/Material/LoaderMaterialIW4Test.cpp b/test/ObjLoadingTests/Game/IW4/Material/LoaderMaterialIW4Test.cpp index 0860550b..6af6297d 100644 --- a/test/ObjLoadingTests/Game/IW4/Material/LoaderMaterialIW4Test.cpp +++ b/test/ObjLoadingTests/Game/IW4/Material/LoaderMaterialIW4Test.cpp @@ -289,7 +289,7 @@ namespace GivenImage("ch_rubble01_col", context, memory); GivenTechset("mc_l_sm_r0c0n0s0", context, memory); - auto loader = CreateMaterialLoader(memory, searchPath); + auto loader = material::CreateLoader(memory, searchPath); auto result = loader->CreateAsset("mc/ch_rubble01", context); REQUIRE(result.HasBeenSuccessful()); diff --git a/test/ObjLoadingTests/Game/IW4/Menu/LoaderMenuListIW4Test.cpp b/test/ObjLoadingTests/Game/IW4/Menu/LoaderMenuListIW4Test.cpp index 69021fe5..d246deb2 100644 --- a/test/ObjLoadingTests/Game/IW4/Menu/LoaderMenuListIW4Test.cpp +++ b/test/ObjLoadingTests/Game/IW4/Menu/LoaderMenuListIW4Test.cpp @@ -11,7 +11,7 @@ #include #include -using namespace menu; +using namespace ::menu; using namespace IW4; using namespace std::literals; using namespace Catch::Matchers; @@ -36,7 +36,7 @@ namespace test::game::iw4::menu::parsing::it m_ignored_asset_lookup(), m_context(m_zone, &m_creator_collection, &m_ignored_asset_lookup) { - m_asset_creator = CreateMenuListLoader(m_zone.Memory(), m_search_path); + m_asset_creator = IW4::menu::CreateMenuListLoader(m_zone.Memory(), m_search_path); } void AddFile(std::string fileName, std::string data) From 95a6a028aba821662554a0ac1816195b7377e151 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Tue, 5 Aug 2025 01:22:39 +0200 Subject: [PATCH 32/35] refactor: streamline IW3 asset loading --- src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.cpp | 6 +++--- src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.h | 6 +++--- .../Game/IW3/Localize/AssetLoaderLocalizeIW3.cpp | 6 +++--- .../Game/IW3/Localize/AssetLoaderLocalizeIW3.h | 6 +++--- src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.cpp | 9 +++++---- src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.h | 6 +++--- src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp | 10 +++++----- .../Game/IW3/RawFile/AssetLoaderRawFileIW3.cpp | 6 +++--- .../Game/IW3/RawFile/AssetLoaderRawFileIW3.h | 6 +++--- .../Game/IW3/StringTable/AssetLoaderStringTableIW3.cpp | 9 +++++---- .../Game/IW3/StringTable/AssetLoaderStringTableIW3.h | 6 +++--- .../Game/IW3/Material/LoaderMaterialIW3Test.cpp | 2 +- .../IW3/StringTable/AssetLoaderStringTableIW3Test.cpp | 2 +- 13 files changed, 41 insertions(+), 39 deletions(-) diff --git a/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.cpp b/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.cpp index a4d921c8..8518ffaf 100644 --- a/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.cpp +++ b/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.cpp @@ -122,10 +122,10 @@ namespace }; } // namespace -namespace IW3 +namespace IW3::image { - std::unique_ptr> CreateImageLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW3 +} // namespace IW3::image diff --git a/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.h b/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.h index ce4dbb81..37bc8cb4 100644 --- a/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.h +++ b/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.h @@ -7,7 +7,7 @@ #include -namespace IW3 +namespace IW3::image { - std::unique_ptr> CreateImageLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW3 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace IW3::image diff --git a/src/ObjLoading/Game/IW3/Localize/AssetLoaderLocalizeIW3.cpp b/src/ObjLoading/Game/IW3/Localize/AssetLoaderLocalizeIW3.cpp index c7f2572f..e56a904c 100644 --- a/src/ObjLoading/Game/IW3/Localize/AssetLoaderLocalizeIW3.cpp +++ b/src/ObjLoading/Game/IW3/Localize/AssetLoaderLocalizeIW3.cpp @@ -36,10 +36,10 @@ namespace }; } // namespace -namespace IW3 +namespace IW3::localize { - std::unique_ptr> CreateLocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace IW3 +} // namespace IW3::localize diff --git a/src/ObjLoading/Game/IW3/Localize/AssetLoaderLocalizeIW3.h b/src/ObjLoading/Game/IW3/Localize/AssetLoaderLocalizeIW3.h index 5469d4ca..447a6a90 100644 --- a/src/ObjLoading/Game/IW3/Localize/AssetLoaderLocalizeIW3.h +++ b/src/ObjLoading/Game/IW3/Localize/AssetLoaderLocalizeIW3.h @@ -8,7 +8,7 @@ #include -namespace IW3 +namespace IW3::localize { - std::unique_ptr> CreateLocalizeLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace IW3 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace IW3::localize diff --git a/src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.cpp b/src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.cpp index aec04c81..769e6b71 100644 --- a/src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.cpp +++ b/src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.cpp @@ -8,6 +8,7 @@ #include using namespace IW3; +using namespace ::material; namespace { @@ -22,7 +23,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto file = m_search_path.Open(material::GetFileNameForAssetName(assetName)); + const auto file = m_search_path.Open(GetFileNameForAssetName(assetName)); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -45,10 +46,10 @@ namespace }; } // namespace -namespace IW3 +namespace IW3::material { - std::unique_ptr> CreateMaterialLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW3 +} // namespace IW3::material diff --git a/src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.h b/src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.h index 8d2dd024..2bfa9db1 100644 --- a/src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.h +++ b/src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.h @@ -6,7 +6,7 @@ #include "SearchPath/ISearchPath.h" #include "Utils/MemoryManager.h" -namespace IW3 +namespace IW3::material { - std::unique_ptr> CreateMaterialLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW3 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace IW3::material diff --git a/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp b/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp index c1c5c512..12583d1a 100644 --- a/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp +++ b/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp @@ -92,9 +92,9 @@ namespace // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); collection.AddAssetCreator(xmodel::CreateXModelLoader(memory, searchPath, zone)); - collection.AddAssetCreator(CreateMaterialLoader(memory, searchPath)); + collection.AddAssetCreator(material::CreateLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateImageLoader(memory, searchPath)); + collection.AddAssetCreator(image::CreateLoader(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); @@ -108,13 +108,13 @@ namespace // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateLocalizeLoader(memory, searchPath, zone)); + collection.AddAssetCreator(localize::CreateLoader(memory, searchPath, zone)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(CreateRawFileLoader(memory, searchPath)); - collection.AddAssetCreator(CreateStringTableLoader(memory, searchPath)); + collection.AddAssetCreator(raw_file::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(string_table::CreateLoader(memory, searchPath)); } } // namespace diff --git a/src/ObjLoading/Game/IW3/RawFile/AssetLoaderRawFileIW3.cpp b/src/ObjLoading/Game/IW3/RawFile/AssetLoaderRawFileIW3.cpp index 92a19b21..6229ac79 100644 --- a/src/ObjLoading/Game/IW3/RawFile/AssetLoaderRawFileIW3.cpp +++ b/src/ObjLoading/Game/IW3/RawFile/AssetLoaderRawFileIW3.cpp @@ -44,10 +44,10 @@ namespace }; } // namespace -namespace IW3 +namespace IW3::raw_file { - std::unique_ptr> CreateRawFileLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW3 +} // namespace IW3::raw_file diff --git a/src/ObjLoading/Game/IW3/RawFile/AssetLoaderRawFileIW3.h b/src/ObjLoading/Game/IW3/RawFile/AssetLoaderRawFileIW3.h index cddae3ea..d3c74f6d 100644 --- a/src/ObjLoading/Game/IW3/RawFile/AssetLoaderRawFileIW3.h +++ b/src/ObjLoading/Game/IW3/RawFile/AssetLoaderRawFileIW3.h @@ -7,7 +7,7 @@ #include -namespace IW3 +namespace IW3::raw_file { - std::unique_ptr> CreateRawFileLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW3 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace IW3::raw_file diff --git a/src/ObjLoading/Game/IW3/StringTable/AssetLoaderStringTableIW3.cpp b/src/ObjLoading/Game/IW3/StringTable/AssetLoaderStringTableIW3.cpp index bb7303ec..bcb640ec 100644 --- a/src/ObjLoading/Game/IW3/StringTable/AssetLoaderStringTableIW3.cpp +++ b/src/ObjLoading/Game/IW3/StringTable/AssetLoaderStringTableIW3.cpp @@ -6,6 +6,7 @@ #include using namespace IW3; +using namespace ::string_table; namespace { @@ -24,7 +25,7 @@ namespace if (!file.IsOpen()) return AssetCreationResult::NoAction(); - string_table::StringTableLoaderV1 loader; + StringTableLoaderV1 loader; auto* stringTable = loader.LoadFromStream(assetName, m_memory, *file.m_stream); if (!stringTable) return AssetCreationResult::Failure(); @@ -38,10 +39,10 @@ namespace }; } // namespace -namespace IW3 +namespace IW3::string_table { - std::unique_ptr> CreateStringTableLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW3 +} // namespace IW3::string_table diff --git a/src/ObjLoading/Game/IW3/StringTable/AssetLoaderStringTableIW3.h b/src/ObjLoading/Game/IW3/StringTable/AssetLoaderStringTableIW3.h index 76702596..497617e3 100644 --- a/src/ObjLoading/Game/IW3/StringTable/AssetLoaderStringTableIW3.h +++ b/src/ObjLoading/Game/IW3/StringTable/AssetLoaderStringTableIW3.h @@ -7,7 +7,7 @@ #include -namespace IW3 +namespace IW3::string_table { - std::unique_ptr> CreateStringTableLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW3 + std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace IW3::string_table diff --git a/test/ObjLoadingTests/Game/IW3/Material/LoaderMaterialIW3Test.cpp b/test/ObjLoadingTests/Game/IW3/Material/LoaderMaterialIW3Test.cpp index 1a469c62..76c8c87c 100644 --- a/test/ObjLoadingTests/Game/IW3/Material/LoaderMaterialIW3Test.cpp +++ b/test/ObjLoadingTests/Game/IW3/Material/LoaderMaterialIW3Test.cpp @@ -286,7 +286,7 @@ namespace GivenImage("ch_plasterwall_long_col", context, memory); GivenTechset("wc_l_sm_r0c0n0s0", context, memory); - auto loader = CreateMaterialLoader(memory, searchPath); + auto loader = material::CreateLoader(memory, searchPath); auto result = loader->CreateAsset("wc/ch_plasterwall_long", context); REQUIRE(result.HasBeenSuccessful()); diff --git a/test/ObjLoadingTests/Game/IW3/StringTable/AssetLoaderStringTableIW3Test.cpp b/test/ObjLoadingTests/Game/IW3/StringTable/AssetLoaderStringTableIW3Test.cpp index 36ee0347..22195105 100644 --- a/test/ObjLoadingTests/Game/IW3/StringTable/AssetLoaderStringTableIW3Test.cpp +++ b/test/ObjLoadingTests/Game/IW3/StringTable/AssetLoaderStringTableIW3Test.cpp @@ -27,7 +27,7 @@ namespace IgnoredAssetLookup ignoredAssetLookup; AssetCreationContext context(zone, &creatorCollection, &ignoredAssetLookup); - auto loader = CreateStringTableLoader(memory, searchPath); + auto loader = string_table::CreateLoader(memory, searchPath); auto result = loader->CreateAsset("mp/cooltable.csv", context); REQUIRE(result.HasBeenSuccessful()); From 33c09dfe617e6e970321b1f22a9db1042297a122 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Tue, 5 Aug 2025 18:51:56 +0200 Subject: [PATCH 33/35] refactor: streamline obj compiling asset loading --- src/ObjCommon/Techset/TechsetCommon.cpp | 5 + src/ObjCommon/Techset/TechsetCommon.h | 1 + src/ObjCompiling/Game/IW3/ObjCompilerIW3.cpp | 4 +- .../Game/IW4/Material/CompilerMaterialIW4.cpp | 27 ++-- .../Game/IW4/Material/CompilerMaterialIW4.h | 6 +- src/ObjCompiling/Game/IW4/ObjCompilerIW4.cpp | 10 +- .../Game/IW4/Techset/CompilerTechsetIW4.cpp | 146 ++++++++---------- .../Game/IW4/Techset/CompilerTechsetIW4.h | 18 +-- .../IW4/Techset/CompilerVertexDeclIW4.cpp | 6 +- .../Game/IW4/Techset/CompilerVertexDeclIW4.h | 6 +- src/ObjCompiling/Game/IW5/ObjCompilerIW5.cpp | 4 +- src/ObjCompiling/Game/T5/ObjCompilerT5.cpp | 4 +- .../Game/T6/Image/ImageCompilerT6.cpp | 0 .../Game/T6/Image/ImageCompilerT6.h | 0 .../KeyValuePairs/KeyValuePairsCompilerT6.cpp | 10 +- .../KeyValuePairs/KeyValuePairsCompilerT6.h | 6 +- src/ObjCompiling/Game/T6/ObjCompilerT6.cpp | 10 +- src/ObjCompiling/Image/IPak/IPakCreator.cpp | 105 +++++++------ src/ObjCompiling/Image/IPak/IPakCreator.h | 47 +++--- .../Image/ImageIPakPostProcessor.cpp | 107 ++++++------- .../Image/ImageIPakPostProcessor.h | 85 +++++----- .../Image/ImageIwdPostProcessor.cpp | 108 ++++++------- .../Image/ImageIwdPostProcessor.h | 82 +++++----- .../KeyValuePairs/KeyValuePairsCreator.cpp | 123 ++++++++------- .../KeyValuePairs/KeyValuePairsCreator.h | 37 +++-- src/ObjLoading/Techset/TechniqueFileReader.h | 11 +- .../KeyValuePairsCompilerT6Test.cpp | 10 +- .../Image/IPak/IPakCreatorTest.cpp | 4 +- .../Image/ImageIPakPostProcessorTest.cpp | 6 +- .../Image/ImageIwdPostProcessorTest.cpp | 2 +- .../KeyValuePairsCreatorTest.cpp | 10 +- 31 files changed, 505 insertions(+), 495 deletions(-) delete mode 100644 src/ObjCompiling/Game/T6/Image/ImageCompilerT6.cpp delete mode 100644 src/ObjCompiling/Game/T6/Image/ImageCompilerT6.h diff --git a/src/ObjCommon/Techset/TechsetCommon.cpp b/src/ObjCommon/Techset/TechsetCommon.cpp index f8e75ea5..f21097bd 100644 --- a/src/ObjCommon/Techset/TechsetCommon.cpp +++ b/src/ObjCommon/Techset/TechsetCommon.cpp @@ -4,6 +4,11 @@ namespace techset { + std::string GetFileNameForStateMapName(const std::string& stateMapName) + { + return std::format("statemaps/{}.sm", stateMapName); + } + std::string GetFileNameForTechniqueName(const std::string& assetName) { return std::format("techniques/{}.tech", assetName); diff --git a/src/ObjCommon/Techset/TechsetCommon.h b/src/ObjCommon/Techset/TechsetCommon.h index 510b9122..ad65b5df 100644 --- a/src/ObjCommon/Techset/TechsetCommon.h +++ b/src/ObjCommon/Techset/TechsetCommon.h @@ -4,6 +4,7 @@ namespace techset { + std::string GetFileNameForStateMapName(const std::string& stateMapName); std::string GetFileNameForTechniqueName(const std::string& assetName); std::string GetFileNameForTechsetName(const std::string& assetName); } // namespace techset diff --git a/src/ObjCompiling/Game/IW3/ObjCompilerIW3.cpp b/src/ObjCompiling/Game/IW3/ObjCompilerIW3.cpp index 02e34655..29ea2ee1 100644 --- a/src/ObjCompiling/Game/IW3/ObjCompilerIW3.cpp +++ b/src/ObjCompiling/Game/IW3/ObjCompilerIW3.cpp @@ -25,8 +25,8 @@ namespace { auto& memory = zone.Memory(); - if (ImageIwdPostProcessor::AppliesToZoneDefinition(zoneDefinition)) - collection.AddAssetPostProcessor(std::make_unique>(zoneDefinition, searchPath, zoneStates, outDir)); + if (image::IwdPostProcessor::AppliesToZoneDefinition(zoneDefinition)) + collection.AddAssetPostProcessor(std::make_unique>(zoneDefinition, searchPath, zoneStates, outDir)); } } // namespace diff --git a/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.cpp b/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.cpp index 7b54ceaa..0fc61324 100644 --- a/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.cpp +++ b/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.cpp @@ -14,6 +14,7 @@ #include "StateMap/StateMapHandler.h" #include "Techset/TechniqueFileReader.h" #include "Techset/TechniqueStateMapCache.h" +#include "Techset/TechsetCommon.h" #include "Techset/TechsetDefinitionCache.h" #include @@ -45,9 +46,9 @@ namespace m_search_path(searchPath), m_context(context), m_registration(registration), - m_state_map_cache(context.GetZoneAssetCreationState()), + m_state_map_cache(context.GetZoneAssetCreationState<::techset::TechniqueStateMapCache>()), m_base_state_bits{}, - m_techset_creator(CreateTechsetLoader(memory, searchPath)) + m_techset_creator(IW4::techset::CreateLoader(memory, searchPath)) { } @@ -793,7 +794,7 @@ namespace m_registration.AddDependency(techset); m_material.techniqueSet = techset->Asset(); - auto& definitionCache = m_context.GetZoneAssetCreationState(); + auto& definitionCache = m_context.GetZoneAssetCreationState<::techset::TechsetDefinitionCache>(); bool failure = false; const auto* techsetDefinition = m_techset_creator->LoadTechsetDefinition(techsetName, m_context, failure); @@ -806,7 +807,7 @@ namespace SetTechniqueSetCameraRegion(techsetDefinition); } - void SetTechniqueSetStateBits(const techset::TechsetDefinition* techsetDefinition) + void SetTechniqueSetStateBits(const ::techset::TechsetDefinition* techsetDefinition) { for (auto i = 0; i < TECHNIQUE_COUNT; i++) { @@ -854,19 +855,19 @@ namespace return stateBits; } - _NODISCARD const state_map::StateMapDefinition* GetStateMapForTechnique(const std::string& techniqueName) const + [[nodiscard]] const state_map::StateMapDefinition* GetStateMapForTechnique(const std::string& techniqueName) const { const auto* preloadedStateMap = m_state_map_cache.GetStateMapForTechnique(techniqueName); if (preloadedStateMap) return preloadedStateMap; - const auto techniqueFileName = GetTechniqueFileName(techniqueName); + const auto techniqueFileName = ::techset::GetFileNameForTechniqueName(techniqueName); const auto file = m_search_path.Open(techniqueFileName); if (!file.IsOpen()) return nullptr; state_map::StateMapFromTechniqueExtractor extractor; - const techset::TechniqueFileReader reader(*file.m_stream, techniqueFileName, &extractor); + const ::techset::TechniqueFileReader reader(*file.m_stream, techniqueFileName, &extractor); if (!reader.ReadTechniqueDefinition()) { m_state_map_cache.SetTechniqueUsesStateMap(techniqueName, nullptr); @@ -890,7 +891,7 @@ namespace return outBits; } - void SetTechniqueSetCameraRegion(const techset::TechsetDefinition* techsetDefinition) const + void SetTechniqueSetCameraRegion(const ::techset::TechsetDefinition* techsetDefinition) const { std::string tempName; if (techsetDefinition->GetTechniqueByIndex(TECHNIQUE_LIT, tempName)) @@ -1316,7 +1317,7 @@ namespace AssetCreationContext& m_context; AssetRegistration& m_registration; - techset::TechniqueStateMapCache& m_state_map_cache; + ::techset::TechniqueStateMapCache& m_state_map_cache; std::unordered_map m_state_bits_per_state_map; GfxStateBits m_base_state_bits; @@ -1324,7 +1325,7 @@ namespace std::vector m_textures; std::vector m_constants; - std::unique_ptr m_techset_creator; + std::unique_ptr<::IW4::techset::ICreator> m_techset_creator; }; class MaterialLoader final : public AssetCreator @@ -1374,10 +1375,10 @@ namespace }; } // namespace -namespace IW4 +namespace IW4::material { - std::unique_ptr> CreateMaterialCompiler(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt) + std::unique_ptr> CreateCompiler(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt) { return std::make_unique(memory, searchPath, gdt); } -} // namespace IW4 +} // namespace IW4::material diff --git a/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.h b/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.h index 52c7d3dd..3258e1b5 100644 --- a/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.h +++ b/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.h @@ -6,7 +6,7 @@ #include "SearchPath/ISearchPath.h" #include "Utils/MemoryManager.h" -namespace IW4 +namespace IW4::material { - std::unique_ptr> CreateMaterialCompiler(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt); -} // namespace IW4 + std::unique_ptr> CreateCompiler(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt); +} // namespace IW4::material diff --git a/src/ObjCompiling/Game/IW4/ObjCompilerIW4.cpp b/src/ObjCompiling/Game/IW4/ObjCompilerIW4.cpp index f33dd566..8ad32e9d 100644 --- a/src/ObjCompiling/Game/IW4/ObjCompilerIW4.cpp +++ b/src/ObjCompiling/Game/IW4/ObjCompilerIW4.cpp @@ -17,10 +17,10 @@ namespace auto& memory = zone.Memory(); #ifdef EXPERIMENTAL_MATERIAL_COMPILATION - collection.AddAssetCreator(CreateMaterialCompiler(memory, searchPath, gdt)); - collection.AddAssetCreator(CreateTechsetLoader(memory, searchPath)); + collection.AddAssetCreator(material::CreateCompiler(memory, searchPath, gdt)); + collection.AddAssetCreator(IW4::techset::CreateLoader(memory, searchPath)); #endif - collection.AddAssetCreator(CreateVertexDeclLoader(memory)); + collection.AddAssetCreator(vertex_decl::CreateLoader(memory)); } void ConfigurePostProcessors(AssetCreatorCollection& collection, @@ -32,8 +32,8 @@ namespace { auto& memory = zone.Memory(); - if (ImageIwdPostProcessor::AppliesToZoneDefinition(zoneDefinition)) - collection.AddAssetPostProcessor(std::make_unique>(zoneDefinition, searchPath, zoneStates, outDir)); + if (image::IwdPostProcessor::AppliesToZoneDefinition(zoneDefinition)) + collection.AddAssetPostProcessor(std::make_unique>(zoneDefinition, searchPath, zoneStates, outDir)); } } // namespace diff --git a/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.cpp b/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.cpp index 321d3297..dd336d7e 100644 --- a/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.cpp +++ b/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.cpp @@ -9,6 +9,7 @@ #include "StateMap/StateMapReader.h" #include "Techset/TechniqueFileReader.h" #include "Techset/TechniqueStateMapCache.h" +#include "Techset/TechsetCommon.h" #include "Techset/TechsetDefinitionCache.h" #include "Techset/TechsetFileReader.h" #include "Utils/Alignment.h" @@ -25,6 +26,7 @@ #include using namespace IW4; +using namespace ::techset; using namespace std::string_literals; namespace @@ -62,7 +64,7 @@ namespace .first->second.get(); } - literal_t GetAllocatedLiteral(MemoryManager& memory, techset::ShaderArgumentLiteralSource source) + literal_t GetAllocatedLiteral(MemoryManager& memory, ShaderArgumentLiteralSource source) { const auto& existingEntry = m_allocated_literals.find(source); @@ -81,7 +83,7 @@ namespace private: std::unordered_map> m_loaded_techniques; - std::map m_allocated_literals; + std::map m_allocated_literals; }; class ShaderInfoFromFileSystemCacheState final : public IZoneAssetCreationState @@ -121,7 +123,7 @@ namespace std::unordered_map> m_cached_shader_info; }; - class TechniqueCreator final : public techset::ITechniqueDefinitionAcceptor + class TechniqueCreator final : public ITechniqueDefinitionAcceptor { public: class PassShaderArgument @@ -197,14 +199,17 @@ namespace std::vector m_arguments; }; - TechniqueCreator( - const std::string& techniqueName, ISearchPath& searchPath, MemoryManager& memory, AssetCreationContext& context, ITechsetCreator* techsetCreator) + TechniqueCreator(const std::string& techniqueName, + ISearchPath& searchPath, + MemoryManager& memory, + AssetCreationContext& context, + IW4::techset::ICreator* techsetCreator) : m_technique_name(techniqueName), m_search_path(searchPath), m_memory(memory), m_context(context), m_zone_state(context.GetZoneAssetCreationState()), - m_state_map_cache(context.GetZoneAssetCreationState()), + m_state_map_cache(context.GetZoneAssetCreationState()), m_shader_info_cache(context.GetZoneAssetCreationState()), m_techset_creator(techsetCreator) { @@ -230,7 +235,7 @@ namespace || constant.m_type == d3d9::ParameterType::SAMPLER_CUBE; } - bool AutoCreateShaderArgument(const techset::ShaderSelector shaderType, + bool AutoCreateShaderArgument(const ShaderSelector shaderType, const d3d9::ShaderConstant& shaderArgument, const size_t elementOffset, const size_t registerOffset) @@ -239,7 +244,7 @@ namespace auto& pass = m_passes.at(m_passes.size() - 1); const auto isSamplerArgument = IsSamplerArgument(shaderArgument); - if (shaderType == techset::ShaderSelector::VERTEX_SHADER && isSamplerArgument) + if (shaderType == ShaderSelector::VERTEX_SHADER && isSamplerArgument) return false; MaterialShaderArgument argument; @@ -270,7 +275,7 @@ namespace if (!constantSource) return false; - argument.type = shaderType == techset::ShaderSelector::VERTEX_SHADER ? MTL_ARG_CODE_VERTEX_CONST : MTL_ARG_CODE_PIXEL_CONST; + argument.type = shaderType == ShaderSelector::VERTEX_SHADER ? MTL_ARG_CODE_VERTEX_CONST : MTL_ARG_CODE_PIXEL_CONST; argument.u.codeConst.index = static_cast(constantSource->source + elementOffset); argument.u.codeConst.firstRow = 0u; argument.u.codeConst.rowCount = static_cast(shaderArgument.m_type_rows); @@ -301,7 +306,7 @@ namespace { if (!pass.m_handled_vertex_shader_arguments[argumentHandledIndex + elementIndex]) { - if (!AutoCreateShaderArgument(techset::ShaderSelector::VERTEX_SHADER, argument, elementIndex, registerIndex)) + if (!AutoCreateShaderArgument(ShaderSelector::VERTEX_SHADER, argument, elementIndex, registerIndex)) { std::string elementIndexStr; if (argument.m_type_elements > 1) @@ -336,7 +341,7 @@ namespace { if (!pass.m_handled_pixel_shader_arguments[argumentHandledIndex + elementIndex]) { - if (!AutoCreateShaderArgument(techset::ShaderSelector::PIXEL_SHADER, argument, elementIndex, registerIndex)) + if (!AutoCreateShaderArgument(ShaderSelector::PIXEL_SHADER, argument, elementIndex, registerIndex)) { std::ostringstream ss; ss << "Unassigned pixel shader \"" << pass.m_pixel_shader->m_name << "\" arg: " << argument.m_name; @@ -572,11 +577,8 @@ namespace return foundSource; } - static bool FindShaderArgument(const d3d9::ShaderInfo& shaderInfo, - const techset::ShaderArgument& argument, - size_t& constantIndex, - size_t& registerOffset, - std::string& errorMessage) + static bool FindShaderArgument( + const d3d9::ShaderInfo& shaderInfo, const ShaderArgument& argument, size_t& constantIndex, size_t& registerOffset, std::string& errorMessage) { const auto matchingShaderConstant = std::ranges::find_if(shaderInfo.m_constants, [argument](const d3d9::ShaderConstant& constant) @@ -622,7 +624,7 @@ namespace } static bool SetArgumentCodeConst(MaterialShaderArgument& argument, - const techset::ShaderArgumentCodeSource& source, + const ShaderArgumentCodeSource& source, const d3d9::ShaderConstant& shaderConstant, const unsigned sourceIndex, const unsigned arrayCount, @@ -660,7 +662,7 @@ namespace } static bool SetArgumentCodeSampler(MaterialShaderArgument& argument, - const techset::ShaderArgumentCodeSource& source, + const ShaderArgumentCodeSource& source, const d3d9::ShaderConstant& shaderConstant, const unsigned sourceIndex, const unsigned arrayCount, @@ -695,9 +697,7 @@ namespace return true; } - bool AcceptVertexShaderConstantArgument(const techset::ShaderArgument& shaderArgument, - const techset::ShaderArgumentCodeSource& source, - std::string& errorMessage) + bool AcceptVertexShaderConstantArgument(const ShaderArgument& shaderArgument, const ShaderArgumentCodeSource& source, std::string& errorMessage) { assert(!m_passes.empty()); auto& pass = m_passes.at(m_passes.size() - 1); @@ -745,8 +745,8 @@ namespace return true; } - bool AcceptPixelShaderCodeArgument(const techset::ShaderArgument& shaderArgument, - const techset::ShaderArgumentCodeSource& source, + bool AcceptPixelShaderCodeArgument(const ShaderArgument& shaderArgument, + const ShaderArgumentCodeSource& source, std::string& errorMessage, const bool isSampler) { @@ -826,36 +826,36 @@ namespace return true; } - bool AcceptShaderConstantArgument(const techset::ShaderSelector shader, - const techset::ShaderArgument shaderArgument, - const techset::ShaderArgumentCodeSource source, + bool AcceptShaderConstantArgument(const ShaderSelector shader, + const ShaderArgument shaderArgument, + const ShaderArgumentCodeSource source, std::string& errorMessage) override { - if (shader == techset::ShaderSelector::VERTEX_SHADER) + if (shader == ShaderSelector::VERTEX_SHADER) return AcceptVertexShaderConstantArgument(shaderArgument, source, errorMessage); - assert(shader == techset::ShaderSelector::PIXEL_SHADER); + assert(shader == ShaderSelector::PIXEL_SHADER); return AcceptPixelShaderCodeArgument(shaderArgument, source, errorMessage, false); } - bool AcceptShaderSamplerArgument(const techset::ShaderSelector shader, - const techset::ShaderArgument shaderArgument, - const techset::ShaderArgumentCodeSource source, + bool AcceptShaderSamplerArgument(const ShaderSelector shader, + const ShaderArgument shaderArgument, + const ShaderArgumentCodeSource source, std::string& errorMessage) override { - if (shader == techset::ShaderSelector::VERTEX_SHADER) + if (shader == ShaderSelector::VERTEX_SHADER) { errorMessage = "Vertex sampler are unsupported"; return false; } - assert(shader == techset::ShaderSelector::PIXEL_SHADER); + assert(shader == ShaderSelector::PIXEL_SHADER); return AcceptPixelShaderCodeArgument(shaderArgument, source, errorMessage, true); } - bool AcceptShaderLiteralArgument(const techset::ShaderSelector shader, - const techset::ShaderArgument shaderArgument, - const techset::ShaderArgumentLiteralSource source, + bool AcceptShaderLiteralArgument(const ShaderSelector shader, + const ShaderArgument shaderArgument, + const ShaderArgumentLiteralSource source, std::string& errorMessage) override { assert(!m_passes.empty()); @@ -864,14 +864,14 @@ namespace MaterialShaderArgument argument; const d3d9::ShaderInfo* shaderInfo; - if (shader == techset::ShaderSelector::VERTEX_SHADER) + if (shader == ShaderSelector::VERTEX_SHADER) { argument.type = MTL_ARG_LITERAL_VERTEX_CONST; shaderInfo = pass.m_vertex_shader_info; } else { - assert(shader == techset::ShaderSelector::PIXEL_SHADER); + assert(shader == ShaderSelector::PIXEL_SHADER); argument.type = MTL_ARG_LITERAL_PIXEL_CONST; shaderInfo = pass.m_pixel_shader_info; } @@ -892,7 +892,7 @@ namespace const auto argumentIsSampler = IsSamplerArgument(shaderConstant); if (argumentIsSampler) { - if (shader == techset::ShaderSelector::VERTEX_SHADER) + if (shader == ShaderSelector::VERTEX_SHADER) errorMessage = "Vertex shader argument expects sampler but got constant"; else errorMessage = "Pixel shader argument expects sampler but got constant"; @@ -904,7 +904,7 @@ namespace argument.u.literalConst = m_zone_state.GetAllocatedLiteral(m_memory, source); pass.m_arguments.emplace_back(argument); - if (shader == techset::ShaderSelector::VERTEX_SHADER) + if (shader == ShaderSelector::VERTEX_SHADER) pass.m_handled_vertex_shader_arguments[pass.m_vertex_shader_argument_handled_offset[shaderConstantIndex] + elementOffset] = true; else pass.m_handled_pixel_shader_arguments[pass.m_pixel_shader_argument_handled_offset[shaderConstantIndex] + elementOffset] = true; @@ -912,9 +912,9 @@ namespace return true; } - bool AcceptShaderMaterialArgument(const techset::ShaderSelector shader, - const techset::ShaderArgument shaderArgument, - const techset::ShaderArgumentMaterialSource source, + bool AcceptShaderMaterialArgument(const ShaderSelector shader, + const ShaderArgument shaderArgument, + const ShaderArgumentMaterialSource source, std::string& errorMessage) override { assert(!m_passes.empty()); @@ -923,13 +923,13 @@ namespace MaterialShaderArgument argument; const d3d9::ShaderInfo* shaderInfo; - if (shader == techset::ShaderSelector::VERTEX_SHADER) + if (shader == ShaderSelector::VERTEX_SHADER) { shaderInfo = pass.m_vertex_shader_info; } else { - assert(shader == techset::ShaderSelector::PIXEL_SHADER); + assert(shader == ShaderSelector::PIXEL_SHADER); shaderInfo = pass.m_pixel_shader_info; } @@ -947,7 +947,7 @@ namespace const auto elementOffset = shaderArgument.m_argument_index_specified ? shaderArgument.m_argument_index : 0u; const auto& shaderConstant = shaderInfo->m_constants[shaderConstantIndex]; const auto argumentIsSampler = IsSamplerArgument(shaderConstant); - if (shader == techset::ShaderSelector::VERTEX_SHADER) + if (shader == ShaderSelector::VERTEX_SHADER) { if (argumentIsSampler) { @@ -958,7 +958,7 @@ namespace } else { - assert(shader == techset::ShaderSelector::PIXEL_SHADER); + assert(shader == ShaderSelector::PIXEL_SHADER); argument.type = !argumentIsSampler ? MTL_ARG_MATERIAL_PIXEL_CONST : MTL_ARG_MATERIAL_PIXEL_SAMPLER; } @@ -970,7 +970,7 @@ namespace argument.dest = static_cast(shaderConstant.m_register_index + registerOffset); pass.m_arguments.emplace_back(argument); - if (shader == techset::ShaderSelector::VERTEX_SHADER) + if (shader == ShaderSelector::VERTEX_SHADER) pass.m_handled_vertex_shader_arguments[pass.m_vertex_shader_argument_handled_offset[shaderConstantIndex] + elementOffset] = true; else pass.m_handled_pixel_shader_arguments[pass.m_pixel_shader_argument_handled_offset[shaderConstantIndex] + elementOffset] = true; @@ -1024,15 +1024,15 @@ namespace MemoryManager& m_memory; AssetCreationContext& m_context; TechniqueZoneLoadingState& m_zone_state; - techset::TechniqueStateMapCache& m_state_map_cache; + TechniqueStateMapCache& m_state_map_cache; ShaderInfoFromFileSystemCacheState& m_shader_info_cache; - ITechsetCreator* m_techset_creator; + IW4::techset::ICreator* m_techset_creator; }; class TechniqueLoader { public: - TechniqueLoader(ISearchPath& searchPath, MemoryManager& memory, AssetCreationContext& context, ITechsetCreator* techsetCreator) + TechniqueLoader(ISearchPath& searchPath, MemoryManager& memory, AssetCreationContext& context, IW4::techset::ICreator* techsetCreator) : m_search_path(searchPath), m_memory(memory), m_context(context), @@ -1243,13 +1243,13 @@ namespace MaterialTechnique* LoadTechniqueFromRaw(const std::string& techniqueName, std::vector& dependencies) const { - const auto techniqueFileName = GetTechniqueFileName(techniqueName); + const auto techniqueFileName = GetFileNameForTechniqueName(techniqueName); const auto file = m_search_path.Open(techniqueFileName); if (!file.IsOpen()) return nullptr; TechniqueCreator creator(techniqueName, m_search_path, m_memory, m_context, m_techset_creator); - const techset::TechniqueFileReader reader(*file.m_stream, techniqueFileName, &creator); + const TechniqueFileReader reader(*file.m_stream, techniqueFileName, &creator); if (!reader.ReadTechniqueDefinition()) return nullptr; @@ -1260,10 +1260,10 @@ namespace MemoryManager& m_memory; AssetCreationContext& m_context; TechniqueZoneLoadingState& m_zone_state; - ITechsetCreator* m_techset_creator; + IW4::techset::ICreator* m_techset_creator; }; - class TechsetLoader final : public ITechsetCreator + class TechsetLoader final : public IW4::techset::ICreator { public: TechsetLoader(MemoryManager& memory, ISearchPath& searchPath) @@ -1283,8 +1283,7 @@ namespace } private: - AssetCreationResult - CreateTechsetFromDefinition(const std::string& assetName, const techset::TechsetDefinition& definition, AssetCreationContext& context) + AssetCreationResult CreateTechsetFromDefinition(const std::string& assetName, const TechsetDefinition& definition, AssetCreationContext& context) { auto* techset = m_memory.Alloc(); techset->name = m_memory.Dup(assetName.c_str()); @@ -1312,20 +1311,20 @@ namespace return AssetCreationResult::Success(context.AddAsset(std::move(registration))); } - techset::TechsetDefinition* LoadTechsetDefinition(const std::string& assetName, AssetCreationContext& context, bool& failure) override + TechsetDefinition* LoadTechsetDefinition(const std::string& assetName, AssetCreationContext& context, bool& failure) override { failure = false; - auto& definitionCache = context.GetZoneAssetCreationState(); + auto& definitionCache = context.GetZoneAssetCreationState(); auto* cachedTechsetDefinition = definitionCache.GetCachedTechsetDefinition(assetName); if (cachedTechsetDefinition) return cachedTechsetDefinition; - const auto techsetFileName = GetTechsetFileName(assetName); + const auto techsetFileName = GetFileNameForTechsetName(assetName); const auto file = m_search_path.Open(techsetFileName); if (!file.IsOpen()) return nullptr; - const techset::TechsetFileReader reader(*file.m_stream, techsetFileName, techniqueTypeNames, std::extent_v); + const TechsetFileReader reader(*file.m_stream, techsetFileName, techniqueTypeNames, std::extent_v); auto techsetDefinition = reader.ReadTechsetDefinition(); if (!techsetDefinition) { @@ -1342,12 +1341,12 @@ namespace const state_map::StateMapDefinition* LoadStateMapDefinition(const std::string& stateMapName, AssetCreationContext& context) override { - auto& stateMapCache = context.GetZoneAssetCreationState(); + auto& stateMapCache = context.GetZoneAssetCreationState(); auto* cachedStateMap = stateMapCache.GetCachedStateMap(stateMapName); if (cachedStateMap) return cachedStateMap; - const auto stateMapFileName = GetStateMapFileName(stateMapName); + const auto stateMapFileName = GetFileNameForStateMapName(stateMapName); const auto file = m_search_path.Open(stateMapFileName); if (!file.IsOpen()) return nullptr; @@ -1370,25 +1369,10 @@ namespace }; } // namespace -namespace IW4 +namespace IW4::techset { - std::string GetTechsetFileName(const std::string& techsetAssetName) - { - return std::format("techsets/{}.techset", techsetAssetName); - } - - std::string GetTechniqueFileName(const std::string& techniqueName) - { - return std::format("techniques/{}.tech", techniqueName); - } - - std::string GetStateMapFileName(const std::string& stateMapName) - { - return std::format("statemaps/{}.sm", stateMapName); - } - - std::unique_ptr CreateTechsetLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr CreateLoader(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4 +} // namespace IW4::techset diff --git a/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.h b/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.h index 2f246031..0187b329 100644 --- a/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.h +++ b/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.h @@ -10,21 +10,17 @@ #include #include -namespace IW4 +namespace IW4::techset { - [[nodiscard]] std::string GetTechsetFileName(const std::string& techsetAssetName); - [[nodiscard]] std::string GetTechniqueFileName(const std::string& techniqueName); - [[nodiscard]] std::string GetStateMapFileName(const std::string& stateMapName); - - class ITechsetCreator : public AssetCreator + class ICreator : public AssetCreator { public: - ITechsetCreator() = default; - virtual ~ITechsetCreator() = default; + ICreator() = default; + virtual ~ICreator() = default; - virtual techset::TechsetDefinition* LoadTechsetDefinition(const std::string& assetName, AssetCreationContext& context, bool& failure) = 0; + virtual ::techset::TechsetDefinition* LoadTechsetDefinition(const std::string& assetName, AssetCreationContext& context, bool& failure) = 0; virtual const state_map::StateMapDefinition* LoadStateMapDefinition(const std::string& stateMapName, AssetCreationContext& context) = 0; }; - std::unique_ptr CreateTechsetLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4 + std::unique_ptr CreateLoader(MemoryManager& memory, ISearchPath& searchPath); +} // namespace IW4::techset diff --git a/src/ObjCompiling/Game/IW4/Techset/CompilerVertexDeclIW4.cpp b/src/ObjCompiling/Game/IW4/Techset/CompilerVertexDeclIW4.cpp index 391975ee..feaa64bf 100644 --- a/src/ObjCompiling/Game/IW4/Techset/CompilerVertexDeclIW4.cpp +++ b/src/ObjCompiling/Game/IW4/Techset/CompilerVertexDeclIW4.cpp @@ -92,10 +92,10 @@ namespace }; } // namespace -namespace IW4 +namespace IW4::vertex_decl { - std::unique_ptr> CreateVertexDeclLoader(MemoryManager& memory) + std::unique_ptr> CreateLoader(MemoryManager& memory) { return std::make_unique(memory); } -} // namespace IW4 +} // namespace IW4::vertex_decl diff --git a/src/ObjCompiling/Game/IW4/Techset/CompilerVertexDeclIW4.h b/src/ObjCompiling/Game/IW4/Techset/CompilerVertexDeclIW4.h index d4bd1b68..3153e5a0 100644 --- a/src/ObjCompiling/Game/IW4/Techset/CompilerVertexDeclIW4.h +++ b/src/ObjCompiling/Game/IW4/Techset/CompilerVertexDeclIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4 +namespace IW4::vertex_decl { - std::unique_ptr> CreateVertexDeclLoader(MemoryManager& memory); -} // namespace IW4 + std::unique_ptr> CreateLoader(MemoryManager& memory); +} // namespace IW4::vertex_decl diff --git a/src/ObjCompiling/Game/IW5/ObjCompilerIW5.cpp b/src/ObjCompiling/Game/IW5/ObjCompilerIW5.cpp index fe02ead8..5f9e9bf9 100644 --- a/src/ObjCompiling/Game/IW5/ObjCompilerIW5.cpp +++ b/src/ObjCompiling/Game/IW5/ObjCompilerIW5.cpp @@ -25,8 +25,8 @@ namespace { auto& memory = zone.Memory(); - if (ImageIwdPostProcessor::AppliesToZoneDefinition(zoneDefinition)) - collection.AddAssetPostProcessor(std::make_unique>(zoneDefinition, searchPath, zoneStates, outDir)); + if (image::IwdPostProcessor::AppliesToZoneDefinition(zoneDefinition)) + collection.AddAssetPostProcessor(std::make_unique>(zoneDefinition, searchPath, zoneStates, outDir)); } } // namespace diff --git a/src/ObjCompiling/Game/T5/ObjCompilerT5.cpp b/src/ObjCompiling/Game/T5/ObjCompilerT5.cpp index 3ca4d416..0442c1e8 100644 --- a/src/ObjCompiling/Game/T5/ObjCompilerT5.cpp +++ b/src/ObjCompiling/Game/T5/ObjCompilerT5.cpp @@ -25,8 +25,8 @@ namespace { auto& memory = zone.Memory(); - if (ImageIwdPostProcessor::AppliesToZoneDefinition(zoneDefinition)) - collection.AddAssetPostProcessor(std::make_unique>(zoneDefinition, searchPath, zoneStates, outDir)); + if (image::IwdPostProcessor::AppliesToZoneDefinition(zoneDefinition)) + collection.AddAssetPostProcessor(std::make_unique>(zoneDefinition, searchPath, zoneStates, outDir)); } } // namespace diff --git a/src/ObjCompiling/Game/T6/Image/ImageCompilerT6.cpp b/src/ObjCompiling/Game/T6/Image/ImageCompilerT6.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/src/ObjCompiling/Game/T6/Image/ImageCompilerT6.h b/src/ObjCompiling/Game/T6/Image/ImageCompilerT6.h deleted file mode 100644 index e69de29b..00000000 diff --git a/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.cpp b/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.cpp index 22da77ce..92d3cd0d 100644 --- a/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.cpp +++ b/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.cpp @@ -18,7 +18,7 @@ namespace : m_memory(memory), m_zone(zone), m_zone_definition(zoneDefinition), - m_kvp_creator(zoneStates.GetZoneAssetCreationState()) + m_kvp_creator(zoneStates.GetZoneAssetCreationState<::key_value_pairs::Creator>()) { } @@ -67,15 +67,15 @@ namespace MemoryManager& m_memory; const Zone& m_zone; const ZoneDefinition& m_zone_definition; - KeyValuePairsCreator& m_kvp_creator; + ::key_value_pairs::Creator m_kvp_creator; }; } // namespace -namespace T6 +namespace T6::key_value_pairs { std::unique_ptr - CreateKeyValuePairsCompiler(MemoryManager& memory, const Zone& zone, const ZoneDefinition& zoneDefinition, ZoneAssetCreationStateContainer& zoneStates) + CreateCompiler(MemoryManager& memory, const Zone& zone, const ZoneDefinition& zoneDefinition, ZoneAssetCreationStateContainer& zoneStates) { return std::make_unique(memory, zone, zoneDefinition, zoneStates); } -} // namespace T6 +} // namespace T6::key_value_pairs diff --git a/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.h b/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.h index c68c06b5..a3dadb8c 100644 --- a/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.h +++ b/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.h @@ -9,8 +9,8 @@ #include -namespace T6 +namespace T6::key_value_pairs { std::unique_ptr - CreateKeyValuePairsCompiler(MemoryManager& memory, const Zone& zone, const ZoneDefinition& zoneDefinition, ZoneAssetCreationStateContainer& zoneStates); -} // namespace T6 + CreateCompiler(MemoryManager& memory, const Zone& zone, const ZoneDefinition& zoneDefinition, ZoneAssetCreationStateContainer& zoneStates); +} // namespace T6::key_value_pairs diff --git a/src/ObjCompiling/Game/T6/ObjCompilerT6.cpp b/src/ObjCompiling/Game/T6/ObjCompilerT6.cpp index eae90387..d25f2dee 100644 --- a/src/ObjCompiling/Game/T6/ObjCompilerT6.cpp +++ b/src/ObjCompiling/Game/T6/ObjCompilerT6.cpp @@ -19,7 +19,7 @@ namespace { auto& memory = zone.Memory(); - collection.AddAssetCreator(CreateKeyValuePairsCompiler(memory, zone, zoneDefinition.m_zone_definition, zoneStates)); + collection.AddAssetCreator(T6::key_value_pairs::CreateCompiler(memory, zone, zoneDefinition.m_zone_definition, zoneStates)); } void ConfigurePostProcessors(AssetCreatorCollection& collection, @@ -31,11 +31,11 @@ namespace { auto& memory = zone.Memory(); - if (ImageIPakPostProcessor::AppliesToZoneDefinition(zoneDefinition)) - collection.AddAssetPostProcessor(std::make_unique>(zoneDefinition, searchPath, zoneStates, outDir)); + if (image::IPakPostProcessor::AppliesToZoneDefinition(zoneDefinition)) + collection.AddAssetPostProcessor(std::make_unique>(zoneDefinition, searchPath, zoneStates, outDir)); - if (ImageIwdPostProcessor::AppliesToZoneDefinition(zoneDefinition)) - collection.AddAssetPostProcessor(std::make_unique>(zoneDefinition, searchPath, zoneStates, outDir)); + if (image::IwdPostProcessor::AppliesToZoneDefinition(zoneDefinition)) + collection.AddAssetPostProcessor(std::make_unique>(zoneDefinition, searchPath, zoneStates, outDir)); } } // namespace diff --git a/src/ObjCompiling/Image/IPak/IPakCreator.cpp b/src/ObjCompiling/Image/IPak/IPakCreator.cpp index 64134b2b..1f3fd36a 100644 --- a/src/ObjCompiling/Image/IPak/IPakCreator.cpp +++ b/src/ObjCompiling/Image/IPak/IPakCreator.cpp @@ -371,68 +371,71 @@ namespace }; } // namespace -IPakToCreate::IPakToCreate(std::string name) - : m_name(std::move(name)) +namespace image { -} - -void IPakToCreate::AddImage(std::string imageName) -{ - m_image_names.emplace_back(std::move(imageName)); -} - -void IPakToCreate::Build(ISearchPath& searchPath, IOutputPath& outPath) -{ - const auto file = outPath.Open(std::format("{}.ipak", m_name)); - if (!file) + IPakToCreate::IPakToCreate(std::string name) + : m_name(std::move(name)) { - std::cerr << std::format("Failed to open file for ipak {}\n", m_name); - return; } - IPakWriter writer(*file, searchPath, m_image_names); - writer.Write(); + void IPakToCreate::AddImage(std::string imageName) + { + m_image_names.emplace_back(std::move(imageName)); + } - std::cout << std::format("Created ipak {} with {} entries\n", m_name, m_image_names.size()); -} + void IPakToCreate::Build(ISearchPath& searchPath, IOutputPath& outPath) + { + const auto file = outPath.Open(std::format("{}.ipak", m_name)); + if (!file) + { + std::cerr << std::format("Failed to open file for ipak {}\n", m_name); + return; + } -const std::vector& IPakToCreate::GetImageNames() const -{ - return m_image_names; -} + IPakWriter writer(*file, searchPath, m_image_names); + writer.Write(); -IPakCreator::IPakCreator() - : m_kvp_creator(nullptr) -{ -} + std::cout << std::format("Created ipak {} with {} entries\n", m_name, m_image_names.size()); + } -void IPakCreator::Inject(ZoneAssetCreationInjection& inject) -{ - m_kvp_creator = &inject.m_zone_states.GetZoneAssetCreationState(); -} + const std::vector& IPakToCreate::GetImageNames() const + { + return m_image_names; + } -IPakToCreate* IPakCreator::GetOrAddIPak(const std::string& ipakName) -{ - const auto existingIPak = m_ipak_lookup.find(ipakName); - if (existingIPak != m_ipak_lookup.end()) - return existingIPak->second; + IPakCreator::IPakCreator() + : m_kvp_creator(nullptr) + { + } - auto newIPak = std::make_unique(ipakName); - auto* result = newIPak.get(); - m_ipak_lookup.emplace(ipakName, result); - m_ipaks.emplace_back(std::move(newIPak)); + void IPakCreator::Inject(ZoneAssetCreationInjection& inject) + { + m_kvp_creator = &inject.m_zone_states.GetZoneAssetCreationState(); + } - assert(m_kvp_creator); - m_kvp_creator->AddKeyValuePair(CommonKeyValuePair("ipak_read", ipakName)); + IPakToCreate* IPakCreator::GetOrAddIPak(const std::string& ipakName) + { + const auto existingIPak = m_ipak_lookup.find(ipakName); + if (existingIPak != m_ipak_lookup.end()) + return existingIPak->second; - return result; -} + auto newIPak = std::make_unique(ipakName); + auto* result = newIPak.get(); + m_ipak_lookup.emplace(ipakName, result); + m_ipaks.emplace_back(std::move(newIPak)); -void IPakCreator::Finalize(ISearchPath& searchPath, IOutputPath& outPath) -{ - for (const auto& ipakToCreate : m_ipaks) - ipakToCreate->Build(searchPath, outPath); + assert(m_kvp_creator); + m_kvp_creator->AddKeyValuePair(key_value_pairs::CommonKeyValuePair("ipak_read", ipakName)); - m_ipaks.clear(); - m_ipak_lookup.clear(); -} + return result; + } + + void IPakCreator::Finalize(ISearchPath& searchPath, IOutputPath& outPath) + { + for (const auto& ipakToCreate : m_ipaks) + ipakToCreate->Build(searchPath, outPath); + + m_ipaks.clear(); + m_ipak_lookup.clear(); + } +} // namespace image diff --git a/src/ObjCompiling/Image/IPak/IPakCreator.h b/src/ObjCompiling/Image/IPak/IPakCreator.h index 31eed0b2..b7891fbf 100644 --- a/src/ObjCompiling/Image/IPak/IPakCreator.h +++ b/src/ObjCompiling/Image/IPak/IPakCreator.h @@ -9,32 +9,35 @@ #include #include -class IPakToCreate +namespace image { -public: - explicit IPakToCreate(std::string name); + class IPakToCreate + { + public: + explicit IPakToCreate(std::string name); - void AddImage(std::string imageName); - void Build(ISearchPath& searchPath, IOutputPath& outPath); - [[nodiscard]] const std::vector& GetImageNames() const; + void AddImage(std::string imageName); + void Build(ISearchPath& searchPath, IOutputPath& outPath); + [[nodiscard]] const std::vector& GetImageNames() const; -private: - std::string m_name; - std::vector m_image_names; -}; + private: + std::string m_name; + std::vector m_image_names; + }; -class IPakCreator final : public IZoneAssetCreationState -{ -public: - IPakCreator(); + class IPakCreator final : public IZoneAssetCreationState + { + public: + IPakCreator(); - void Inject(ZoneAssetCreationInjection& inject) override; + void Inject(ZoneAssetCreationInjection& inject) override; - IPakToCreate* GetOrAddIPak(const std::string& ipakName); - void Finalize(ISearchPath& searchPath, IOutputPath& outPath); + IPakToCreate* GetOrAddIPak(const std::string& ipakName); + void Finalize(ISearchPath& searchPath, IOutputPath& outPath); -private: - KeyValuePairsCreator* m_kvp_creator; - std::unordered_map m_ipak_lookup; - std::vector> m_ipaks; -}; + private: + key_value_pairs::Creator* m_kvp_creator; + std::unordered_map m_ipak_lookup; + std::vector> m_ipaks; + }; +} // namespace image diff --git a/src/ObjCompiling/Image/ImageIPakPostProcessor.cpp b/src/ObjCompiling/Image/ImageIPakPostProcessor.cpp index 24c0ace2..2c05d22b 100644 --- a/src/ObjCompiling/Image/ImageIPakPostProcessor.cpp +++ b/src/ObjCompiling/Image/ImageIPakPostProcessor.cpp @@ -4,63 +4,66 @@ #include -AbstractImageIPakPostProcessor::AbstractImageIPakPostProcessor(const ZoneDefinitionContext& zoneDefinition, - ISearchPath& searchPath, - ZoneAssetCreationStateContainer& zoneStates, - IOutputPath& outDir) - : m_zone_definition(zoneDefinition), - m_search_path(searchPath), - m_ipak_creator(zoneStates.GetZoneAssetCreationState()), - m_out_dir(outDir), - m_obj_container_index(0u), - m_current_ipak(nullptr), - m_current_ipak_start_index(0u), - m_current_ipak_end_index(0u) +namespace image { - FindNextObjContainer(); -} - -bool AbstractImageIPakPostProcessor::AppliesToZoneDefinition(const ZoneDefinitionContext& zoneDefinition) -{ - return std::ranges::any_of(zoneDefinition.m_zone_definition.m_obj_containers, - [](const ZoneDefinitionObjContainer& objContainer) - { - return objContainer.m_type == ZoneDefinitionObjContainerType::IPAK; - }); -} - -void AbstractImageIPakPostProcessor::FindNextObjContainer() -{ - const auto objContainerCount = m_zone_definition.m_zone_definition.m_obj_containers.size(); - while (m_obj_container_index < objContainerCount) + AbstractIPakPostProcessor::AbstractIPakPostProcessor(const ZoneDefinitionContext& zoneDefinition, + ISearchPath& searchPath, + ZoneAssetCreationStateContainer& zoneStates, + IOutputPath& outDir) + : m_zone_definition(zoneDefinition), + m_search_path(searchPath), + m_ipak_creator(zoneStates.GetZoneAssetCreationState()), + m_out_dir(outDir), + m_obj_container_index(0u), + m_current_ipak(nullptr), + m_current_ipak_start_index(0u), + m_current_ipak_end_index(0u) { - const auto& objContainer = m_zone_definition.m_zone_definition.m_obj_containers[m_obj_container_index++]; - - if (objContainer.m_type != ZoneDefinitionObjContainerType::IPAK) - continue; - - m_current_ipak = m_ipak_creator.GetOrAddIPak(objContainer.m_name); - m_current_ipak_start_index = objContainer.m_asset_start; - m_current_ipak_end_index = objContainer.m_asset_end; - return; + FindNextObjContainer(); } - m_current_ipak = nullptr; -} + bool AbstractIPakPostProcessor::AppliesToZoneDefinition(const ZoneDefinitionContext& zoneDefinition) + { + return std::ranges::any_of(zoneDefinition.m_zone_definition.m_obj_containers, + [](const ZoneDefinitionObjContainer& objContainer) + { + return objContainer.m_type == ZoneDefinitionObjContainerType::IPAK; + }); + } -void AbstractImageIPakPostProcessor::PostProcessAsset(XAssetInfoGeneric& assetInfo, AssetCreationContext& context) -{ - if (assetInfo.m_name.empty() || assetInfo.m_name[0] == ',') - return; + void AbstractIPakPostProcessor::FindNextObjContainer() + { + const auto objContainerCount = m_zone_definition.m_zone_definition.m_obj_containers.size(); + while (m_obj_container_index < objContainerCount) + { + const auto& objContainer = m_zone_definition.m_zone_definition.m_obj_containers[m_obj_container_index++]; - while (m_current_ipak && m_zone_definition.m_asset_index_in_definition >= m_current_ipak_end_index) - FindNextObjContainer(); + if (objContainer.m_type != ZoneDefinitionObjContainerType::IPAK) + continue; - if (m_current_ipak && m_zone_definition.m_asset_index_in_definition >= m_current_ipak_start_index) - m_current_ipak->AddImage(assetInfo.m_name); -} + m_current_ipak = m_ipak_creator.GetOrAddIPak(objContainer.m_name); + m_current_ipak_start_index = objContainer.m_asset_start; + m_current_ipak_end_index = objContainer.m_asset_end; + return; + } -void AbstractImageIPakPostProcessor::FinalizeZone(AssetCreationContext& context) -{ - m_ipak_creator.Finalize(m_search_path, m_out_dir); -} + m_current_ipak = nullptr; + } + + void AbstractIPakPostProcessor::PostProcessAsset(XAssetInfoGeneric& assetInfo, AssetCreationContext& context) + { + if (assetInfo.m_name.empty() || assetInfo.m_name[0] == ',') + return; + + while (m_current_ipak && m_zone_definition.m_asset_index_in_definition >= m_current_ipak_end_index) + FindNextObjContainer(); + + if (m_current_ipak && m_zone_definition.m_asset_index_in_definition >= m_current_ipak_start_index) + m_current_ipak->AddImage(assetInfo.m_name); + } + + void AbstractIPakPostProcessor::FinalizeZone(AssetCreationContext& context) + { + m_ipak_creator.Finalize(m_search_path, m_out_dir); + } +} // namespace image diff --git a/src/ObjCompiling/Image/ImageIPakPostProcessor.h b/src/ObjCompiling/Image/ImageIPakPostProcessor.h index 675b79cf..b6a6ec2d 100644 --- a/src/ObjCompiling/Image/ImageIPakPostProcessor.h +++ b/src/ObjCompiling/Image/ImageIPakPostProcessor.h @@ -5,48 +5,51 @@ #include "Image/IPak/IPakCreator.h" #include "SearchPath/IOutputPath.h" -class AbstractImageIPakPostProcessor : public IAssetPostProcessor +namespace image { -public: - AbstractImageIPakPostProcessor(const ZoneDefinitionContext& zoneDefinition, - ISearchPath& searchPath, - ZoneAssetCreationStateContainer& zoneStates, - IOutputPath& outDir); - - static bool AppliesToZoneDefinition(const ZoneDefinitionContext& zoneDefinition); - - void PostProcessAsset(XAssetInfoGeneric& assetInfo, AssetCreationContext& context) override; - void FinalizeZone(AssetCreationContext& context) override; - -private: - void FindNextObjContainer(); - - const ZoneDefinitionContext& m_zone_definition; - ISearchPath& m_search_path; - IPakCreator& m_ipak_creator; - IOutputPath& m_out_dir; - - unsigned m_obj_container_index; - IPakToCreate* m_current_ipak; - unsigned m_current_ipak_start_index; - unsigned m_current_ipak_end_index; -}; - -template class ImageIPakPostProcessor final : public AbstractImageIPakPostProcessor -{ -public: - static_assert(std::is_base_of_v); - - ImageIPakPostProcessor(const ZoneDefinitionContext& zoneDefinition, - ISearchPath& searchPath, - ZoneAssetCreationStateContainer& zoneStates, - IOutputPath& outDir) - : AbstractImageIPakPostProcessor(zoneDefinition, searchPath, zoneStates, outDir) + class AbstractIPakPostProcessor : public IAssetPostProcessor { - } + public: + AbstractIPakPostProcessor(const ZoneDefinitionContext& zoneDefinition, + ISearchPath& searchPath, + ZoneAssetCreationStateContainer& zoneStates, + IOutputPath& outDir); - [[nodiscard]] asset_type_t GetHandlingAssetType() const override + static bool AppliesToZoneDefinition(const ZoneDefinitionContext& zoneDefinition); + + void PostProcessAsset(XAssetInfoGeneric& assetInfo, AssetCreationContext& context) override; + void FinalizeZone(AssetCreationContext& context) override; + + private: + void FindNextObjContainer(); + + const ZoneDefinitionContext& m_zone_definition; + ISearchPath& m_search_path; + IPakCreator& m_ipak_creator; + IOutputPath& m_out_dir; + + unsigned m_obj_container_index; + IPakToCreate* m_current_ipak; + unsigned m_current_ipak_start_index; + unsigned m_current_ipak_end_index; + }; + + template class IPakPostProcessor final : public AbstractIPakPostProcessor { - return AssetType::EnumEntry; - } -}; + public: + static_assert(std::is_base_of_v); + + IPakPostProcessor(const ZoneDefinitionContext& zoneDefinition, + ISearchPath& searchPath, + ZoneAssetCreationStateContainer& zoneStates, + IOutputPath& outDir) + : AbstractIPakPostProcessor(zoneDefinition, searchPath, zoneStates, outDir) + { + } + + [[nodiscard]] asset_type_t GetHandlingAssetType() const override + { + return AssetType::EnumEntry; + } + }; +} // namespace image diff --git a/src/ObjCompiling/Image/ImageIwdPostProcessor.cpp b/src/ObjCompiling/Image/ImageIwdPostProcessor.cpp index b329546c..3163ea81 100644 --- a/src/ObjCompiling/Image/ImageIwdPostProcessor.cpp +++ b/src/ObjCompiling/Image/ImageIwdPostProcessor.cpp @@ -1,67 +1,71 @@ #include "ImageIwdPostProcessor.h" +#include "Image/ImageCommon.h" #include "Iwd/IwdCreator.h" #include #include -AbstractImageIwdPostProcessor::AbstractImageIwdPostProcessor(const ZoneDefinitionContext& zoneDefinition, - ISearchPath& searchPath, - ZoneAssetCreationStateContainer& zoneStates, - IOutputPath& outDir) - : m_zone_definition(zoneDefinition), - m_search_path(searchPath), - m_iwd_creator(zoneStates.GetZoneAssetCreationState()), - m_out_dir(outDir), - m_obj_container_index(0u), - m_current_iwd(nullptr), - m_current_iwd_start_index(0u), - m_current_iwd_end_index(0u) +namespace image { - FindNextObjContainer(); -} - -bool AbstractImageIwdPostProcessor::AppliesToZoneDefinition(const ZoneDefinitionContext& zoneDefinition) -{ - return std::ranges::any_of(zoneDefinition.m_zone_definition.m_obj_containers, - [](const ZoneDefinitionObjContainer& objContainer) - { - return objContainer.m_type == ZoneDefinitionObjContainerType::IWD; - }); -} - -void AbstractImageIwdPostProcessor::FindNextObjContainer() -{ - const auto objContainerCount = m_zone_definition.m_zone_definition.m_obj_containers.size(); - while (m_obj_container_index < objContainerCount) + AbstractIwdPostProcessor::AbstractIwdPostProcessor(const ZoneDefinitionContext& zoneDefinition, + ISearchPath& searchPath, + ZoneAssetCreationStateContainer& zoneStates, + IOutputPath& outDir) + : m_zone_definition(zoneDefinition), + m_search_path(searchPath), + m_iwd_creator(zoneStates.GetZoneAssetCreationState()), + m_out_dir(outDir), + m_obj_container_index(0u), + m_current_iwd(nullptr), + m_current_iwd_start_index(0u), + m_current_iwd_end_index(0u) { - const auto& objContainer = m_zone_definition.m_zone_definition.m_obj_containers[m_obj_container_index++]; - - if (objContainer.m_type != ZoneDefinitionObjContainerType::IWD) - continue; - - m_current_iwd = m_iwd_creator.GetOrAddIwd(objContainer.m_name); - m_current_iwd_start_index = objContainer.m_asset_start; - m_current_iwd_end_index = objContainer.m_asset_end; - return; + FindNextObjContainer(); } - m_current_iwd = nullptr; -} + bool AbstractIwdPostProcessor::AppliesToZoneDefinition(const ZoneDefinitionContext& zoneDefinition) + { + return std::ranges::any_of(zoneDefinition.m_zone_definition.m_obj_containers, + [](const ZoneDefinitionObjContainer& objContainer) + { + return objContainer.m_type == ZoneDefinitionObjContainerType::IWD; + }); + } -void AbstractImageIwdPostProcessor::PostProcessAsset(XAssetInfoGeneric& assetInfo, AssetCreationContext& context) -{ - if (assetInfo.m_name.empty() || assetInfo.m_name[0] == ',') - return; + void AbstractIwdPostProcessor::FindNextObjContainer() + { + const auto objContainerCount = m_zone_definition.m_zone_definition.m_obj_containers.size(); + while (m_obj_container_index < objContainerCount) + { + const auto& objContainer = m_zone_definition.m_zone_definition.m_obj_containers[m_obj_container_index++]; - while (m_current_iwd && m_zone_definition.m_asset_index_in_definition >= m_current_iwd_end_index) - FindNextObjContainer(); + if (objContainer.m_type != ZoneDefinitionObjContainerType::IWD) + continue; - if (m_current_iwd && m_zone_definition.m_asset_index_in_definition >= m_current_iwd_start_index) - m_current_iwd->AddFile(std::format("images/{}.iwi", assetInfo.m_name)); -} + m_current_iwd = m_iwd_creator.GetOrAddIwd(objContainer.m_name); + m_current_iwd_start_index = objContainer.m_asset_start; + m_current_iwd_end_index = objContainer.m_asset_end; + return; + } -void AbstractImageIwdPostProcessor::FinalizeZone(AssetCreationContext& context) -{ - m_iwd_creator.Finalize(m_search_path, m_out_dir); -} + m_current_iwd = nullptr; + } + + void AbstractIwdPostProcessor::PostProcessAsset(XAssetInfoGeneric& assetInfo, AssetCreationContext& context) + { + if (assetInfo.m_name.empty() || assetInfo.m_name[0] == ',') + return; + + while (m_current_iwd && m_zone_definition.m_asset_index_in_definition >= m_current_iwd_end_index) + FindNextObjContainer(); + + if (m_current_iwd && m_zone_definition.m_asset_index_in_definition >= m_current_iwd_start_index) + m_current_iwd->AddFile(GetFileNameForAsset(assetInfo.m_name, ".iwi")); + } + + void AbstractIwdPostProcessor::FinalizeZone(AssetCreationContext& context) + { + m_iwd_creator.Finalize(m_search_path, m_out_dir); + } +} // namespace image diff --git a/src/ObjCompiling/Image/ImageIwdPostProcessor.h b/src/ObjCompiling/Image/ImageIwdPostProcessor.h index 8225c29f..a7bf657b 100644 --- a/src/ObjCompiling/Image/ImageIwdPostProcessor.h +++ b/src/ObjCompiling/Image/ImageIwdPostProcessor.h @@ -5,48 +5,48 @@ #include "Iwd/IwdCreator.h" #include "SearchPath/IOutputPath.h" -class AbstractImageIwdPostProcessor : public IAssetPostProcessor +namespace image { -public: - AbstractImageIwdPostProcessor(const ZoneDefinitionContext& zoneDefinition, - ISearchPath& searchPath, - ZoneAssetCreationStateContainer& zoneStates, - IOutputPath& outDir); - - static bool AppliesToZoneDefinition(const ZoneDefinitionContext& zoneDefinition); - - void PostProcessAsset(XAssetInfoGeneric& assetInfo, AssetCreationContext& context) override; - void FinalizeZone(AssetCreationContext& context) override; - -private: - void FindNextObjContainer(); - - const ZoneDefinitionContext& m_zone_definition; - ISearchPath& m_search_path; - IwdCreator& m_iwd_creator; - IOutputPath& m_out_dir; - - unsigned m_obj_container_index; - IwdToCreate* m_current_iwd; - unsigned m_current_iwd_start_index; - unsigned m_current_iwd_end_index; -}; - -template class ImageIwdPostProcessor final : public AbstractImageIwdPostProcessor -{ -public: - static_assert(std::is_base_of_v); - - ImageIwdPostProcessor(const ZoneDefinitionContext& zoneDefinition, - ISearchPath& searchPath, - ZoneAssetCreationStateContainer& zoneStates, - IOutputPath& outDir) - : AbstractImageIwdPostProcessor(zoneDefinition, searchPath, zoneStates, outDir) + class AbstractIwdPostProcessor : public IAssetPostProcessor { - } + public: + AbstractIwdPostProcessor(const ZoneDefinitionContext& zoneDefinition, + ISearchPath& searchPath, + ZoneAssetCreationStateContainer& zoneStates, + IOutputPath& outDir); - [[nodiscard]] asset_type_t GetHandlingAssetType() const override + static bool AppliesToZoneDefinition(const ZoneDefinitionContext& zoneDefinition); + + void PostProcessAsset(XAssetInfoGeneric& assetInfo, AssetCreationContext& context) override; + void FinalizeZone(AssetCreationContext& context) override; + + private: + void FindNextObjContainer(); + + const ZoneDefinitionContext& m_zone_definition; + ISearchPath& m_search_path; + IwdCreator& m_iwd_creator; + IOutputPath& m_out_dir; + + unsigned m_obj_container_index; + IwdToCreate* m_current_iwd; + unsigned m_current_iwd_start_index; + unsigned m_current_iwd_end_index; + }; + + template class IwdPostProcessor final : public AbstractIwdPostProcessor { - return AssetType::EnumEntry; - } -}; + public: + static_assert(std::is_base_of_v); + + IwdPostProcessor(const ZoneDefinitionContext& zoneDefinition, ISearchPath& searchPath, ZoneAssetCreationStateContainer& zoneStates, IOutputPath& outDir) + : AbstractIwdPostProcessor(zoneDefinition, searchPath, zoneStates, outDir) + { + } + + [[nodiscard]] asset_type_t GetHandlingAssetType() const override + { + return AssetType::EnumEntry; + } + }; +} // namespace image diff --git a/src/ObjCompiling/KeyValuePairs/KeyValuePairsCreator.cpp b/src/ObjCompiling/KeyValuePairs/KeyValuePairsCreator.cpp index 348a6177..ec9b2cc8 100644 --- a/src/ObjCompiling/KeyValuePairs/KeyValuePairsCreator.cpp +++ b/src/ObjCompiling/KeyValuePairs/KeyValuePairsCreator.cpp @@ -5,72 +5,75 @@ #include #include -CommonKeyValuePair::CommonKeyValuePair(std::string keyStr, std::string value) - : m_key_str(std::move(keyStr)), - m_value(std::move(value)) +namespace key_value_pairs { -} - -CommonKeyValuePair::CommonKeyValuePair(const unsigned keyHash, std::string value) - : m_key_hash(keyHash), - m_value(std::move(value)) -{ -} - -void KeyValuePairsCreator::AddKeyValuePair(CommonKeyValuePair keyValuePair) -{ - m_key_value_pairs.emplace_back(std::move(keyValuePair)); -} - -void KeyValuePairsCreator::Finalize(const ZoneDefinition& zoneDefinition) -{ - for (const auto& metaData : zoneDefinition.m_properties.m_properties) + CommonKeyValuePair::CommonKeyValuePair(std::string keyStr, std::string value) + : m_key_str(std::move(keyStr)), + m_value(std::move(value)) { - if (metaData.first.rfind("level.", 0) == 0) - { - std::string strValue = metaData.first.substr(std::char_traits::length("level.")); - if (strValue.empty()) - continue; - - if (strValue[0] == '@') - { - char* endPtr; - const unsigned keyHash = strtoul(&strValue[1], &endPtr, 16); - - if (endPtr != &strValue[strValue.size()]) - { - std::cerr << std::format("Could not parse metadata key \"{}\" as hash\n", metaData.first); - continue; - } - - m_key_value_pairs.emplace_back(keyHash, metaData.second); - } - else - { - m_key_value_pairs.emplace_back(std::move(strValue), metaData.second); - } - } } - std::ranges::sort(m_key_value_pairs, - [](const CommonKeyValuePair& v0, const CommonKeyValuePair& v1) - { - if (v0.m_key_str.has_value()) + CommonKeyValuePair::CommonKeyValuePair(const unsigned keyHash, std::string value) + : m_key_hash(keyHash), + m_value(std::move(value)) + { + } + + void Creator::AddKeyValuePair(CommonKeyValuePair keyValuePair) + { + m_key_value_pairs.emplace_back(std::move(keyValuePair)); + } + + void Creator::Finalize(const ZoneDefinition& zoneDefinition) + { + for (const auto& metaData : zoneDefinition.m_properties.m_properties) + { + if (metaData.first.rfind("level.", 0) == 0) + { + std::string strValue = metaData.first.substr(std::char_traits::length("level.")); + if (strValue.empty()) + continue; + + if (strValue[0] == '@') + { + char* endPtr; + const unsigned keyHash = strtoul(&strValue[1], &endPtr, 16); + + if (endPtr != &strValue[strValue.size()]) + { + std::cerr << std::format("Could not parse metadata key \"{}\" as hash\n", metaData.first); + continue; + } + + m_key_value_pairs.emplace_back(keyHash, metaData.second); + } + else + { + m_key_value_pairs.emplace_back(std::move(strValue), metaData.second); + } + } + } + + std::ranges::sort(m_key_value_pairs, + [](const CommonKeyValuePair& v0, const CommonKeyValuePair& v1) { - if (!v1.m_key_str.has_value()) - return true; + if (v0.m_key_str.has_value()) + { + if (!v1.m_key_str.has_value()) + return true; - return *v0.m_key_str < *v1.m_key_str; - } + return *v0.m_key_str < *v1.m_key_str; + } - if (!v1.m_key_hash.has_value()) - return false; + if (!v1.m_key_hash.has_value()) + return false; - return *v0.m_key_hash < *v1.m_key_hash; - }); -} + return *v0.m_key_hash < *v1.m_key_hash; + }); + } -std::vector KeyValuePairsCreator::GetFinalKeyValuePairs() -{ - return std::move(m_key_value_pairs); -} + std::vector Creator::GetFinalKeyValuePairs() + { + return std::move(m_key_value_pairs); + } +} // namespace key_value_pairs diff --git a/src/ObjCompiling/KeyValuePairs/KeyValuePairsCreator.h b/src/ObjCompiling/KeyValuePairs/KeyValuePairsCreator.h index eb91d33f..dd35d260 100644 --- a/src/ObjCompiling/KeyValuePairs/KeyValuePairsCreator.h +++ b/src/ObjCompiling/KeyValuePairs/KeyValuePairsCreator.h @@ -7,24 +7,27 @@ #include #include -class CommonKeyValuePair +namespace key_value_pairs { -public: - CommonKeyValuePair(std::string keyStr, std::string value); - CommonKeyValuePair(unsigned keyHash, std::string value); + class CommonKeyValuePair + { + public: + CommonKeyValuePair(std::string keyStr, std::string value); + CommonKeyValuePair(unsigned keyHash, std::string value); - std::optional m_key_str; - std::optional m_key_hash; - std::string m_value; -}; + std::optional m_key_str; + std::optional m_key_hash; + std::string m_value; + }; -class KeyValuePairsCreator final : public IZoneAssetCreationState -{ -public: - void AddKeyValuePair(CommonKeyValuePair keyValuePair); - void Finalize(const ZoneDefinition& zoneDefinition); - std::vector GetFinalKeyValuePairs(); + class Creator final : public IZoneAssetCreationState + { + public: + void AddKeyValuePair(CommonKeyValuePair keyValuePair); + void Finalize(const ZoneDefinition& zoneDefinition); + std::vector GetFinalKeyValuePairs(); -private: - std::vector m_key_value_pairs; -}; + private: + std::vector m_key_value_pairs; + }; +} // namespace key_value_pairs diff --git a/src/ObjLoading/Techset/TechniqueFileReader.h b/src/ObjLoading/Techset/TechniqueFileReader.h index fe85f9a8..2090304b 100644 --- a/src/ObjLoading/Techset/TechniqueFileReader.h +++ b/src/ObjLoading/Techset/TechniqueFileReader.h @@ -11,14 +11,15 @@ namespace techset { class TechniqueFileReader { + public: + TechniqueFileReader(std::istream& stream, std::string fileName, ITechniqueDefinitionAcceptor* acceptor); + + [[nodiscard]] bool ReadTechniqueDefinition() const; + + private: std::string m_file_name; ITechniqueDefinitionAcceptor* m_acceptor; std::unique_ptr m_base_stream; std::unique_ptr m_comment_proxy; - - public: - TechniqueFileReader(std::istream& stream, std::string fileName, ITechniqueDefinitionAcceptor* acceptor); - - _NODISCARD bool ReadTechniqueDefinition() const; }; } // namespace techset diff --git a/test/ObjCompilingTests/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6Test.cpp b/test/ObjCompilingTests/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6Test.cpp index b25715b9..dc771218 100644 --- a/test/ObjCompilingTests/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6Test.cpp +++ b/test/ObjCompilingTests/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6Test.cpp @@ -26,13 +26,13 @@ namespace m_creators(m_zone), m_ignored_assets(), m_context(m_zone, &m_creators, &m_ignored_assets), - m_kvp_creator(m_zone_states.GetZoneAssetCreationState()) + m_kvp_creator(m_zone_states.GetZoneAssetCreationState<::key_value_pairs::Creator>()) { } std::unique_ptr CreateSut() { - return CreateKeyValuePairsCompiler(m_memory, m_zone, m_zone_definition, m_zone_states); + return T6::key_value_pairs::CreateCompiler(m_memory, m_zone, m_zone_definition, m_zone_states); } TestMemoryManager m_memory; @@ -43,7 +43,7 @@ namespace IgnoredAssetLookup m_ignored_assets; AssetCreationContext m_context; - KeyValuePairsCreator& m_kvp_creator; + ::key_value_pairs::Creator& m_kvp_creator; }; } // namespace @@ -81,7 +81,7 @@ namespace test::game::t6::keyvaluepairs TestContext testContext; const auto sut = testContext.CreateSut(); - testContext.m_kvp_creator.AddKeyValuePair(CommonKeyValuePair("ipak_read", "test_ipak")); + testContext.m_kvp_creator.AddKeyValuePair(::key_value_pairs::CommonKeyValuePair("ipak_read", "test_ipak")); sut->FinalizeZone(testContext.m_context); @@ -107,7 +107,7 @@ namespace test::game::t6::keyvaluepairs TestContext testContext; const auto sut = testContext.CreateSut(); - testContext.m_kvp_creator.AddKeyValuePair(CommonKeyValuePair(0xDDEEFFAA, "hello_there")); + testContext.m_kvp_creator.AddKeyValuePair(::key_value_pairs::CommonKeyValuePair(0xDDEEFFAA, "hello_there")); sut->FinalizeZone(testContext.m_context); diff --git a/test/ObjCompilingTests/Image/IPak/IPakCreatorTest.cpp b/test/ObjCompilingTests/Image/IPak/IPakCreatorTest.cpp index bd49745f..4b4fcd9f 100644 --- a/test/ObjCompilingTests/Image/IPak/IPakCreatorTest.cpp +++ b/test/ObjCompilingTests/Image/IPak/IPakCreatorTest.cpp @@ -26,9 +26,9 @@ namespace { } - IPakCreator& CreateSut() + image::IPakCreator& CreateSut() { - return m_zone_states.GetZoneAssetCreationState(); + return m_zone_states.GetZoneAssetCreationState(); } Zone m_zone; diff --git a/test/ObjCompilingTests/Image/ImageIPakPostProcessorTest.cpp b/test/ObjCompilingTests/Image/ImageIPakPostProcessorTest.cpp index 29dd627f..3955146d 100644 --- a/test/ObjCompilingTests/Image/ImageIPakPostProcessorTest.cpp +++ b/test/ObjCompilingTests/Image/ImageIPakPostProcessorTest.cpp @@ -28,13 +28,13 @@ namespace m_ignored_assets(), m_out_dir(), m_context(m_zone, &m_creators, &m_ignored_assets), - m_ipak_creator(m_zone_states.GetZoneAssetCreationState()) + m_ipak_creator(m_zone_states.GetZoneAssetCreationState()) { } std::unique_ptr CreateSut() { - return std::make_unique>(m_zone_definition_context, m_search_path, m_zone_states, m_out_dir); + return std::make_unique>(m_zone_definition_context, m_search_path, m_zone_states, m_out_dir); } Zone m_zone; @@ -47,7 +47,7 @@ namespace MockOutputPath m_out_dir; AssetCreationContext m_context; - IPakCreator& m_ipak_creator; + image::IPakCreator& m_ipak_creator; }; } // namespace diff --git a/test/ObjCompilingTests/Image/ImageIwdPostProcessorTest.cpp b/test/ObjCompilingTests/Image/ImageIwdPostProcessorTest.cpp index 8e971524..a357e550 100644 --- a/test/ObjCompilingTests/Image/ImageIwdPostProcessorTest.cpp +++ b/test/ObjCompilingTests/Image/ImageIwdPostProcessorTest.cpp @@ -33,7 +33,7 @@ namespace std::unique_ptr CreateSut() { - return std::make_unique>(m_zone_definition_context, m_search_path, m_zone_states, m_out_dir); + return std::make_unique>(m_zone_definition_context, m_search_path, m_zone_states, m_out_dir); } Zone m_zone; diff --git a/test/ObjCompilingTests/KeyValuePairs/KeyValuePairsCreatorTest.cpp b/test/ObjCompilingTests/KeyValuePairs/KeyValuePairsCreatorTest.cpp index 48bffd61..42c21fb1 100644 --- a/test/ObjCompilingTests/KeyValuePairs/KeyValuePairsCreatorTest.cpp +++ b/test/ObjCompilingTests/KeyValuePairs/KeyValuePairsCreatorTest.cpp @@ -13,7 +13,7 @@ namespace test::keyvaluepairs { TEST_CASE("KeyValuePairsCreator: ZoneDefinition with no properties produces no KeyValuePairs", "[keyvaluepairs]") { - KeyValuePairsCreator sut; + key_value_pairs::Creator sut; ZoneDefinition zoneDefinition; sut.Finalize(zoneDefinition); @@ -25,7 +25,7 @@ namespace test::keyvaluepairs TEST_CASE("KeyValuePairsCreator: ZoneDefinition with unrelated properties produce no KeyValuePairs", "[keyvaluepairs]") { - KeyValuePairsCreator sut; + key_value_pairs::Creator sut; ZoneDefinition zoneDefinition; zoneDefinition.m_properties.AddProperty("linker.test", "yes"); @@ -38,7 +38,7 @@ namespace test::keyvaluepairs TEST_CASE("KeyValuePairsCreator: ZoneDefinition with level properties produce KeyValuePairs", "[keyvaluepairs]") { - KeyValuePairsCreator sut; + key_value_pairs::Creator sut; ZoneDefinition zoneDefinition; zoneDefinition.m_properties.AddProperty("linker.test", "yes"); @@ -56,7 +56,7 @@ namespace test::keyvaluepairs TEST_CASE("KeyValuePairsCreator: ZoneDefinition can have level properties with hash", "[keyvaluepairs]") { - KeyValuePairsCreator sut; + key_value_pairs::Creator sut; ZoneDefinition zoneDefinition; zoneDefinition.m_properties.AddProperty("level.@D34DB33F", "yes"); @@ -77,7 +77,7 @@ namespace test::keyvaluepairs TEST_CASE("KeyValuePairsCreator: ZoneDefinition can have level properties with name and/or hash", "[keyvaluepairs]") { - KeyValuePairsCreator sut; + key_value_pairs::Creator sut; ZoneDefinition zoneDefinition; zoneDefinition.m_properties.AddProperty("level.ipak_read", "asdf"); From 46fb919a5246f80fa5f3439586217880e5d5395d Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Wed, 6 Aug 2025 00:50:35 +0200 Subject: [PATCH 34/35] refactor: do not nest asset namespaces in game namespaces * Duplicated namespace names are kind of annoying --- .../FontIconCommon.cpp} | 6 +- .../FontIconCommon.h} | 2 +- .../Game/IW4/Material/CompilerMaterialIW4.cpp | 10 ++-- .../Game/IW4/Material/CompilerMaterialIW4.h | 6 +- src/ObjCompiling/Game/IW4/ObjCompilerIW4.cpp | 6 +- .../Game/IW4/Techset/CompilerTechsetIW4.cpp | 16 +++--- .../Game/IW4/Techset/CompilerTechsetIW4.h | 14 ++--- .../IW4/Techset/CompilerVertexDeclIW4.cpp | 6 +- .../Game/IW4/Techset/CompilerVertexDeclIW4.h | 6 +- .../KeyValuePairs/KeyValuePairsCompilerT6.cpp | 6 +- .../KeyValuePairs/KeyValuePairsCompilerT6.h | 6 +- src/ObjCompiling/Game/T6/ObjCompilerT6.cpp | 2 +- .../Game/IW3/Image/AssetLoaderImageIW3.cpp | 6 +- .../Game/IW3/Image/AssetLoaderImageIW3.h | 6 +- .../IW3/Localize/AssetLoaderLocalizeIW3.cpp | 6 +- .../IW3/Localize/AssetLoaderLocalizeIW3.h | 6 +- .../Game/IW3/Material/LoaderMaterialIW3.cpp | 9 ++- .../Game/IW3/Material/LoaderMaterialIW3.h | 6 +- src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp | 12 ++-- .../IW3/RawFile/AssetLoaderRawFileIW3.cpp | 6 +- .../Game/IW3/RawFile/AssetLoaderRawFileIW3.h | 6 +- .../StringTable/AssetLoaderStringTableIW3.cpp | 9 ++- .../StringTable/AssetLoaderStringTableIW3.h | 6 +- .../IW4/Leaderboard/LoaderLeaderboardIW4.cpp | 9 ++- .../IW4/Leaderboard/LoaderLeaderboardIW4.h | 6 +- .../Game/IW4/LightDef/LightDefLoaderIW4.cpp | 9 ++- .../Game/IW4/LightDef/LightDefLoaderIW4.h | 6 +- .../Game/IW4/Localize/LoaderLocalizeIW4.cpp | 6 +- .../Game/IW4/Localize/LoaderLocalizeIW4.h | 6 +- .../Game/IW4/Material/LoaderMaterialIW4.cpp | 9 ++- .../Game/IW4/Material/LoaderMaterialIW4.h | 6 +- .../Game/IW4/Menu/LoaderMenuListIW4.cpp | 20 +++---- .../Game/IW4/Menu/LoaderMenuListIW4.h | 6 +- .../Game/IW4/Menu/MenuConverterIW4.h | 2 +- src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp | 32 +++++------ .../IW4/PhysPreset/GdtLoaderPhysPresetIW4.cpp | 8 +-- .../IW4/PhysPreset/GdtLoaderPhysPresetIW4.h | 6 +- .../InfoStringLoaderPhysPresetIW4.cpp | 8 +-- .../InfoStringLoaderPhysPresetIW4.h | 8 +-- .../IW4/PhysPreset/RawLoaderPhysPresetIW4.cpp | 11 ++-- .../IW4/PhysPreset/RawLoaderPhysPresetIW4.h | 6 +- .../Game/IW4/RawFile/LoaderRawFileIW4.cpp | 6 +- .../Game/IW4/RawFile/LoaderRawFileIW4.h | 6 +- .../Game/IW4/Shader/LoaderPixelShaderIW4.cpp | 9 ++- .../Game/IW4/Shader/LoaderPixelShaderIW4.h | 6 +- .../Game/IW4/Shader/LoaderVertexShaderIW4.cpp | 9 ++- .../Game/IW4/Shader/LoaderVertexShaderIW4.h | 6 +- .../Game/IW4/Sound/LoaderSoundCurveIW4.cpp | 9 ++- .../Game/IW4/Sound/LoaderSoundCurveIW4.h | 6 +- .../IW4/StringTable/LoaderStringTableIW4.cpp | 9 ++- .../IW4/StringTable/LoaderStringTableIW4.h | 6 +- .../LoaderStructuredDataDefIW4.cpp | 6 +- .../LoaderStructuredDataDefIW4.h | 6 +- .../Game/IW4/Weapon/GdtLoaderWeaponIW4.cpp | 8 +-- .../Game/IW4/Weapon/GdtLoaderWeaponIW4.h | 6 +- .../IW4/Weapon/InfoStringLoaderWeaponIW4.cpp | 8 +-- .../IW4/Weapon/InfoStringLoaderWeaponIW4.h | 8 +-- .../Game/IW4/Weapon/RawLoaderWeaponIW4.cpp | 11 ++-- .../Game/IW4/Weapon/RawLoaderWeaponIW4.h | 6 +- .../Game/IW5/Image/LoaderImageIW5.cpp | 9 ++- .../Game/IW5/Image/LoaderImageIW5.h | 6 +- .../IW5/Leaderboard/LoaderLeaderboardIW5.cpp | 9 ++- .../IW5/Leaderboard/LoaderLeaderboardIW5.h | 6 +- .../Game/IW5/Localize/LoaderLocalizeIW5.cpp | 6 +- .../Game/IW5/Localize/LoaderLocalizeIW5.h | 6 +- .../Game/IW5/Material/LoaderMaterialIW5.cpp | 9 ++- .../Game/IW5/Material/LoaderMaterialIW5.h | 6 +- .../Game/IW5/Menu/LoaderMenuListIW5.cpp | 20 +++---- .../Game/IW5/Menu/LoaderMenuListIW5.h | 6 +- src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp | 24 ++++---- .../Game/IW5/RawFile/LoaderRawFileIW5.cpp | 6 +- .../Game/IW5/RawFile/LoaderRawFileIW5.h | 6 +- .../Game/IW5/Script/LoaderScriptFileIW5.cpp | 6 +- .../Game/IW5/Script/LoaderScriptFileIW5.h | 6 +- .../IW5/StringTable/LoaderStringTableIW5.cpp | 9 ++- .../IW5/StringTable/LoaderStringTableIW5.h | 6 +- .../Game/IW5/Weapon/GdtLoaderWeaponIW5.cpp | 8 +-- .../Game/IW5/Weapon/GdtLoaderWeaponIW5.h | 6 +- .../IW5/Weapon/InfoStringLoaderWeaponIW5.cpp | 8 +-- .../IW5/Weapon/InfoStringLoaderWeaponIW5.h | 8 +-- .../Game/IW5/Weapon/LoaderAttachmentIW5.cpp | 9 ++- .../Game/IW5/Weapon/LoaderAttachmentIW5.h | 6 +- .../Game/IW5/Weapon/RawLoaderWeaponIW5.cpp | 8 +-- .../Game/IW5/Weapon/RawLoaderWeaponIW5.h | 6 +- .../Game/T5/Localize/LoaderLocalizeT5.cpp | 6 +- .../Game/T5/Localize/LoaderLocalizeT5.h | 6 +- .../Game/T5/Material/LoaderMaterialT5.cpp | 9 ++- .../Game/T5/Material/LoaderMaterialT5.h | 6 +- src/ObjLoading/Game/T5/ObjLoaderT5.cpp | 10 ++-- .../Game/T5/RawFile/LoaderRawFileT5.cpp | 6 +- .../Game/T5/RawFile/LoaderRawFileT5.h | 6 +- .../T5/StringTable/LoaderStringTableT5.cpp | 9 ++- .../Game/T5/StringTable/LoaderStringTableT5.h | 6 +- .../Game/T6/FontIcon/CsvLoaderFontIconT6.cpp | 6 +- .../Game/T6/FontIcon/CsvLoaderFontIconT6.h | 6 +- .../Game/T6/FontIcon/JsonLoaderFontIconT6.cpp | 8 +-- .../Game/T6/FontIcon/JsonLoaderFontIconT6.h | 6 +- .../Game/T6/Image/LoaderImageT6.cpp | 9 ++- src/ObjLoading/Game/T6/Image/LoaderImageT6.h | 6 +- .../Leaderboard/JsonLoaderLeaderboardT6.cpp | 9 ++- .../T6/Leaderboard/JsonLoaderLeaderboardT6.h | 6 +- .../Game/T6/Localize/LocalizeLoaderT6.cpp | 6 +- .../Game/T6/Localize/LocalizeLoaderT6.h | 6 +- .../Game/T6/Material/LoaderMaterialT6.cpp | 9 ++- .../Game/T6/Material/LoaderMaterialT6.h | 6 +- src/ObjLoading/Game/T6/ObjLoaderT6.cpp | 56 +++++++++---------- .../GdtLoaderPhysConstraintsT6.cpp | 8 +-- .../GdtLoaderPhysConstraintsT6.h | 6 +- .../InfoStringLoaderPhysConstraintsT6.cpp | 8 +-- .../InfoStringLoaderPhysConstraintsT6.h | 8 +-- .../RawLoaderPhysConstraintsT6.cpp | 11 ++-- .../RawLoaderPhysConstraintsT6.h | 6 +- .../T6/PhysPreset/GdtLoaderPhysPresetT6.cpp | 8 +-- .../T6/PhysPreset/GdtLoaderPhysPresetT6.h | 6 +- .../InfoStringLoaderPhysPresetT6.cpp | 8 +-- .../PhysPreset/InfoStringLoaderPhysPresetT6.h | 8 +-- .../T6/PhysPreset/RawLoaderPhysPresetT6.cpp | 11 ++-- .../T6/PhysPreset/RawLoaderPhysPresetT6.h | 6 +- src/ObjLoading/Game/T6/Qdb/LoaderQdbT6.cpp | 6 +- src/ObjLoading/Game/T6/Qdb/LoaderQdbT6.h | 6 +- .../Game/T6/RawFile/LoaderRawFileT6.cpp | 6 +- .../Game/T6/RawFile/LoaderRawFileT6.h | 6 +- .../Game/T6/Script/LoaderScriptT6.cpp | 6 +- .../Game/T6/Script/LoaderScriptT6.h | 6 +- src/ObjLoading/Game/T6/Slug/LoaderSlugT6.cpp | 6 +- src/ObjLoading/Game/T6/Slug/LoaderSlugT6.h | 6 +- .../Game/T6/Sound/LoaderSoundBankT6.cpp | 6 +- .../Game/T6/Sound/LoaderSoundBankT6.h | 6 +- .../T6/StringTable/LoaderStringTableT6.cpp | 9 ++- .../Game/T6/StringTable/LoaderStringTableT6.h | 6 +- .../Game/T6/Tracer/GdtLoaderTracerT6.cpp | 8 +-- .../Game/T6/Tracer/GdtLoaderTracerT6.h | 6 +- .../T6/Tracer/InfoStringLoaderTracerT6.cpp | 9 ++- .../Game/T6/Tracer/InfoStringLoaderTracerT6.h | 8 +-- .../Game/T6/Tracer/RawLoaderTracerT6.cpp | 11 ++-- .../Game/T6/Tracer/RawLoaderTracerT6.h | 6 +- .../Game/T6/Vehicle/GdtLoaderVehicleT6.cpp | 8 +-- .../Game/T6/Vehicle/GdtLoaderVehicleT6.h | 6 +- .../T6/Vehicle/InfoStringLoaderVehicleT6.cpp | 8 +-- .../T6/Vehicle/InfoStringLoaderVehicleT6.h | 8 +-- .../Game/T6/Vehicle/RawLoaderVehicleT6.cpp | 11 ++-- .../Game/T6/Vehicle/RawLoaderVehicleT6.h | 6 +- .../Game/T6/Weapon/AttachmentGdtLoaderT6.cpp | 8 +-- .../Game/T6/Weapon/AttachmentGdtLoaderT6.h | 6 +- .../Weapon/AttachmentInfoStringLoaderT6.cpp | 8 +-- .../T6/Weapon/AttachmentInfoStringLoaderT6.h | 8 +-- .../Game/T6/Weapon/AttachmentRawLoaderT6.cpp | 8 +-- .../Game/T6/Weapon/AttachmentRawLoaderT6.h | 6 +- .../T6/Weapon/AttachmentUniqueGdtLoaderT6.cpp | 8 +-- .../T6/Weapon/AttachmentUniqueGdtLoaderT6.h | 6 +- .../AttachmentUniqueInfoStringLoaderT6.cpp | 12 ++-- .../AttachmentUniqueInfoStringLoaderT6.h | 10 ++-- .../T6/Weapon/AttachmentUniqueRawLoaderT6.cpp | 11 ++-- .../T6/Weapon/AttachmentUniqueRawLoaderT6.h | 6 +- .../Game/T6/Weapon/CamoJsonLoaderT6.cpp | 9 ++- .../Game/T6/Weapon/CamoJsonLoaderT6.h | 6 +- .../Game/T6/Weapon/WeaponGdtLoaderT6.cpp | 8 +-- .../Game/T6/Weapon/WeaponGdtLoaderT6.h | 6 +- .../T6/Weapon/WeaponInfoStringLoaderT6.cpp | 10 ++-- .../Game/T6/Weapon/WeaponInfoStringLoaderT6.h | 8 +-- .../Game/T6/Weapon/WeaponRawLoaderT6.cpp | 11 ++-- .../Game/T6/Weapon/WeaponRawLoaderT6.h | 6 +- .../Game/T6/ZBarrier/GdtLoaderZBarrierT6.cpp | 8 +-- .../Game/T6/ZBarrier/GdtLoaderZBarrierT6.h | 6 +- .../ZBarrier/InfoStringLoaderZBarrierT6.cpp | 8 +-- .../T6/ZBarrier/InfoStringLoaderZBarrierT6.h | 8 +-- .../Game/T6/ZBarrier/RawLoaderZBarrierT6.cpp | 11 ++-- .../Game/T6/ZBarrier/RawLoaderZBarrierT6.h | 6 +- .../XModel/LoaderXModel.cpp.template | 6 +- src/ObjLoading/XModel/LoaderXModel.h.template | 6 +- .../Game/IW3/Image/ImageDumperIW3.cpp | 13 ++--- .../Game/IW3/Image/ImageDumperIW3.h | 12 ++-- .../Game/IW3/Localize/LocalizeDumperIW3.cpp | 6 +- .../Game/IW3/Localize/LocalizeDumperIW3.h | 8 +-- .../Game/IW3/Maps/MapEntsDumperIW3.cpp | 8 +-- .../Game/IW3/Maps/MapEntsDumperIW3.h | 10 ++-- src/ObjWriting/Game/IW3/ObjWriterIW3.cpp | 16 +++--- .../Game/IW3/RawFile/RawFileDumperIW3.cpp | 8 +-- .../Game/IW3/RawFile/RawFileDumperIW3.h | 10 ++-- .../Game/IW3/Sound/LoadedSoundDumperIW3.cpp | 8 +-- .../Game/IW3/Sound/LoadedSoundDumperIW3.h | 10 ++-- .../IW3/StringTable/StringTableDumperIW3.cpp | 8 +-- .../IW3/StringTable/StringTableDumperIW3.h | 10 ++-- .../Game/IW4/Image/ImageDumperIW4.cpp | 13 ++--- .../Game/IW4/Image/ImageDumperIW4.h | 12 ++-- .../Leaderboard/LeaderboardJsonDumperIW4.cpp | 9 ++- .../Leaderboard/LeaderboardJsonDumperIW4.h | 10 ++-- .../Game/IW4/LightDef/LightDefDumperIW4.cpp | 9 ++- .../Game/IW4/LightDef/LightDefDumperIW4.h | 10 ++-- .../Game/IW4/Localize/LocalizeDumperIW4.cpp | 6 +- .../Game/IW4/Localize/LocalizeDumperIW4.h | 8 +-- .../Game/IW4/Maps/AddonMapEntsDumperIW4.cpp | 8 +-- .../Game/IW4/Maps/AddonMapEntsDumperIW4.h | 10 ++-- .../Material/MaterialDecompilingDumperIW4.cpp | 8 +-- .../Material/MaterialDecompilingDumperIW4.h | 10 ++-- .../Game/IW4/Menu/MenuDumperIW4.cpp | 15 +++-- src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.h | 10 ++-- .../Game/IW4/Menu/MenuListDumperIW4.cpp | 21 ++++--- .../Game/IW4/Menu/MenuListDumperIW4.h | 14 ++--- .../Game/IW4/Menu/MenuWriterIW4.cpp | 8 +-- src/ObjWriting/Game/IW4/Menu/MenuWriterIW4.h | 12 ++-- src/ObjWriting/Game/IW4/ObjWriterIW4.cpp | 46 +++++++-------- .../IW4/PhysCollmap/PhysCollmapDumperIW4.cpp | 11 ++-- .../IW4/PhysCollmap/PhysCollmapDumperIW4.h | 10 ++-- .../PhysPresetInfoStringDumperIW4.cpp | 9 ++- .../PhysPresetInfoStringDumperIW4.h | 10 ++-- .../Game/IW4/RawFile/RawFileDumperIW4.cpp | 8 +-- .../Game/IW4/RawFile/RawFileDumperIW4.h | 10 ++-- .../Game/IW4/Shader/PixelShaderDumperIW4.cpp | 11 ++-- .../Game/IW4/Shader/PixelShaderDumperIW4.h | 10 ++-- .../Game/IW4/Shader/VertexShaderDumperIW4.cpp | 11 ++-- .../Game/IW4/Shader/VertexShaderDumperIW4.h | 10 ++-- .../Game/IW4/Sound/LoadedSoundDumperIW4.cpp | 8 +-- .../Game/IW4/Sound/LoadedSoundDumperIW4.h | 10 ++-- .../Game/IW4/Sound/SndCurveDumperIW4.cpp | 9 ++- .../Game/IW4/Sound/SndCurveDumperIW4.h | 10 ++-- .../IW4/StringTable/StringTableDumperIW4.cpp | 8 +-- .../IW4/StringTable/StringTableDumperIW4.h | 10 ++-- .../StructuredDataDefDumperIW4.cpp | 8 +-- .../StructuredDataDefDumperIW4.h | 10 ++-- .../Game/IW4/Techset/TechsetDumperIW4.cpp | 9 ++- .../Game/IW4/Techset/TechsetDumperIW4.h | 10 ++-- .../Game/IW4/Tracer/TracerDumperIW4.cpp | 9 ++- .../Game/IW4/Tracer/TracerDumperIW4.h | 10 ++-- .../Game/IW4/Vehicle/VehicleDumperIW4.cpp | 9 ++- .../Game/IW4/Vehicle/VehicleDumperIW4.h | 10 ++-- .../Game/IW4/Weapon/WeaponDumperIW4.cpp | 9 ++- .../Game/IW4/Weapon/WeaponDumperIW4.h | 10 ++-- .../Game/IW5/Image/ImageDumperIW5.cpp | 13 ++--- .../Game/IW5/Image/ImageDumperIW5.h | 12 ++-- .../Leaderboard/LeaderboardJsonDumperIW5.cpp | 9 ++- .../Leaderboard/LeaderboardJsonDumperIW5.h | 10 ++-- .../Game/IW5/Localize/LocalizeDumperIW5.cpp | 6 +- .../Game/IW5/Localize/LocalizeDumperIW5.h | 8 +-- .../Game/IW5/Maps/AddonMapEntsDumperIW5.cpp | 8 +-- .../Game/IW5/Maps/AddonMapEntsDumperIW5.h | 10 ++-- .../Game/IW5/Menu/MenuDumperIW5.cpp | 10 ++-- src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.h | 10 ++-- .../Game/IW5/Menu/MenuListDumperIW5.cpp | 14 ++--- .../Game/IW5/Menu/MenuListDumperIW5.h | 10 ++-- .../Game/IW5/Menu/MenuWriterIW5.cpp | 8 +-- src/ObjWriting/Game/IW5/Menu/MenuWriterIW5.h | 12 ++-- src/ObjWriting/Game/IW5/ObjWriterIW5.cpp | 28 +++++----- .../Game/IW5/RawFile/RawFileDumperIW5.cpp | 8 +-- .../Game/IW5/RawFile/RawFileDumperIW5.h | 10 ++-- .../Game/IW5/Script/ScriptDumperIW5.cpp | 8 +-- .../Game/IW5/Script/ScriptDumperIW5.h | 10 ++-- .../Game/IW5/Sound/LoadedSoundDumperIW5.cpp | 8 +-- .../Game/IW5/Sound/LoadedSoundDumperIW5.h | 10 ++-- .../IW5/StringTable/StringTableDumperIW5.cpp | 8 +-- .../IW5/StringTable/StringTableDumperIW5.h | 10 ++-- .../IW5/Weapon/AttachmentJsonDumperIW5.cpp | 9 ++- .../Game/IW5/Weapon/AttachmentJsonDumperIW5.h | 10 ++-- .../Game/IW5/Weapon/WeaponDumperIW5.cpp | 9 ++- .../Game/IW5/Weapon/WeaponDumperIW5.h | 10 ++-- .../Game/T5/Image/ImageDumperT5.cpp | 13 ++--- src/ObjWriting/Game/T5/Image/ImageDumperT5.h | 12 ++-- .../Game/T5/Localize/LocalizeDumperT5.cpp | 6 +- .../Game/T5/Localize/LocalizeDumperT5.h | 8 +-- src/ObjWriting/Game/T5/ObjWriterT5.cpp | 12 ++-- .../Game/T5/RawFile/RawFileDumperT5.cpp | 8 +-- .../Game/T5/RawFile/RawFileDumperT5.h | 10 ++-- .../T5/StringTable/StringTableDumperT5.cpp | 8 +-- .../Game/T5/StringTable/StringTableDumperT5.h | 10 ++-- .../Game/T6/FontIcon/FontIconCsvDumperT6.cpp | 8 +-- .../Game/T6/FontIcon/FontIconCsvDumperT6.h | 10 ++-- .../Game/T6/FontIcon/FontIconDumperT6.cpp | 10 ++-- .../Game/T6/FontIcon/FontIconDumperT6.h | 8 ++- .../Game/T6/FontIcon/FontIconJsonDumperT6.cpp | 12 ++-- .../Game/T6/FontIcon/FontIconJsonDumperT6.h | 10 ++-- .../Game/T6/Image/ImageDumperT6.cpp | 13 ++--- src/ObjWriting/Game/T6/Image/ImageDumperT6.h | 12 ++-- .../Leaderboard/LeaderboardJsonDumperT6.cpp | 9 ++- .../T6/Leaderboard/LeaderboardJsonDumperT6.h | 10 ++-- .../Game/T6/Localize/LocalizeDumperT6.cpp | 6 +- .../Game/T6/Localize/LocalizeDumperT6.h | 8 +-- .../Game/T6/Maps/MapEntsDumperT6.cpp | 8 +-- src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.h | 10 ++-- src/ObjWriting/Game/T6/ObjWriterT6.cpp | 48 ++++++++-------- .../PhysConstraintsInfoStringDumperT6.cpp | 9 ++- .../PhysConstraintsInfoStringDumperT6.h | 10 ++-- .../PhysPresetInfoStringDumperT6.cpp | 9 ++- .../PhysPreset/PhysPresetInfoStringDumperT6.h | 10 ++-- src/ObjWriting/Game/T6/Qdb/QdbDumperT6.cpp | 8 +-- src/ObjWriting/Game/T6/Qdb/QdbDumperT6.h | 10 ++-- .../Game/T6/RawFile/RawFileDumperT6.cpp | 8 +-- .../Game/T6/RawFile/RawFileDumperT6.h | 10 ++-- .../Game/T6/Script/ScriptDumperT6.cpp | 8 +-- .../Game/T6/Script/ScriptDumperT6.h | 10 ++-- src/ObjWriting/Game/T6/Slug/SlugDumperT6.cpp | 8 +-- src/ObjWriting/Game/T6/Slug/SlugDumperT6.h | 10 ++-- .../Game/T6/Sound/SndBankDumperT6.cpp | 6 +- .../Game/T6/Sound/SndBankDumperT6.h | 8 +-- .../T6/Sound/SndDriverGlobalsDumperT6.cpp | 6 +- .../Game/T6/Sound/SndDriverGlobalsDumperT6.h | 8 +-- .../T6/StringTable/StringTableDumperT6.cpp | 8 +-- .../Game/T6/StringTable/StringTableDumperT6.h | 10 ++-- .../Game/T6/Techset/TechsetDumperT6.cpp | 8 +-- .../Game/T6/Techset/TechsetDumperT6.h | 10 ++-- .../Game/T6/Tracer/TracerDumperT6.cpp | 9 ++- .../Game/T6/Tracer/TracerDumperT6.h | 10 ++-- .../Game/T6/Vehicle/VehicleDumperT6.cpp | 8 +-- .../Game/T6/Vehicle/VehicleDumperT6.h | 10 ++-- .../Game/T6/Weapon/AttachmentDumperT6.cpp | 9 ++- .../Game/T6/Weapon/AttachmentDumperT6.h | 10 ++-- .../T6/Weapon/AttachmentUniqueDumperT6.cpp | 9 ++- .../Game/T6/Weapon/AttachmentUniqueDumperT6.h | 10 ++-- .../Game/T6/Weapon/CamoJsonDumperT6.cpp | 9 ++- .../Game/T6/Weapon/CamoJsonDumperT6.h | 10 ++-- .../Game/T6/Weapon/WeaponDumperT6.cpp | 9 ++- .../Game/T6/Weapon/WeaponDumperT6.h | 10 ++-- .../Game/T6/ZBarrier/ZBarrierDumperT6.cpp | 9 ++- .../Game/T6/ZBarrier/ZBarrierDumperT6.h | 10 ++-- .../Material/MaterialJsonDumper.cpp.template | 13 +++-- .../Material/MaterialJsonDumper.h.template | 14 +++-- .../XModel/XModelDumper.cpp.template | 11 ++-- src/ObjWriting/XModel/XModelDumper.h.template | 12 ++-- .../KeyValuePairsCompilerT6Test.cpp | 4 +- .../IW3/Material/LoaderMaterialIW3Test.cpp | 2 +- .../AssetLoaderStringTableIW3Test.cpp | 2 +- .../AssetLoaders/LoaderStringTableIW4Test.cpp | 2 +- .../IW4/Material/LoaderMaterialIW4Test.cpp | 2 +- .../Game/IW4/Menu/LoaderMenuListIW4Test.cpp | 3 +- .../AssetLoaders/LoaderStringTableIW5Test.cpp | 2 +- .../IW5/Material/LoaderMaterialIW5Test.cpp | 2 +- .../AssetLoaders/LoaderStringTableT5Test.cpp | 2 +- .../Game/T5/Material/LoaderMaterialT5Test.cpp | 2 +- .../AssetLoaders/LoaderStringTableT6Test.cpp | 2 +- .../T6/FontIcon/JsonLoaderFontIconT6Test.cpp | 2 +- .../Game/T6/Material/LoaderMaterialT6Test.cpp | 2 +- ...rIW3.cpp => MaterialJsonDumperIW3Test.cpp} | 2 +- ...rIW4.cpp => MaterialJsonDumperIW4Test.cpp} | 2 +- ...rIW5.cpp => MaterialJsonDumperIW5Test.cpp} | 2 +- ...perT5.cpp => MaterialJsonDumperT5Test.cpp} | 2 +- .../T6/FontIcon/FontIconJsonDumperT6Test.cpp | 2 +- .../T6/Material/MaterialJsonDumperT6Test.cpp | 2 +- 336 files changed, 1430 insertions(+), 1480 deletions(-) rename src/ObjCommon/{Game/T6/FontIcon/FontIconCommonT6.cpp => FontIcon/FontIconCommon.cpp} (85%) rename src/ObjCommon/{Game/T6/FontIcon/FontIconCommonT6.h => FontIcon/FontIconCommon.h} (82%) rename test/ObjWritingTests/Game/IW3/Material/{MaterialJsonDumperIW3.cpp => MaterialJsonDumperIW3Test.cpp} (99%) rename test/ObjWritingTests/Game/IW4/Material/{MaterialJsonDumperIW4.cpp => MaterialJsonDumperIW4Test.cpp} (99%) rename test/ObjWritingTests/Game/IW5/Material/{MaterialJsonDumperIW5.cpp => MaterialJsonDumperIW5Test.cpp} (99%) rename test/ObjWritingTests/Game/T5/Material/{MaterialJsonDumperT5.cpp => MaterialJsonDumperT5Test.cpp} (99%) diff --git a/src/ObjCommon/Game/T6/FontIcon/FontIconCommonT6.cpp b/src/ObjCommon/FontIcon/FontIconCommon.cpp similarity index 85% rename from src/ObjCommon/Game/T6/FontIcon/FontIconCommonT6.cpp rename to src/ObjCommon/FontIcon/FontIconCommon.cpp index 5ae57d48..af9cbfb1 100644 --- a/src/ObjCommon/Game/T6/FontIcon/FontIconCommonT6.cpp +++ b/src/ObjCommon/FontIcon/FontIconCommon.cpp @@ -1,11 +1,11 @@ -#include "FontIconCommonT6.h" +#include "FontIconCommon.h" #include "Utils/StringUtils.h" #include namespace fs = std::filesystem; -namespace T6::font_icon +namespace font_icon { std::string GetJsonFileNameForAssetName(const std::string& assetName) { @@ -20,4 +20,4 @@ namespace T6::font_icon return assetName; } -} // namespace T6::font_icon +} // namespace font_icon diff --git a/src/ObjCommon/Game/T6/FontIcon/FontIconCommonT6.h b/src/ObjCommon/FontIcon/FontIconCommon.h similarity index 82% rename from src/ObjCommon/Game/T6/FontIcon/FontIconCommonT6.h rename to src/ObjCommon/FontIcon/FontIconCommon.h index bcce4518..e4c887bd 100644 --- a/src/ObjCommon/Game/T6/FontIcon/FontIconCommonT6.h +++ b/src/ObjCommon/FontIcon/FontIconCommon.h @@ -2,7 +2,7 @@ #include -namespace T6::font_icon +namespace font_icon { std::string GetJsonFileNameForAssetName(const std::string& assetName); } diff --git a/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.cpp b/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.cpp index 0fc61324..82d6ceb5 100644 --- a/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.cpp +++ b/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.cpp @@ -48,7 +48,7 @@ namespace m_registration(registration), m_state_map_cache(context.GetZoneAssetCreationState<::techset::TechniqueStateMapCache>()), m_base_state_bits{}, - m_techset_creator(IW4::techset::CreateLoader(memory, searchPath)) + m_techset_creator(techset::CreateLoaderIW4(memory, searchPath)) { } @@ -1325,7 +1325,7 @@ namespace std::vector m_textures; std::vector m_constants; - std::unique_ptr<::IW4::techset::ICreator> m_techset_creator; + std::unique_ptr m_techset_creator; }; class MaterialLoader final : public AssetCreator @@ -1375,10 +1375,10 @@ namespace }; } // namespace -namespace IW4::material +namespace material { - std::unique_ptr> CreateCompiler(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt) + std::unique_ptr> CreateCompilerIW4(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt) { return std::make_unique(memory, searchPath, gdt); } -} // namespace IW4::material +} // namespace material diff --git a/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.h b/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.h index 3258e1b5..7d3e216a 100644 --- a/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.h +++ b/src/ObjCompiling/Game/IW4/Material/CompilerMaterialIW4.h @@ -6,7 +6,7 @@ #include "SearchPath/ISearchPath.h" #include "Utils/MemoryManager.h" -namespace IW4::material +namespace material { - std::unique_ptr> CreateCompiler(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt); -} // namespace IW4::material + std::unique_ptr> CreateCompilerIW4(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt); +} // namespace material diff --git a/src/ObjCompiling/Game/IW4/ObjCompilerIW4.cpp b/src/ObjCompiling/Game/IW4/ObjCompilerIW4.cpp index 8ad32e9d..3930a746 100644 --- a/src/ObjCompiling/Game/IW4/ObjCompilerIW4.cpp +++ b/src/ObjCompiling/Game/IW4/ObjCompilerIW4.cpp @@ -17,10 +17,10 @@ namespace auto& memory = zone.Memory(); #ifdef EXPERIMENTAL_MATERIAL_COMPILATION - collection.AddAssetCreator(material::CreateCompiler(memory, searchPath, gdt)); - collection.AddAssetCreator(IW4::techset::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(material::CreateCompilerIW4(memory, searchPath, gdt)); + collection.AddAssetCreator(techset::CreateLoaderIW4(memory, searchPath)); #endif - collection.AddAssetCreator(vertex_decl::CreateLoader(memory)); + collection.AddAssetCreator(vertex_decl::CreateLoaderIW4(memory)); } void ConfigurePostProcessors(AssetCreatorCollection& collection, diff --git a/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.cpp b/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.cpp index dd336d7e..50fe5b4e 100644 --- a/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.cpp +++ b/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.cpp @@ -203,7 +203,7 @@ namespace ISearchPath& searchPath, MemoryManager& memory, AssetCreationContext& context, - IW4::techset::ICreator* techsetCreator) + techset::ICreatorIW4* techsetCreator) : m_technique_name(techniqueName), m_search_path(searchPath), m_memory(memory), @@ -1026,13 +1026,13 @@ namespace TechniqueZoneLoadingState& m_zone_state; TechniqueStateMapCache& m_state_map_cache; ShaderInfoFromFileSystemCacheState& m_shader_info_cache; - IW4::techset::ICreator* m_techset_creator; + techset::ICreatorIW4* m_techset_creator; }; class TechniqueLoader { public: - TechniqueLoader(ISearchPath& searchPath, MemoryManager& memory, AssetCreationContext& context, IW4::techset::ICreator* techsetCreator) + TechniqueLoader(ISearchPath& searchPath, MemoryManager& memory, AssetCreationContext& context, techset::ICreatorIW4* techsetCreator) : m_search_path(searchPath), m_memory(memory), m_context(context), @@ -1260,10 +1260,10 @@ namespace MemoryManager& m_memory; AssetCreationContext& m_context; TechniqueZoneLoadingState& m_zone_state; - IW4::techset::ICreator* m_techset_creator; + techset::ICreatorIW4* m_techset_creator; }; - class TechsetLoader final : public IW4::techset::ICreator + class TechsetLoader final : public techset::ICreatorIW4 { public: TechsetLoader(MemoryManager& memory, ISearchPath& searchPath) @@ -1369,10 +1369,10 @@ namespace }; } // namespace -namespace IW4::techset +namespace techset { - std::unique_ptr CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr CreateLoaderIW4(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4::techset +} // namespace techset diff --git a/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.h b/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.h index 0187b329..09fd1375 100644 --- a/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.h +++ b/src/ObjCompiling/Game/IW4/Techset/CompilerTechsetIW4.h @@ -10,17 +10,17 @@ #include #include -namespace IW4::techset +namespace techset { - class ICreator : public AssetCreator + class ICreatorIW4 : public AssetCreator { public: - ICreator() = default; - virtual ~ICreator() = default; + ICreatorIW4() = default; + virtual ~ICreatorIW4() = default; - virtual ::techset::TechsetDefinition* LoadTechsetDefinition(const std::string& assetName, AssetCreationContext& context, bool& failure) = 0; + virtual TechsetDefinition* LoadTechsetDefinition(const std::string& assetName, AssetCreationContext& context, bool& failure) = 0; virtual const state_map::StateMapDefinition* LoadStateMapDefinition(const std::string& stateMapName, AssetCreationContext& context) = 0; }; - std::unique_ptr CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4::techset + std::unique_ptr CreateLoaderIW4(MemoryManager& memory, ISearchPath& searchPath); +} // namespace techset diff --git a/src/ObjCompiling/Game/IW4/Techset/CompilerVertexDeclIW4.cpp b/src/ObjCompiling/Game/IW4/Techset/CompilerVertexDeclIW4.cpp index feaa64bf..9ce59278 100644 --- a/src/ObjCompiling/Game/IW4/Techset/CompilerVertexDeclIW4.cpp +++ b/src/ObjCompiling/Game/IW4/Techset/CompilerVertexDeclIW4.cpp @@ -92,10 +92,10 @@ namespace }; } // namespace -namespace IW4::vertex_decl +namespace vertex_decl { - std::unique_ptr> CreateLoader(MemoryManager& memory) + std::unique_ptr> CreateLoaderIW4(MemoryManager& memory) { return std::make_unique(memory); } -} // namespace IW4::vertex_decl +} // namespace vertex_decl diff --git a/src/ObjCompiling/Game/IW4/Techset/CompilerVertexDeclIW4.h b/src/ObjCompiling/Game/IW4/Techset/CompilerVertexDeclIW4.h index 3153e5a0..4713a652 100644 --- a/src/ObjCompiling/Game/IW4/Techset/CompilerVertexDeclIW4.h +++ b/src/ObjCompiling/Game/IW4/Techset/CompilerVertexDeclIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4::vertex_decl +namespace vertex_decl { - std::unique_ptr> CreateLoader(MemoryManager& memory); -} // namespace IW4::vertex_decl + std::unique_ptr> CreateLoaderIW4(MemoryManager& memory); +} // namespace vertex_decl diff --git a/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.cpp b/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.cpp index 92d3cd0d..92be6c06 100644 --- a/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.cpp +++ b/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.cpp @@ -71,11 +71,11 @@ namespace }; } // namespace -namespace T6::key_value_pairs +namespace key_value_pairs { std::unique_ptr - CreateCompiler(MemoryManager& memory, const Zone& zone, const ZoneDefinition& zoneDefinition, ZoneAssetCreationStateContainer& zoneStates) + CreateCompilerT6(MemoryManager& memory, const Zone& zone, const ZoneDefinition& zoneDefinition, ZoneAssetCreationStateContainer& zoneStates) { return std::make_unique(memory, zone, zoneDefinition, zoneStates); } -} // namespace T6::key_value_pairs +} // namespace key_value_pairs diff --git a/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.h b/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.h index a3dadb8c..f5ce8b37 100644 --- a/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.h +++ b/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.h @@ -9,8 +9,8 @@ #include -namespace T6::key_value_pairs +namespace key_value_pairs { std::unique_ptr - CreateCompiler(MemoryManager& memory, const Zone& zone, const ZoneDefinition& zoneDefinition, ZoneAssetCreationStateContainer& zoneStates); -} // namespace T6::key_value_pairs + CreateCompilerT6(MemoryManager& memory, const Zone& zone, const ZoneDefinition& zoneDefinition, ZoneAssetCreationStateContainer& zoneStates); +} // namespace key_value_pairs diff --git a/src/ObjCompiling/Game/T6/ObjCompilerT6.cpp b/src/ObjCompiling/Game/T6/ObjCompilerT6.cpp index d25f2dee..8228234d 100644 --- a/src/ObjCompiling/Game/T6/ObjCompilerT6.cpp +++ b/src/ObjCompiling/Game/T6/ObjCompilerT6.cpp @@ -19,7 +19,7 @@ namespace { auto& memory = zone.Memory(); - collection.AddAssetCreator(T6::key_value_pairs::CreateCompiler(memory, zone, zoneDefinition.m_zone_definition, zoneStates)); + collection.AddAssetCreator(key_value_pairs::CreateCompilerT6(memory, zone, zoneDefinition.m_zone_definition, zoneStates)); } void ConfigurePostProcessors(AssetCreatorCollection& collection, diff --git a/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.cpp b/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.cpp index 8518ffaf..b7f03a20 100644 --- a/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.cpp +++ b/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.cpp @@ -122,10 +122,10 @@ namespace }; } // namespace -namespace IW3::image +namespace image { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderIW3(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW3::image +} // namespace image diff --git a/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.h b/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.h index 37bc8cb4..b8d60124 100644 --- a/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.h +++ b/src/ObjLoading/Game/IW3/Image/AssetLoaderImageIW3.h @@ -7,7 +7,7 @@ #include -namespace IW3::image +namespace image { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW3::image + std::unique_ptr> CreateLoaderIW3(MemoryManager& memory, ISearchPath& searchPath); +} // namespace image diff --git a/src/ObjLoading/Game/IW3/Localize/AssetLoaderLocalizeIW3.cpp b/src/ObjLoading/Game/IW3/Localize/AssetLoaderLocalizeIW3.cpp index e56a904c..0afa5b6c 100644 --- a/src/ObjLoading/Game/IW3/Localize/AssetLoaderLocalizeIW3.cpp +++ b/src/ObjLoading/Game/IW3/Localize/AssetLoaderLocalizeIW3.cpp @@ -36,10 +36,10 @@ namespace }; } // namespace -namespace IW3::localize +namespace localize { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateLoaderIW3(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace IW3::localize +} // namespace localize diff --git a/src/ObjLoading/Game/IW3/Localize/AssetLoaderLocalizeIW3.h b/src/ObjLoading/Game/IW3/Localize/AssetLoaderLocalizeIW3.h index 447a6a90..7d1c30ed 100644 --- a/src/ObjLoading/Game/IW3/Localize/AssetLoaderLocalizeIW3.h +++ b/src/ObjLoading/Game/IW3/Localize/AssetLoaderLocalizeIW3.h @@ -8,7 +8,7 @@ #include -namespace IW3::localize +namespace localize { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace IW3::localize + std::unique_ptr> CreateLoaderIW3(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace localize diff --git a/src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.cpp b/src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.cpp index 769e6b71..5172498a 100644 --- a/src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.cpp +++ b/src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.cpp @@ -8,7 +8,6 @@ #include using namespace IW3; -using namespace ::material; namespace { @@ -23,7 +22,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto file = m_search_path.Open(GetFileNameForAssetName(assetName)); + const auto file = m_search_path.Open(material::GetFileNameForAssetName(assetName)); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -46,10 +45,10 @@ namespace }; } // namespace -namespace IW3::material +namespace material { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderIW3(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW3::material +} // namespace material diff --git a/src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.h b/src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.h index 2bfa9db1..fd51d2c4 100644 --- a/src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.h +++ b/src/ObjLoading/Game/IW3/Material/LoaderMaterialIW3.h @@ -6,7 +6,7 @@ #include "SearchPath/ISearchPath.h" #include "Utils/MemoryManager.h" -namespace IW3::material +namespace material { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW3::material + std::unique_ptr> CreateLoaderIW3(MemoryManager& memory, ISearchPath& searchPath); +} // namespace material diff --git a/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp b/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp index 12583d1a..fb2c1627 100644 --- a/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp +++ b/src/ObjLoading/Game/IW3/ObjLoaderIW3.cpp @@ -91,10 +91,10 @@ namespace // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(xmodel::CreateXModelLoader(memory, searchPath, zone)); - collection.AddAssetCreator(material::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(xmodel::CreateLoaderIW3(memory, searchPath, zone)); + collection.AddAssetCreator(material::CreateLoaderIW3(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(image::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(image::CreateLoaderIW3(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); @@ -108,13 +108,13 @@ namespace // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(localize::CreateLoader(memory, searchPath, zone)); + collection.AddAssetCreator(localize::CreateLoaderIW3(memory, searchPath, zone)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(raw_file::CreateLoader(memory, searchPath)); - collection.AddAssetCreator(string_table::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(raw_file::CreateLoaderIW3(memory, searchPath)); + collection.AddAssetCreator(string_table::CreateLoaderIW3(memory, searchPath)); } } // namespace diff --git a/src/ObjLoading/Game/IW3/RawFile/AssetLoaderRawFileIW3.cpp b/src/ObjLoading/Game/IW3/RawFile/AssetLoaderRawFileIW3.cpp index 6229ac79..ffeaef61 100644 --- a/src/ObjLoading/Game/IW3/RawFile/AssetLoaderRawFileIW3.cpp +++ b/src/ObjLoading/Game/IW3/RawFile/AssetLoaderRawFileIW3.cpp @@ -44,10 +44,10 @@ namespace }; } // namespace -namespace IW3::raw_file +namespace raw_file { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderIW3(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW3::raw_file +} // namespace raw_file diff --git a/src/ObjLoading/Game/IW3/RawFile/AssetLoaderRawFileIW3.h b/src/ObjLoading/Game/IW3/RawFile/AssetLoaderRawFileIW3.h index d3c74f6d..914c0529 100644 --- a/src/ObjLoading/Game/IW3/RawFile/AssetLoaderRawFileIW3.h +++ b/src/ObjLoading/Game/IW3/RawFile/AssetLoaderRawFileIW3.h @@ -7,7 +7,7 @@ #include -namespace IW3::raw_file +namespace raw_file { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW3::raw_file + std::unique_ptr> CreateLoaderIW3(MemoryManager& memory, ISearchPath& searchPath); +} // namespace raw_file diff --git a/src/ObjLoading/Game/IW3/StringTable/AssetLoaderStringTableIW3.cpp b/src/ObjLoading/Game/IW3/StringTable/AssetLoaderStringTableIW3.cpp index bcb640ec..e8146808 100644 --- a/src/ObjLoading/Game/IW3/StringTable/AssetLoaderStringTableIW3.cpp +++ b/src/ObjLoading/Game/IW3/StringTable/AssetLoaderStringTableIW3.cpp @@ -6,7 +6,6 @@ #include using namespace IW3; -using namespace ::string_table; namespace { @@ -25,7 +24,7 @@ namespace if (!file.IsOpen()) return AssetCreationResult::NoAction(); - StringTableLoaderV1 loader; + string_table::StringTableLoaderV1 loader; auto* stringTable = loader.LoadFromStream(assetName, m_memory, *file.m_stream); if (!stringTable) return AssetCreationResult::Failure(); @@ -39,10 +38,10 @@ namespace }; } // namespace -namespace IW3::string_table +namespace string_table { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderIW3(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW3::string_table +} // namespace string_table diff --git a/src/ObjLoading/Game/IW3/StringTable/AssetLoaderStringTableIW3.h b/src/ObjLoading/Game/IW3/StringTable/AssetLoaderStringTableIW3.h index 497617e3..5b5a1ded 100644 --- a/src/ObjLoading/Game/IW3/StringTable/AssetLoaderStringTableIW3.h +++ b/src/ObjLoading/Game/IW3/StringTable/AssetLoaderStringTableIW3.h @@ -7,7 +7,7 @@ #include -namespace IW3::string_table +namespace string_table { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW3::string_table + std::unique_ptr> CreateLoaderIW3(MemoryManager& memory, ISearchPath& searchPath); +} // namespace string_table diff --git a/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.cpp b/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.cpp index 3a8b7b12..b0acadf4 100644 --- a/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.cpp +++ b/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.cpp @@ -11,7 +11,6 @@ using namespace nlohmann; using namespace IW4; -using namespace ::leaderboard; namespace { @@ -116,7 +115,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto file = m_search_path.Open(GetJsonFileNameForAsset(assetName)); + const auto file = m_search_path.Open(leaderboard::GetJsonFileNameForAsset(assetName)); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -139,10 +138,10 @@ namespace }; } // namespace -namespace IW4::leaderboard +namespace leaderboard { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderIW4(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4::leaderboard +} // namespace leaderboard diff --git a/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.h b/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.h index 832d6b94..931a8fca 100644 --- a/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.h +++ b/src/ObjLoading/Game/IW4/Leaderboard/LoaderLeaderboardIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4::leaderboard +namespace leaderboard { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4::leaderboard + std::unique_ptr> CreateLoaderIW4(MemoryManager& memory, ISearchPath& searchPath); +} // namespace leaderboard diff --git a/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.cpp b/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.cpp index dacdf3d1..1485c361 100644 --- a/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.cpp +++ b/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.cpp @@ -8,7 +8,6 @@ #include using namespace IW4; -using namespace ::light_def; namespace { @@ -25,7 +24,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto filename = GetFileNameForAsset(assetName); + const auto filename = light_def::GetFileNameForAsset(assetName); const auto file = m_search_path.Open(filename); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -68,10 +67,10 @@ namespace }; } // namespace -namespace IW4::light_def +namespace light_def { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderIW4(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4::light_def +} // namespace light_def diff --git a/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.h b/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.h index 96d93357..7ac2880c 100644 --- a/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.h +++ b/src/ObjLoading/Game/IW4/LightDef/LightDefLoaderIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4::light_def +namespace light_def { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4::light_def + std::unique_ptr> CreateLoaderIW4(MemoryManager& memory, ISearchPath& searchPath); +} // namespace light_def diff --git a/src/ObjLoading/Game/IW4/Localize/LoaderLocalizeIW4.cpp b/src/ObjLoading/Game/IW4/Localize/LoaderLocalizeIW4.cpp index a7dc2c42..64ce403f 100644 --- a/src/ObjLoading/Game/IW4/Localize/LoaderLocalizeIW4.cpp +++ b/src/ObjLoading/Game/IW4/Localize/LoaderLocalizeIW4.cpp @@ -35,10 +35,10 @@ namespace }; } // namespace -namespace IW4::localize +namespace localize { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateLoaderIW4(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace IW4::localize +} // namespace localize diff --git a/src/ObjLoading/Game/IW4/Localize/LoaderLocalizeIW4.h b/src/ObjLoading/Game/IW4/Localize/LoaderLocalizeIW4.h index 032e02d6..e6abda46 100644 --- a/src/ObjLoading/Game/IW4/Localize/LoaderLocalizeIW4.h +++ b/src/ObjLoading/Game/IW4/Localize/LoaderLocalizeIW4.h @@ -8,7 +8,7 @@ #include -namespace IW4::localize +namespace localize { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace IW4::localize + std::unique_ptr> CreateLoaderIW4(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace localize diff --git a/src/ObjLoading/Game/IW4/Material/LoaderMaterialIW4.cpp b/src/ObjLoading/Game/IW4/Material/LoaderMaterialIW4.cpp index 5a37af7d..b6367630 100644 --- a/src/ObjLoading/Game/IW4/Material/LoaderMaterialIW4.cpp +++ b/src/ObjLoading/Game/IW4/Material/LoaderMaterialIW4.cpp @@ -8,7 +8,6 @@ #include using namespace IW4; -using namespace ::material; namespace { @@ -23,7 +22,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto file = m_search_path.Open(GetFileNameForAssetName(assetName)); + const auto file = m_search_path.Open(material::GetFileNameForAssetName(assetName)); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -46,10 +45,10 @@ namespace }; } // namespace -namespace IW4::material +namespace material { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderIW4(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4::material +} // namespace material diff --git a/src/ObjLoading/Game/IW4/Material/LoaderMaterialIW4.h b/src/ObjLoading/Game/IW4/Material/LoaderMaterialIW4.h index 8f634c0c..6016cc17 100644 --- a/src/ObjLoading/Game/IW4/Material/LoaderMaterialIW4.h +++ b/src/ObjLoading/Game/IW4/Material/LoaderMaterialIW4.h @@ -6,7 +6,7 @@ #include "SearchPath/ISearchPath.h" #include "Utils/MemoryManager.h" -namespace IW4::material +namespace material { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4::material + std::unique_ptr> CreateLoaderIW4(MemoryManager& memory, ISearchPath& searchPath); +} // namespace material diff --git a/src/ObjLoading/Game/IW4/Menu/LoaderMenuListIW4.cpp b/src/ObjLoading/Game/IW4/Menu/LoaderMenuListIW4.cpp index e6e8843f..91fb70a0 100644 --- a/src/ObjLoading/Game/IW4/Menu/LoaderMenuListIW4.cpp +++ b/src/ObjLoading/Game/IW4/Menu/LoaderMenuListIW4.cpp @@ -11,7 +11,6 @@ #include using namespace IW4; -using namespace ::menu; namespace { @@ -29,7 +28,7 @@ namespace std::vector menus; AssetRegistration registration(assetName); - auto& zoneState = context.GetZoneAssetCreationState(); + auto& zoneState = context.GetZoneAssetCreationState(); auto& conversionState = context.GetZoneAssetCreationState(); std::deque menuLoadQueue; @@ -81,7 +80,7 @@ namespace private: bool LoadMenuFileFromQueue(const std::string& menuFilePath, AssetCreationContext& context, - MenuAssetZoneState& zoneState, + menu::MenuAssetZoneState& zoneState, MenuConversionZoneState& conversionState, std::vector& menus, AssetRegistration& registration) const @@ -122,8 +121,8 @@ namespace bool ProcessParsedResults(const std::string& fileName, AssetCreationContext& context, - ParsingResult& parsingResult, - MenuAssetZoneState& zoneState, + menu::ParsingResult& parsingResult, + menu::MenuAssetZoneState& zoneState, MenuConversionZoneState& conversionState, std::vector& menus, AssetRegistration& registration) const @@ -197,9 +196,10 @@ namespace menuList.menus = nullptr; } - std::unique_ptr ParseMenuFile(std::istream& stream, const std::string& menuFileName, const MenuAssetZoneState& zoneState) const + std::unique_ptr + ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState& zoneState) const { - MenuFileReader reader(stream, menuFileName, FeatureLevel::IW4, m_search_path); + menu::MenuFileReader reader(stream, menuFileName, menu::FeatureLevel::IW4, m_search_path); reader.IncludeZoneState(zoneState); reader.SetPermissiveMode(ObjLoading::Configuration.MenuPermissiveParsing); @@ -212,10 +212,10 @@ namespace }; } // namespace -namespace IW4::menu +namespace menu { - std::unique_ptr> CreateMenuListLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateMenuListLoaderIW4(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4::menu +} // namespace menu diff --git a/src/ObjLoading/Game/IW4/Menu/LoaderMenuListIW4.h b/src/ObjLoading/Game/IW4/Menu/LoaderMenuListIW4.h index 2cb21bb3..a22d7b2c 100644 --- a/src/ObjLoading/Game/IW4/Menu/LoaderMenuListIW4.h +++ b/src/ObjLoading/Game/IW4/Menu/LoaderMenuListIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4::menu +namespace menu { - std::unique_ptr> CreateMenuListLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4::menu + std::unique_ptr> CreateMenuListLoaderIW4(MemoryManager& memory, ISearchPath& searchPath); +} // namespace menu diff --git a/src/ObjLoading/Game/IW4/Menu/MenuConverterIW4.h b/src/ObjLoading/Game/IW4/Menu/MenuConverterIW4.h index 8b32e98b..234cedb5 100644 --- a/src/ObjLoading/Game/IW4/Menu/MenuConverterIW4.h +++ b/src/ObjLoading/Game/IW4/Menu/MenuConverterIW4.h @@ -14,7 +14,7 @@ namespace IW4 IMenuConverter() = default; virtual ~IMenuConverter() = default; - virtual void ConvertMenu(const ::menu::CommonMenuDef& commonMenu, menuDef_t& menu, AssetRegistration& registration) = 0; + virtual void ConvertMenu(const menu::CommonMenuDef& commonMenu, menuDef_t& menu, AssetRegistration& registration) = 0; static std::unique_ptr Create(bool disableOptimizations, ISearchPath& searchPath, MemoryManager& memory, AssetCreationContext& context); }; diff --git a/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp b/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp index 7e0811f6..ad5b83c4 100644 --- a/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp +++ b/src/ObjLoading/Game/IW4/ObjLoaderIW4.cpp @@ -119,19 +119,19 @@ namespace { auto& memory = zone.Memory(); - collection.AddAssetCreator(phys_preset::CreateRawLoader(memory, searchPath, zone)); - collection.AddAssetCreator(phys_preset::CreateGdtLoader(memory, gdt, zone)); + collection.AddAssetCreator(phys_preset::CreateRawLoaderIW4(memory, searchPath, zone)); + collection.AddAssetCreator(phys_preset::CreateGdtLoaderIW4(memory, gdt, zone)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(xmodel::CreateXModelLoader(memory, searchPath, zone)); - collection.AddAssetCreator(material::CreateLoader(memory, searchPath)); - collection.AddAssetCreator(shader::CreatePixelShaderLoader(memory, searchPath)); - collection.AddAssetCreator(shader::CreateVertexShaderLoader(memory, searchPath)); + collection.AddAssetCreator(xmodel::CreateLoaderIW4(memory, searchPath, zone)); + collection.AddAssetCreator(material::CreateLoaderIW4(memory, searchPath)); + collection.AddAssetCreator(shader::CreatePixelShaderLoaderIW4(memory, searchPath)); + collection.AddAssetCreator(shader::CreateVertexShaderLoaderIW4(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(sound_curve::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(sound_curve::CreateLoaderIW4(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); @@ -140,19 +140,19 @@ namespace // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(light_def::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(light_def::CreateLoaderIW4(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(menu::CreateMenuListLoader(memory, searchPath)); + collection.AddAssetCreator(menu::CreateMenuListLoaderIW4(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(localize::CreateLoader(memory, searchPath, zone)); - collection.AddAssetCreator(weapon::CreateRawLoader(memory, searchPath, zone)); - collection.AddAssetCreator(weapon::CreateGdtLoader(memory, searchPath, gdt, zone)); + collection.AddAssetCreator(localize::CreateLoaderIW4(memory, searchPath, zone)); + collection.AddAssetCreator(weapon::CreateRawLoaderIW4(memory, searchPath, zone)); + collection.AddAssetCreator(weapon::CreateGdtLoaderIW4(memory, searchPath, gdt, zone)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(raw_file::CreateLoader(memory, searchPath)); - collection.AddAssetCreator(string_table::CreateLoader(memory, searchPath)); - collection.AddAssetCreator(leaderboard::CreateLoader(memory, searchPath)); - collection.AddAssetCreator(structured_data_def::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(raw_file::CreateLoaderIW4(memory, searchPath)); + collection.AddAssetCreator(string_table::CreateLoaderIW4(memory, searchPath)); + collection.AddAssetCreator(leaderboard::CreateLoaderIW4(memory, searchPath)); + collection.AddAssetCreator(structured_data_def::CreateLoaderIW4(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); diff --git a/src/ObjLoading/Game/IW4/PhysPreset/GdtLoaderPhysPresetIW4.cpp b/src/ObjLoading/Game/IW4/PhysPreset/GdtLoaderPhysPresetIW4.cpp index 4532e91e..26634fd7 100644 --- a/src/ObjLoading/Game/IW4/PhysPreset/GdtLoaderPhysPresetIW4.cpp +++ b/src/ObjLoading/Game/IW4/PhysPreset/GdtLoaderPhysPresetIW4.cpp @@ -39,14 +39,14 @@ namespace private: IGdtQueryable& m_gdt; - IW4::phys_preset::InfoStringLoader m_info_string_loader; + phys_preset::InfoStringLoaderIW4 m_info_string_loader; }; } // namespace -namespace IW4::phys_preset +namespace phys_preset { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoaderIW4(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone) { return std::make_unique(memory, gdt, zone); } -} // namespace IW4::phys_preset +} // namespace phys_preset diff --git a/src/ObjLoading/Game/IW4/PhysPreset/GdtLoaderPhysPresetIW4.h b/src/ObjLoading/Game/IW4/PhysPreset/GdtLoaderPhysPresetIW4.h index c51f29db..c5e474f6 100644 --- a/src/ObjLoading/Game/IW4/PhysPreset/GdtLoaderPhysPresetIW4.h +++ b/src/ObjLoading/Game/IW4/PhysPreset/GdtLoaderPhysPresetIW4.h @@ -8,7 +8,7 @@ #include -namespace IW4::phys_preset +namespace phys_preset { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone); -} // namespace IW4::phys_preset + std::unique_ptr> CreateGdtLoaderIW4(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone); +} // namespace phys_preset diff --git a/src/ObjLoading/Game/IW4/PhysPreset/InfoStringLoaderPhysPresetIW4.cpp b/src/ObjLoading/Game/IW4/PhysPreset/InfoStringLoaderPhysPresetIW4.cpp index dc83cca1..e8b69203 100644 --- a/src/ObjLoading/Game/IW4/PhysPreset/InfoStringLoaderPhysPresetIW4.cpp +++ b/src/ObjLoading/Game/IW4/PhysPreset/InfoStringLoaderPhysPresetIW4.cpp @@ -58,15 +58,15 @@ namespace } } // namespace -namespace IW4::phys_preset +namespace phys_preset { - InfoStringLoader::InfoStringLoader(MemoryManager& memory, Zone& zone) + InfoStringLoaderIW4::InfoStringLoaderIW4(MemoryManager& memory, Zone& zone) : m_memory(memory), m_zone(zone) { } - AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) + AssetCreationResult InfoStringLoaderIW4::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) { PhysPresetInfo presetInfo; std::memset(&presetInfo, 0, sizeof(presetInfo)); @@ -87,4 +87,4 @@ namespace IW4::phys_preset return AssetCreationResult::Success(context.AddAsset(std::move(registration))); } -} // namespace IW4::phys_preset +} // namespace phys_preset diff --git a/src/ObjLoading/Game/IW4/PhysPreset/InfoStringLoaderPhysPresetIW4.h b/src/ObjLoading/Game/IW4/PhysPreset/InfoStringLoaderPhysPresetIW4.h index c864ca3e..1618bd80 100644 --- a/src/ObjLoading/Game/IW4/PhysPreset/InfoStringLoaderPhysPresetIW4.h +++ b/src/ObjLoading/Game/IW4/PhysPreset/InfoStringLoaderPhysPresetIW4.h @@ -4,12 +4,12 @@ #include "Asset/AssetCreationResult.h" #include "InfoString/InfoString.h" -namespace IW4::phys_preset +namespace phys_preset { - class InfoStringLoader + class InfoStringLoaderIW4 { public: - InfoStringLoader(MemoryManager& memory, Zone& zone); + InfoStringLoaderIW4(MemoryManager& memory, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context); @@ -17,4 +17,4 @@ namespace IW4::phys_preset MemoryManager& m_memory; Zone& m_zone; }; -} // namespace IW4::phys_preset +} // namespace phys_preset diff --git a/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.cpp b/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.cpp index aa9b88a5..5d05a588 100644 --- a/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.cpp +++ b/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.cpp @@ -10,7 +10,6 @@ #include using namespace IW4; -using namespace ::phys_preset; namespace { @@ -25,7 +24,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = GetFileNameForAssetName(assetName); + const auto fileName = phys_preset::GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -42,14 +41,14 @@ namespace private: ISearchPath& m_search_path; - IW4::phys_preset::InfoStringLoader m_info_string_loader; + phys_preset::InfoStringLoaderIW4 m_info_string_loader; }; } // namespace -namespace IW4::phys_preset +namespace phys_preset { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoaderIW4(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace IW4::phys_preset +} // namespace phys_preset diff --git a/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.h b/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.h index a711c13c..ab78361b 100644 --- a/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.h +++ b/src/ObjLoading/Game/IW4/PhysPreset/RawLoaderPhysPresetIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4::phys_preset +namespace phys_preset { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace IW4::phys_preset + std::unique_ptr> CreateRawLoaderIW4(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace phys_preset diff --git a/src/ObjLoading/Game/IW4/RawFile/LoaderRawFileIW4.cpp b/src/ObjLoading/Game/IW4/RawFile/LoaderRawFileIW4.cpp index 381d7b16..2b25158a 100644 --- a/src/ObjLoading/Game/IW4/RawFile/LoaderRawFileIW4.cpp +++ b/src/ObjLoading/Game/IW4/RawFile/LoaderRawFileIW4.cpp @@ -82,10 +82,10 @@ namespace }; } // namespace -namespace IW4::raw_file +namespace raw_file { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderIW4(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4::raw_file +} // namespace raw_file diff --git a/src/ObjLoading/Game/IW4/RawFile/LoaderRawFileIW4.h b/src/ObjLoading/Game/IW4/RawFile/LoaderRawFileIW4.h index 1d483736..624b5b69 100644 --- a/src/ObjLoading/Game/IW4/RawFile/LoaderRawFileIW4.h +++ b/src/ObjLoading/Game/IW4/RawFile/LoaderRawFileIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4::raw_file +namespace raw_file { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4::raw_file + std::unique_ptr> CreateLoaderIW4(MemoryManager& memory, ISearchPath& searchPath); +} // namespace raw_file diff --git a/src/ObjLoading/Game/IW4/Shader/LoaderPixelShaderIW4.cpp b/src/ObjLoading/Game/IW4/Shader/LoaderPixelShaderIW4.cpp index 6e13a9e0..1d6ad597 100644 --- a/src/ObjLoading/Game/IW4/Shader/LoaderPixelShaderIW4.cpp +++ b/src/ObjLoading/Game/IW4/Shader/LoaderPixelShaderIW4.cpp @@ -8,7 +8,6 @@ #include using namespace IW4; -using namespace ::shader; namespace { @@ -23,7 +22,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = GetFileNameForPixelShaderAssetName(assetName); + const auto fileName = shader::GetFileNameForPixelShaderAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -55,10 +54,10 @@ namespace }; } // namespace -namespace IW4::shader +namespace shader { - std::unique_ptr> CreatePixelShaderLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreatePixelShaderLoaderIW4(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4::shader +} // namespace shader diff --git a/src/ObjLoading/Game/IW4/Shader/LoaderPixelShaderIW4.h b/src/ObjLoading/Game/IW4/Shader/LoaderPixelShaderIW4.h index 3ea15f98..0bc212a5 100644 --- a/src/ObjLoading/Game/IW4/Shader/LoaderPixelShaderIW4.h +++ b/src/ObjLoading/Game/IW4/Shader/LoaderPixelShaderIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4::shader +namespace shader { - std::unique_ptr> CreatePixelShaderLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4::shader + std::unique_ptr> CreatePixelShaderLoaderIW4(MemoryManager& memory, ISearchPath& searchPath); +} // namespace shader diff --git a/src/ObjLoading/Game/IW4/Shader/LoaderVertexShaderIW4.cpp b/src/ObjLoading/Game/IW4/Shader/LoaderVertexShaderIW4.cpp index b47069f0..99bea4dd 100644 --- a/src/ObjLoading/Game/IW4/Shader/LoaderVertexShaderIW4.cpp +++ b/src/ObjLoading/Game/IW4/Shader/LoaderVertexShaderIW4.cpp @@ -8,7 +8,6 @@ #include using namespace IW4; -using namespace ::shader; namespace { @@ -23,7 +22,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = GetFileNameForVertexShaderAssetName(assetName); + const auto fileName = shader::GetFileNameForVertexShaderAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -55,10 +54,10 @@ namespace }; } // namespace -namespace IW4::shader +namespace shader { - std::unique_ptr> CreateVertexShaderLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateVertexShaderLoaderIW4(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4::shader +} // namespace shader diff --git a/src/ObjLoading/Game/IW4/Shader/LoaderVertexShaderIW4.h b/src/ObjLoading/Game/IW4/Shader/LoaderVertexShaderIW4.h index 7cc7e600..28076aaf 100644 --- a/src/ObjLoading/Game/IW4/Shader/LoaderVertexShaderIW4.h +++ b/src/ObjLoading/Game/IW4/Shader/LoaderVertexShaderIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4::shader +namespace shader { - std::unique_ptr> CreateVertexShaderLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4::shader + std::unique_ptr> CreateVertexShaderLoaderIW4(MemoryManager& memory, ISearchPath& searchPath); +} // namespace shader diff --git a/src/ObjLoading/Game/IW4/Sound/LoaderSoundCurveIW4.cpp b/src/ObjLoading/Game/IW4/Sound/LoaderSoundCurveIW4.cpp index 84a88655..765b4bfb 100644 --- a/src/ObjLoading/Game/IW4/Sound/LoaderSoundCurveIW4.cpp +++ b/src/ObjLoading/Game/IW4/Sound/LoaderSoundCurveIW4.cpp @@ -12,7 +12,6 @@ #include using namespace IW4; -using namespace ::sound_curve; namespace { @@ -27,7 +26,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = GetFileNameForAssetName(assetName); + const auto fileName = sound_curve::GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -71,10 +70,10 @@ namespace }; } // namespace -namespace IW4::sound_curve +namespace sound_curve { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderIW4(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4::sound_curve +} // namespace sound_curve diff --git a/src/ObjLoading/Game/IW4/Sound/LoaderSoundCurveIW4.h b/src/ObjLoading/Game/IW4/Sound/LoaderSoundCurveIW4.h index 808cc0e1..b8b12cd3 100644 --- a/src/ObjLoading/Game/IW4/Sound/LoaderSoundCurveIW4.h +++ b/src/ObjLoading/Game/IW4/Sound/LoaderSoundCurveIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4::sound_curve +namespace sound_curve { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4::sound_curve + std::unique_ptr> CreateLoaderIW4(MemoryManager& memory, ISearchPath& searchPath); +} // namespace sound_curve diff --git a/src/ObjLoading/Game/IW4/StringTable/LoaderStringTableIW4.cpp b/src/ObjLoading/Game/IW4/StringTable/LoaderStringTableIW4.cpp index d19d32d1..11483031 100644 --- a/src/ObjLoading/Game/IW4/StringTable/LoaderStringTableIW4.cpp +++ b/src/ObjLoading/Game/IW4/StringTable/LoaderStringTableIW4.cpp @@ -6,7 +6,6 @@ #include "StringTable/StringTableLoader.h" using namespace IW4; -using namespace ::string_table; namespace { @@ -25,7 +24,7 @@ namespace if (!file.IsOpen()) return AssetCreationResult::NoAction(); - StringTableLoaderV2 loader; + string_table::StringTableLoaderV2 loader; auto* stringTable = loader.LoadFromStream(assetName, m_memory, *file.m_stream); if (!stringTable) return AssetCreationResult::Failure(); @@ -39,10 +38,10 @@ namespace }; } // namespace -namespace IW4::string_table +namespace string_table { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderIW4(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4::string_table +} // namespace string_table diff --git a/src/ObjLoading/Game/IW4/StringTable/LoaderStringTableIW4.h b/src/ObjLoading/Game/IW4/StringTable/LoaderStringTableIW4.h index 5bba65f4..89c53c50 100644 --- a/src/ObjLoading/Game/IW4/StringTable/LoaderStringTableIW4.h +++ b/src/ObjLoading/Game/IW4/StringTable/LoaderStringTableIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4::string_table +namespace string_table { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4::string_table + std::unique_ptr> CreateLoaderIW4(MemoryManager& memory, ISearchPath& searchPath); +} // namespace string_table diff --git a/src/ObjLoading/Game/IW4/StructuredDataDef/LoaderStructuredDataDefIW4.cpp b/src/ObjLoading/Game/IW4/StructuredDataDef/LoaderStructuredDataDefIW4.cpp index 8dad6ce2..673d715d 100644 --- a/src/ObjLoading/Game/IW4/StructuredDataDef/LoaderStructuredDataDefIW4.cpp +++ b/src/ObjLoading/Game/IW4/StructuredDataDef/LoaderStructuredDataDefIW4.cpp @@ -207,10 +207,10 @@ namespace }; } // namespace -namespace IW4::structured_data_def +namespace structured_data_def { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderIW4(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW4::structured_data_def +} // namespace structured_data_def diff --git a/src/ObjLoading/Game/IW4/StructuredDataDef/LoaderStructuredDataDefIW4.h b/src/ObjLoading/Game/IW4/StructuredDataDef/LoaderStructuredDataDefIW4.h index c3670e25..527a9389 100644 --- a/src/ObjLoading/Game/IW4/StructuredDataDef/LoaderStructuredDataDefIW4.h +++ b/src/ObjLoading/Game/IW4/StructuredDataDef/LoaderStructuredDataDefIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4::structured_data_def +namespace structured_data_def { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW4::structured_data_def + std::unique_ptr> CreateLoaderIW4(MemoryManager& memory, ISearchPath& searchPath); +} // namespace structured_data_def diff --git a/src/ObjLoading/Game/IW4/Weapon/GdtLoaderWeaponIW4.cpp b/src/ObjLoading/Game/IW4/Weapon/GdtLoaderWeaponIW4.cpp index ecd7f59a..ef632e47 100644 --- a/src/ObjLoading/Game/IW4/Weapon/GdtLoaderWeaponIW4.cpp +++ b/src/ObjLoading/Game/IW4/Weapon/GdtLoaderWeaponIW4.cpp @@ -40,14 +40,14 @@ namespace private: IGdtQueryable& m_gdt; - IW4::weapon::InfoStringLoader m_info_string_loader; + weapon::InfoStringLoaderIW4 m_info_string_loader; }; } // namespace -namespace IW4::weapon +namespace weapon { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoaderIW4(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) { return std::make_unique(memory, searchPath, gdt, zone); } -} // namespace IW4::weapon +} // namespace weapon diff --git a/src/ObjLoading/Game/IW4/Weapon/GdtLoaderWeaponIW4.h b/src/ObjLoading/Game/IW4/Weapon/GdtLoaderWeaponIW4.h index ce66f584..6fcac0a4 100644 --- a/src/ObjLoading/Game/IW4/Weapon/GdtLoaderWeaponIW4.h +++ b/src/ObjLoading/Game/IW4/Weapon/GdtLoaderWeaponIW4.h @@ -8,7 +8,7 @@ #include -namespace IW4::weapon +namespace weapon { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); -} // namespace IW4::weapon + std::unique_ptr> CreateGdtLoaderIW4(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); +} // namespace weapon diff --git a/src/ObjLoading/Game/IW4/Weapon/InfoStringLoaderWeaponIW4.cpp b/src/ObjLoading/Game/IW4/Weapon/InfoStringLoaderWeaponIW4.cpp index bd38e04a..be8ac8d6 100644 --- a/src/ObjLoading/Game/IW4/Weapon/InfoStringLoaderWeaponIW4.cpp +++ b/src/ObjLoading/Game/IW4/Weapon/InfoStringLoaderWeaponIW4.cpp @@ -426,16 +426,16 @@ namespace } } // namespace -namespace IW4::weapon +namespace weapon { - InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + InfoStringLoaderIW4::InfoStringLoaderIW4(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) : m_memory(memory), m_search_path(searchPath), m_zone(zone) { } - AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) + AssetCreationResult InfoStringLoaderIW4::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) { auto* weaponFullDef = m_memory.Alloc(); @@ -458,4 +458,4 @@ namespace IW4::weapon return AssetCreationResult::Success(context.AddAsset(std::move(registration))); } -} // namespace IW4::weapon +} // namespace weapon diff --git a/src/ObjLoading/Game/IW4/Weapon/InfoStringLoaderWeaponIW4.h b/src/ObjLoading/Game/IW4/Weapon/InfoStringLoaderWeaponIW4.h index d1ba5d80..1f82539b 100644 --- a/src/ObjLoading/Game/IW4/Weapon/InfoStringLoaderWeaponIW4.h +++ b/src/ObjLoading/Game/IW4/Weapon/InfoStringLoaderWeaponIW4.h @@ -4,12 +4,12 @@ #include "Asset/AssetCreationResult.h" #include "InfoString/InfoString.h" -namespace IW4::weapon +namespace weapon { - class InfoStringLoader + class InfoStringLoaderIW4 { public: - InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); + InfoStringLoaderIW4(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context); @@ -18,4 +18,4 @@ namespace IW4::weapon ISearchPath& m_search_path; Zone& m_zone; }; -} // namespace IW4::weapon +} // namespace weapon diff --git a/src/ObjLoading/Game/IW4/Weapon/RawLoaderWeaponIW4.cpp b/src/ObjLoading/Game/IW4/Weapon/RawLoaderWeaponIW4.cpp index 2b4b4283..ae6de026 100644 --- a/src/ObjLoading/Game/IW4/Weapon/RawLoaderWeaponIW4.cpp +++ b/src/ObjLoading/Game/IW4/Weapon/RawLoaderWeaponIW4.cpp @@ -11,7 +11,6 @@ #include using namespace IW4; -using namespace ::weapon; namespace { @@ -26,7 +25,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = GetFileNameForAssetName(assetName); + const auto fileName = weapon::GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -43,14 +42,14 @@ namespace private: ISearchPath& m_search_path; - IW4::weapon::InfoStringLoader m_info_string_loader; + weapon::InfoStringLoaderIW4 m_info_string_loader; }; } // namespace -namespace IW4::weapon +namespace weapon { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoaderIW4(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace IW4::weapon +} // namespace weapon diff --git a/src/ObjLoading/Game/IW4/Weapon/RawLoaderWeaponIW4.h b/src/ObjLoading/Game/IW4/Weapon/RawLoaderWeaponIW4.h index e8995ac3..208fc440 100644 --- a/src/ObjLoading/Game/IW4/Weapon/RawLoaderWeaponIW4.h +++ b/src/ObjLoading/Game/IW4/Weapon/RawLoaderWeaponIW4.h @@ -7,7 +7,7 @@ #include -namespace IW4::weapon +namespace weapon { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace IW4::weapon + std::unique_ptr> CreateRawLoaderIW4(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace weapon diff --git a/src/ObjLoading/Game/IW5/Image/LoaderImageIW5.cpp b/src/ObjLoading/Game/IW5/Image/LoaderImageIW5.cpp index 09bb4046..0f812f80 100644 --- a/src/ObjLoading/Game/IW5/Image/LoaderImageIW5.cpp +++ b/src/ObjLoading/Game/IW5/Image/LoaderImageIW5.cpp @@ -10,7 +10,6 @@ #include using namespace IW5; -using namespace ::image; namespace { @@ -27,7 +26,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = GetFileNameForAsset(assetName, ".iwi"); + const auto fileName = image::GetFileNameForAsset(assetName, ".iwi"); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -62,10 +61,10 @@ namespace }; } // namespace -namespace IW5::image +namespace image { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW5::image +} // namespace image diff --git a/src/ObjLoading/Game/IW5/Image/LoaderImageIW5.h b/src/ObjLoading/Game/IW5/Image/LoaderImageIW5.h index 120897b0..b95a8f23 100644 --- a/src/ObjLoading/Game/IW5/Image/LoaderImageIW5.h +++ b/src/ObjLoading/Game/IW5/Image/LoaderImageIW5.h @@ -7,7 +7,7 @@ #include -namespace IW5::image +namespace image { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW5::image + std::unique_ptr> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath); +} // namespace image diff --git a/src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.cpp b/src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.cpp index 4ec9f420..aa25767a 100644 --- a/src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.cpp +++ b/src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.cpp @@ -11,7 +11,6 @@ using namespace nlohmann; using namespace IW5; -using namespace ::leaderboard; namespace { @@ -133,7 +132,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto file = m_search_path.Open(GetJsonFileNameForAsset(assetName)); + const auto file = m_search_path.Open(leaderboard::GetJsonFileNameForAsset(assetName)); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -156,10 +155,10 @@ namespace }; } // namespace -namespace IW5::leaderboard +namespace leaderboard { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW5::leaderboard +} // namespace leaderboard diff --git a/src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.h b/src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.h index d074b9b3..d2841638 100644 --- a/src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.h +++ b/src/ObjLoading/Game/IW5/Leaderboard/LoaderLeaderboardIW5.h @@ -7,7 +7,7 @@ #include -namespace IW5::leaderboard +namespace leaderboard { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW5::leaderboard + std::unique_ptr> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath); +} // namespace leaderboard diff --git a/src/ObjLoading/Game/IW5/Localize/LoaderLocalizeIW5.cpp b/src/ObjLoading/Game/IW5/Localize/LoaderLocalizeIW5.cpp index 218e9aab..a7512a26 100644 --- a/src/ObjLoading/Game/IW5/Localize/LoaderLocalizeIW5.cpp +++ b/src/ObjLoading/Game/IW5/Localize/LoaderLocalizeIW5.cpp @@ -35,10 +35,10 @@ namespace }; } // namespace -namespace IW5::localize +namespace localize { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace IW5::localize +} // namespace localize diff --git a/src/ObjLoading/Game/IW5/Localize/LoaderLocalizeIW5.h b/src/ObjLoading/Game/IW5/Localize/LoaderLocalizeIW5.h index 9588b800..f161e6c6 100644 --- a/src/ObjLoading/Game/IW5/Localize/LoaderLocalizeIW5.h +++ b/src/ObjLoading/Game/IW5/Localize/LoaderLocalizeIW5.h @@ -8,7 +8,7 @@ #include -namespace IW5::localize +namespace localize { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace IW5::localize + std::unique_ptr> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace localize diff --git a/src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.cpp b/src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.cpp index 9ed987d1..3a72f0bb 100644 --- a/src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.cpp +++ b/src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.cpp @@ -8,7 +8,6 @@ #include using namespace IW5; -using namespace ::material; namespace { @@ -23,7 +22,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto file = m_search_path.Open(GetFileNameForAssetName(assetName)); + const auto file = m_search_path.Open(material::GetFileNameForAssetName(assetName)); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -46,10 +45,10 @@ namespace }; } // namespace -namespace IW5::material +namespace material { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW5::material +} // namespace material diff --git a/src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.h b/src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.h index 1f0d7690..ebfaf88d 100644 --- a/src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.h +++ b/src/ObjLoading/Game/IW5/Material/LoaderMaterialIW5.h @@ -7,7 +7,7 @@ #include -namespace IW5::material +namespace material { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW5::material + std::unique_ptr> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath); +} // namespace material diff --git a/src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.cpp b/src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.cpp index f68b8dd4..ca7414df 100644 --- a/src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.cpp +++ b/src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.cpp @@ -11,7 +11,6 @@ #include using namespace IW5; -using namespace ::menu; namespace { @@ -29,7 +28,7 @@ namespace std::vector menus; AssetRegistration registration(assetName); - auto& zoneState = context.GetZoneAssetCreationState(); + auto& zoneState = context.GetZoneAssetCreationState(); auto& conversionState = context.GetZoneAssetCreationState(); std::deque menuLoadQueue; @@ -81,7 +80,7 @@ namespace private: bool LoadMenuFileFromQueue(const std::string& menuFilePath, AssetCreationContext& context, - MenuAssetZoneState& zoneState, + menu::MenuAssetZoneState& zoneState, MenuConversionZoneState& conversionState, std::vector& menus, AssetRegistration& registration) const @@ -122,8 +121,8 @@ namespace bool ProcessParsedResults(const std::string& fileName, AssetCreationContext& context, - ParsingResult& parsingResult, - MenuAssetZoneState& zoneState, + menu::ParsingResult& parsingResult, + menu::MenuAssetZoneState& zoneState, MenuConversionZoneState& conversionState, std::vector& menus, AssetRegistration& registration) const @@ -197,9 +196,10 @@ namespace menuList.menus = nullptr; } - std::unique_ptr ParseMenuFile(std::istream& stream, const std::string& menuFileName, const MenuAssetZoneState& zoneState) const + std::unique_ptr + ParseMenuFile(std::istream& stream, const std::string& menuFileName, const menu::MenuAssetZoneState& zoneState) const { - MenuFileReader reader(stream, menuFileName, FeatureLevel::IW5, m_search_path); + menu::MenuFileReader reader(stream, menuFileName, menu::FeatureLevel::IW5, m_search_path); reader.IncludeZoneState(zoneState); reader.SetPermissiveMode(ObjLoading::Configuration.MenuPermissiveParsing); @@ -212,10 +212,10 @@ namespace }; } // namespace -namespace IW5::menu +namespace menu { - std::unique_ptr> CreateMenuListLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateMenuListLoaderIW5(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW5::menu +} // namespace menu diff --git a/src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.h b/src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.h index a323e807..4a8f1c4b 100644 --- a/src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.h +++ b/src/ObjLoading/Game/IW5/Menu/LoaderMenuListIW5.h @@ -7,7 +7,7 @@ #include -namespace IW5::menu +namespace menu { - std::unique_ptr> CreateMenuListLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW5::menu + std::unique_ptr> CreateMenuListLoaderIW5(MemoryManager& memory, ISearchPath& searchPath); +} // namespace menu diff --git a/src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp b/src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp index b331a795..cb3d96cd 100644 --- a/src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp +++ b/src/ObjLoading/Game/IW5/ObjLoaderIW5.cpp @@ -125,13 +125,13 @@ namespace // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(xmodel::CreateXModelLoader(memory, searchPath, zone)); - collection.AddAssetCreator(material::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(xmodel::CreateLoaderIW5(memory, searchPath, zone)); + collection.AddAssetCreator(material::CreateLoaderIW5(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(image::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(image::CreateLoaderIW5(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); @@ -145,19 +145,19 @@ namespace // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(menu::CreateMenuListLoader(memory, searchPath)); + collection.AddAssetCreator(menu::CreateMenuListLoaderIW5(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(localize::CreateLoader(memory, searchPath, zone)); - collection.AddAssetCreator(attachment::CreateLoader(memory, searchPath)); - collection.AddAssetCreator(weapon::CreateRawLoader(memory, searchPath, zone)); - collection.AddAssetCreator(weapon::CreateGdtLoader(memory, searchPath, gdt, zone)); + collection.AddAssetCreator(localize::CreateLoaderIW5(memory, searchPath, zone)); + collection.AddAssetCreator(attachment::CreateLoaderIW5(memory, searchPath)); + collection.AddAssetCreator(weapon::CreateRawLoaderIW5(memory, searchPath, zone)); + collection.AddAssetCreator(weapon::CreateGdtLoaderIW5(memory, searchPath, gdt, zone)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(raw_file::CreateLoader(memory, searchPath)); - collection.AddAssetCreator(script::CreateLoader(memory, searchPath)); - collection.AddAssetCreator(string_table::CreateLoader(memory, searchPath)); - collection.AddAssetCreator(leaderboard::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(raw_file::CreateLoaderIW5(memory, searchPath)); + collection.AddAssetCreator(script::CreateLoaderIW5(memory, searchPath)); + collection.AddAssetCreator(string_table::CreateLoaderIW5(memory, searchPath)); + collection.AddAssetCreator(leaderboard::CreateLoaderIW5(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); diff --git a/src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.cpp b/src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.cpp index 9692a6f9..fe67715a 100644 --- a/src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.cpp +++ b/src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.cpp @@ -81,10 +81,10 @@ namespace }; } // namespace -namespace IW5::raw_file +namespace raw_file { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW5::raw_file +} // namespace raw_file diff --git a/src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.h b/src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.h index e8c96461..a8b2ad97 100644 --- a/src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.h +++ b/src/ObjLoading/Game/IW5/RawFile/LoaderRawFileIW5.h @@ -7,7 +7,7 @@ #include -namespace IW5::raw_file +namespace raw_file { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW5::raw_file + std::unique_ptr> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath); +} // namespace raw_file diff --git a/src/ObjLoading/Game/IW5/Script/LoaderScriptFileIW5.cpp b/src/ObjLoading/Game/IW5/Script/LoaderScriptFileIW5.cpp index cfbf8125..5e64f0a3 100644 --- a/src/ObjLoading/Game/IW5/Script/LoaderScriptFileIW5.cpp +++ b/src/ObjLoading/Game/IW5/Script/LoaderScriptFileIW5.cpp @@ -79,10 +79,10 @@ namespace }; } // namespace -namespace IW5::script +namespace script { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW5::script +} // namespace script diff --git a/src/ObjLoading/Game/IW5/Script/LoaderScriptFileIW5.h b/src/ObjLoading/Game/IW5/Script/LoaderScriptFileIW5.h index 1380a837..5d960798 100644 --- a/src/ObjLoading/Game/IW5/Script/LoaderScriptFileIW5.h +++ b/src/ObjLoading/Game/IW5/Script/LoaderScriptFileIW5.h @@ -7,7 +7,7 @@ #include -namespace IW5::script +namespace script { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW5::script + std::unique_ptr> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath); +} // namespace script diff --git a/src/ObjLoading/Game/IW5/StringTable/LoaderStringTableIW5.cpp b/src/ObjLoading/Game/IW5/StringTable/LoaderStringTableIW5.cpp index 4f56de03..ba499cd1 100644 --- a/src/ObjLoading/Game/IW5/StringTable/LoaderStringTableIW5.cpp +++ b/src/ObjLoading/Game/IW5/StringTable/LoaderStringTableIW5.cpp @@ -10,7 +10,6 @@ #include using namespace IW5; -using namespace ::string_table; namespace { @@ -29,7 +28,7 @@ namespace if (!file.IsOpen()) return AssetCreationResult::NoAction(); - StringTableLoaderV2 loader; + string_table::StringTableLoaderV2 loader; auto* stringTable = loader.LoadFromStream(assetName, m_memory, *file.m_stream); return AssetCreationResult::Success(context.AddAsset(assetName, stringTable)); @@ -41,10 +40,10 @@ namespace }; } // namespace -namespace IW5::string_table +namespace string_table { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW5::string_table +} // namespace string_table diff --git a/src/ObjLoading/Game/IW5/StringTable/LoaderStringTableIW5.h b/src/ObjLoading/Game/IW5/StringTable/LoaderStringTableIW5.h index 804b8444..52d88396 100644 --- a/src/ObjLoading/Game/IW5/StringTable/LoaderStringTableIW5.h +++ b/src/ObjLoading/Game/IW5/StringTable/LoaderStringTableIW5.h @@ -7,7 +7,7 @@ #include -namespace IW5::string_table +namespace string_table { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW5::string_table + std::unique_ptr> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath); +} // namespace string_table diff --git a/src/ObjLoading/Game/IW5/Weapon/GdtLoaderWeaponIW5.cpp b/src/ObjLoading/Game/IW5/Weapon/GdtLoaderWeaponIW5.cpp index 02d8d733..19f5d7c7 100644 --- a/src/ObjLoading/Game/IW5/Weapon/GdtLoaderWeaponIW5.cpp +++ b/src/ObjLoading/Game/IW5/Weapon/GdtLoaderWeaponIW5.cpp @@ -40,14 +40,14 @@ namespace private: IGdtQueryable& m_gdt; - IW5::weapon::InfoStringLoader m_info_string_loader; + weapon::InfoStringLoaderIW5 m_info_string_loader; }; } // namespace -namespace IW5::weapon +namespace weapon { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoaderIW5(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) { return std::make_unique(memory, searchPath, gdt, zone); } -} // namespace IW5::weapon +} // namespace weapon diff --git a/src/ObjLoading/Game/IW5/Weapon/GdtLoaderWeaponIW5.h b/src/ObjLoading/Game/IW5/Weapon/GdtLoaderWeaponIW5.h index 2bccdb9c..f4b729c1 100644 --- a/src/ObjLoading/Game/IW5/Weapon/GdtLoaderWeaponIW5.h +++ b/src/ObjLoading/Game/IW5/Weapon/GdtLoaderWeaponIW5.h @@ -8,7 +8,7 @@ #include -namespace IW5::weapon +namespace weapon { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); -} // namespace IW5::weapon + std::unique_ptr> CreateGdtLoaderIW5(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); +} // namespace weapon diff --git a/src/ObjLoading/Game/IW5/Weapon/InfoStringLoaderWeaponIW5.cpp b/src/ObjLoading/Game/IW5/Weapon/InfoStringLoaderWeaponIW5.cpp index cc9f1f3e..aaaa6c27 100644 --- a/src/ObjLoading/Game/IW5/Weapon/InfoStringLoaderWeaponIW5.cpp +++ b/src/ObjLoading/Game/IW5/Weapon/InfoStringLoaderWeaponIW5.cpp @@ -856,16 +856,16 @@ namespace } } // namespace -namespace IW5::weapon +namespace weapon { - InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + InfoStringLoaderIW5::InfoStringLoaderIW5(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) : m_memory(memory), m_search_path(searchPath), m_zone(zone) { } - AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) const + AssetCreationResult InfoStringLoaderIW5::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) const { auto* weaponFullDef = m_memory.Alloc(); @@ -888,4 +888,4 @@ namespace IW5::weapon return AssetCreationResult::Success(context.AddAsset(std::move(registration))); } -} // namespace IW5::weapon +} // namespace weapon diff --git a/src/ObjLoading/Game/IW5/Weapon/InfoStringLoaderWeaponIW5.h b/src/ObjLoading/Game/IW5/Weapon/InfoStringLoaderWeaponIW5.h index e34dbde8..d8935b8c 100644 --- a/src/ObjLoading/Game/IW5/Weapon/InfoStringLoaderWeaponIW5.h +++ b/src/ObjLoading/Game/IW5/Weapon/InfoStringLoaderWeaponIW5.h @@ -4,12 +4,12 @@ #include "Asset/AssetCreationResult.h" #include "InfoString/InfoString.h" -namespace IW5::weapon +namespace weapon { - class InfoStringLoader + class InfoStringLoaderIW5 { public: - InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); + InfoStringLoaderIW5(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) const; @@ -18,4 +18,4 @@ namespace IW5::weapon ISearchPath& m_search_path; Zone& m_zone; }; -} // namespace IW5::weapon +} // namespace weapon diff --git a/src/ObjLoading/Game/IW5/Weapon/LoaderAttachmentIW5.cpp b/src/ObjLoading/Game/IW5/Weapon/LoaderAttachmentIW5.cpp index 9d261f8e..492baea4 100644 --- a/src/ObjLoading/Game/IW5/Weapon/LoaderAttachmentIW5.cpp +++ b/src/ObjLoading/Game/IW5/Weapon/LoaderAttachmentIW5.cpp @@ -11,7 +11,6 @@ using namespace nlohmann; using namespace IW5; -using namespace ::attachment; namespace { @@ -643,7 +642,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto file = m_search_path.Open(GetJsonFileNameForAssetName(assetName)); + const auto file = m_search_path.Open(attachment::GetJsonFileNameForAssetName(assetName)); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -667,10 +666,10 @@ namespace }; } // namespace -namespace IW5::attachment +namespace attachment { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace IW5::attachment +} // namespace attachment diff --git a/src/ObjLoading/Game/IW5/Weapon/LoaderAttachmentIW5.h b/src/ObjLoading/Game/IW5/Weapon/LoaderAttachmentIW5.h index cf793afa..5ba1c07e 100644 --- a/src/ObjLoading/Game/IW5/Weapon/LoaderAttachmentIW5.h +++ b/src/ObjLoading/Game/IW5/Weapon/LoaderAttachmentIW5.h @@ -7,7 +7,7 @@ #include -namespace IW5::attachment +namespace attachment { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace IW5::attachment + std::unique_ptr> CreateLoaderIW5(MemoryManager& memory, ISearchPath& searchPath); +} // namespace attachment diff --git a/src/ObjLoading/Game/IW5/Weapon/RawLoaderWeaponIW5.cpp b/src/ObjLoading/Game/IW5/Weapon/RawLoaderWeaponIW5.cpp index 2d487ae8..8d30bf2a 100644 --- a/src/ObjLoading/Game/IW5/Weapon/RawLoaderWeaponIW5.cpp +++ b/src/ObjLoading/Game/IW5/Weapon/RawLoaderWeaponIW5.cpp @@ -43,14 +43,14 @@ namespace private: ISearchPath& m_search_path; - IW5::weapon::InfoStringLoader m_info_string_loader; + weapon::InfoStringLoaderIW5 m_info_string_loader; }; } // namespace -namespace IW5::weapon +namespace weapon { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoaderIW5(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace IW5::weapon +} // namespace weapon diff --git a/src/ObjLoading/Game/IW5/Weapon/RawLoaderWeaponIW5.h b/src/ObjLoading/Game/IW5/Weapon/RawLoaderWeaponIW5.h index ceba2d77..88b8053a 100644 --- a/src/ObjLoading/Game/IW5/Weapon/RawLoaderWeaponIW5.h +++ b/src/ObjLoading/Game/IW5/Weapon/RawLoaderWeaponIW5.h @@ -7,7 +7,7 @@ #include -namespace IW5::weapon +namespace weapon { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace IW5::weapon + std::unique_ptr> CreateRawLoaderIW5(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace weapon diff --git a/src/ObjLoading/Game/T5/Localize/LoaderLocalizeT5.cpp b/src/ObjLoading/Game/T5/Localize/LoaderLocalizeT5.cpp index fefc44d3..c66a7f93 100644 --- a/src/ObjLoading/Game/T5/Localize/LoaderLocalizeT5.cpp +++ b/src/ObjLoading/Game/T5/Localize/LoaderLocalizeT5.cpp @@ -35,10 +35,10 @@ namespace }; } // namespace -namespace T5::localize +namespace localize { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateLoaderT5(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace T5::localize +} // namespace localize diff --git a/src/ObjLoading/Game/T5/Localize/LoaderLocalizeT5.h b/src/ObjLoading/Game/T5/Localize/LoaderLocalizeT5.h index c4d2a787..a6d14d5e 100644 --- a/src/ObjLoading/Game/T5/Localize/LoaderLocalizeT5.h +++ b/src/ObjLoading/Game/T5/Localize/LoaderLocalizeT5.h @@ -8,7 +8,7 @@ #include -namespace T5::localize +namespace localize { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace T5::localize + std::unique_ptr> CreateLoaderT5(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace localize diff --git a/src/ObjLoading/Game/T5/Material/LoaderMaterialT5.cpp b/src/ObjLoading/Game/T5/Material/LoaderMaterialT5.cpp index f0218e1b..093f5e04 100644 --- a/src/ObjLoading/Game/T5/Material/LoaderMaterialT5.cpp +++ b/src/ObjLoading/Game/T5/Material/LoaderMaterialT5.cpp @@ -8,7 +8,6 @@ #include using namespace T5; -using namespace ::material; namespace { @@ -23,7 +22,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto file = m_search_path.Open(GetFileNameForAssetName(assetName)); + const auto file = m_search_path.Open(material::GetFileNameForAssetName(assetName)); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -46,10 +45,10 @@ namespace }; } // namespace -namespace T5::material +namespace material { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderT5(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T5::material +} // namespace material diff --git a/src/ObjLoading/Game/T5/Material/LoaderMaterialT5.h b/src/ObjLoading/Game/T5/Material/LoaderMaterialT5.h index 1dfee2d2..8b11165a 100644 --- a/src/ObjLoading/Game/T5/Material/LoaderMaterialT5.h +++ b/src/ObjLoading/Game/T5/Material/LoaderMaterialT5.h @@ -6,7 +6,7 @@ #include "SearchPath/ISearchPath.h" #include "Utils/MemoryManager.h" -namespace T5::material +namespace material { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T5::material + std::unique_ptr> CreateLoaderT5(MemoryManager& memory, ISearchPath& searchPath); +} // namespace material diff --git a/src/ObjLoading/Game/T5/ObjLoaderT5.cpp b/src/ObjLoading/Game/T5/ObjLoaderT5.cpp index 67cbccc6..cc67cc5a 100644 --- a/src/ObjLoading/Game/T5/ObjLoaderT5.cpp +++ b/src/ObjLoading/Game/T5/ObjLoaderT5.cpp @@ -104,8 +104,8 @@ namespace // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(xmodel::CreateXModelLoader(memory, searchPath, zone)); - collection.AddAssetCreator(material::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(xmodel::CreateLoaderT5(memory, searchPath, zone)); + collection.AddAssetCreator(material::CreateLoaderT5(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); @@ -120,13 +120,13 @@ namespace // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(localize::CreateLoader(memory, searchPath, zone)); + collection.AddAssetCreator(localize::CreateLoaderT5(memory, searchPath, zone)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(raw_file::CreateLoader(memory, searchPath)); - collection.AddAssetCreator(string_table::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(raw_file::CreateLoaderT5(memory, searchPath)); + collection.AddAssetCreator(string_table::CreateLoaderT5(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); diff --git a/src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.cpp b/src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.cpp index 9b3eb7e8..f261f06f 100644 --- a/src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.cpp +++ b/src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.cpp @@ -114,10 +114,10 @@ namespace }; } // namespace -namespace T5::raw_file +namespace raw_file { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderT5(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T5::raw_file +} // namespace raw_file diff --git a/src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.h b/src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.h index d0308037..ba06bd12 100644 --- a/src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.h +++ b/src/ObjLoading/Game/T5/RawFile/LoaderRawFileT5.h @@ -7,7 +7,7 @@ #include -namespace T5::raw_file +namespace raw_file { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T5::raw_file + std::unique_ptr> CreateLoaderT5(MemoryManager& memory, ISearchPath& searchPath); +} // namespace raw_file diff --git a/src/ObjLoading/Game/T5/StringTable/LoaderStringTableT5.cpp b/src/ObjLoading/Game/T5/StringTable/LoaderStringTableT5.cpp index 4408fa37..b1085572 100644 --- a/src/ObjLoading/Game/T5/StringTable/LoaderStringTableT5.cpp +++ b/src/ObjLoading/Game/T5/StringTable/LoaderStringTableT5.cpp @@ -7,7 +7,6 @@ #include using namespace T5; -using namespace ::string_table; namespace { @@ -26,7 +25,7 @@ namespace if (!file.IsOpen()) return AssetCreationResult::NoAction(); - StringTableLoaderV3 loader; + string_table::StringTableLoaderV3 loader; auto* stringTable = loader.LoadFromStream(assetName, m_memory, *file.m_stream); return AssetCreationResult::Success(context.AddAsset(assetName, stringTable)); @@ -38,10 +37,10 @@ namespace }; } // namespace -namespace T5::string_table +namespace string_table { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderT5(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T5::string_table +} // namespace string_table diff --git a/src/ObjLoading/Game/T5/StringTable/LoaderStringTableT5.h b/src/ObjLoading/Game/T5/StringTable/LoaderStringTableT5.h index 3c661793..81146e31 100644 --- a/src/ObjLoading/Game/T5/StringTable/LoaderStringTableT5.h +++ b/src/ObjLoading/Game/T5/StringTable/LoaderStringTableT5.h @@ -7,7 +7,7 @@ #include -namespace T5::string_table +namespace string_table { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T5::string_table + std::unique_ptr> CreateLoaderT5(MemoryManager& memory, ISearchPath& searchPath); +} // namespace string_table diff --git a/src/ObjLoading/Game/T6/FontIcon/CsvLoaderFontIconT6.cpp b/src/ObjLoading/Game/T6/FontIcon/CsvLoaderFontIconT6.cpp index 047b1c39..4d135cf3 100644 --- a/src/ObjLoading/Game/T6/FontIcon/CsvLoaderFontIconT6.cpp +++ b/src/ObjLoading/Game/T6/FontIcon/CsvLoaderFontIconT6.cpp @@ -282,10 +282,10 @@ namespace }; } // namespace -namespace T6::font_icon +namespace font_icon { - std::unique_ptr> CreateCsvLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateCsvLoaderT6(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6::font_icon +} // namespace font_icon diff --git a/src/ObjLoading/Game/T6/FontIcon/CsvLoaderFontIconT6.h b/src/ObjLoading/Game/T6/FontIcon/CsvLoaderFontIconT6.h index 76e623ea..ea6d60a2 100644 --- a/src/ObjLoading/Game/T6/FontIcon/CsvLoaderFontIconT6.h +++ b/src/ObjLoading/Game/T6/FontIcon/CsvLoaderFontIconT6.h @@ -7,7 +7,7 @@ #include -namespace T6::font_icon +namespace font_icon { - std::unique_ptr> CreateCsvLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6::font_icon + std::unique_ptr> CreateCsvLoaderT6(MemoryManager& memory, ISearchPath& searchPath); +} // namespace font_icon diff --git a/src/ObjLoading/Game/T6/FontIcon/JsonLoaderFontIconT6.cpp b/src/ObjLoading/Game/T6/FontIcon/JsonLoaderFontIconT6.cpp index 5ff32a18..fe909307 100644 --- a/src/ObjLoading/Game/T6/FontIcon/JsonLoaderFontIconT6.cpp +++ b/src/ObjLoading/Game/T6/FontIcon/JsonLoaderFontIconT6.cpp @@ -1,7 +1,7 @@ #include "JsonLoaderFontIconT6.h" +#include "FontIcon/FontIconCommon.h" #include "Game/T6/CommonT6.h" -#include "Game/T6/FontIcon/FontIconCommonT6.h" #include "Game/T6/FontIcon/JsonFontIconT6.h" #include "Game/T6/T6.h" @@ -141,10 +141,10 @@ namespace }; } // namespace -namespace T6::font_icon +namespace font_icon { - std::unique_ptr> CreateJsonLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateJsonLoaderT6(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6::font_icon +} // namespace font_icon diff --git a/src/ObjLoading/Game/T6/FontIcon/JsonLoaderFontIconT6.h b/src/ObjLoading/Game/T6/FontIcon/JsonLoaderFontIconT6.h index e770f0d4..262354df 100644 --- a/src/ObjLoading/Game/T6/FontIcon/JsonLoaderFontIconT6.h +++ b/src/ObjLoading/Game/T6/FontIcon/JsonLoaderFontIconT6.h @@ -7,7 +7,7 @@ #include -namespace T6::font_icon +namespace font_icon { - std::unique_ptr> CreateJsonLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6::font_icon + std::unique_ptr> CreateJsonLoaderT6(MemoryManager& memory, ISearchPath& searchPath); +} // namespace font_icon diff --git a/src/ObjLoading/Game/T6/Image/LoaderImageT6.cpp b/src/ObjLoading/Game/T6/Image/LoaderImageT6.cpp index 1b41701a..0c618792 100644 --- a/src/ObjLoading/Game/T6/Image/LoaderImageT6.cpp +++ b/src/ObjLoading/Game/T6/Image/LoaderImageT6.cpp @@ -12,7 +12,6 @@ #include using namespace T6; -using namespace ::image; namespace { @@ -27,7 +26,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = GetFileNameForAsset(assetName, ".iwi"); + const auto fileName = image::GetFileNameForAsset(assetName, ".iwi"); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -70,10 +69,10 @@ namespace }; } // namespace -namespace T6::image +namespace image { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6::image +} // namespace image diff --git a/src/ObjLoading/Game/T6/Image/LoaderImageT6.h b/src/ObjLoading/Game/T6/Image/LoaderImageT6.h index e77f4591..610af102 100644 --- a/src/ObjLoading/Game/T6/Image/LoaderImageT6.h +++ b/src/ObjLoading/Game/T6/Image/LoaderImageT6.h @@ -7,7 +7,7 @@ #include -namespace T6::image +namespace image { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6::image + std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath); +} // namespace image diff --git a/src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.cpp b/src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.cpp index ffbb5e0b..3a8415ec 100644 --- a/src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.cpp +++ b/src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.cpp @@ -12,7 +12,6 @@ using namespace nlohmann; using namespace T6; -using namespace ::leaderboard; namespace { @@ -140,7 +139,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto file = m_search_path.Open(GetJsonFileNameForAsset(assetName)); + const auto file = m_search_path.Open(leaderboard::GetJsonFileNameForAsset(assetName)); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -163,10 +162,10 @@ namespace }; } // namespace -namespace T6::leaderboard +namespace leaderboard { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6::leaderboard +} // namespace leaderboard diff --git a/src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.h b/src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.h index 24865730..cbe7c604 100644 --- a/src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.h +++ b/src/ObjLoading/Game/T6/Leaderboard/JsonLoaderLeaderboardT6.h @@ -7,7 +7,7 @@ #include -namespace T6::leaderboard +namespace leaderboard { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6::leaderboard + std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath); +} // namespace leaderboard diff --git a/src/ObjLoading/Game/T6/Localize/LocalizeLoaderT6.cpp b/src/ObjLoading/Game/T6/Localize/LocalizeLoaderT6.cpp index f28fa7d0..a51abb2f 100644 --- a/src/ObjLoading/Game/T6/Localize/LocalizeLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Localize/LocalizeLoaderT6.cpp @@ -35,10 +35,10 @@ namespace }; } // namespace -namespace T6::localize +namespace localize { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace T6::localize +} // namespace localize diff --git a/src/ObjLoading/Game/T6/Localize/LocalizeLoaderT6.h b/src/ObjLoading/Game/T6/Localize/LocalizeLoaderT6.h index 0aecaa98..dc7f49eb 100644 --- a/src/ObjLoading/Game/T6/Localize/LocalizeLoaderT6.h +++ b/src/ObjLoading/Game/T6/Localize/LocalizeLoaderT6.h @@ -8,7 +8,7 @@ #include -namespace T6::localize +namespace localize { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace T6::localize + std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace localize diff --git a/src/ObjLoading/Game/T6/Material/LoaderMaterialT6.cpp b/src/ObjLoading/Game/T6/Material/LoaderMaterialT6.cpp index eeb7b7fa..82e3649b 100644 --- a/src/ObjLoading/Game/T6/Material/LoaderMaterialT6.cpp +++ b/src/ObjLoading/Game/T6/Material/LoaderMaterialT6.cpp @@ -8,7 +8,6 @@ #include using namespace T6; -using namespace ::material; namespace { @@ -23,7 +22,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto file = m_search_path.Open(GetFileNameForAssetName(assetName)); + const auto file = m_search_path.Open(material::GetFileNameForAssetName(assetName)); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -46,10 +45,10 @@ namespace }; } // namespace -namespace T6::material +namespace material { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6::material +} // namespace material diff --git a/src/ObjLoading/Game/T6/Material/LoaderMaterialT6.h b/src/ObjLoading/Game/T6/Material/LoaderMaterialT6.h index d0dcc461..af1a1f92 100644 --- a/src/ObjLoading/Game/T6/Material/LoaderMaterialT6.h +++ b/src/ObjLoading/Game/T6/Material/LoaderMaterialT6.h @@ -7,7 +7,7 @@ #include -namespace T6::material +namespace material { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6::material + std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath); +} // namespace material diff --git a/src/ObjLoading/Game/T6/ObjLoaderT6.cpp b/src/ObjLoading/Game/T6/ObjLoaderT6.cpp index 3e02b7f6..9281a38b 100644 --- a/src/ObjLoading/Game/T6/ObjLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/ObjLoaderT6.cpp @@ -393,17 +393,17 @@ namespace T6 { auto& memory = zone.Memory(); - collection.AddAssetCreator(phys_preset::CreateRawLoader(memory, searchPath, zone)); - collection.AddAssetCreator(phys_preset::CreateGdtLoader(memory, gdt, zone)); - collection.AddAssetCreator(phys_constraints::CreateRawLoader(memory, searchPath, zone)); - collection.AddAssetCreator(phys_constraints::CreateGdtLoader(memory, searchPath, gdt, zone)); + collection.AddAssetCreator(phys_preset::CreateRawLoaderT6(memory, searchPath, zone)); + collection.AddAssetCreator(phys_preset::CreateGdtLoaderT6(memory, gdt, zone)); + collection.AddAssetCreator(phys_constraints::CreateRawLoaderT6(memory, searchPath, zone)); + collection.AddAssetCreator(phys_constraints::CreateGdtLoaderT6(memory, searchPath, gdt, zone)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(xmodel::CreateXModelLoader(memory, searchPath, zone)); - collection.AddAssetCreator(material::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(xmodel::CreateLoaderT6(memory, searchPath, zone)); + collection.AddAssetCreator(material::CreateLoaderT6(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(image::CreateLoader(memory, searchPath)); - collection.AddAssetCreator(sound::CreateSoundBankLoader(memory, searchPath)); + collection.AddAssetCreator(image::CreateLoaderT6(memory, searchPath)); + collection.AddAssetCreator(sound::CreateSoundBankLoaderT6(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); @@ -413,41 +413,41 @@ namespace T6 // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(font_icon::CreateCsvLoader(memory, searchPath)); - collection.AddAssetCreator(font_icon::CreateJsonLoader(memory, searchPath)); + collection.AddAssetCreator(font_icon::CreateCsvLoaderT6(memory, searchPath)); + collection.AddAssetCreator(font_icon::CreateJsonLoaderT6(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(localize::CreateLoader(memory, searchPath, zone)); - collection.AddAssetCreator(weapon::CreateRawLoader(memory, searchPath, zone)); - collection.AddAssetCreator(weapon::CreateGdtLoader(memory, searchPath, gdt, zone)); - collection.AddAssetCreator(attachment::CreateRawLoader(memory, searchPath, zone)); - collection.AddAssetCreator(attachment::CreateGdtLoader(memory, searchPath, gdt, zone)); - collection.AddAssetCreator(attachment_unique::CreateRawLoader(memory, searchPath, zone)); - collection.AddAssetCreator(attachment_unique::CreateGdtLoader(memory, searchPath, gdt, zone)); - collection.AddAssetCreator(camo::CreateJsonLoader(memory, searchPath)); + collection.AddAssetCreator(localize::CreateLoaderT6(memory, searchPath, zone)); + collection.AddAssetCreator(weapon::CreateRawLoaderT6(memory, searchPath, zone)); + collection.AddAssetCreator(weapon::CreateGdtLoaderT6(memory, searchPath, gdt, zone)); + collection.AddAssetCreator(attachment::CreateRawLoaderT6(memory, searchPath, zone)); + collection.AddAssetCreator(attachment::CreateGdtLoaderT6(memory, searchPath, gdt, zone)); + collection.AddAssetCreator(attachment_unique::CreateRawLoaderT6(memory, searchPath, zone)); + collection.AddAssetCreator(attachment_unique::CreateGdtLoaderT6(memory, searchPath, gdt, zone)); + collection.AddAssetCreator(camo::CreateJsonLoaderT6(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(raw_file::CreateLoader(memory, searchPath)); - collection.AddAssetCreator(string_table::CreateLoader(memory, searchPath)); - collection.AddAssetCreator(leaderboard::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(raw_file::CreateLoaderT6(memory, searchPath)); + collection.AddAssetCreator(string_table::CreateLoaderT6(memory, searchPath)); + collection.AddAssetCreator(leaderboard::CreateLoaderT6(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(script::CreateLoader(memory, searchPath)); - collection.AddAssetCreator(vehicle::CreateRawLoader(memory, searchPath, zone)); - collection.AddAssetCreator(vehicle::CreateGdtLoader(memory, searchPath, gdt, zone)); + collection.AddAssetCreator(script::CreateLoaderT6(memory, searchPath)); + collection.AddAssetCreator(vehicle::CreateRawLoaderT6(memory, searchPath, zone)); + collection.AddAssetCreator(vehicle::CreateGdtLoaderT6(memory, searchPath, gdt, zone)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(qdb::CreateLoader(memory, searchPath)); - collection.AddAssetCreator(slug::CreateLoader(memory, searchPath)); + collection.AddAssetCreator(qdb::CreateLoaderT6(memory, searchPath)); + collection.AddAssetCreator(slug::CreateLoaderT6(memory, searchPath)); // collection.AddAssetCreator(std::make_unique(memory)); // collection.AddAssetCreator(std::make_unique(memory)); - collection.AddAssetCreator(z_barrier::CreateRawLoader(memory, searchPath, zone)); - collection.AddAssetCreator(z_barrier::CreateGdtLoader(memory, searchPath, gdt, zone)); + collection.AddAssetCreator(z_barrier::CreateRawLoaderT6(memory, searchPath, zone)); + collection.AddAssetCreator(z_barrier::CreateGdtLoaderT6(memory, searchPath, gdt, zone)); } } // namespace diff --git a/src/ObjLoading/Game/T6/PhysConstraints/GdtLoaderPhysConstraintsT6.cpp b/src/ObjLoading/Game/T6/PhysConstraints/GdtLoaderPhysConstraintsT6.cpp index fae17b92..3b033248 100644 --- a/src/ObjLoading/Game/T6/PhysConstraints/GdtLoaderPhysConstraintsT6.cpp +++ b/src/ObjLoading/Game/T6/PhysConstraints/GdtLoaderPhysConstraintsT6.cpp @@ -40,14 +40,14 @@ namespace private: IGdtQueryable& m_gdt; - T6::phys_constraints::InfoStringLoader m_info_string_loader; + phys_constraints::InfoStringLoaderT6 m_info_string_loader; }; } // namespace -namespace T6::phys_constraints +namespace phys_constraints { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoaderT6(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) { return std::make_unique(memory, searchPath, gdt, zone); } -} // namespace T6::phys_constraints +} // namespace phys_constraints diff --git a/src/ObjLoading/Game/T6/PhysConstraints/GdtLoaderPhysConstraintsT6.h b/src/ObjLoading/Game/T6/PhysConstraints/GdtLoaderPhysConstraintsT6.h index c55f8e1a..c35e49bd 100644 --- a/src/ObjLoading/Game/T6/PhysConstraints/GdtLoaderPhysConstraintsT6.h +++ b/src/ObjLoading/Game/T6/PhysConstraints/GdtLoaderPhysConstraintsT6.h @@ -8,7 +8,7 @@ #include -namespace T6::phys_constraints +namespace phys_constraints { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); -} // namespace T6::phys_constraints + std::unique_ptr> CreateGdtLoaderT6(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); +} // namespace phys_constraints diff --git a/src/ObjLoading/Game/T6/PhysConstraints/InfoStringLoaderPhysConstraintsT6.cpp b/src/ObjLoading/Game/T6/PhysConstraints/InfoStringLoaderPhysConstraintsT6.cpp index 1242dfe0..525d9771 100644 --- a/src/ObjLoading/Game/T6/PhysConstraints/InfoStringLoaderPhysConstraintsT6.cpp +++ b/src/ObjLoading/Game/T6/PhysConstraints/InfoStringLoaderPhysConstraintsT6.cpp @@ -76,16 +76,16 @@ namespace } } // namespace -namespace T6::phys_constraints +namespace phys_constraints { - InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + InfoStringLoaderT6::InfoStringLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) : m_memory(memory), m_search_path(searchPath), m_zone(zone) { } - AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) + AssetCreationResult InfoStringLoaderT6::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) { auto* physConstraints = m_memory.Alloc(); physConstraints->name = m_memory.Dup(assetName.c_str()); @@ -110,4 +110,4 @@ namespace T6::phys_constraints return AssetCreationResult::Success(context.AddAsset(std::move(registration))); } -} // namespace T6::phys_constraints +} // namespace phys_constraints diff --git a/src/ObjLoading/Game/T6/PhysConstraints/InfoStringLoaderPhysConstraintsT6.h b/src/ObjLoading/Game/T6/PhysConstraints/InfoStringLoaderPhysConstraintsT6.h index 14bf7512..134b3500 100644 --- a/src/ObjLoading/Game/T6/PhysConstraints/InfoStringLoaderPhysConstraintsT6.h +++ b/src/ObjLoading/Game/T6/PhysConstraints/InfoStringLoaderPhysConstraintsT6.h @@ -4,12 +4,12 @@ #include "Asset/AssetCreationResult.h" #include "InfoString/InfoString.h" -namespace T6::phys_constraints +namespace phys_constraints { - class InfoStringLoader + class InfoStringLoaderT6 { public: - InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); + InfoStringLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context); @@ -18,4 +18,4 @@ namespace T6::phys_constraints ISearchPath& m_search_path; Zone& m_zone; }; -} // namespace T6::phys_constraints +} // namespace phys_constraints diff --git a/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.cpp b/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.cpp index 8a85fe93..a4edbb53 100644 --- a/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.cpp +++ b/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.cpp @@ -11,7 +11,6 @@ #include using namespace T6; -using namespace ::phys_constraints; namespace { @@ -26,7 +25,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = GetFileNameForAssetName(assetName); + const auto fileName = phys_constraints::GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -43,14 +42,14 @@ namespace private: ISearchPath& m_search_path; - T6::phys_constraints::InfoStringLoader m_info_string_loader; + phys_constraints::InfoStringLoaderT6 m_info_string_loader; }; } // namespace -namespace T6::phys_constraints +namespace phys_constraints { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace T6::phys_constraints +} // namespace phys_constraints diff --git a/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.h b/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.h index e347be28..33342687 100644 --- a/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.h +++ b/src/ObjLoading/Game/T6/PhysConstraints/RawLoaderPhysConstraintsT6.h @@ -7,7 +7,7 @@ #include -namespace T6::phys_constraints +namespace phys_constraints { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace T6::phys_constraints + std::unique_ptr> CreateRawLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace phys_constraints diff --git a/src/ObjLoading/Game/T6/PhysPreset/GdtLoaderPhysPresetT6.cpp b/src/ObjLoading/Game/T6/PhysPreset/GdtLoaderPhysPresetT6.cpp index ed681d4f..36679dab 100644 --- a/src/ObjLoading/Game/T6/PhysPreset/GdtLoaderPhysPresetT6.cpp +++ b/src/ObjLoading/Game/T6/PhysPreset/GdtLoaderPhysPresetT6.cpp @@ -40,14 +40,14 @@ namespace private: IGdtQueryable& m_gdt; - T6::phys_preset::InfoStringLoader m_info_string_loader; + phys_preset::InfoStringLoaderT6 m_info_string_loader; }; } // namespace -namespace T6::phys_preset +namespace phys_preset { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoaderT6(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone) { return std::make_unique(memory, gdt, zone); } -} // namespace T6::phys_preset +} // namespace phys_preset diff --git a/src/ObjLoading/Game/T6/PhysPreset/GdtLoaderPhysPresetT6.h b/src/ObjLoading/Game/T6/PhysPreset/GdtLoaderPhysPresetT6.h index c832e2a7..bc167205 100644 --- a/src/ObjLoading/Game/T6/PhysPreset/GdtLoaderPhysPresetT6.h +++ b/src/ObjLoading/Game/T6/PhysPreset/GdtLoaderPhysPresetT6.h @@ -8,7 +8,7 @@ #include -namespace T6::phys_preset +namespace phys_preset { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone); -} // namespace T6::phys_preset + std::unique_ptr> CreateGdtLoaderT6(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone); +} // namespace phys_preset diff --git a/src/ObjLoading/Game/T6/PhysPreset/InfoStringLoaderPhysPresetT6.cpp b/src/ObjLoading/Game/T6/PhysPreset/InfoStringLoaderPhysPresetT6.cpp index 88e86f90..6e996ad1 100644 --- a/src/ObjLoading/Game/T6/PhysPreset/InfoStringLoaderPhysPresetT6.cpp +++ b/src/ObjLoading/Game/T6/PhysPreset/InfoStringLoaderPhysPresetT6.cpp @@ -60,15 +60,15 @@ namespace } } // namespace -namespace T6::phys_preset +namespace phys_preset { - InfoStringLoader::InfoStringLoader(MemoryManager& memory, Zone& zone) + InfoStringLoaderT6::InfoStringLoaderT6(MemoryManager& memory, Zone& zone) : m_memory(memory), m_zone(zone) { } - AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) + AssetCreationResult InfoStringLoaderT6::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) { auto* physPreset = m_memory.Alloc(); physPreset->name = m_memory.Dup(assetName.c_str()); @@ -95,4 +95,4 @@ namespace T6::phys_preset return AssetCreationResult::Success(context.AddAsset(std::move(registration))); } -} // namespace T6::phys_preset +} // namespace phys_preset diff --git a/src/ObjLoading/Game/T6/PhysPreset/InfoStringLoaderPhysPresetT6.h b/src/ObjLoading/Game/T6/PhysPreset/InfoStringLoaderPhysPresetT6.h index 99d0d1f5..06e10b2f 100644 --- a/src/ObjLoading/Game/T6/PhysPreset/InfoStringLoaderPhysPresetT6.h +++ b/src/ObjLoading/Game/T6/PhysPreset/InfoStringLoaderPhysPresetT6.h @@ -4,12 +4,12 @@ #include "Asset/AssetCreationResult.h" #include "InfoString/InfoString.h" -namespace T6::phys_preset +namespace phys_preset { - class InfoStringLoader + class InfoStringLoaderT6 { public: - InfoStringLoader(MemoryManager& memory, Zone& zone); + InfoStringLoaderT6(MemoryManager& memory, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context); @@ -17,4 +17,4 @@ namespace T6::phys_preset MemoryManager& m_memory; Zone& m_zone; }; -} // namespace T6::phys_preset +} // namespace phys_preset diff --git a/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.cpp b/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.cpp index 034f11a7..46430470 100644 --- a/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.cpp +++ b/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.cpp @@ -11,7 +11,6 @@ #include using namespace T6; -using namespace ::phys_preset; namespace { @@ -26,7 +25,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = GetFileNameForAssetName(assetName); + const auto fileName = phys_preset::GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -43,14 +42,14 @@ namespace private: ISearchPath& m_search_path; - T6::phys_preset::InfoStringLoader m_info_string_loader; + phys_preset::InfoStringLoaderT6 m_info_string_loader; }; } // namespace -namespace T6::phys_preset +namespace phys_preset { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace T6::phys_preset +} // namespace phys_preset diff --git a/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.h b/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.h index ecc7fa40..f319a936 100644 --- a/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.h +++ b/src/ObjLoading/Game/T6/PhysPreset/RawLoaderPhysPresetT6.h @@ -7,7 +7,7 @@ #include -namespace T6::phys_preset +namespace phys_preset { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace T6::phys_preset + std::unique_ptr> CreateRawLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace phys_preset diff --git a/src/ObjLoading/Game/T6/Qdb/LoaderQdbT6.cpp b/src/ObjLoading/Game/T6/Qdb/LoaderQdbT6.cpp index 7c2bed1b..e1327edc 100644 --- a/src/ObjLoading/Game/T6/Qdb/LoaderQdbT6.cpp +++ b/src/ObjLoading/Game/T6/Qdb/LoaderQdbT6.cpp @@ -44,10 +44,10 @@ namespace }; } // namespace -namespace T6::qdb +namespace qdb { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6::qdb +} // namespace qdb diff --git a/src/ObjLoading/Game/T6/Qdb/LoaderQdbT6.h b/src/ObjLoading/Game/T6/Qdb/LoaderQdbT6.h index f769cc85..17a44611 100644 --- a/src/ObjLoading/Game/T6/Qdb/LoaderQdbT6.h +++ b/src/ObjLoading/Game/T6/Qdb/LoaderQdbT6.h @@ -7,7 +7,7 @@ #include -namespace T6::qdb +namespace qdb { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6::qdb + std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath); +} // namespace qdb diff --git a/src/ObjLoading/Game/T6/RawFile/LoaderRawFileT6.cpp b/src/ObjLoading/Game/T6/RawFile/LoaderRawFileT6.cpp index f4644e8c..8782da60 100644 --- a/src/ObjLoading/Game/T6/RawFile/LoaderRawFileT6.cpp +++ b/src/ObjLoading/Game/T6/RawFile/LoaderRawFileT6.cpp @@ -114,10 +114,10 @@ namespace }; } // namespace -namespace T6::raw_file +namespace raw_file { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6::raw_file +} // namespace raw_file diff --git a/src/ObjLoading/Game/T6/RawFile/LoaderRawFileT6.h b/src/ObjLoading/Game/T6/RawFile/LoaderRawFileT6.h index 1af4421b..1ef99df6 100644 --- a/src/ObjLoading/Game/T6/RawFile/LoaderRawFileT6.h +++ b/src/ObjLoading/Game/T6/RawFile/LoaderRawFileT6.h @@ -7,7 +7,7 @@ #include -namespace T6::raw_file +namespace raw_file { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6::raw_file + std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath); +} // namespace raw_file diff --git a/src/ObjLoading/Game/T6/Script/LoaderScriptT6.cpp b/src/ObjLoading/Game/T6/Script/LoaderScriptT6.cpp index e1b98e8e..a7284bc7 100644 --- a/src/ObjLoading/Game/T6/Script/LoaderScriptT6.cpp +++ b/src/ObjLoading/Game/T6/Script/LoaderScriptT6.cpp @@ -44,10 +44,10 @@ namespace }; } // namespace -namespace T6::script +namespace script { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6::script +} // namespace script diff --git a/src/ObjLoading/Game/T6/Script/LoaderScriptT6.h b/src/ObjLoading/Game/T6/Script/LoaderScriptT6.h index 88c90948..ebaab5da 100644 --- a/src/ObjLoading/Game/T6/Script/LoaderScriptT6.h +++ b/src/ObjLoading/Game/T6/Script/LoaderScriptT6.h @@ -7,7 +7,7 @@ #include -namespace T6::script +namespace script { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6::script + std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath); +} // namespace script diff --git a/src/ObjLoading/Game/T6/Slug/LoaderSlugT6.cpp b/src/ObjLoading/Game/T6/Slug/LoaderSlugT6.cpp index 407d0fb7..cce61264 100644 --- a/src/ObjLoading/Game/T6/Slug/LoaderSlugT6.cpp +++ b/src/ObjLoading/Game/T6/Slug/LoaderSlugT6.cpp @@ -44,10 +44,10 @@ namespace }; } // namespace -namespace T6::slug +namespace slug { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6::slug +} // namespace slug diff --git a/src/ObjLoading/Game/T6/Slug/LoaderSlugT6.h b/src/ObjLoading/Game/T6/Slug/LoaderSlugT6.h index bcf50625..fefc89c1 100644 --- a/src/ObjLoading/Game/T6/Slug/LoaderSlugT6.h +++ b/src/ObjLoading/Game/T6/Slug/LoaderSlugT6.h @@ -7,7 +7,7 @@ #include -namespace T6::slug +namespace slug { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6::slug + std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath); +} // namespace slug diff --git a/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.cpp b/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.cpp index 2d772c67..9b9b3781 100644 --- a/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.cpp +++ b/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.cpp @@ -1079,10 +1079,10 @@ namespace }; } // namespace -namespace T6::sound +namespace sound { - std::unique_ptr> CreateSoundBankLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateSoundBankLoaderT6(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6::sound +} // namespace sound diff --git a/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.h b/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.h index c4d1af75..358b7710 100644 --- a/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.h +++ b/src/ObjLoading/Game/T6/Sound/LoaderSoundBankT6.h @@ -7,7 +7,7 @@ #include -namespace T6::sound +namespace sound { - std::unique_ptr> CreateSoundBankLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6::sound + std::unique_ptr> CreateSoundBankLoaderT6(MemoryManager& memory, ISearchPath& searchPath); +} // namespace sound diff --git a/src/ObjLoading/Game/T6/StringTable/LoaderStringTableT6.cpp b/src/ObjLoading/Game/T6/StringTable/LoaderStringTableT6.cpp index a07301e6..d5e092d6 100644 --- a/src/ObjLoading/Game/T6/StringTable/LoaderStringTableT6.cpp +++ b/src/ObjLoading/Game/T6/StringTable/LoaderStringTableT6.cpp @@ -8,7 +8,6 @@ #include using namespace T6; -using namespace ::string_table; namespace { @@ -27,7 +26,7 @@ namespace if (!file.IsOpen()) return AssetCreationResult::NoAction(); - StringTableLoaderV3 loader; + string_table::StringTableLoaderV3 loader; auto* stringTable = loader.LoadFromStream(assetName, m_memory, *file.m_stream); return AssetCreationResult::Success(context.AddAsset(assetName, stringTable)); @@ -39,10 +38,10 @@ namespace }; } // namespace -namespace T6::string_table +namespace string_table { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6::string_table +} // namespace string_table diff --git a/src/ObjLoading/Game/T6/StringTable/LoaderStringTableT6.h b/src/ObjLoading/Game/T6/StringTable/LoaderStringTableT6.h index 448c15b8..bebd85b2 100644 --- a/src/ObjLoading/Game/T6/StringTable/LoaderStringTableT6.h +++ b/src/ObjLoading/Game/T6/StringTable/LoaderStringTableT6.h @@ -7,7 +7,7 @@ #include -namespace T6::string_table +namespace string_table { - std::unique_ptr> CreateLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6::string_table + std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath); +} // namespace string_table diff --git a/src/ObjLoading/Game/T6/Tracer/GdtLoaderTracerT6.cpp b/src/ObjLoading/Game/T6/Tracer/GdtLoaderTracerT6.cpp index 84a2dc3b..7cad238c 100644 --- a/src/ObjLoading/Game/T6/Tracer/GdtLoaderTracerT6.cpp +++ b/src/ObjLoading/Game/T6/Tracer/GdtLoaderTracerT6.cpp @@ -40,14 +40,14 @@ namespace private: IGdtQueryable& m_gdt; - T6::tracer::InfoStringLoader m_info_string_loader; + tracer::InfoStringLoaderT6 m_info_string_loader; }; } // namespace -namespace T6::tracer +namespace tracer { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoaderT6(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) { return std::make_unique(memory, searchPath, gdt, zone); } -} // namespace T6::tracer +} // namespace tracer diff --git a/src/ObjLoading/Game/T6/Tracer/GdtLoaderTracerT6.h b/src/ObjLoading/Game/T6/Tracer/GdtLoaderTracerT6.h index 57108194..e48dd81b 100644 --- a/src/ObjLoading/Game/T6/Tracer/GdtLoaderTracerT6.h +++ b/src/ObjLoading/Game/T6/Tracer/GdtLoaderTracerT6.h @@ -8,7 +8,7 @@ #include -namespace T6::tracer +namespace tracer { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); -} // namespace T6::tracer + std::unique_ptr> CreateGdtLoaderT6(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); +} // namespace tracer diff --git a/src/ObjLoading/Game/T6/Tracer/InfoStringLoaderTracerT6.cpp b/src/ObjLoading/Game/T6/Tracer/InfoStringLoaderTracerT6.cpp index 03f3a29c..e7bc4377 100644 --- a/src/ObjLoading/Game/T6/Tracer/InfoStringLoaderTracerT6.cpp +++ b/src/ObjLoading/Game/T6/Tracer/InfoStringLoaderTracerT6.cpp @@ -12,7 +12,6 @@ #include using namespace T6; -using namespace ::tracer; namespace { @@ -48,16 +47,16 @@ namespace }; } // namespace -namespace T6::tracer +namespace tracer { - InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + InfoStringLoaderT6::InfoStringLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) : m_memory(memory), m_search_path(searchPath), m_zone(zone) { } - AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) + AssetCreationResult InfoStringLoaderT6::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) { auto* tracer = m_memory.Alloc(); tracer->name = m_memory.Dup(assetName.c_str()); @@ -75,4 +74,4 @@ namespace T6::tracer return AssetCreationResult::Success(context.AddAsset(std::move(registration))); } -} // namespace T6::tracer +} // namespace tracer diff --git a/src/ObjLoading/Game/T6/Tracer/InfoStringLoaderTracerT6.h b/src/ObjLoading/Game/T6/Tracer/InfoStringLoaderTracerT6.h index 2f3c029d..d5ace0a6 100644 --- a/src/ObjLoading/Game/T6/Tracer/InfoStringLoaderTracerT6.h +++ b/src/ObjLoading/Game/T6/Tracer/InfoStringLoaderTracerT6.h @@ -4,12 +4,12 @@ #include "Asset/AssetCreationResult.h" #include "InfoString/InfoString.h" -namespace T6::tracer +namespace tracer { - class InfoStringLoader + class InfoStringLoaderT6 { public: - InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); + InfoStringLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context); @@ -18,4 +18,4 @@ namespace T6::tracer ISearchPath& m_search_path; Zone& m_zone; }; -} // namespace T6::tracer +} // namespace tracer diff --git a/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.cpp b/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.cpp index 162253b2..ff3fdc42 100644 --- a/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.cpp +++ b/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.cpp @@ -11,7 +11,6 @@ #include using namespace T6; -using namespace ::tracer; namespace { @@ -26,7 +25,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = GetFileNameForAssetName(assetName); + const auto fileName = tracer::GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -43,14 +42,14 @@ namespace private: ISearchPath& m_search_path; - T6::tracer::InfoStringLoader m_info_string_loader; + tracer::InfoStringLoaderT6 m_info_string_loader; }; } // namespace -namespace T6::tracer +namespace tracer { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace T6::tracer +} // namespace tracer diff --git a/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.h b/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.h index 500c992d..3667c410 100644 --- a/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.h +++ b/src/ObjLoading/Game/T6/Tracer/RawLoaderTracerT6.h @@ -7,7 +7,7 @@ #include -namespace T6::tracer +namespace tracer { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace T6::tracer + std::unique_ptr> CreateRawLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace tracer diff --git a/src/ObjLoading/Game/T6/Vehicle/GdtLoaderVehicleT6.cpp b/src/ObjLoading/Game/T6/Vehicle/GdtLoaderVehicleT6.cpp index 932bc544..e0267246 100644 --- a/src/ObjLoading/Game/T6/Vehicle/GdtLoaderVehicleT6.cpp +++ b/src/ObjLoading/Game/T6/Vehicle/GdtLoaderVehicleT6.cpp @@ -40,14 +40,14 @@ namespace private: IGdtQueryable& m_gdt; - T6::vehicle::InfoStringLoader m_info_string_loader; + vehicle::InfoStringLoaderT6 m_info_string_loader; }; } // namespace -namespace T6::vehicle +namespace vehicle { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoaderT6(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) { return std::make_unique(memory, searchPath, gdt, zone); } -} // namespace T6::vehicle +} // namespace vehicle diff --git a/src/ObjLoading/Game/T6/Vehicle/GdtLoaderVehicleT6.h b/src/ObjLoading/Game/T6/Vehicle/GdtLoaderVehicleT6.h index b24400df..4bc647fe 100644 --- a/src/ObjLoading/Game/T6/Vehicle/GdtLoaderVehicleT6.h +++ b/src/ObjLoading/Game/T6/Vehicle/GdtLoaderVehicleT6.h @@ -8,7 +8,7 @@ #include -namespace T6::vehicle +namespace vehicle { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); -} // namespace T6::vehicle + std::unique_ptr> CreateGdtLoaderT6(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); +} // namespace vehicle diff --git a/src/ObjLoading/Game/T6/Vehicle/InfoStringLoaderVehicleT6.cpp b/src/ObjLoading/Game/T6/Vehicle/InfoStringLoaderVehicleT6.cpp index b0a6150b..76f4c2ce 100644 --- a/src/ObjLoading/Game/T6/Vehicle/InfoStringLoaderVehicleT6.cpp +++ b/src/ObjLoading/Game/T6/Vehicle/InfoStringLoaderVehicleT6.cpp @@ -107,16 +107,16 @@ namespace }; } // namespace -namespace T6::vehicle +namespace vehicle { - InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + InfoStringLoaderT6::InfoStringLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) : m_memory(memory), m_search_path(searchPath), m_zone(zone) { } - AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) + AssetCreationResult InfoStringLoaderT6::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) { auto* vehicleDef = m_memory.Alloc(); vehicleDef->name = m_memory.Dup(assetName.c_str()); @@ -133,4 +133,4 @@ namespace T6::vehicle return AssetCreationResult::Success(context.AddAsset(std::move(registration))); } -} // namespace T6::vehicle +} // namespace vehicle diff --git a/src/ObjLoading/Game/T6/Vehicle/InfoStringLoaderVehicleT6.h b/src/ObjLoading/Game/T6/Vehicle/InfoStringLoaderVehicleT6.h index f8cacd00..15995e94 100644 --- a/src/ObjLoading/Game/T6/Vehicle/InfoStringLoaderVehicleT6.h +++ b/src/ObjLoading/Game/T6/Vehicle/InfoStringLoaderVehicleT6.h @@ -4,12 +4,12 @@ #include "Asset/AssetCreationResult.h" #include "InfoString/InfoString.h" -namespace T6::vehicle +namespace vehicle { - class InfoStringLoader + class InfoStringLoaderT6 { public: - InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); + InfoStringLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context); @@ -18,4 +18,4 @@ namespace T6::vehicle ISearchPath& m_search_path; Zone& m_zone; }; -} // namespace T6::vehicle +} // namespace vehicle diff --git a/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.cpp b/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.cpp index 5e829b85..a7b5368b 100644 --- a/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.cpp +++ b/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.cpp @@ -11,7 +11,6 @@ #include using namespace T6; -using namespace ::vehicle; namespace { @@ -26,7 +25,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = GetFileNameForAssetName(assetName); + const auto fileName = vehicle::GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -43,14 +42,14 @@ namespace private: ISearchPath& m_search_path; - T6::vehicle::InfoStringLoader m_info_string_loader; + vehicle::InfoStringLoaderT6 m_info_string_loader; }; } // namespace -namespace T6::vehicle +namespace vehicle { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace T6::vehicle +} // namespace vehicle diff --git a/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.h b/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.h index 37a709d6..59759b0a 100644 --- a/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.h +++ b/src/ObjLoading/Game/T6/Vehicle/RawLoaderVehicleT6.h @@ -7,7 +7,7 @@ #include -namespace T6::vehicle +namespace vehicle { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace T6::vehicle + std::unique_ptr> CreateRawLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace vehicle diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentGdtLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/AttachmentGdtLoaderT6.cpp index 0357b7d8..66a3b1d9 100644 --- a/src/ObjLoading/Game/T6/Weapon/AttachmentGdtLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentGdtLoaderT6.cpp @@ -40,14 +40,14 @@ namespace private: IGdtQueryable& m_gdt; - T6::attachment::InfoStringLoader m_info_string_loader; + attachment::InfoStringLoaderT6 m_info_string_loader; }; } // namespace -namespace T6::attachment +namespace attachment { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoaderT6(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) { return std::make_unique(memory, searchPath, gdt, zone); } -} // namespace T6::attachment +} // namespace attachment diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentGdtLoaderT6.h b/src/ObjLoading/Game/T6/Weapon/AttachmentGdtLoaderT6.h index 799507bf..f2ca06ac 100644 --- a/src/ObjLoading/Game/T6/Weapon/AttachmentGdtLoaderT6.h +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentGdtLoaderT6.h @@ -8,7 +8,7 @@ #include -namespace T6::attachment +namespace attachment { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); -} // namespace T6::attachment + std::unique_ptr> CreateGdtLoaderT6(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); +} // namespace attachment diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentInfoStringLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/AttachmentInfoStringLoaderT6.cpp index 721a4b81..dd296d58 100644 --- a/src/ObjLoading/Game/T6/Weapon/AttachmentInfoStringLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentInfoStringLoaderT6.cpp @@ -93,16 +93,16 @@ namespace } } // namespace -namespace T6::attachment +namespace attachment { - InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + InfoStringLoaderT6::InfoStringLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) : m_memory(memory), m_search_path(searchPath), m_zone(zone) { } - AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) + AssetCreationResult InfoStringLoaderT6::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) { auto* attachment = m_memory.Alloc(); attachment->szInternalName = m_memory.Dup(assetName.c_str()); @@ -121,4 +121,4 @@ namespace T6::attachment return AssetCreationResult::Success(context.AddAsset(std::move(registration))); } -} // namespace T6::attachment +} // namespace attachment diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentInfoStringLoaderT6.h b/src/ObjLoading/Game/T6/Weapon/AttachmentInfoStringLoaderT6.h index c9dd12d7..b4782772 100644 --- a/src/ObjLoading/Game/T6/Weapon/AttachmentInfoStringLoaderT6.h +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentInfoStringLoaderT6.h @@ -4,12 +4,12 @@ #include "Asset/AssetCreationResult.h" #include "InfoString/InfoString.h" -namespace T6::attachment +namespace attachment { - class InfoStringLoader + class InfoStringLoaderT6 { public: - InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); + InfoStringLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context); @@ -18,4 +18,4 @@ namespace T6::attachment ISearchPath& m_search_path; Zone& m_zone; }; -} // namespace T6::attachment +} // namespace attachment diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentRawLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/AttachmentRawLoaderT6.cpp index c2158ba2..815694d4 100644 --- a/src/ObjLoading/Game/T6/Weapon/AttachmentRawLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentRawLoaderT6.cpp @@ -43,14 +43,14 @@ namespace private: ISearchPath& m_search_path; - T6::attachment::InfoStringLoader m_info_string_loader; + attachment::InfoStringLoaderT6 m_info_string_loader; }; } // namespace -namespace T6::attachment +namespace attachment { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace T6::attachment +} // namespace attachment diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentRawLoaderT6.h b/src/ObjLoading/Game/T6/Weapon/AttachmentRawLoaderT6.h index 5726e166..43748226 100644 --- a/src/ObjLoading/Game/T6/Weapon/AttachmentRawLoaderT6.h +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentRawLoaderT6.h @@ -7,7 +7,7 @@ #include -namespace T6::attachment +namespace attachment { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace T6::attachment + std::unique_ptr> CreateRawLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace attachment diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueGdtLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueGdtLoaderT6.cpp index b79492ff..01a9a006 100644 --- a/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueGdtLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueGdtLoaderT6.cpp @@ -40,14 +40,14 @@ namespace private: IGdtQueryable& m_gdt; - T6::attachment_unique::InfoStringLoader m_info_string_loader; + attachment_unique::InfoStringLoaderT6 m_info_string_loader; }; } // namespace -namespace T6::attachment_unique +namespace attachment_unique { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoaderT6(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) { return std::make_unique(memory, searchPath, gdt, zone); } -} // namespace T6::attachment_unique +} // namespace attachment_unique diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueGdtLoaderT6.h b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueGdtLoaderT6.h index b7065166..1b1ad408 100644 --- a/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueGdtLoaderT6.h +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueGdtLoaderT6.h @@ -8,7 +8,7 @@ #include -namespace T6::attachment_unique +namespace attachment_unique { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); -} // namespace T6::attachment_unique + std::unique_ptr> CreateGdtLoaderT6(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); +} // namespace attachment_unique diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueInfoStringLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueInfoStringLoaderT6.cpp index 02429b3f..059091a1 100644 --- a/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueInfoStringLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueInfoStringLoaderT6.cpp @@ -141,7 +141,7 @@ namespace { // combinedAttachmentTypeMask std::vector attachmentsFromName; - if (!T6::attachment_unique::ExtractAttachmentsFromAssetName(assetName, attachmentsFromName)) + if (!attachment_unique::ExtractAttachmentsFromAssetNameT6(assetName, attachmentsFromName)) { std::cerr << std::format("Failed to determine attachments from attachment unique name \"{}\"\n", assetName); return false; @@ -159,9 +159,9 @@ namespace } } // namespace -namespace T6::attachment_unique +namespace attachment_unique { - bool ExtractAttachmentsFromAssetName(const std::string& assetName, std::vector& attachmentList) + bool ExtractAttachmentsFromAssetNameT6(const std::string& assetName, std::vector& attachmentList) { std::vector parts; @@ -210,14 +210,14 @@ namespace T6::attachment_unique return true; } - InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + InfoStringLoaderT6::InfoStringLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) : m_memory(memory), m_search_path(searchPath), m_zone(zone) { } - AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) + AssetCreationResult InfoStringLoaderT6::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) { auto* attachmentUniqueFull = m_memory.Alloc(); attachmentUniqueFull->attachment.szInternalName = m_memory.Dup(assetName.c_str()); @@ -244,4 +244,4 @@ namespace T6::attachment_unique return AssetCreationResult::Success(context.AddAsset(std::move(registration))); } -} // namespace T6::attachment_unique +} // namespace attachment_unique diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueInfoStringLoaderT6.h b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueInfoStringLoaderT6.h index 5c50650b..265b294f 100644 --- a/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueInfoStringLoaderT6.h +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueInfoStringLoaderT6.h @@ -7,14 +7,14 @@ #include -namespace T6::attachment_unique +namespace attachment_unique { - bool ExtractAttachmentsFromAssetName(const std::string& assetName, std::vector& attachmentList); + bool ExtractAttachmentsFromAssetNameT6(const std::string& assetName, std::vector& attachmentList); - class InfoStringLoader + class InfoStringLoaderT6 { public: - InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); + InfoStringLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context); @@ -23,4 +23,4 @@ namespace T6::attachment_unique ISearchPath& m_search_path; Zone& m_zone; }; -} // namespace T6::attachment_unique +} // namespace attachment_unique diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueRawLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueRawLoaderT6.cpp index 4023168f..a8a11dd0 100644 --- a/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueRawLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueRawLoaderT6.cpp @@ -11,7 +11,6 @@ #include using namespace T6; -using namespace ::attachment_unique; namespace { @@ -26,7 +25,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = GetFileNameForAssetName(assetName); + const auto fileName = attachment_unique::GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -43,14 +42,14 @@ namespace private: ISearchPath& m_search_path; - T6::attachment_unique::InfoStringLoader m_info_string_loader; + attachment_unique::InfoStringLoaderT6 m_info_string_loader; }; } // namespace -namespace T6::attachment_unique +namespace attachment_unique { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace T6::attachment_unique +} // namespace attachment_unique diff --git a/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueRawLoaderT6.h b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueRawLoaderT6.h index afdf3584..b6c83a64 100644 --- a/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueRawLoaderT6.h +++ b/src/ObjLoading/Game/T6/Weapon/AttachmentUniqueRawLoaderT6.h @@ -7,7 +7,7 @@ #include -namespace T6::attachment_unique +namespace attachment_unique { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace T6::attachment_unique + std::unique_ptr> CreateRawLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace attachment_unique diff --git a/src/ObjLoading/Game/T6/Weapon/CamoJsonLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/CamoJsonLoaderT6.cpp index 65a57723..c1a2fdbb 100644 --- a/src/ObjLoading/Game/T6/Weapon/CamoJsonLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/CamoJsonLoaderT6.cpp @@ -12,7 +12,6 @@ using namespace nlohmann; using namespace T6; -using namespace ::camo; namespace { @@ -253,7 +252,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto file = m_search_path.Open(GetJsonFileNameForAssetName(assetName)); + const auto file = m_search_path.Open(camo::GetJsonFileNameForAssetName(assetName)); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -277,10 +276,10 @@ namespace }; } // namespace -namespace T6::camo +namespace camo { - std::unique_ptr> CreateJsonLoader(MemoryManager& memory, ISearchPath& searchPath) + std::unique_ptr> CreateJsonLoaderT6(MemoryManager& memory, ISearchPath& searchPath) { return std::make_unique(memory, searchPath); } -} // namespace T6::camo +} // namespace camo diff --git a/src/ObjLoading/Game/T6/Weapon/CamoJsonLoaderT6.h b/src/ObjLoading/Game/T6/Weapon/CamoJsonLoaderT6.h index 3b5f7f7f..cd6da51d 100644 --- a/src/ObjLoading/Game/T6/Weapon/CamoJsonLoaderT6.h +++ b/src/ObjLoading/Game/T6/Weapon/CamoJsonLoaderT6.h @@ -7,7 +7,7 @@ #include -namespace T6::camo +namespace camo { - std::unique_ptr> CreateJsonLoader(MemoryManager& memory, ISearchPath& searchPath); -} // namespace T6::camo + std::unique_ptr> CreateJsonLoaderT6(MemoryManager& memory, ISearchPath& searchPath); +} // namespace camo diff --git a/src/ObjLoading/Game/T6/Weapon/WeaponGdtLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/WeaponGdtLoaderT6.cpp index 9caabce5..02f77115 100644 --- a/src/ObjLoading/Game/T6/Weapon/WeaponGdtLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/WeaponGdtLoaderT6.cpp @@ -40,14 +40,14 @@ namespace private: IGdtQueryable& m_gdt; - T6::weapon::InfoStringLoader m_info_string_loader; + weapon::InfoStringLoaderT6 m_info_string_loader; }; } // namespace -namespace T6::weapon +namespace weapon { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoaderT6(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) { return std::make_unique(memory, searchPath, gdt, zone); } -} // namespace T6::weapon +} // namespace weapon diff --git a/src/ObjLoading/Game/T6/Weapon/WeaponGdtLoaderT6.h b/src/ObjLoading/Game/T6/Weapon/WeaponGdtLoaderT6.h index 34670907..ef2b6914 100644 --- a/src/ObjLoading/Game/T6/Weapon/WeaponGdtLoaderT6.h +++ b/src/ObjLoading/Game/T6/Weapon/WeaponGdtLoaderT6.h @@ -8,7 +8,7 @@ #include -namespace T6::weapon +namespace weapon { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); -} // namespace T6::weapon + std::unique_ptr> CreateGdtLoaderT6(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); +} // namespace weapon diff --git a/src/ObjLoading/Game/T6/Weapon/WeaponInfoStringLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/WeaponInfoStringLoaderT6.cpp index d5cefc6f..ccaf394e 100644 --- a/src/ObjLoading/Game/T6/Weapon/WeaponInfoStringLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/WeaponInfoStringLoaderT6.cpp @@ -568,7 +568,7 @@ namespace && weapon.attachmentUniques[attachmentUniqueIndex]->attachmentType != attachmentUnique.attachmentType) { std::vector attachments; - if (T6::attachment_unique::ExtractAttachmentsFromAssetName(weapon.attachmentUniques[attachmentUniqueIndex]->szInternalName, attachments) + if (attachment_unique::ExtractAttachmentsFromAssetNameT6(weapon.attachmentUniques[attachmentUniqueIndex]->szInternalName, attachments) && attachments.front() == attachmentUnique.attachmentType) { if (lastSibling == nullptr) @@ -599,16 +599,16 @@ namespace } } // namespace -namespace T6::weapon +namespace weapon { - InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + InfoStringLoaderT6::InfoStringLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) : m_memory(memory), m_search_path(searchPath), m_zone(zone) { } - AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) + AssetCreationResult InfoStringLoaderT6::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) { auto* weaponFullDef = m_memory.Alloc(); weaponFullDef->weapVariantDef.szInternalName = m_memory.Dup(assetName.c_str()); @@ -632,4 +632,4 @@ namespace T6::weapon return AssetCreationResult::Success(context.AddAsset(std::move(registration))); } -} // namespace T6::weapon +} // namespace weapon diff --git a/src/ObjLoading/Game/T6/Weapon/WeaponInfoStringLoaderT6.h b/src/ObjLoading/Game/T6/Weapon/WeaponInfoStringLoaderT6.h index 7ba8a410..a4d146cb 100644 --- a/src/ObjLoading/Game/T6/Weapon/WeaponInfoStringLoaderT6.h +++ b/src/ObjLoading/Game/T6/Weapon/WeaponInfoStringLoaderT6.h @@ -4,12 +4,12 @@ #include "Asset/AssetCreationResult.h" #include "InfoString/InfoString.h" -namespace T6::weapon +namespace weapon { - class InfoStringLoader + class InfoStringLoaderT6 { public: - InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); + InfoStringLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context); @@ -18,4 +18,4 @@ namespace T6::weapon ISearchPath& m_search_path; Zone& m_zone; }; -} // namespace T6::weapon +} // namespace weapon diff --git a/src/ObjLoading/Game/T6/Weapon/WeaponRawLoaderT6.cpp b/src/ObjLoading/Game/T6/Weapon/WeaponRawLoaderT6.cpp index 09304559..97f37dec 100644 --- a/src/ObjLoading/Game/T6/Weapon/WeaponRawLoaderT6.cpp +++ b/src/ObjLoading/Game/T6/Weapon/WeaponRawLoaderT6.cpp @@ -11,7 +11,6 @@ #include using namespace T6; -using namespace ::weapon; namespace { @@ -26,7 +25,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = GetFileNameForAssetName(assetName); + const auto fileName = weapon::GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -43,14 +42,14 @@ namespace private: ISearchPath& m_search_path; - T6::weapon::InfoStringLoader m_info_string_loader; + weapon::InfoStringLoaderT6 m_info_string_loader; }; } // namespace -namespace T6::weapon +namespace weapon { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace T6::weapon +} // namespace weapon diff --git a/src/ObjLoading/Game/T6/Weapon/WeaponRawLoaderT6.h b/src/ObjLoading/Game/T6/Weapon/WeaponRawLoaderT6.h index e02ce562..f026b99b 100644 --- a/src/ObjLoading/Game/T6/Weapon/WeaponRawLoaderT6.h +++ b/src/ObjLoading/Game/T6/Weapon/WeaponRawLoaderT6.h @@ -7,7 +7,7 @@ #include -namespace T6::weapon +namespace weapon { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace T6::weapon + std::unique_ptr> CreateRawLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace weapon diff --git a/src/ObjLoading/Game/T6/ZBarrier/GdtLoaderZBarrierT6.cpp b/src/ObjLoading/Game/T6/ZBarrier/GdtLoaderZBarrierT6.cpp index 0f8d5d22..09dbb255 100644 --- a/src/ObjLoading/Game/T6/ZBarrier/GdtLoaderZBarrierT6.cpp +++ b/src/ObjLoading/Game/T6/ZBarrier/GdtLoaderZBarrierT6.cpp @@ -40,14 +40,14 @@ namespace private: IGdtQueryable& m_gdt; - T6::z_barrier::InfoStringLoader m_info_string_loader; + z_barrier::InfoStringLoaderT6 m_info_string_loader; }; } // namespace -namespace T6::z_barrier +namespace z_barrier { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) + std::unique_ptr> CreateGdtLoaderT6(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone) { return std::make_unique(memory, searchPath, gdt, zone); } -} // namespace T6::z_barrier +} // namespace z_barrier diff --git a/src/ObjLoading/Game/T6/ZBarrier/GdtLoaderZBarrierT6.h b/src/ObjLoading/Game/T6/ZBarrier/GdtLoaderZBarrierT6.h index 7631005e..abf79682 100644 --- a/src/ObjLoading/Game/T6/ZBarrier/GdtLoaderZBarrierT6.h +++ b/src/ObjLoading/Game/T6/ZBarrier/GdtLoaderZBarrierT6.h @@ -8,7 +8,7 @@ #include -namespace T6::z_barrier +namespace z_barrier { - std::unique_ptr> CreateGdtLoader(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); -} // namespace T6::z_barrier + std::unique_ptr> CreateGdtLoaderT6(MemoryManager& memory, ISearchPath& searchPath, IGdtQueryable& gdt, Zone& zone); +} // namespace z_barrier diff --git a/src/ObjLoading/Game/T6/ZBarrier/InfoStringLoaderZBarrierT6.cpp b/src/ObjLoading/Game/T6/ZBarrier/InfoStringLoaderZBarrierT6.cpp index 43d93ab3..3952a969 100644 --- a/src/ObjLoading/Game/T6/ZBarrier/InfoStringLoaderZBarrierT6.cpp +++ b/src/ObjLoading/Game/T6/ZBarrier/InfoStringLoaderZBarrierT6.cpp @@ -55,16 +55,16 @@ namespace } } // namespace -namespace T6::z_barrier +namespace z_barrier { - InfoStringLoader::InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + InfoStringLoaderT6::InfoStringLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) : m_memory(memory), m_search_path(searchPath), m_zone(zone) { } - AssetCreationResult InfoStringLoader::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) + AssetCreationResult InfoStringLoaderT6::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context) { auto* zbarrier = m_memory.Alloc(); zbarrier->name = m_memory.Dup(assetName.c_str()); @@ -83,4 +83,4 @@ namespace T6::z_barrier return AssetCreationResult::Success(context.AddAsset(std::move(registration))); } -} // namespace T6::z_barrier +} // namespace z_barrier diff --git a/src/ObjLoading/Game/T6/ZBarrier/InfoStringLoaderZBarrierT6.h b/src/ObjLoading/Game/T6/ZBarrier/InfoStringLoaderZBarrierT6.h index efba4096..403fec2e 100644 --- a/src/ObjLoading/Game/T6/ZBarrier/InfoStringLoaderZBarrierT6.h +++ b/src/ObjLoading/Game/T6/ZBarrier/InfoStringLoaderZBarrierT6.h @@ -4,12 +4,12 @@ #include "Asset/AssetCreationResult.h" #include "InfoString/InfoString.h" -namespace T6::z_barrier +namespace z_barrier { - class InfoStringLoader + class InfoStringLoaderT6 { public: - InfoStringLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); + InfoStringLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context); @@ -18,4 +18,4 @@ namespace T6::z_barrier ISearchPath& m_search_path; Zone& m_zone; }; -} // namespace T6::z_barrier +} // namespace z_barrier diff --git a/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.cpp b/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.cpp index 9f0b3349..9b169786 100644 --- a/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.cpp +++ b/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.cpp @@ -11,7 +11,6 @@ #include using namespace T6; -using namespace ::z_barrier; namespace { @@ -26,7 +25,7 @@ namespace AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { - const auto fileName = GetFileNameForAssetName(assetName); + const auto fileName = z_barrier::GetFileNameForAssetName(assetName); const auto file = m_search_path.Open(fileName); if (!file.IsOpen()) return AssetCreationResult::NoAction(); @@ -43,14 +42,14 @@ namespace private: ISearchPath& m_search_path; - T6::z_barrier::InfoStringLoader m_info_string_loader; + z_barrier::InfoStringLoaderT6 m_info_string_loader; }; } // namespace -namespace T6::z_barrier +namespace z_barrier { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CreateRawLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } -} // namespace T6::z_barrier +} // namespace z_barrier diff --git a/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.h b/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.h index 0ae04d30..87ed18db 100644 --- a/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.h +++ b/src/ObjLoading/Game/T6/ZBarrier/RawLoaderZBarrierT6.h @@ -7,7 +7,7 @@ #include -namespace T6::z_barrier +namespace z_barrier { - std::unique_ptr> CreateRawLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); -} // namespace T6::z_barrier + std::unique_ptr> CreateRawLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); +} // namespace z_barrier diff --git a/src/ObjLoading/XModel/LoaderXModel.cpp.template b/src/ObjLoading/XModel/LoaderXModel.cpp.template index 08243114..c47b260e 100644 --- a/src/ObjLoading/XModel/LoaderXModel.cpp.template +++ b/src/ObjLoading/XModel/LoaderXModel.cpp.template @@ -1082,9 +1082,11 @@ namespace }; } // namespace -namespace GAME::xmodel +#set CREATE_LOADER_METHOD "CreateLoader" + GAME + +namespace xmodel { - std::unique_ptr> CreateXModelLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) + std::unique_ptr> CREATE_LOADER_METHOD (MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone.m_script_strings); } diff --git a/src/ObjLoading/XModel/LoaderXModel.h.template b/src/ObjLoading/XModel/LoaderXModel.h.template index 20590a8b..f6668ca2 100644 --- a/src/ObjLoading/XModel/LoaderXModel.h.template +++ b/src/ObjLoading/XModel/LoaderXModel.h.template @@ -13,7 +13,9 @@ #include -namespace GAME::xmodel +#set CREATE_LOADER_METHOD "CreateLoader" + GAME + +namespace xmodel { - std::unique_ptr> CreateXModelLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone); + std::unique_ptr> CREATE_LOADER_METHOD (MemoryManager& memory, ISearchPath& searchPath, Zone& zone); } // namespace GAME diff --git a/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.cpp b/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.cpp index 5459adcf..245e5790 100644 --- a/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.cpp +++ b/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.cpp @@ -15,7 +15,6 @@ #include using namespace IW3; -using namespace ::image; namespace { @@ -40,7 +39,7 @@ namespace std::unique_ptr LoadImageFromIwi(const GfxImage& image, ISearchPath& searchPath) { - const auto imageFileName = std::format("images/{}.iwi", image.name); + const auto imageFileName = image::GetFileNameForAsset(image.name, ".iwi"); const auto filePathImage = searchPath.Open(imageFileName); if (!filePathImage.IsOpen()) { @@ -60,9 +59,9 @@ namespace } } // namespace -namespace IW3::image +namespace image { - Dumper::Dumper() + DumperIW3::DumperIW3() { switch (ObjWriting::Configuration.ImageOutputFormat) { @@ -79,12 +78,12 @@ namespace IW3::image } } - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW3::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW3::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* image = asset->Asset(); const auto texture = LoadImageData(context.m_obj_search_path, *image); @@ -99,4 +98,4 @@ namespace IW3::image auto& stream = *assetFile; m_writer->DumpImage(stream, texture.get()); } -} // namespace IW3::image +} // namespace image diff --git a/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.h b/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.h index 24a22efa..7a1b181c 100644 --- a/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.h +++ b/src/ObjWriting/Game/IW3/Image/ImageDumperIW3.h @@ -6,18 +6,18 @@ #include -namespace IW3::image +namespace image { - class Dumper final : public AbstractAssetDumper + class DumperIW3 final : public AbstractAssetDumper { public: - Dumper(); + DumperIW3(); protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; private: std::unique_ptr m_writer; }; -} // namespace IW3::image +} // namespace image diff --git a/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.cpp b/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.cpp index e01f32d7..9cb481db 100644 --- a/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.cpp +++ b/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.cpp @@ -8,9 +8,9 @@ using namespace IW3; -namespace IW3::localize +namespace localize { - void Dumper::DumpPool(AssetDumpingContext& context, AssetPool* pool) + void DumperIW3::DumpPool(AssetDumpingContext& context, AssetPool* pool) { if (pool->m_asset_lookup.empty()) return; @@ -41,4 +41,4 @@ namespace IW3::localize std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name); } } -} // namespace IW3::localize +} // namespace localize diff --git a/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.h b/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.h index aebdd9aa..4cebd7c8 100644 --- a/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.h +++ b/src/ObjWriting/Game/IW3/Localize/LocalizeDumperIW3.h @@ -3,11 +3,11 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW3/IW3.h" -namespace IW3::localize +namespace localize { - class Dumper final : public IAssetDumper + class DumperIW3 final : public IAssetDumper { public: - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; + void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; }; -} // namespace IW3::localize +} // namespace localize diff --git a/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.cpp b/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.cpp index abe0e937..759623e4 100644 --- a/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.cpp +++ b/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.cpp @@ -2,14 +2,14 @@ using namespace IW3; -namespace IW3::map_ents +namespace map_ents { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW3::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW3::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* mapEnts = asset->Asset(); const auto assetFile = context.OpenAssetFile(asset->m_name + ".ents"); @@ -20,4 +20,4 @@ namespace IW3::map_ents auto& stream = *assetFile; stream.write(mapEnts->entityString, mapEnts->numEntityChars); } -} // namespace IW3::map_ents +} // namespace map_ents diff --git a/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.h b/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.h index 55518202..cd41ccc8 100644 --- a/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.h +++ b/src/ObjWriting/Game/IW3/Maps/MapEntsDumperIW3.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW3/IW3.h" -namespace IW3::map_ents +namespace map_ents { - class Dumper final : public AbstractAssetDumper + class DumperIW3 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW3::map_ents +} // namespace map_ents diff --git a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp index 59cd7a00..418e3156 100644 --- a/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp +++ b/src/ObjWriting/Game/IW3/ObjWriterIW3.cpp @@ -26,30 +26,30 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperPhysPreset, m_phys_preset, ASSET_TYPE_PHYSPRESET) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) - DUMP_ASSET_POOL(xmodel::Dumper, m_xmodel, ASSET_TYPE_XMODEL) - DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) + DUMP_ASSET_POOL(xmodel::DumperIW3, m_xmodel, ASSET_TYPE_XMODEL) + DUMP_ASSET_POOL(material::JsonDumperIW3, m_material, ASSET_TYPE_MATERIAL) // DUMP_ASSET_POOL(AssetDumperMaterialTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) - DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) + DUMP_ASSET_POOL(image::DumperIW3, m_image, ASSET_TYPE_IMAGE) // DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND) // DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE) - DUMP_ASSET_POOL(sound::LoadedSoundDumper, m_loaded_sound, ASSET_TYPE_LOADED_SOUND) + DUMP_ASSET_POOL(sound::LoadedSoundDumperIW3, m_loaded_sound, ASSET_TYPE_LOADED_SOUND) // DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_PVS) // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD) // DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP) // DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP) - DUMP_ASSET_POOL(map_ents::Dumper, m_map_ents, ASSET_TYPE_MAP_ENTS) + DUMP_ASSET_POOL(map_ents::DumperIW3, m_map_ents, ASSET_TYPE_MAP_ENTS) // DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD) // DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF) // DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT) // DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST) // DUMP_ASSET_POOL(AssetDumpermenuDef_t, m_menu_def, ASSET_TYPE_MENU) - DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) + DUMP_ASSET_POOL(localize::DumperIW3, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) // DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON) // DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) - DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE) - DUMP_ASSET_POOL(string_table::Dumper, m_string_table, ASSET_TYPE_STRINGTABLE) + DUMP_ASSET_POOL(raw_file::DumperIW3, m_raw_file, ASSET_TYPE_RAWFILE) + DUMP_ASSET_POOL(string_table::DumperIW3, m_string_table, ASSET_TYPE_STRINGTABLE) return true; diff --git a/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.cpp b/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.cpp index 22af389d..4b2eb11b 100644 --- a/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.cpp +++ b/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.cpp @@ -2,14 +2,14 @@ using namespace IW3; -namespace IW3::raw_file +namespace raw_file { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW3::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW3::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* rawFile = asset->Asset(); const auto assetFile = context.OpenAssetFile(asset->m_name); @@ -20,4 +20,4 @@ namespace IW3::raw_file auto& stream = *assetFile; stream.write(rawFile->buffer, rawFile->len); } -} // namespace IW3::raw_file +} // namespace raw_file diff --git a/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.h b/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.h index 3ea995c8..250bea7c 100644 --- a/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.h +++ b/src/ObjWriting/Game/IW3/RawFile/RawFileDumperIW3.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW3/IW3.h" -namespace IW3::raw_file +namespace raw_file { - class Dumper final : public AbstractAssetDumper + class DumperIW3 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW3::raw_file +} // namespace raw_file diff --git a/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.cpp b/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.cpp index 4e3ab817..ccf79977 100644 --- a/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.cpp +++ b/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.cpp @@ -22,14 +22,14 @@ namespace } } // namespace -namespace IW3::sound +namespace sound { - bool LoadedSoundDumper::ShouldDump(XAssetInfo* asset) + bool LoadedSoundDumperIW3::ShouldDump(XAssetInfo* asset) { return true; } - void LoadedSoundDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void LoadedSoundDumperIW3::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* loadedSound = asset->Asset(); const auto assetFile = context.OpenAssetFile(std::format("sound/{}", asset->m_name)); @@ -49,4 +49,4 @@ namespace IW3::sound break; } } -} // namespace IW3::sound +} // namespace sound diff --git a/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.h b/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.h index cfe8b811..458af961 100644 --- a/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.h +++ b/src/ObjWriting/Game/IW3/Sound/LoadedSoundDumperIW3.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW3/IW3.h" -namespace IW3::sound +namespace sound { - class LoadedSoundDumper final : public AbstractAssetDumper + class LoadedSoundDumperIW3 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW3::sound +} // namespace sound diff --git a/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.cpp b/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.cpp index 381660a7..b7188a34 100644 --- a/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.cpp +++ b/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.cpp @@ -4,14 +4,14 @@ using namespace IW3; -namespace IW3::string_table +namespace string_table { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW3::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW3::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* stringTable = asset->Asset(); const auto assetFile = context.OpenAssetFile(asset->m_name); @@ -31,4 +31,4 @@ namespace IW3::string_table csv.NextRow(); } } -} // namespace IW3::string_table +} // namespace string_table diff --git a/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.h b/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.h index c010dd89..21ef05d5 100644 --- a/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.h +++ b/src/ObjWriting/Game/IW3/StringTable/StringTableDumperIW3.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW3/IW3.h" -namespace IW3::string_table +namespace string_table { - class Dumper final : public AbstractAssetDumper + class DumperIW3 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW3::string_table +} // namespace string_table diff --git a/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.cpp b/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.cpp index ad2bf5c9..57fd3cf3 100644 --- a/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.cpp @@ -12,7 +12,6 @@ #include using namespace IW4; -using namespace ::image; namespace { @@ -37,7 +36,7 @@ namespace std::unique_ptr LoadImageFromIwi(const GfxImage& image, ISearchPath& searchPath) { - const auto imageFileName = std::format("images/{}.iwi", image.name); + const auto imageFileName = image::GetFileNameForAsset(image.name, ".iwi"); const auto filePathImage = searchPath.Open(imageFileName); if (!filePathImage.IsOpen()) { @@ -57,9 +56,9 @@ namespace } } // namespace -namespace IW4::image +namespace image { - Dumper::Dumper() + DumperIW4::DumperIW4() { switch (ObjWriting::Configuration.ImageOutputFormat) { @@ -76,12 +75,12 @@ namespace IW4::image } } - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW4::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* image = asset->Asset(); const auto texture = LoadImageData(context.m_obj_search_path, *image); @@ -96,4 +95,4 @@ namespace IW4::image auto& stream = *assetFile; m_writer->DumpImage(stream, texture.get()); } -} // namespace IW4::image +} // namespace image diff --git a/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.h b/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.h index ee9910f4..5d268ccc 100644 --- a/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Image/ImageDumperIW4.h @@ -6,18 +6,18 @@ #include -namespace IW4::image +namespace image { - class Dumper final : public AbstractAssetDumper + class DumperIW4 final : public AbstractAssetDumper { public: - Dumper(); + DumperIW4(); protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; private: std::unique_ptr m_writer; }; -} // namespace IW4::image +} // namespace image diff --git a/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.cpp b/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.cpp index 363335bd..80ed3625 100644 --- a/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.cpp @@ -9,7 +9,6 @@ using namespace nlohmann; using namespace IW4; -using namespace ::leaderboard; namespace { @@ -76,14 +75,14 @@ namespace }; } // namespace -namespace IW4::leaderboard +namespace leaderboard { - bool JsonDumper::ShouldDump(XAssetInfo* asset) + bool JsonDumperIW4::ShouldDump(XAssetInfo* asset) { return true; } - void JsonDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void JsonDumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAsset(asset->m_name)); @@ -93,4 +92,4 @@ namespace IW4::leaderboard Dumper dumper(*assetFile); dumper.Dump(*asset->Asset()); } -} // namespace IW4::leaderboard +} // namespace leaderboard diff --git a/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.h b/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.h index eb7f7183..a56e5127 100644 --- a/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Leaderboard/LeaderboardJsonDumperIW4.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4::leaderboard +namespace leaderboard { - class JsonDumper final : public AbstractAssetDumper + class JsonDumperIW4 final : public AbstractAssetDumper { protected: - [[nodiscard]] bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + [[nodiscard]] bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4::leaderboard +} // namespace leaderboard diff --git a/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.cpp b/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.cpp index 549da3d1..205df266 100644 --- a/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.cpp @@ -5,16 +5,15 @@ #include using namespace IW4; -using namespace ::light_def; -namespace IW4::light_def +namespace light_def { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW4::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* lightDef = asset->Asset(); const auto assetFile = context.OpenAssetFile(GetFileNameForAsset(asset->m_name)); @@ -30,4 +29,4 @@ namespace IW4::light_def stream << lightDef->attenuation.samplerState << imageName << static_cast(lightDef->lmapLookupStart); } -} // namespace IW4::light_def +} // namespace light_def diff --git a/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.h b/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.h index f80236df..29531abb 100644 --- a/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.h +++ b/src/ObjWriting/Game/IW4/LightDef/LightDefDumperIW4.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4::light_def +namespace light_def { - class Dumper final : public AbstractAssetDumper + class DumperIW4 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4::light_def +} // namespace light_def diff --git a/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.cpp b/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.cpp index 3efb30ea..77b4b44e 100644 --- a/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.cpp @@ -8,9 +8,9 @@ using namespace IW4; -namespace IW4::localize +namespace localize { - void Dumper::DumpPool(AssetDumpingContext& context, AssetPool* pool) + void DumperIW4::DumpPool(AssetDumpingContext& context, AssetPool* pool) { if (pool->m_asset_lookup.empty()) return; @@ -41,4 +41,4 @@ namespace IW4::localize std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name); } } -} // namespace IW4::localize +} // namespace localize diff --git a/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.h b/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.h index f7435a5b..fd88c200 100644 --- a/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Localize/LocalizeDumperIW4.h @@ -3,11 +3,11 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4::localize +namespace localize { - class Dumper final : public IAssetDumper + class DumperIW4 final : public IAssetDumper { public: - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; + void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; }; -} // namespace IW4::localize +} // namespace localize diff --git a/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.cpp b/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.cpp index 7f708cc0..37b45249 100644 --- a/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.cpp @@ -5,14 +5,14 @@ using namespace IW4; -namespace IW4::addon_map_ents +namespace addon_map_ents { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW4::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* addonMapEnts = asset->Asset(); const auto assetFile = context.OpenAssetFile(asset->m_name); @@ -24,4 +24,4 @@ namespace IW4::addon_map_ents stream.write(addonMapEnts->entityString, std::max(addonMapEnts->numEntityChars - 1, 0)); } -} // namespace IW4::addon_map_ents +} // namespace addon_map_ents diff --git a/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.h b/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.h index a4691a78..4f1ef6c8 100644 --- a/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Maps/AddonMapEntsDumperIW4.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4::addon_map_ents +namespace addon_map_ents { - class Dumper final : public AbstractAssetDumper + class DumperIW4 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4::addon_map_ents +} // namespace addon_map_ents diff --git a/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.cpp b/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.cpp index 21ca149e..a61c012a 100644 --- a/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.cpp @@ -1108,14 +1108,14 @@ namespace }; } // namespace -namespace IW4::material +namespace material { - bool DecompilingGdtDumper::ShouldDump(XAssetInfo* asset) + bool DecompilingGdtDumperIW4::ShouldDump(XAssetInfo* asset) { return true; } - void DecompilingGdtDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DecompilingGdtDumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { if (!context.m_gdt) return; @@ -1123,4 +1123,4 @@ namespace IW4::material MaterialGdtDumper dumper(*asset->Asset()); context.m_gdt->WriteEntry(dumper.CreateGdtEntry()); } -} // namespace IW4::material +} // namespace material diff --git a/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.h b/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.h index dd192116..e6b73e35 100644 --- a/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Material/MaterialDecompilingDumperIW4.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4::material +namespace material { - class DecompilingGdtDumper final : public AbstractAssetDumper + class DecompilingGdtDumperIW4 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4::material +} // namespace material diff --git a/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.cpp b/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.cpp index 995f1cf2..d3828080 100644 --- a/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.cpp @@ -10,11 +10,10 @@ #include using namespace IW4; -using namespace ::menu; namespace { - std::string GetPathForMenu(MenuDumpingZoneState* zoneState, XAssetInfo* asset) + std::string GetPathForMenu(menu::MenuDumpingZoneState* zoneState, XAssetInfo* asset) { const auto menuDumpingState = zoneState->m_menu_dumping_state_map.find(asset->Asset()); @@ -25,14 +24,14 @@ namespace } } // namespace -namespace IW4::menu +namespace menu { - bool MenuDumper::ShouldDump(XAssetInfo* asset) + bool MenuDumperIW4::ShouldDump(XAssetInfo* asset) { return true; } - void MenuDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void MenuDumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* menu = asset->Asset(); auto* zoneState = context.GetZoneAssetDumperState(); @@ -42,7 +41,7 @@ namespace IW4::menu // Make sure menu paths based on menu lists are created const auto* gameAssetPool = dynamic_cast(asset->m_zone->m_pools.get()); for (auto* menuListAsset : *gameAssetPool->m_menu_list) - CreateDumpingStateForMenuList(zoneState, menuListAsset->Asset()); + CreateDumpingStateForMenuListIW4(zoneState, menuListAsset->Asset()); } const auto menuFilePath = GetPathForMenu(zoneState, asset); @@ -51,10 +50,10 @@ namespace IW4::menu if (!assetFile) return; - auto menuWriter = CreateMenuWriter(*assetFile); + auto menuWriter = CreateMenuWriterIW4(*assetFile); menuWriter->Start(); menuWriter->WriteMenu(*menu); menuWriter->End(); } -} // namespace IW4::menu +} // namespace menu diff --git a/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.h b/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.h index 5567b3f6..43317e26 100644 --- a/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Menu/MenuDumperIW4.h @@ -4,12 +4,12 @@ #include "Game/IW4/IW4.h" #include "Menu/MenuDumpingZoneState.h" -namespace IW4::menu +namespace menu { - class MenuDumper final : public AbstractAssetDumper + class MenuDumperIW4 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4::menu +} // namespace menu diff --git a/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.cpp b/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.cpp index 2d2614af..7946dfe9 100644 --- a/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.cpp @@ -13,7 +13,6 @@ namespace fs = std::filesystem; using namespace IW4; -using namespace ::menu; namespace { @@ -45,7 +44,7 @@ namespace return result; } - void DumpFunctions(IW4::menu::IWriterIW4& menuDumper, const MenuList* menuList) + void DumpFunctions(menu::IWriterIW4& menuDumper, const MenuList* menuList) { const auto allSupportingData = GetAllUniqueExpressionSupportingData(menuList); auto functionIndex = 0u; @@ -73,7 +72,7 @@ namespace } } - void DumpMenus(IW4::menu::IWriterIW4& menuDumper, ::menu::MenuDumpingZoneState* zoneState, const MenuList* menuList) + void DumpMenus(menu::IWriterIW4& menuDumper, menu::MenuDumpingZoneState* zoneState, const MenuList* menuList) { for (auto menuNum = 0; menuNum < menuList->menuCount; menuNum++) { @@ -108,9 +107,9 @@ namespace } } // namespace -namespace IW4::menu +namespace menu { - void CreateDumpingStateForMenuList(::menu::MenuDumpingZoneState* zoneState, const MenuList* menuList) + void CreateDumpingStateForMenuListIW4(MenuDumpingZoneState* zoneState, const MenuList* menuList) { if (menuList->menuCount <= 0 || menuList->menus == nullptr || menuList->name == nullptr) return; @@ -148,12 +147,12 @@ namespace IW4::menu } } - bool MenuListDumper::ShouldDump(XAssetInfo* asset) + bool MenuListDumperIW4::ShouldDump(XAssetInfo* asset) { return true; } - void MenuListDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void MenuListDumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* menuList = asset->Asset(); const auto assetFile = context.OpenAssetFile(asset->m_name); @@ -163,7 +162,7 @@ namespace IW4::menu auto* zoneState = context.GetZoneAssetDumperState(); - auto menuWriter = CreateMenuWriter(*assetFile); + auto menuWriter = CreateMenuWriterIW4(*assetFile); menuWriter->Start(); @@ -175,13 +174,13 @@ namespace IW4::menu menuWriter->End(); } - void MenuListDumper::DumpPool(AssetDumpingContext& context, AssetPool* pool) + void MenuListDumperIW4::DumpPool(AssetDumpingContext& context, AssetPool* pool) { auto* zoneState = context.GetZoneAssetDumperState(); for (auto* asset : *pool) - CreateDumpingStateForMenuList(zoneState, asset->Asset()); + CreateDumpingStateForMenuListIW4(zoneState, asset->Asset()); AbstractAssetDumper::DumpPool(context, pool); } -} // namespace IW4::menu +} // namespace menu diff --git a/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.h b/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.h index 891ba458..b9329966 100644 --- a/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Menu/MenuListDumperIW4.h @@ -5,17 +5,17 @@ #include "Game/IW4/Menu/MenuDumperIW4.h" #include "Menu/MenuDumpingZoneState.h" -namespace IW4::menu +namespace menu { - void CreateDumpingStateForMenuList(::menu::MenuDumpingZoneState* zoneState, const MenuList* menuList); + void CreateDumpingStateForMenuListIW4(MenuDumpingZoneState* zoneState, const IW4::MenuList* menuList); - class MenuListDumper final : public AbstractAssetDumper + class MenuListDumperIW4 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; public: - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; + void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; }; -} // namespace IW4::menu +} // namespace menu diff --git a/src/ObjWriting/Game/IW4/Menu/MenuWriterIW4.cpp b/src/ObjWriting/Game/IW4/Menu/MenuWriterIW4.cpp index ad19833b..b20cec15 100644 --- a/src/ObjWriting/Game/IW4/Menu/MenuWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/Menu/MenuWriterIW4.cpp @@ -54,7 +54,7 @@ namespace return statementEnd; } - class MenuWriter final : public ::menu::AbstractBaseWriter, public IW4::menu::IWriterIW4 + class MenuWriter final : public ::menu::AbstractBaseWriter, public menu::IWriterIW4 { public: explicit MenuWriter(std::ostream& stream) @@ -948,10 +948,10 @@ namespace }; } // namespace -namespace IW4::menu +namespace menu { - std::unique_ptr CreateMenuWriter(std::ostream& stream) + std::unique_ptr CreateMenuWriterIW4(std::ostream& stream) { return std::make_unique(stream); } -} // namespace IW4::menu +} // namespace menu diff --git a/src/ObjWriting/Game/IW4/Menu/MenuWriterIW4.h b/src/ObjWriting/Game/IW4/Menu/MenuWriterIW4.h index 5c198f80..3988bbb3 100644 --- a/src/ObjWriting/Game/IW4/Menu/MenuWriterIW4.h +++ b/src/ObjWriting/Game/IW4/Menu/MenuWriterIW4.h @@ -6,14 +6,14 @@ #include #include -namespace IW4::menu +namespace menu { - class IWriterIW4 : public ::menu::IWriter + class IWriterIW4 : public IWriter { public: - virtual void WriteFunctionDef(const std::string& functionName, const Statement_s* statement) = 0; - virtual void WriteMenu(const menuDef_t& menu) = 0; + virtual void WriteFunctionDef(const std::string& functionName, const IW4::Statement_s* statement) = 0; + virtual void WriteMenu(const IW4::menuDef_t& menu) = 0; }; - std::unique_ptr CreateMenuWriter(std::ostream& stream); -} // namespace IW4::menu + std::unique_ptr CreateMenuWriterIW4(std::ostream& stream); +} // namespace menu diff --git a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp index 0a39cf0e..b749a985 100644 --- a/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp +++ b/src/ObjWriting/Game/IW4/ObjWriterIW4.cpp @@ -39,21 +39,21 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const const auto* assetPools = dynamic_cast(context.m_zone.m_pools.get()); - DUMP_ASSET_POOL(phys_preset::InfoStringDumper, m_phys_preset, ASSET_TYPE_PHYSPRESET) - DUMP_ASSET_POOL(phys_collmap::Dumper, m_phys_collmap, ASSET_TYPE_PHYSCOLLMAP) + DUMP_ASSET_POOL(phys_preset::InfoStringDumperIW4, m_phys_preset, ASSET_TYPE_PHYSPRESET) + DUMP_ASSET_POOL(phys_collmap::DumperIW4, m_phys_collmap, ASSET_TYPE_PHYSCOLLMAP) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) - DUMP_ASSET_POOL(xmodel::Dumper, m_xmodel, ASSET_TYPE_XMODEL) - DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) + DUMP_ASSET_POOL(xmodel::DumperIW4, m_xmodel, ASSET_TYPE_XMODEL) + DUMP_ASSET_POOL(material::JsonDumperIW4, m_material, ASSET_TYPE_MATERIAL) #ifdef EXPERIMENTAL_MATERIAL_COMPILATION - DUMP_ASSET_POOL(material::DecompilingGdtDumper, m_material, ASSET_TYPE_MATERIAL) + DUMP_ASSET_POOL(material::DecompilingGdtDumperIW4, m_material, ASSET_TYPE_MATERIAL) #endif - DUMP_ASSET_POOL(shader::PixelShaderDumper, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER) - DUMP_ASSET_POOL(shader::VertexShaderDumper, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER) - DUMP_ASSET_POOL(techset::Dumper, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) - DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) + DUMP_ASSET_POOL(shader::PixelShaderDumperIW4, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER) + DUMP_ASSET_POOL(shader::VertexShaderDumperIW4, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER) + DUMP_ASSET_POOL(techset::DumperIW4, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) + DUMP_ASSET_POOL(image::DumperIW4, m_image, ASSET_TYPE_IMAGE) // DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND) - DUMP_ASSET_POOL(sound_curve::Dumper, m_sound_curve, ASSET_TYPE_SOUND_CURVE) - DUMP_ASSET_POOL(sound::LoadedSoundDumper, m_loaded_sound, ASSET_TYPE_LOADED_SOUND) + DUMP_ASSET_POOL(sound_curve::DumperIW4, m_sound_curve, ASSET_TYPE_SOUND_CURVE) + DUMP_ASSET_POOL(sound::LoadedSoundDumperIW4, m_loaded_sound, ASSET_TYPE_LOADED_SOUND) // DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_MP) // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD) // DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP) @@ -61,22 +61,22 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperMapEnts, m_map_ents, ASSET_TYPE_MAP_ENTS) // DUMP_ASSET_POOL(AssetDumperFxWorld, m_fx_world, ASSET_TYPE_FXWORLD) // DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD) - DUMP_ASSET_POOL(light_def::Dumper, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF) + DUMP_ASSET_POOL(light_def::DumperIW4, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF) // DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT) - DUMP_ASSET_POOL(menu::MenuListDumper, m_menu_list, ASSET_TYPE_MENULIST) - DUMP_ASSET_POOL(menu::MenuDumper, m_menu_def, ASSET_TYPE_MENU) - DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) - DUMP_ASSET_POOL(weapon::Dumper, m_weapon, ASSET_TYPE_WEAPON) + DUMP_ASSET_POOL(menu::MenuListDumperIW4, m_menu_list, ASSET_TYPE_MENULIST) + DUMP_ASSET_POOL(menu::MenuDumperIW4, m_menu_def, ASSET_TYPE_MENU) + DUMP_ASSET_POOL(localize::DumperIW4, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) + DUMP_ASSET_POOL(weapon::DumperIW4, m_weapon, ASSET_TYPE_WEAPON) // DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) - DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE) - DUMP_ASSET_POOL(string_table::Dumper, m_string_table, ASSET_TYPE_STRINGTABLE) - DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD) - DUMP_ASSET_POOL(structured_data_def::Dumper, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF) - DUMP_ASSET_POOL(tracer::Dumper, m_tracer, ASSET_TYPE_TRACER) - DUMP_ASSET_POOL(vehicle::Dumper, m_vehicle, ASSET_TYPE_VEHICLE) - DUMP_ASSET_POOL(addon_map_ents::Dumper, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS) + DUMP_ASSET_POOL(raw_file::DumperIW4, m_raw_file, ASSET_TYPE_RAWFILE) + DUMP_ASSET_POOL(string_table::DumperIW4, m_string_table, ASSET_TYPE_STRINGTABLE) + DUMP_ASSET_POOL(leaderboard::JsonDumperIW4, m_leaderboard, ASSET_TYPE_LEADERBOARD) + DUMP_ASSET_POOL(structured_data_def::DumperIW4, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF) + DUMP_ASSET_POOL(tracer::DumperIW4, m_tracer, ASSET_TYPE_TRACER) + DUMP_ASSET_POOL(vehicle::DumperIW4, m_vehicle, ASSET_TYPE_VEHICLE) + DUMP_ASSET_POOL(addon_map_ents::DumperIW4, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS) return true; diff --git a/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.cpp b/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.cpp index 046a9c5e..523c64c8 100644 --- a/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.cpp @@ -7,19 +7,18 @@ #include using namespace IW4; -using namespace ::phys_collmap; -namespace IW4::phys_collmap +namespace phys_collmap { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW4::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* physCollmap = asset->Asset(); - const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name)); + const auto assetFile = context.OpenAssetFile(phys_collmap::GetFileNameForAssetName(asset->m_name)); if (!assetFile) return; @@ -80,4 +79,4 @@ namespace IW4::phys_collmap mapFileDumper.EndEntity(); } -} // namespace IW4::phys_collmap +} // namespace phys_collmap diff --git a/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.h b/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.h index 2407233e..4dbf68d6 100644 --- a/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.h +++ b/src/ObjWriting/Game/IW4/PhysCollmap/PhysCollmapDumperIW4.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4::phys_collmap +namespace phys_collmap { - class Dumper final : public AbstractAssetDumper + class DumperIW4 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4::phys_collmap +} // namespace phys_collmap diff --git a/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.cpp b/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.cpp index 734bd8d8..41ac1f64 100644 --- a/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.cpp @@ -11,7 +11,6 @@ #include using namespace IW4; -using namespace ::phys_preset; namespace { @@ -79,14 +78,14 @@ namespace } } // namespace -namespace IW4::phys_preset +namespace phys_preset { - bool InfoStringDumper::ShouldDump(XAssetInfo* asset) + bool InfoStringDumperIW4::ShouldDump(XAssetInfo* asset) { return true; } - void InfoStringDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void InfoStringDumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { // Only dump raw when no gdt available if (context.m_gdt) @@ -109,4 +108,4 @@ namespace IW4::phys_preset stream.write(stringValue.c_str(), stringValue.size()); } } -} // namespace IW4::phys_preset +} // namespace phys_preset diff --git a/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.h b/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.h index 22998751..4651c1e0 100644 --- a/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.h +++ b/src/ObjWriting/Game/IW4/PhysPreset/PhysPresetInfoStringDumperIW4.h @@ -4,12 +4,12 @@ #include "Game/IW4/IW4.h" #include "InfoString/InfoString.h" -namespace IW4::phys_preset +namespace phys_preset { - class InfoStringDumper final : public AbstractAssetDumper + class InfoStringDumperIW4 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4::phys_preset +} // namespace phys_preset diff --git a/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.cpp b/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.cpp index ec4224af..9698e608 100644 --- a/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.cpp @@ -6,14 +6,14 @@ using namespace IW4; -namespace IW4::raw_file +namespace raw_file { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW4::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* rawFile = asset->Asset(); const auto assetFile = context.OpenAssetFile(asset->m_name); @@ -67,4 +67,4 @@ namespace IW4::raw_file stream.write(rawFile->data.buffer, rawFile->len); } } -} // namespace IW4::raw_file +} // namespace raw_file diff --git a/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.h b/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.h index a1657fb5..9b8966ea 100644 --- a/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.h +++ b/src/ObjWriting/Game/IW4/RawFile/RawFileDumperIW4.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4::raw_file +namespace raw_file { - class Dumper final : public AbstractAssetDumper + class DumperIW4 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4::raw_file +} // namespace raw_file diff --git a/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.cpp b/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.cpp index bbd382fa..318c9a68 100644 --- a/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.cpp @@ -3,19 +3,18 @@ #include "Shader/ShaderCommon.h" using namespace IW4; -using namespace ::shader; -namespace IW4::shader +namespace shader { - bool PixelShaderDumper::ShouldDump(XAssetInfo* asset) + bool PixelShaderDumperIW4::ShouldDump(XAssetInfo* asset) { return true; } - void PixelShaderDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void PixelShaderDumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* pixelShader = asset->Asset(); - const auto shaderFile = context.OpenAssetFile(GetFileNameForPixelShaderAssetName(asset->m_name)); + const auto shaderFile = context.OpenAssetFile(shader::GetFileNameForPixelShaderAssetName(asset->m_name)); if (!shaderFile) return; @@ -23,4 +22,4 @@ namespace IW4::shader shaderFile->write(reinterpret_cast(pixelShader->prog.loadDef.program), static_cast(pixelShader->prog.loadDef.programSize) * 4u); } -} // namespace IW4::shader +} // namespace shader diff --git a/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.h b/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.h index 875576ca..01404d0a 100644 --- a/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Shader/PixelShaderDumperIW4.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4::shader +namespace shader { - class PixelShaderDumper final : public AbstractAssetDumper + class PixelShaderDumperIW4 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4::shader +} // namespace shader diff --git a/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.cpp b/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.cpp index 3dacbc04..c3954562 100644 --- a/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.cpp @@ -3,19 +3,18 @@ #include "Shader/ShaderCommon.h" using namespace IW4; -using namespace ::shader; -namespace IW4::shader +namespace shader { - bool VertexShaderDumper::ShouldDump(XAssetInfo* asset) + bool VertexShaderDumperIW4::ShouldDump(XAssetInfo* asset) { return true; } - void VertexShaderDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void VertexShaderDumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* vertexShader = asset->Asset(); - const auto shaderFile = context.OpenAssetFile(GetFileNameForVertexShaderAssetName(asset->m_name)); + const auto shaderFile = context.OpenAssetFile(shader::GetFileNameForVertexShaderAssetName(asset->m_name)); if (!shaderFile) return; @@ -23,4 +22,4 @@ namespace IW4::shader shaderFile->write(reinterpret_cast(vertexShader->prog.loadDef.program), static_cast(vertexShader->prog.loadDef.programSize) * 4u); } -} // namespace IW4::shader +} // namespace shader diff --git a/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.h b/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.h index 6f24fce7..1b722461 100644 --- a/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Shader/VertexShaderDumperIW4.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4::shader +namespace shader { - class VertexShaderDumper final : public AbstractAssetDumper + class VertexShaderDumperIW4 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4::shader +} // namespace shader diff --git a/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.cpp b/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.cpp index 8a363418..8a2c6360 100644 --- a/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.cpp @@ -22,14 +22,14 @@ namespace } } // namespace -namespace IW4::sound +namespace sound { - bool LoadedSoundDumper::ShouldDump(XAssetInfo* asset) + bool LoadedSoundDumperIW4::ShouldDump(XAssetInfo* asset) { return true; } - void LoadedSoundDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void LoadedSoundDumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* loadedSound = asset->Asset(); const auto assetFile = context.OpenAssetFile(std::format("sound/{}", asset->m_name)); @@ -49,4 +49,4 @@ namespace IW4::sound break; } } -} // namespace IW4::sound +} // namespace sound diff --git a/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.h b/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.h index 2799152c..7256bc88 100644 --- a/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Sound/LoadedSoundDumperIW4.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4::sound +namespace sound { - class LoadedSoundDumper final : public AbstractAssetDumper + class LoadedSoundDumperIW4 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4::sound +} // namespace sound diff --git a/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.cpp b/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.cpp index 69b51223..b7e00629 100644 --- a/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.cpp @@ -6,16 +6,15 @@ #include using namespace IW4; -using namespace ::sound_curve; -namespace IW4::sound_curve +namespace sound_curve { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW4::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* sndCurve = asset->Asset(); @@ -32,4 +31,4 @@ namespace IW4::sound_curve for (auto i = 0u; i < knotCount; i++) dumper.WriteKnot(sndCurve->knots[i][0], sndCurve->knots[i][1]); } -} // namespace IW4::sound_curve +} // namespace sound_curve diff --git a/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.h b/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.h index 85ff48a1..241b7a79 100644 --- a/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Sound/SndCurveDumperIW4.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4::sound_curve +namespace sound_curve { - class Dumper final : public AbstractAssetDumper + class DumperIW4 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4::sound_curve +} // namespace sound_curve diff --git a/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.cpp b/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.cpp index 7e86896a..784164e2 100644 --- a/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.cpp @@ -4,14 +4,14 @@ using namespace IW4; -namespace IW4::string_table +namespace string_table { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW4::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* stringTable = asset->Asset(); const auto assetFile = context.OpenAssetFile(asset->m_name); @@ -39,4 +39,4 @@ namespace IW4::string_table csv.NextRow(); } } -} // namespace IW4::string_table +} // namespace string_table diff --git a/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.h b/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.h index 2321c6ae..93f1af2b 100644 --- a/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.h +++ b/src/ObjWriting/Game/IW4/StringTable/StringTableDumperIW4.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4::string_table +namespace string_table { - class Dumper final : public AbstractAssetDumper + class DumperIW4 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4::string_table +} // namespace string_table diff --git a/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.cpp b/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.cpp index 22177b7e..2e5cf317 100644 --- a/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.cpp @@ -183,14 +183,14 @@ namespace } } // namespace -namespace IW4::structured_data_def +namespace structured_data_def { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW4::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* set = asset->Asset(); const auto assetFile = context.OpenAssetFile(asset->m_name); @@ -205,4 +205,4 @@ namespace IW4::structured_data_def dumper.DumpDef(*def); } } -} // namespace IW4::structured_data_def +} // namespace structured_data_def diff --git a/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.h b/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.h index da36a645..e03d8c61 100644 --- a/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.h +++ b/src/ObjWriting/Game/IW4/StructuredDataDef/StructuredDataDefDumperIW4.h @@ -6,12 +6,12 @@ #include -namespace IW4::structured_data_def +namespace structured_data_def { - class Dumper final : public AbstractAssetDumper + class DumperIW4 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4::structured_data_def +} // namespace structured_data_def diff --git a/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.cpp b/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.cpp index 2fa97986..24ae8652 100644 --- a/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.cpp @@ -13,7 +13,6 @@ #include using namespace IW4; -using namespace ::techset; namespace IW4 { @@ -533,14 +532,14 @@ namespace IW4 }; } // namespace IW4 -namespace IW4::techset +namespace techset { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW4::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* techset = asset->Asset(); @@ -566,4 +565,4 @@ namespace IW4::techset } } } -} // namespace IW4::techset +} // namespace techset diff --git a/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.h b/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.h index 97535e3e..8115f527 100644 --- a/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Techset/TechsetDumperIW4.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW4/IW4.h" -namespace IW4::techset +namespace techset { - class Dumper final : public AbstractAssetDumper + class DumperIW4 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4::techset +} // namespace techset diff --git a/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.cpp b/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.cpp index 1cf1eb84..2e3635f8 100644 --- a/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.cpp @@ -11,7 +11,6 @@ #include using namespace IW4; -using namespace ::tracer; namespace { @@ -51,14 +50,14 @@ namespace } } // namespace -namespace IW4::tracer +namespace tracer { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW4::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { // Only dump raw when no gdt available if (context.m_gdt) @@ -81,4 +80,4 @@ namespace IW4::tracer stream.write(stringValue.c_str(), stringValue.size()); } } -} // namespace IW4::tracer +} // namespace tracer diff --git a/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.h b/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.h index 5beb2809..d13a9f60 100644 --- a/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Tracer/TracerDumperIW4.h @@ -4,12 +4,12 @@ #include "Game/IW4/IW4.h" #include "InfoString/InfoString.h" -namespace IW4::tracer +namespace tracer { - class Dumper final : public AbstractAssetDumper + class DumperIW4 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4::tracer +} // namespace tracer diff --git a/src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.cpp b/src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.cpp index 137c30de..9110b559 100644 --- a/src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.cpp @@ -12,7 +12,6 @@ #include using namespace IW4; -using namespace ::vehicle; namespace { @@ -92,14 +91,14 @@ namespace } } // namespace -namespace IW4::vehicle +namespace vehicle { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW4::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { // Only dump raw when no gdt available if (context.m_gdt) @@ -122,4 +121,4 @@ namespace IW4::vehicle stream.write(stringValue.c_str(), stringValue.size()); } } -} // namespace IW4::vehicle +} // namespace vehicle diff --git a/src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.h b/src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.h index c4c230e2..5afae348 100644 --- a/src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Vehicle/VehicleDumperIW4.h @@ -4,12 +4,12 @@ #include "Game/IW4/IW4.h" #include "InfoString/InfoString.h" -namespace IW4::vehicle +namespace vehicle { - class Dumper final : public AbstractAssetDumper + class DumperIW4 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4::vehicle +} // namespace vehicle diff --git a/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.cpp b/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.cpp index 7fce3396..1ebabfe7 100644 --- a/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.cpp +++ b/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.cpp @@ -14,7 +14,6 @@ #include using namespace IW4; -using namespace ::weapon; namespace { @@ -404,14 +403,14 @@ namespace } } // namespace -namespace IW4::weapon +namespace weapon { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW4::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW4::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { // Only dump raw when no gdt available if (context.m_gdt) @@ -436,4 +435,4 @@ namespace IW4::weapon DumpAccuracyGraphs(context, asset); } -} // namespace IW4::weapon +} // namespace weapon diff --git a/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.h b/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.h index 0beff65e..d6935e77 100644 --- a/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.h +++ b/src/ObjWriting/Game/IW4/Weapon/WeaponDumperIW4.h @@ -4,12 +4,12 @@ #include "Game/IW4/IW4.h" #include "InfoString/InfoString.h" -namespace IW4::weapon +namespace weapon { - class Dumper final : public AbstractAssetDumper + class DumperIW4 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW4::weapon +} // namespace weapon diff --git a/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.cpp b/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.cpp index cbb596c1..e25b8227 100644 --- a/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.cpp @@ -12,7 +12,6 @@ #include using namespace IW5; -using namespace ::image; namespace { @@ -38,7 +37,7 @@ namespace std::unique_ptr LoadImageFromIwi(const GfxImage& image, ISearchPath& searchPath) { - const auto imageFileName = std::format("images/{}.iwi", image.name); + const auto imageFileName = image::GetFileNameForAsset(image.name, ".iwi"); const auto filePathImage = searchPath.Open(imageFileName); if (!filePathImage.IsOpen()) { @@ -58,9 +57,9 @@ namespace } } // namespace -namespace IW5::image +namespace image { - Dumper::Dumper() + DumperIW5::DumperIW5() { switch (ObjWriting::Configuration.ImageOutputFormat) { @@ -77,12 +76,12 @@ namespace IW5::image } } - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW5::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* image = asset->Asset(); const auto texture = LoadImageData(context.m_obj_search_path, *image); @@ -97,4 +96,4 @@ namespace IW5::image auto& stream = *assetFile; m_writer->DumpImage(stream, texture.get()); } -} // namespace IW5::image +} // namespace image diff --git a/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.h b/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.h index ff6edf39..414465aa 100644 --- a/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Image/ImageDumperIW5.h @@ -6,18 +6,18 @@ #include -namespace IW5::image +namespace image { - class Dumper final : public AbstractAssetDumper + class DumperIW5 final : public AbstractAssetDumper { public: - Dumper(); + DumperIW5(); protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; private: std::unique_ptr m_writer; }; -} // namespace IW5::image +} // namespace image diff --git a/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.cpp b/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.cpp index ced74ca0..f79ea849 100644 --- a/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.cpp @@ -10,7 +10,6 @@ using namespace nlohmann; using namespace IW5; -using namespace ::leaderboard; namespace { @@ -93,14 +92,14 @@ namespace }; } // namespace -namespace IW5::leaderboard +namespace leaderboard { - bool JsonDumper::ShouldDump(XAssetInfo* asset) + bool JsonDumperIW5::ShouldDump(XAssetInfo* asset) { return true; } - void JsonDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void JsonDumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAsset(asset->m_name)); @@ -110,4 +109,4 @@ namespace IW5::leaderboard Dumper dumper(*assetFile); dumper.Dump(*asset->Asset()); } -} // namespace IW5::leaderboard +} // namespace leaderboard diff --git a/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.h b/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.h index 88b32415..3e6ff7f8 100644 --- a/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Leaderboard/LeaderboardJsonDumperIW5.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW5/IW5.h" -namespace IW5::leaderboard +namespace leaderboard { - class JsonDumper final : public AbstractAssetDumper + class JsonDumperIW5 final : public AbstractAssetDumper { protected: - [[nodiscard]] bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + [[nodiscard]] bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW5::leaderboard +} // namespace leaderboard diff --git a/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.cpp b/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.cpp index f29817a2..c8b7b0d0 100644 --- a/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.cpp @@ -8,9 +8,9 @@ using namespace IW5; -namespace IW5::localize +namespace localize { - void Dumper::DumpPool(AssetDumpingContext& context, AssetPool* pool) + void DumperIW5::DumpPool(AssetDumpingContext& context, AssetPool* pool) { if (pool->m_asset_lookup.empty()) return; @@ -41,4 +41,4 @@ namespace IW5::localize std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name); } } -} // namespace IW5::localize +} // namespace localize diff --git a/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.h b/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.h index 91cfdee3..26373073 100644 --- a/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Localize/LocalizeDumperIW5.h @@ -3,11 +3,11 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW5/IW5.h" -namespace IW5::localize +namespace localize { - class Dumper final : public IAssetDumper + class DumperIW5 final : public IAssetDumper { public: - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; + void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; }; -} // namespace IW5::localize +} // namespace localize diff --git a/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.cpp b/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.cpp index 5c2cc0c4..3facfa1c 100644 --- a/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.cpp @@ -5,14 +5,14 @@ using namespace IW5; -namespace IW5::addon_map_ents +namespace addon_map_ents { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW5::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* addonMapEnts = asset->Asset(); const auto assetFile = context.OpenAssetFile(asset->m_name); @@ -23,4 +23,4 @@ namespace IW5::addon_map_ents auto& stream = *assetFile; stream.write(addonMapEnts->entityString, std::max(addonMapEnts->numEntityChars - 1, 0)); } -} // namespace IW5::addon_map_ents +} // namespace addon_map_ents diff --git a/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.h b/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.h index 928fc8e1..6c251086 100644 --- a/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Maps/AddonMapEntsDumperIW5.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW5/IW5.h" -namespace IW5::addon_map_ents +namespace addon_map_ents { - class Dumper final : public AbstractAssetDumper + class DumperIW5 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW5::addon_map_ents +} // namespace addon_map_ents diff --git a/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.cpp b/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.cpp index 713006b4..2abe44a0 100644 --- a/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.cpp @@ -49,14 +49,14 @@ namespace } } // namespace -namespace IW5::menu +namespace menu { - bool MenuDumper::ShouldDump(XAssetInfo* asset) + bool MenuDumperIW5::ShouldDump(XAssetInfo* asset) { return true; } - void MenuDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void MenuDumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* menu = asset->Asset(); const auto menuFilePath = GetPathForMenu(asset); @@ -74,10 +74,10 @@ namespace IW5::menu if (!assetFile) return; - auto menuWriter = CreateMenuWriter(*assetFile); + auto menuWriter = CreateMenuWriterIW5(*assetFile); menuWriter->Start(); menuWriter->WriteMenu(*menu); menuWriter->End(); } -} // namespace IW5::menu +} // namespace menu diff --git a/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.h b/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.h index e5bd12ad..03577fcb 100644 --- a/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Menu/MenuDumperIW5.h @@ -4,12 +4,12 @@ #include "Game/IW5/IW5.h" #include "Game/IW5/Menu/MenuDumperIW5.h" -namespace IW5::menu +namespace menu { - class MenuDumper final : public AbstractAssetDumper + class MenuDumperIW5 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW5::menu +} // namespace menu diff --git a/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.cpp b/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.cpp index 8806de3b..9a1d674c 100644 --- a/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.cpp @@ -45,7 +45,7 @@ namespace return result; } - void DumpFunctions(IW5::menu::IWriterIW5& menuDumper, const MenuList* menuList) + void DumpFunctions(menu::IWriterIW5& menuDumper, const MenuList* menuList) { const auto allSupportingData = GetAllUniqueExpressionSupportingData(menuList); auto functionIndex = 0u; @@ -70,7 +70,7 @@ namespace } } - void DumpMenus(IW5::menu::IWriterIW5& menuDumper, const MenuList* menuList) + void DumpMenus(menu::IWriterIW5& menuDumper, const MenuList* menuList) { const fs::path p(menuList->name); @@ -104,14 +104,14 @@ namespace } } // namespace -namespace IW5::menu +namespace menu { - bool MenuListDumper::ShouldDump(XAssetInfo* asset) + bool MenuListDumperIW5::ShouldDump(XAssetInfo* asset) { return true; } - void MenuListDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void MenuListDumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* menuList = asset->Asset(); const auto assetFile = context.OpenAssetFile(asset->m_name); @@ -119,7 +119,7 @@ namespace IW5::menu if (!assetFile) return; - auto menuWriter = CreateMenuWriter(*assetFile); + auto menuWriter = CreateMenuWriterIW5(*assetFile); menuWriter->Start(); @@ -130,4 +130,4 @@ namespace IW5::menu menuWriter->End(); } -} // namespace IW5::menu +} // namespace menu diff --git a/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.h b/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.h index 29daedb6..d4da415f 100644 --- a/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Menu/MenuListDumperIW5.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW5/IW5.h" -namespace IW5::menu +namespace menu { - class MenuListDumper final : public AbstractAssetDumper + class MenuListDumperIW5 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW5::menu +} // namespace menu diff --git a/src/ObjWriting/Game/IW5/Menu/MenuWriterIW5.cpp b/src/ObjWriting/Game/IW5/Menu/MenuWriterIW5.cpp index 1ef3c4cb..72a9307c 100644 --- a/src/ObjWriting/Game/IW5/Menu/MenuWriterIW5.cpp +++ b/src/ObjWriting/Game/IW5/Menu/MenuWriterIW5.cpp @@ -57,7 +57,7 @@ namespace namespace { - class MenuWriter final : public ::menu::AbstractBaseWriter, public IW5::menu::IWriterIW5 + class MenuWriter final : public menu::AbstractBaseWriter, public menu::IWriterIW5 { public: explicit MenuWriter(std::ostream& stream) @@ -948,10 +948,10 @@ namespace }; } // namespace -namespace IW5::menu +namespace menu { - std::unique_ptr CreateMenuWriter(std::ostream& stream) + std::unique_ptr CreateMenuWriterIW5(std::ostream& stream) { return std::make_unique(stream); } -} // namespace IW5::menu +} // namespace menu diff --git a/src/ObjWriting/Game/IW5/Menu/MenuWriterIW5.h b/src/ObjWriting/Game/IW5/Menu/MenuWriterIW5.h index eb9fe690..dbf6428a 100644 --- a/src/ObjWriting/Game/IW5/Menu/MenuWriterIW5.h +++ b/src/ObjWriting/Game/IW5/Menu/MenuWriterIW5.h @@ -6,14 +6,14 @@ #include #include -namespace IW5::menu +namespace menu { - class IWriterIW5 : public ::menu::IWriter + class IWriterIW5 : public IWriter { public: - virtual void WriteFunctionDef(const std::string& functionName, const Statement_s* statement) = 0; - virtual void WriteMenu(const menuDef_t& menu) = 0; + virtual void WriteFunctionDef(const std::string& functionName, const IW5::Statement_s* statement) = 0; + virtual void WriteMenu(const IW5::menuDef_t& menu) = 0; }; - std::unique_ptr CreateMenuWriter(std::ostream& stream); -} // namespace IW5::menu + std::unique_ptr CreateMenuWriterIW5(std::ostream& stream); +} // namespace menu diff --git a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp index 536f7935..4cbd3f31 100644 --- a/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp +++ b/src/ObjWriting/Game/IW5/ObjWriterIW5.cpp @@ -33,16 +33,16 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperPhysCollmap, m_phys_collmap, ASSET_TYPE_PHYSCOLLMAP) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) // DUMP_ASSET_POOL(AssetDumperXModelSurfs, m_xmodel_surfs, ASSET_TYPE_XMODEL_SURFS) - DUMP_ASSET_POOL(xmodel::Dumper, m_xmodel, ASSET_TYPE_XMODEL) - DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) + DUMP_ASSET_POOL(xmodel::DumperIW5, m_xmodel, ASSET_TYPE_XMODEL) + DUMP_ASSET_POOL(material::JsonDumperIW5, m_material, ASSET_TYPE_MATERIAL) // DUMP_ASSET_POOL(AssetDumperMaterialPixelShader, m_material_pixel_shader, ASSET_TYPE_PIXELSHADER) // DUMP_ASSET_POOL(AssetDumperMaterialVertexShader, m_material_vertex_shader, ASSET_TYPE_VERTEXSHADER) // DUMP_ASSET_POOL(AssetDumperMaterialVertexDeclaration, m_material_vertex_decl, ASSET_TYPE_VERTEXDECL) // DUMP_ASSET_POOL(AssetDumperMaterialTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) - DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) + DUMP_ASSET_POOL(image::DumperIW5, m_image, ASSET_TYPE_IMAGE) // DUMP_ASSET_POOL(AssetDumpersnd_alias_list_t, m_sound, ASSET_TYPE_SOUND) // DUMP_ASSET_POOL(AssetDumperSndCurve, m_sound_curve, ASSET_TYPE_SOUND_CURVE) - DUMP_ASSET_POOL(sound::LoadedSoundDumper, m_loaded_sound, ASSET_TYPE_LOADED_SOUND) + DUMP_ASSET_POOL(sound::LoadedSoundDumperIW5, m_loaded_sound, ASSET_TYPE_LOADED_SOUND) // DUMP_ASSET_POOL(AssetDumperclipMap_t, m_clip_map, ASSET_TYPE_CLIPMAP) // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD) // DUMP_ASSET_POOL(AssetDumperGlassWorld, m_glass_world, ASSET_TYPE_GLASSWORLD) @@ -53,22 +53,22 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD) // DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF) // DUMP_ASSET_POOL(AssetDumperFont_s, m_font, ASSET_TYPE_FONT) - DUMP_ASSET_POOL(menu::MenuListDumper, m_menu_list, ASSET_TYPE_MENULIST) - DUMP_ASSET_POOL(menu::MenuDumper, m_menu_def, ASSET_TYPE_MENU) - DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) - DUMP_ASSET_POOL(attachment::JsonDumper, m_attachment, ASSET_TYPE_ATTACHMENT) - DUMP_ASSET_POOL(weapon::Dumper, m_weapon, ASSET_TYPE_WEAPON) + DUMP_ASSET_POOL(menu::MenuListDumperIW5, m_menu_list, ASSET_TYPE_MENULIST) + DUMP_ASSET_POOL(menu::MenuDumperIW5, m_menu_def, ASSET_TYPE_MENU) + DUMP_ASSET_POOL(localize::DumperIW5, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) + DUMP_ASSET_POOL(attachment::JsonDumperIW5, m_attachment, ASSET_TYPE_ATTACHMENT) + DUMP_ASSET_POOL(weapon::DumperIW5, m_weapon, ASSET_TYPE_WEAPON) // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) // DUMP_ASSET_POOL(AssetDumperSurfaceFxTable, m_surface_fx_table, ASSET_TYPE_SURFACE_FX) - DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE) - DUMP_ASSET_POOL(script::Dumper, m_script_file, ASSET_TYPE_SCRIPTFILE) - DUMP_ASSET_POOL(string_table::Dumper, m_string_table, ASSET_TYPE_STRINGTABLE) - DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD) + DUMP_ASSET_POOL(raw_file::DumperIW5, m_raw_file, ASSET_TYPE_RAWFILE) + DUMP_ASSET_POOL(script::DumperIW5, m_script_file, ASSET_TYPE_SCRIPTFILE) + DUMP_ASSET_POOL(string_table::DumperIW5, m_string_table, ASSET_TYPE_STRINGTABLE) + DUMP_ASSET_POOL(leaderboard::JsonDumperIW5, m_leaderboard, ASSET_TYPE_LEADERBOARD) // DUMP_ASSET_POOL(AssetDumperStructuredDataDefSet, m_structed_data_def_set, ASSET_TYPE_STRUCTURED_DATA_DEF) // DUMP_ASSET_POOL(AssetDumperTracerDef, m_tracer, ASSET_TYPE_TRACER) // DUMP_ASSET_POOL(AssetDumperVehicleDef, m_vehicle, ASSET_TYPE_VEHICLE) - DUMP_ASSET_POOL(addon_map_ents::Dumper, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS) + DUMP_ASSET_POOL(addon_map_ents::DumperIW5, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS) return true; diff --git a/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.cpp b/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.cpp index ba444e30..71ca717b 100644 --- a/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.cpp @@ -6,14 +6,14 @@ using namespace IW5; -namespace IW5::raw_file +namespace raw_file { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW5::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* rawFile = asset->Asset(); const auto assetFile = context.OpenAssetFile(asset->m_name); @@ -62,4 +62,4 @@ namespace IW5::raw_file inflateEnd(&zs); } -} // namespace IW5::raw_file +} // namespace raw_file diff --git a/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.h b/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.h index b3fff52f..ed2ceb4f 100644 --- a/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.h +++ b/src/ObjWriting/Game/IW5/RawFile/RawFileDumperIW5.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW5/IW5.h" -namespace IW5::raw_file +namespace raw_file { - class Dumper final : public AbstractAssetDumper + class DumperIW5 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW5::raw_file +} // namespace raw_file diff --git a/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.cpp b/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.cpp index c81ba1d4..d334cb1c 100644 --- a/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.cpp @@ -2,15 +2,15 @@ using namespace IW5; -namespace IW5::script +namespace script { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW5::ShouldDump(XAssetInfo* asset) { return true; } // See https://github.com/xensik/gsc-tool#file-format for an in-depth explanation about the .gscbin format - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { auto* scriptFile = asset->Asset(); const auto assetFile = context.OpenAssetFile(asset->m_name + ".gscbin"); @@ -30,4 +30,4 @@ namespace IW5::script stream.write(scriptFile->buffer, scriptFile->compressedLen); stream.write(reinterpret_cast(scriptFile->bytecode), scriptFile->bytecodeLen); } -} // namespace IW5::script +} // namespace script diff --git a/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.h b/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.h index 7a3dce2b..e1220f5f 100644 --- a/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Script/ScriptDumperIW5.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW5/IW5.h" -namespace IW5::script +namespace script { - class Dumper final : public AbstractAssetDumper + class DumperIW5 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW5::script +} // namespace script diff --git a/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.cpp b/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.cpp index 8feae9b7..8deec609 100644 --- a/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.cpp @@ -22,14 +22,14 @@ namespace } } // namespace -namespace IW5::sound +namespace sound { - bool LoadedSoundDumper::ShouldDump(XAssetInfo* asset) + bool LoadedSoundDumperIW5::ShouldDump(XAssetInfo* asset) { return true; } - void LoadedSoundDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void LoadedSoundDumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* loadedSound = asset->Asset(); const auto assetFile = context.OpenAssetFile(std::format("sound/{}", asset->m_name)); @@ -49,4 +49,4 @@ namespace IW5::sound break; } } -} // namespace IW5::sound +} // namespace sound diff --git a/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.h b/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.h index 9758b545..8079f27d 100644 --- a/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Sound/LoadedSoundDumperIW5.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW5/IW5.h" -namespace IW5::sound +namespace sound { - class LoadedSoundDumper final : public AbstractAssetDumper + class LoadedSoundDumperIW5 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW5::sound +} // namespace sound diff --git a/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.cpp b/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.cpp index 023013c1..2bd7fa00 100644 --- a/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.cpp @@ -4,14 +4,14 @@ using namespace IW5; -namespace IW5::string_table +namespace string_table { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW5::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* stringTable = asset->Asset(); const auto assetFile = context.OpenAssetFile(asset->m_name); @@ -39,4 +39,4 @@ namespace IW5::string_table csv.NextRow(); } } -} // namespace IW5::string_table +} // namespace string_table diff --git a/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.h b/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.h index fe6d5e4c..e826dfd0 100644 --- a/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.h +++ b/src/ObjWriting/Game/IW5/StringTable/StringTableDumperIW5.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW5/IW5.h" -namespace IW5::string_table +namespace string_table { - class Dumper final : public AbstractAssetDumper + class DumperIW5 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW5::string_table +} // namespace string_table diff --git a/src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.cpp b/src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.cpp index 763e96fe..c44f99a2 100644 --- a/src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.cpp @@ -9,7 +9,6 @@ using namespace nlohmann; using namespace IW5; -using namespace ::attachment; namespace { @@ -394,14 +393,14 @@ namespace }; } // namespace -namespace IW5::attachment +namespace attachment { - bool JsonDumper::ShouldDump(XAssetInfo* asset) + bool JsonDumperIW5::ShouldDump(XAssetInfo* asset) { return true; } - void JsonDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void JsonDumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAssetName(asset->m_name)); @@ -411,4 +410,4 @@ namespace IW5::attachment const JsonDumperImpl dumper(context, *assetFile); dumper.Dump(asset->Asset()); } -} // namespace IW5::attachment +} // namespace attachment diff --git a/src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.h b/src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.h index 26547be9..81088a63 100644 --- a/src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Weapon/AttachmentJsonDumperIW5.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/IW5/IW5.h" -namespace IW5::attachment +namespace attachment { - class JsonDumper final : public AbstractAssetDumper + class JsonDumperIW5 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW5::attachment +} // namespace attachment diff --git a/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.cpp b/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.cpp index adc4b899..67ab7628 100644 --- a/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.cpp +++ b/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.cpp @@ -15,7 +15,6 @@ #include using namespace IW5; -using namespace ::weapon; namespace { @@ -732,14 +731,14 @@ namespace } } // namespace -namespace IW5::weapon +namespace weapon { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperIW5::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperIW5::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { // TODO: only dump infostring fields when non-default @@ -766,4 +765,4 @@ namespace IW5::weapon DumpAccuracyGraphs(context, asset); } -} // namespace IW5::weapon +} // namespace weapon diff --git a/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.h b/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.h index 4a33e035..3e80c669 100644 --- a/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.h +++ b/src/ObjWriting/Game/IW5/Weapon/WeaponDumperIW5.h @@ -4,12 +4,12 @@ #include "Game/IW5/IW5.h" #include "InfoString/InfoString.h" -namespace IW5::weapon +namespace weapon { - class Dumper final : public AbstractAssetDumper + class DumperIW5 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace IW5::weapon +} // namespace weapon diff --git a/src/ObjWriting/Game/T5/Image/ImageDumperT5.cpp b/src/ObjWriting/Game/T5/Image/ImageDumperT5.cpp index a0ba1d0a..d8992797 100644 --- a/src/ObjWriting/Game/T5/Image/ImageDumperT5.cpp +++ b/src/ObjWriting/Game/T5/Image/ImageDumperT5.cpp @@ -12,7 +12,6 @@ #include using namespace T5; -using namespace ::image; namespace { @@ -37,7 +36,7 @@ namespace std::unique_ptr LoadImageFromIwi(const GfxImage& image, ISearchPath& searchPath) { - const auto imageFileName = std::format("images/{}.iwi", image.name); + const auto imageFileName = image::GetFileNameForAsset(image.name, ".iwi"); const auto filePathImage = searchPath.Open(imageFileName); if (!filePathImage.IsOpen()) { @@ -57,9 +56,9 @@ namespace } } // namespace -namespace T5::image +namespace image { - Dumper::Dumper() + DumperT5::DumperT5() { switch (ObjWriting::Configuration.ImageOutputFormat) { @@ -76,12 +75,12 @@ namespace T5::image } } - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperT5::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperT5::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* image = asset->Asset(); const auto texture = LoadImageData(context.m_obj_search_path, *image); @@ -96,4 +95,4 @@ namespace T5::image auto& stream = *assetFile; m_writer->DumpImage(stream, texture.get()); } -} // namespace T5::image +} // namespace image diff --git a/src/ObjWriting/Game/T5/Image/ImageDumperT5.h b/src/ObjWriting/Game/T5/Image/ImageDumperT5.h index 82581dde..0be6b9bb 100644 --- a/src/ObjWriting/Game/T5/Image/ImageDumperT5.h +++ b/src/ObjWriting/Game/T5/Image/ImageDumperT5.h @@ -6,18 +6,18 @@ #include -namespace T5::image +namespace image { - class Dumper final : public AbstractAssetDumper + class DumperT5 final : public AbstractAssetDumper { public: - Dumper(); + DumperT5(); protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; private: std::unique_ptr m_writer; }; -} // namespace T5::image +} // namespace image diff --git a/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.cpp b/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.cpp index 5da3d791..60f3ca58 100644 --- a/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.cpp +++ b/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.cpp @@ -8,9 +8,9 @@ using namespace T5; -namespace T5::localize +namespace localize { - void Dumper::DumpPool(AssetDumpingContext& context, AssetPool* pool) + void DumperT5::DumpPool(AssetDumpingContext& context, AssetPool* pool) { if (pool->m_asset_lookup.empty()) return; @@ -41,4 +41,4 @@ namespace T5::localize std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name); } } -} // namespace T5::localize +} // namespace localize diff --git a/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.h b/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.h index e317d37d..321a9aef 100644 --- a/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.h +++ b/src/ObjWriting/Game/T5/Localize/LocalizeDumperT5.h @@ -3,11 +3,11 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T5/T5.h" -namespace T5::localize +namespace localize { - class Dumper final : public IAssetDumper + class DumperT5 final : public IAssetDumper { public: - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; + void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; }; -} // namespace T5::localize +} // namespace localize diff --git a/src/ObjWriting/Game/T5/ObjWriterT5.cpp b/src/ObjWriting/Game/T5/ObjWriterT5.cpp index 2c5a3a2e..208f14ba 100644 --- a/src/ObjWriting/Game/T5/ObjWriterT5.cpp +++ b/src/ObjWriting/Game/T5/ObjWriterT5.cpp @@ -26,10 +26,10 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperPhysConstraints, m_phys_constraints, ASSET_TYPE_PHYSCONSTRAINTS) // DUMP_ASSET_POOL(AssetDumperDestructibleDef, m_destructible_def, ASSET_TYPE_DESTRUCTIBLEDEF) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) - DUMP_ASSET_POOL(xmodel::Dumper, m_xmodel, ASSET_TYPE_XMODEL) - DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) + DUMP_ASSET_POOL(xmodel::DumperT5, m_xmodel, ASSET_TYPE_XMODEL) + DUMP_ASSET_POOL(material::JsonDumperT5, m_material, ASSET_TYPE_MATERIAL) // DUMP_ASSET_POOL(AssetDumperTechniqueSet, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) - DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) + DUMP_ASSET_POOL(image::DumperT5, m_image, ASSET_TYPE_IMAGE) // DUMP_ASSET_POOL(AssetDumperSndBank, m_sound_bank, ASSET_TYPE_SOUND) // DUMP_ASSET_POOL(AssetDumperSndPatch, m_sound_patch, ASSET_TYPE_SOUND_PATCH) // DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_PVS) @@ -42,13 +42,13 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const // DUMP_ASSET_POOL(AssetDumperFont, m_font, ASSET_TYPE_FONT) // DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST) // DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU) - DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) + DUMP_ASSET_POOL(localize::DumperT5, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) // DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon, ASSET_TYPE_WEAPON) // DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) - DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE) - DUMP_ASSET_POOL(string_table::Dumper, m_string_table, ASSET_TYPE_STRINGTABLE) + DUMP_ASSET_POOL(raw_file::DumperT5, m_raw_file, ASSET_TYPE_RAWFILE) + DUMP_ASSET_POOL(string_table::DumperT5, m_string_table, ASSET_TYPE_STRINGTABLE) // DUMP_ASSET_POOL(AssetDumperPackIndex, m_pack_index, ASSET_TYPE_PACK_INDEX) // DUMP_ASSET_POOL(AssetDumperXGlobals, m_xglobals, ASSET_TYPE_XGLOBALS) // DUMP_ASSET_POOL(AssetDumperDDLRoot, m_ddl, ASSET_TYPE_DDL) diff --git a/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.cpp b/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.cpp index 5c57964a..2043098c 100644 --- a/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.cpp +++ b/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.cpp @@ -93,14 +93,14 @@ namespace } } // namespace -namespace T5::raw_file +namespace raw_file { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperT5::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperT5::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* rawFile = asset->Asset(); const auto assetFile = context.OpenAssetFile(asset->m_name); @@ -118,4 +118,4 @@ namespace T5::raw_file else stream.write(rawFile->buffer, rawFile->len); } -} // namespace T5::raw_file +} // namespace raw_file diff --git a/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.h b/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.h index 2c6f6ba2..056266ae 100644 --- a/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.h +++ b/src/ObjWriting/Game/T5/RawFile/RawFileDumperT5.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T5/T5.h" -namespace T5::raw_file +namespace raw_file { - class Dumper final : public AbstractAssetDumper + class DumperT5 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T5::raw_file +} // namespace raw_file diff --git a/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.cpp b/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.cpp index e77ade0b..0acc3587 100644 --- a/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.cpp +++ b/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.cpp @@ -4,14 +4,14 @@ using namespace T5; -namespace T5::string_table +namespace string_table { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperT5::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperT5::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* stringTable = asset->Asset(); const auto assetFile = context.OpenAssetFile(asset->m_name); @@ -39,4 +39,4 @@ namespace T5::string_table csv.NextRow(); } } -} // namespace T5::string_table +} // namespace string_table diff --git a/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.h b/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.h index c9621b4d..12ee953b 100644 --- a/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.h +++ b/src/ObjWriting/Game/T5/StringTable/StringTableDumperT5.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T5/T5.h" -namespace T5::string_table +namespace string_table { - class Dumper final : public AbstractAssetDumper + class DumperT5 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T5::string_table +} // namespace string_table diff --git a/src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.cpp b/src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.cpp index c8974ff1..95c6f1cc 100644 --- a/src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.cpp +++ b/src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.cpp @@ -131,14 +131,14 @@ namespace }; } // namespace -namespace T6::font_icon +namespace font_icon { - bool CsvDumper::ShouldDump(XAssetInfo* asset) + bool CsvDumperT6::ShouldDump(XAssetInfo* asset) { return true; } - void CsvDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void CsvDumperT6::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto assetFile = context.OpenAssetFile(asset->m_name); @@ -148,4 +148,4 @@ namespace T6::font_icon Dumper dumper(*assetFile); dumper.Dump(*asset->Asset()); } -} // namespace T6::font_icon +} // namespace font_icon diff --git a/src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.h b/src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.h index 7483dddf..aeaa8877 100644 --- a/src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.h +++ b/src/ObjWriting/Game/T6/FontIcon/FontIconCsvDumperT6.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6::font_icon +namespace font_icon { - class CsvDumper final : public AbstractAssetDumper + class CsvDumperT6 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6::font_icon +} // namespace font_icon diff --git a/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.cpp b/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.cpp index a3ec3322..9f41412b 100644 --- a/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.cpp +++ b/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.cpp @@ -7,14 +7,14 @@ using namespace T6; // #define DUMP_FONT_ICON_AS_CSV 1 -namespace T6::font_icon +namespace font_icon { - std::unique_ptr> CreateDumper() + std::unique_ptr> CreateDumperT6() { #ifdef DUMP_FONT_ICON_AS_CSV - return std::make_unique(); + return std::make_unique(); #else - return std::make_unique(); + return std::make_unique(); #endif } -} // namespace T6::font_icon +} // namespace font_icon diff --git a/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.h b/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.h index a9e06e13..55d048f9 100644 --- a/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.h +++ b/src/ObjWriting/Game/T6/FontIcon/FontIconDumperT6.h @@ -3,7 +3,9 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6::font_icon +#include + +namespace font_icon { - std::unique_ptr> CreateDumper(); -} // namespace T6::font_icon + std::unique_ptr> CreateDumperT6(); +} // namespace font_icon diff --git a/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.cpp b/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.cpp index cd3078f5..e82b3b36 100644 --- a/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.cpp +++ b/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.cpp @@ -1,7 +1,7 @@ #include "FontIconJsonDumperT6.h" +#include "FontIcon/FontIconCommon.h" #include "Game/T6/CommonT6.h" -#include "Game/T6/FontIcon/FontIconCommonT6.h" #include "Game/T6/FontIcon/JsonFontIconT6.h" #include "KnownFontIconAliasesT6.h" @@ -76,20 +76,20 @@ namespace } } // namespace -namespace T6::font_icon +namespace font_icon { - bool JsonDumper::ShouldDump(XAssetInfo* asset) + bool JsonDumperT6::ShouldDump(XAssetInfo* asset) { return true; } - void JsonDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void JsonDumperT6::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { - const auto assetFile = context.OpenAssetFile(font_icon::GetJsonFileNameForAssetName(asset->m_name)); + const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAssetName(asset->m_name)); if (!assetFile) return; DumpFontIcon(*assetFile, *asset->Asset()); } -} // namespace T6::font_icon +} // namespace font_icon diff --git a/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.h b/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.h index ade8bf33..aa1c0017 100644 --- a/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.h +++ b/src/ObjWriting/Game/T6/FontIcon/FontIconJsonDumperT6.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6::font_icon +namespace font_icon { - class JsonDumper final : public AbstractAssetDumper + class JsonDumperT6 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6::font_icon +} // namespace font_icon diff --git a/src/ObjWriting/Game/T6/Image/ImageDumperT6.cpp b/src/ObjWriting/Game/T6/Image/ImageDumperT6.cpp index d492a848..bb3255b2 100644 --- a/src/ObjWriting/Game/T6/Image/ImageDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Image/ImageDumperT6.cpp @@ -13,7 +13,6 @@ #include using namespace T6; -using namespace ::image; namespace { @@ -55,7 +54,7 @@ namespace } } - const auto imageFileName = std::format("images/{}.iwi", image.name); + const auto imageFileName = image::GetFileNameForAsset(image.name, ".iwi"); const auto filePathImage = searchPath.Open(imageFileName); if (!filePathImage.IsOpen()) { @@ -75,9 +74,9 @@ namespace } } // namespace -namespace T6::image +namespace image { - Dumper::Dumper() + DumperT6::DumperT6() { switch (ObjWriting::Configuration.ImageOutputFormat) { @@ -94,12 +93,12 @@ namespace T6::image } } - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperT6::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperT6::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* image = asset->Asset(); const auto texture = LoadImageData(context.m_obj_search_path, *image); @@ -114,4 +113,4 @@ namespace T6::image auto& stream = *assetFile; m_writer->DumpImage(stream, texture.get()); } -} // namespace T6::image +} // namespace image diff --git a/src/ObjWriting/Game/T6/Image/ImageDumperT6.h b/src/ObjWriting/Game/T6/Image/ImageDumperT6.h index 4b0c2599..5fac0233 100644 --- a/src/ObjWriting/Game/T6/Image/ImageDumperT6.h +++ b/src/ObjWriting/Game/T6/Image/ImageDumperT6.h @@ -6,18 +6,18 @@ #include -namespace T6::image +namespace image { - class Dumper final : public AbstractAssetDumper + class DumperT6 final : public AbstractAssetDumper { public: - Dumper(); + DumperT6(); protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; private: std::unique_ptr m_writer; }; -} // namespace T6::image +} // namespace image diff --git a/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.cpp b/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.cpp index 9947924d..4a90d7b2 100644 --- a/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.cpp @@ -10,7 +10,6 @@ using namespace nlohmann; using namespace T6; -using namespace ::leaderboard; namespace { @@ -97,14 +96,14 @@ namespace }; } // namespace -namespace T6::leaderboard +namespace leaderboard { - bool JsonDumper::ShouldDump(XAssetInfo* asset) + bool JsonDumperT6::ShouldDump(XAssetInfo* asset) { return true; } - void JsonDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void JsonDumperT6::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAsset(asset->m_name)); @@ -114,4 +113,4 @@ namespace T6::leaderboard Dumper dumper(*assetFile); dumper.Dump(*asset->Asset()); } -} // namespace T6::leaderboard +} // namespace leaderboard diff --git a/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.h b/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.h index 85d18061..ebbe4c9f 100644 --- a/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.h +++ b/src/ObjWriting/Game/T6/Leaderboard/LeaderboardJsonDumperT6.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6::leaderboard +namespace leaderboard { - class JsonDumper final : public AbstractAssetDumper + class JsonDumperT6 final : public AbstractAssetDumper { protected: - [[nodiscard]] bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + [[nodiscard]] bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6::leaderboard +} // namespace leaderboard diff --git a/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.cpp b/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.cpp index b989f9e2..550b92d6 100644 --- a/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.cpp @@ -8,9 +8,9 @@ using namespace T6; -namespace T6::localize +namespace localize { - void Dumper::DumpPool(AssetDumpingContext& context, AssetPool* pool) + void DumperT6::DumpPool(AssetDumpingContext& context, AssetPool* pool) { if (pool->m_asset_lookup.empty()) return; @@ -41,4 +41,4 @@ namespace T6::localize std::cerr << std::format("Could not create string file for dumping localized strings of zone '{}'\n", context.m_zone.m_name); } } -} // namespace T6::localize +} // namespace localize diff --git a/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.h b/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.h index f0591f38..1a39defe 100644 --- a/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.h +++ b/src/ObjWriting/Game/T6/Localize/LocalizeDumperT6.h @@ -3,11 +3,11 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6::localize +namespace localize { - class Dumper final : public IAssetDumper + class DumperT6 final : public IAssetDumper { public: - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; + void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; }; -} // namespace T6::localize +} // namespace localize diff --git a/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.cpp b/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.cpp index 7dce7a29..caf8abd5 100644 --- a/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.cpp @@ -4,14 +4,14 @@ using namespace T6; -namespace T6::map_ents +namespace map_ents { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperT6::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperT6::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* mapEnts = asset->Asset(); @@ -23,4 +23,4 @@ namespace T6::map_ents auto& stream = *mapEntsFile; stream.write(mapEnts->entityString, mapEnts->numEntityChars - 1); } -} // namespace T6::map_ents +} // namespace map_ents diff --git a/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.h b/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.h index 9fc7a6b8..9dbf36bb 100644 --- a/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.h +++ b/src/ObjWriting/Game/T6/Maps/MapEntsDumperT6.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6::map_ents +namespace map_ents { - class Dumper final : public AbstractAssetDumper + class DumperT6 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6::map_ents +} // namespace map_ents diff --git a/src/ObjWriting/Game/T6/ObjWriterT6.cpp b/src/ObjWriting/Game/T6/ObjWriterT6.cpp index 1b28dba0..06c66520 100644 --- a/src/ObjWriting/Game/T6/ObjWriterT6.cpp +++ b/src/ObjWriting/Game/T6/ObjWriterT6.cpp @@ -46,54 +46,54 @@ bool ObjWriter::DumpZone(AssetDumpingContext& context) const const auto* assetPools = dynamic_cast(context.m_zone.m_pools.get()); - DUMP_ASSET_POOL(phys_preset::InfoStringDumper, m_phys_preset, ASSET_TYPE_PHYSPRESET) - DUMP_ASSET_POOL(phys_constraints::InfoStringDumper, m_phys_constraints, ASSET_TYPE_PHYSCONSTRAINTS) + DUMP_ASSET_POOL(phys_preset::InfoStringDumperT6, m_phys_preset, ASSET_TYPE_PHYSPRESET) + DUMP_ASSET_POOL(phys_constraints::InfoStringDumperT6, m_phys_constraints, ASSET_TYPE_PHYSCONSTRAINTS) // DUMP_ASSET_POOL(AssetDumperDestructibleDef, m_destructible_def, ASSET_TYPE_DESTRUCTIBLEDEF) // DUMP_ASSET_POOL(AssetDumperXAnimParts, m_xanim_parts, ASSET_TYPE_XANIMPARTS) - DUMP_ASSET_POOL(xmodel::Dumper, m_xmodel, ASSET_TYPE_XMODEL) - DUMP_ASSET_POOL(material::JsonDumper, m_material, ASSET_TYPE_MATERIAL) - DUMP_ASSET_POOL(techset::Dumper, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) - DUMP_ASSET_POOL(image::Dumper, m_image, ASSET_TYPE_IMAGE) - DUMP_ASSET_POOL(sound::SndBankDumper, m_sound_bank, ASSET_TYPE_SOUND) + DUMP_ASSET_POOL(xmodel::DumperT6, m_xmodel, ASSET_TYPE_XMODEL) + DUMP_ASSET_POOL(material::JsonDumperT6, m_material, ASSET_TYPE_MATERIAL) + DUMP_ASSET_POOL(techset::DumperT6, m_technique_set, ASSET_TYPE_TECHNIQUE_SET) + DUMP_ASSET_POOL(image::DumperT6, m_image, ASSET_TYPE_IMAGE) + DUMP_ASSET_POOL(sound::SndBankDumperT6, m_sound_bank, ASSET_TYPE_SOUND) // DUMP_ASSET_POOL(AssetDumperSndPatch, m_sound_patch, ASSET_TYPE_SOUND_PATCH) // DUMP_ASSET_POOL(AssetDumperClipMap, m_clip_map, ASSET_TYPE_CLIPMAP_PVS) // DUMP_ASSET_POOL(AssetDumperComWorld, m_com_world, ASSET_TYPE_COMWORLD) // DUMP_ASSET_POOL(AssetDumperGameWorldSp, m_game_world_sp, ASSET_TYPE_GAMEWORLD_SP) // DUMP_ASSET_POOL(AssetDumperGameWorldMp, m_game_world_mp, ASSET_TYPE_GAMEWORLD_MP) - DUMP_ASSET_POOL(map_ents::Dumper, m_map_ents, ASSET_TYPE_MAP_ENTS) + DUMP_ASSET_POOL(map_ents::DumperT6, m_map_ents, ASSET_TYPE_MAP_ENTS) // DUMP_ASSET_POOL(AssetDumperGfxWorld, m_gfx_world, ASSET_TYPE_GFXWORLD) // DUMP_ASSET_POOL(AssetDumperGfxLightDef, m_gfx_light_def, ASSET_TYPE_LIGHT_DEF) // DUMP_ASSET_POOL(AssetDumperFont, m_font, ASSET_TYPE_FONT) - DUMP_ASSET_POOL_WITH_FACTORY(font_icon::CreateDumper(), m_font_icon, ASSET_TYPE_FONTICON) + DUMP_ASSET_POOL_WITH_FACTORY(font_icon::CreateDumperT6(), m_font_icon, ASSET_TYPE_FONTICON) // DUMP_ASSET_POOL(AssetDumperMenuList, m_menu_list, ASSET_TYPE_MENULIST) // DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def, ASSET_TYPE_MENU) - DUMP_ASSET_POOL(localize::Dumper, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) - DUMP_ASSET_POOL(weapon::Dumper, m_weapon, ASSET_TYPE_WEAPON) - DUMP_ASSET_POOL(attachment::Dumper, m_attachment, ASSET_TYPE_ATTACHMENT) - DUMP_ASSET_POOL(attachment_unique::Dumper, m_attachment_unique, ASSET_TYPE_ATTACHMENT_UNIQUE) - DUMP_ASSET_POOL(camo::JsonDumper, m_camo, ASSET_TYPE_WEAPON_CAMO) - DUMP_ASSET_POOL(sound::SndDriverGlobalsDumper, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) + DUMP_ASSET_POOL(localize::DumperT6, m_localize, ASSET_TYPE_LOCALIZE_ENTRY) + DUMP_ASSET_POOL(weapon::DumperT6, m_weapon, ASSET_TYPE_WEAPON) + DUMP_ASSET_POOL(attachment::DumperT6, m_attachment, ASSET_TYPE_ATTACHMENT) + DUMP_ASSET_POOL(attachment_unique::DumperT6, m_attachment_unique, ASSET_TYPE_ATTACHMENT_UNIQUE) + DUMP_ASSET_POOL(camo::JsonDumperT6, m_camo, ASSET_TYPE_WEAPON_CAMO) + DUMP_ASSET_POOL(sound::SndDriverGlobalsDumperT6, m_snd_driver_globals, ASSET_TYPE_SNDDRIVER_GLOBALS) // DUMP_ASSET_POOL(AssetDumperFxEffectDef, m_fx, ASSET_TYPE_FX) // DUMP_ASSET_POOL(AssetDumperFxImpactTable, m_fx_impact_table, ASSET_TYPE_IMPACT_FX) - DUMP_ASSET_POOL(raw_file::Dumper, m_raw_file, ASSET_TYPE_RAWFILE) - DUMP_ASSET_POOL(string_table::Dumper, m_string_table, ASSET_TYPE_STRINGTABLE) - DUMP_ASSET_POOL(leaderboard::JsonDumper, m_leaderboard, ASSET_TYPE_LEADERBOARD) + DUMP_ASSET_POOL(raw_file::DumperT6, m_raw_file, ASSET_TYPE_RAWFILE) + DUMP_ASSET_POOL(string_table::DumperT6, m_string_table, ASSET_TYPE_STRINGTABLE) + DUMP_ASSET_POOL(leaderboard::JsonDumperT6, m_leaderboard, ASSET_TYPE_LEADERBOARD) // DUMP_ASSET_POOL(AssetDumperXGlobals, m_xglobals, ASSET_TYPE_XGLOBALS) // DUMP_ASSET_POOL(AssetDumperDDLRoot, m_ddl, ASSET_TYPE_DDL) // DUMP_ASSET_POOL(AssetDumperGlasses, m_glasses, ASSET_TYPE_GLASSES) // DUMP_ASSET_POOL(AssetDumperEmblemSet, m_emblem_set, ASSET_TYPE_EMBLEMSET) - DUMP_ASSET_POOL(script::Dumper, m_script, ASSET_TYPE_SCRIPTPARSETREE) + DUMP_ASSET_POOL(script::DumperT6, m_script, ASSET_TYPE_SCRIPTPARSETREE) // DUMP_ASSET_POOL(AssetDumperKeyValuePairs, m_key_value_pairs, ASSET_TYPE_KEYVALUEPAIRS) - DUMP_ASSET_POOL(vehicle::Dumper, m_vehicle, ASSET_TYPE_VEHICLEDEF) + DUMP_ASSET_POOL(vehicle::DumperT6, m_vehicle, ASSET_TYPE_VEHICLEDEF) // DUMP_ASSET_POOL(AssetDumperMemoryBlock, m_memory_block, ASSET_TYPE_MEMORYBLOCK) // DUMP_ASSET_POOL(AssetDumperAddonMapEnts, m_addon_map_ents, ASSET_TYPE_ADDON_MAP_ENTS) - DUMP_ASSET_POOL(tracer::Dumper, m_tracer, ASSET_TYPE_TRACER) + DUMP_ASSET_POOL(tracer::DumperT6, m_tracer, ASSET_TYPE_TRACER) // DUMP_ASSET_POOL(AssetDumperSkinnedVertsDef, m_skinned_verts, ASSET_TYPE_SKINNEDVERTS) - DUMP_ASSET_POOL(qdb::Dumper, m_qdb, ASSET_TYPE_QDB) - DUMP_ASSET_POOL(slug::Dumper, m_slug, ASSET_TYPE_SLUG) + DUMP_ASSET_POOL(qdb::DumperT6, m_qdb, ASSET_TYPE_QDB) + DUMP_ASSET_POOL(slug::DumperT6, m_slug, ASSET_TYPE_SLUG) // DUMP_ASSET_POOL(AssetDumperFootstepTableDef, m_footstep_table, ASSET_TYPE_FOOTSTEP_TABLE) // DUMP_ASSET_POOL(AssetDumperFootstepFXTableDef, m_footstep_fx_table, ASSET_TYPE_FOOTSTEPFX_TABLE) - DUMP_ASSET_POOL(z_barrier::Dumper, m_zbarrier, ASSET_TYPE_ZBARRIER) + DUMP_ASSET_POOL(z_barrier::DumperT6, m_zbarrier, ASSET_TYPE_ZBARRIER) return true; diff --git a/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.cpp b/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.cpp index e34862e8..c0c2d7ce 100644 --- a/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.cpp +++ b/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.cpp @@ -9,7 +9,6 @@ #include using namespace T6; -using namespace ::phys_constraints; namespace { @@ -60,14 +59,14 @@ namespace } } // namespace -namespace T6::phys_constraints +namespace phys_constraints { - bool InfoStringDumper::ShouldDump(XAssetInfo* asset) + bool InfoStringDumperT6::ShouldDump(XAssetInfo* asset) { return true; } - void InfoStringDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void InfoStringDumperT6::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { // Only dump raw when no gdt available if (context.m_gdt) @@ -90,4 +89,4 @@ namespace T6::phys_constraints stream.write(stringValue.c_str(), stringValue.size()); } } -} // namespace T6::phys_constraints +} // namespace phys_constraints diff --git a/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.h b/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.h index 2af16570..4d1c5e70 100644 --- a/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.h +++ b/src/ObjWriting/Game/T6/PhysConstraints/PhysConstraintsInfoStringDumperT6.h @@ -4,12 +4,12 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" -namespace T6::phys_constraints +namespace phys_constraints { - class InfoStringDumper final : public AbstractAssetDumper + class InfoStringDumperT6 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6::phys_constraints +} // namespace phys_constraints diff --git a/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.cpp b/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.cpp index 8941af2d..c4f5dd85 100644 --- a/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.cpp +++ b/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.cpp @@ -11,7 +11,6 @@ #include using namespace T6; -using namespace ::phys_preset; namespace { @@ -81,14 +80,14 @@ namespace } } // namespace -namespace T6::phys_preset +namespace phys_preset { - bool InfoStringDumper::ShouldDump(XAssetInfo* asset) + bool InfoStringDumperT6::ShouldDump(XAssetInfo* asset) { return true; } - void InfoStringDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void InfoStringDumperT6::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { // Only dump raw when no gdt available if (context.m_gdt) @@ -111,4 +110,4 @@ namespace T6::phys_preset stream.write(stringValue.c_str(), stringValue.size()); } } -} // namespace T6::phys_preset +} // namespace phys_preset diff --git a/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.h b/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.h index 26ce2296..df52d539 100644 --- a/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.h +++ b/src/ObjWriting/Game/T6/PhysPreset/PhysPresetInfoStringDumperT6.h @@ -4,12 +4,12 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" -namespace T6::phys_preset +namespace phys_preset { - class InfoStringDumper final : public AbstractAssetDumper + class InfoStringDumperT6 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6::phys_preset +} // namespace phys_preset diff --git a/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.cpp b/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.cpp index 5d4aa41b..f990de0d 100644 --- a/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.cpp @@ -2,14 +2,14 @@ using namespace T6; -namespace T6::qdb +namespace qdb { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperT6::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperT6::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* qdb = asset->Asset(); const auto assetFile = context.OpenAssetFile(asset->m_name); @@ -20,4 +20,4 @@ namespace T6::qdb auto& stream = *assetFile; stream.write(qdb->buffer, qdb->len); } -} // namespace T6::qdb +} // namespace qdb diff --git a/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.h b/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.h index 9f270398..eb452510 100644 --- a/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.h +++ b/src/ObjWriting/Game/T6/Qdb/QdbDumperT6.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6::qdb +namespace qdb { - class Dumper final : public AbstractAssetDumper + class DumperT6 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6::qdb +} // namespace qdb diff --git a/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.cpp b/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.cpp index b456eb9c..a7f29926 100644 --- a/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.cpp +++ b/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.cpp @@ -73,14 +73,14 @@ namespace } } // namespace -namespace T6::raw_file +namespace raw_file { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperT6::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperT6::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* rawFile = asset->Asset(); const auto assetFile = context.OpenAssetFile(asset->m_name); @@ -101,4 +101,4 @@ namespace T6::raw_file stream.write(rawFile->buffer, rawFile->len); } } -} // namespace T6::raw_file +} // namespace raw_file diff --git a/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.h b/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.h index 6544e974..c2faa0f9 100644 --- a/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.h +++ b/src/ObjWriting/Game/T6/RawFile/RawFileDumperT6.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6::raw_file +namespace raw_file { - class Dumper final : public AbstractAssetDumper + class DumperT6 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6::raw_file +} // namespace raw_file diff --git a/src/ObjWriting/Game/T6/Script/ScriptDumperT6.cpp b/src/ObjWriting/Game/T6/Script/ScriptDumperT6.cpp index 15c4eb6c..2b2be090 100644 --- a/src/ObjWriting/Game/T6/Script/ScriptDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Script/ScriptDumperT6.cpp @@ -2,14 +2,14 @@ using namespace T6; -namespace T6::script +namespace script { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperT6::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperT6::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* scriptParseTree = asset->Asset(); const auto assetFile = context.OpenAssetFile(asset->m_name); @@ -20,4 +20,4 @@ namespace T6::script auto& stream = *assetFile; stream.write(scriptParseTree->buffer, scriptParseTree->len); } -} // namespace T6::script +} // namespace script diff --git a/src/ObjWriting/Game/T6/Script/ScriptDumperT6.h b/src/ObjWriting/Game/T6/Script/ScriptDumperT6.h index fb388b36..895b55b4 100644 --- a/src/ObjWriting/Game/T6/Script/ScriptDumperT6.h +++ b/src/ObjWriting/Game/T6/Script/ScriptDumperT6.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6::script +namespace script { - class Dumper final : public AbstractAssetDumper + class DumperT6 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6::script +} // namespace script diff --git a/src/ObjWriting/Game/T6/Slug/SlugDumperT6.cpp b/src/ObjWriting/Game/T6/Slug/SlugDumperT6.cpp index 63f07f7a..d02a11d0 100644 --- a/src/ObjWriting/Game/T6/Slug/SlugDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Slug/SlugDumperT6.cpp @@ -2,14 +2,14 @@ using namespace T6; -namespace T6::slug +namespace slug { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperT6::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperT6::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* slug = asset->Asset(); const auto assetFile = context.OpenAssetFile(asset->m_name); @@ -20,4 +20,4 @@ namespace T6::slug auto& stream = *assetFile; stream.write(slug->buffer, slug->len); } -} // namespace T6::slug +} // namespace slug diff --git a/src/ObjWriting/Game/T6/Slug/SlugDumperT6.h b/src/ObjWriting/Game/T6/Slug/SlugDumperT6.h index f33960e6..3dd202e5 100644 --- a/src/ObjWriting/Game/T6/Slug/SlugDumperT6.h +++ b/src/ObjWriting/Game/T6/Slug/SlugDumperT6.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6::slug +namespace slug { - class Dumper final : public AbstractAssetDumper + class DumperT6 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6::slug +} // namespace slug diff --git a/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.cpp b/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.cpp index f72517a4..55d1b792 100644 --- a/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.cpp @@ -910,9 +910,9 @@ namespace } } // namespace -namespace T6::sound +namespace sound { - void SndBankDumper::DumpPool(AssetDumpingContext& context, AssetPool* pool) + void SndBankDumperT6::DumpPool(AssetDumpingContext& context, AssetPool* pool) { LoadedSoundBankHashes soundBankHashes; soundBankHashes.Initialize(); @@ -924,4 +924,4 @@ namespace T6::sound DumpSndBank(context, soundBankHashes, *assetInfo); } } -} // namespace T6::sound +} // namespace sound diff --git a/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.h b/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.h index 77141ac3..f5d4f59d 100644 --- a/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.h +++ b/src/ObjWriting/Game/T6/Sound/SndBankDumperT6.h @@ -3,11 +3,11 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6::sound +namespace sound { - class SndBankDumper final : public IAssetDumper + class SndBankDumperT6 final : public IAssetDumper { public: - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; + void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; }; -} // namespace T6::sound +} // namespace sound diff --git a/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.cpp b/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.cpp index 1b27898e..02e7899e 100644 --- a/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.cpp @@ -382,11 +382,11 @@ namespace }; } // namespace -namespace T6::sound +namespace sound { - void SndDriverGlobalsDumper::DumpPool(AssetDumpingContext& context, AssetPool* pool) + void SndDriverGlobalsDumperT6::DumpPool(AssetDumpingContext& context, AssetPool* pool) { Internal internal(context); internal.DumpPool(pool); } -} // namespace T6::sound +} // namespace sound diff --git a/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.h b/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.h index b20c4f16..042de43c 100644 --- a/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.h +++ b/src/ObjWriting/Game/T6/Sound/SndDriverGlobalsDumperT6.h @@ -3,11 +3,11 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6::sound +namespace sound { - class SndDriverGlobalsDumper final : public IAssetDumper + class SndDriverGlobalsDumperT6 final : public IAssetDumper { public: - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; + void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; }; -} // namespace T6::sound +} // namespace sound diff --git a/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.cpp b/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.cpp index 83f0c860..4bd96479 100644 --- a/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.cpp +++ b/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.cpp @@ -4,14 +4,14 @@ using namespace T6; -namespace T6::string_table +namespace string_table { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperT6::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperT6::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* stringTable = asset->Asset(); const auto assetFile = context.OpenAssetFile(asset->m_name); @@ -39,4 +39,4 @@ namespace T6::string_table csv.NextRow(); } } -} // namespace T6::string_table +} // namespace string_table diff --git a/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.h b/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.h index 0fbbdb18..b61a4380 100644 --- a/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.h +++ b/src/ObjWriting/Game/T6/StringTable/StringTableDumperT6.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6::string_table +namespace string_table { - class Dumper final : public AbstractAssetDumper + class DumperT6 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6::string_table +} // namespace string_table diff --git a/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.cpp b/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.cpp index abbb953a..a2d7273c 100644 --- a/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.cpp @@ -75,14 +75,14 @@ namespace } } // namespace -namespace T6::techset +namespace techset { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperT6::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperT6::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto* techniqueSet = asset->Asset(); auto* shaderState = context.GetZoneAssetDumperState(); @@ -104,4 +104,4 @@ namespace T6::techset } } } -} // namespace T6::techset +} // namespace techset diff --git a/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.h b/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.h index 885be6c2..59a48f3f 100644 --- a/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.h +++ b/src/ObjWriting/Game/T6/Techset/TechsetDumperT6.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6::techset +namespace techset { - class Dumper final : public AbstractAssetDumper + class DumperT6 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6::techset +} // namespace techset diff --git a/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.cpp b/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.cpp index 6a3b1cab..854a45af 100644 --- a/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.cpp @@ -9,7 +9,6 @@ #include using namespace T6; -using namespace ::tracer; namespace { @@ -59,14 +58,14 @@ namespace } } // namespace -namespace T6::tracer +namespace tracer { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperT6::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperT6::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { // Only dump raw when no gdt available if (context.m_gdt) @@ -89,4 +88,4 @@ namespace T6::tracer stream.write(stringValue.c_str(), stringValue.size()); } } -} // namespace T6::tracer +} // namespace tracer diff --git a/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.h b/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.h index b3a54052..0bfb6d75 100644 --- a/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.h +++ b/src/ObjWriting/Game/T6/Tracer/TracerDumperT6.h @@ -4,12 +4,12 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" -namespace T6::tracer +namespace tracer { - class Dumper final : public AbstractAssetDumper + class DumperT6 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6::tracer +} // namespace tracer diff --git a/src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.cpp b/src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.cpp index 40eb02ad..1178b394 100644 --- a/src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.cpp @@ -109,14 +109,14 @@ namespace } } // namespace -namespace T6::vehicle +namespace vehicle { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperT6::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperT6::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { // Only dump raw when no gdt available if (context.m_gdt) @@ -139,4 +139,4 @@ namespace T6::vehicle stream.write(stringValue.c_str(), stringValue.size()); } } -} // namespace T6::vehicle +} // namespace vehicle diff --git a/src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.h b/src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.h index 61c53ebf..5d328e87 100644 --- a/src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.h +++ b/src/ObjWriting/Game/T6/Vehicle/VehicleDumperT6.h @@ -4,12 +4,12 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" -namespace T6::vehicle +namespace vehicle { - class Dumper final : public AbstractAssetDumper + class DumperT6 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6::vehicle +} // namespace vehicle diff --git a/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.cpp b/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.cpp index ff521c15..d7fcc4c7 100644 --- a/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.cpp @@ -10,7 +10,6 @@ #include using namespace T6; -using namespace ::attachment; namespace { @@ -66,14 +65,14 @@ namespace } } // namespace -namespace T6::attachment +namespace attachment { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperT6::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperT6::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { // Only dump raw when no gdt available if (context.m_gdt) @@ -96,4 +95,4 @@ namespace T6::attachment stream.write(stringValue.c_str(), stringValue.size()); } } -} // namespace T6::attachment +} // namespace attachment diff --git a/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.h b/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.h index 2f386ccc..0472e2a0 100644 --- a/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.h +++ b/src/ObjWriting/Game/T6/Weapon/AttachmentDumperT6.h @@ -4,12 +4,12 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" -namespace T6::attachment +namespace attachment { - class Dumper final : public AbstractAssetDumper + class DumperT6 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6::attachment +} // namespace attachment diff --git a/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.cpp b/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.cpp index 88e4c054..c10605ac 100644 --- a/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.cpp @@ -12,7 +12,6 @@ #include using namespace T6; -using namespace ::attachment_unique; namespace { @@ -130,14 +129,14 @@ namespace } } // namespace -namespace T6::attachment_unique +namespace attachment_unique { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperT6::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperT6::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { // Only dump raw when no gdt available if (context.m_gdt) @@ -160,4 +159,4 @@ namespace T6::attachment_unique stream.write(stringValue.c_str(), stringValue.size()); } } -} // namespace T6::attachment_unique +} // namespace attachment_unique diff --git a/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.h b/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.h index e84fcb74..b3e2ae1a 100644 --- a/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.h +++ b/src/ObjWriting/Game/T6/Weapon/AttachmentUniqueDumperT6.h @@ -4,12 +4,12 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" -namespace T6::attachment_unique +namespace attachment_unique { - class Dumper final : public AbstractAssetDumper + class DumperT6 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6::attachment_unique +} // namespace attachment_unique diff --git a/src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.cpp b/src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.cpp index 958470c7..4a68492e 100644 --- a/src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.cpp @@ -9,7 +9,6 @@ using namespace nlohmann; using namespace T6; -using namespace ::camo; namespace { @@ -103,14 +102,14 @@ namespace }; } // namespace -namespace T6::camo +namespace camo { - bool JsonDumper::ShouldDump(XAssetInfo* asset) + bool JsonDumperT6::ShouldDump(XAssetInfo* asset) { return true; } - void JsonDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void JsonDumperT6::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto fileName = GetJsonFileNameForAssetName(asset->m_name); const auto assetFile = context.OpenAssetFile(fileName); @@ -121,4 +120,4 @@ namespace T6::camo const JsonDumperImpl dumper(*assetFile); dumper.Dump(asset->Asset()); } -} // namespace T6::camo +} // namespace camo diff --git a/src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.h b/src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.h index e7c316e0..8bb91f12 100644 --- a/src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.h +++ b/src/ObjWriting/Game/T6/Weapon/CamoJsonDumperT6.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6::camo +namespace camo { - class JsonDumper final : public AbstractAssetDumper + class JsonDumperT6 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6::camo +} // namespace camo diff --git a/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.cpp b/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.cpp index 96ad8700..96c5bcdc 100644 --- a/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.cpp +++ b/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.cpp @@ -14,7 +14,6 @@ #include using namespace T6; -using namespace ::weapon; namespace { @@ -460,14 +459,14 @@ namespace } } // namespace -namespace T6::weapon +namespace weapon { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperT6::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperT6::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { // Only dump raw when no gdt available if (context.m_gdt) @@ -492,4 +491,4 @@ namespace T6::weapon DumpAccuracyGraphs(context, asset); } -} // namespace T6::weapon +} // namespace weapon diff --git a/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.h b/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.h index 15ac83b6..4b3b500f 100644 --- a/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.h +++ b/src/ObjWriting/Game/T6/Weapon/WeaponDumperT6.h @@ -3,12 +3,12 @@ #include "Dumping/AbstractAssetDumper.h" #include "Game/T6/T6.h" -namespace T6::weapon +namespace weapon { - class Dumper final : public AbstractAssetDumper + class DumperT6 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6::weapon +} // namespace weapon diff --git a/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.cpp b/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.cpp index 23710e54..1a7edb80 100644 --- a/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.cpp +++ b/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.cpp @@ -9,7 +9,6 @@ #include using namespace T6; -using namespace ::z_barrier; namespace { @@ -49,14 +48,14 @@ namespace } } // namespace -namespace T6::z_barrier +namespace z_barrier { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool DumperT6::ShouldDump(XAssetInfo* asset) { return true; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void DumperT6::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { // Only dump raw when no gdt available if (context.m_gdt) @@ -79,4 +78,4 @@ namespace T6::z_barrier stream.write(stringValue.c_str(), stringValue.size()); } } -} // namespace T6::z_barrier +} // namespace z_barrier diff --git a/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.h b/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.h index efde331b..9e60f414 100644 --- a/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.h +++ b/src/ObjWriting/Game/T6/ZBarrier/ZBarrierDumperT6.h @@ -4,12 +4,12 @@ #include "Game/T6/T6.h" #include "InfoString/InfoString.h" -namespace T6::z_barrier +namespace z_barrier { - class Dumper final : public AbstractAssetDumper + class DumperT6 final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace T6::z_barrier +} // namespace z_barrier diff --git a/src/ObjWriting/Material/MaterialJsonDumper.cpp.template b/src/ObjWriting/Material/MaterialJsonDumper.cpp.template index 817788f0..7eb8ad51 100644 --- a/src/ObjWriting/Material/MaterialJsonDumper.cpp.template +++ b/src/ObjWriting/Material/MaterialJsonDumper.cpp.template @@ -48,7 +48,8 @@ using namespace nlohmann; using namespace GAME; -using namespace ::material; + +#set CLASS_NAME "JsonDumper" + GAME namespace { @@ -358,9 +359,9 @@ namespace }; } // namespace -namespace GAME::material +namespace material { - void JsonDumper::DumpPool(AssetDumpingContext& context, AssetPool* pool) + void CLASS_NAME::DumpPool(AssetDumpingContext& context, AssetPool* pool) { auto* materialConstantState = context.GetZoneAssetDumperState(); materialConstantState->ExtractNamesFromZone(); @@ -368,12 +369,12 @@ namespace GAME::material AbstractAssetDumper::DumpPool(context, pool); } - bool JsonDumper::ShouldDump(XAssetInfo* asset) + bool CLASS_NAME::ShouldDump(XAssetInfo* asset) { return true; } - void JsonDumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void CLASS_NAME::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { const auto assetFile = context.OpenAssetFile(GetFileNameForAssetName(asset->m_name)); @@ -393,5 +394,5 @@ namespace GAME::material JsonDumperImpl dumper(context, *assetFile); dumper.Dump(*material); } -} // namespace T6::leaderboard +} // namespace material diff --git a/src/ObjWriting/Material/MaterialJsonDumper.h.template b/src/ObjWriting/Material/MaterialJsonDumper.h.template index a9677b77..f8a41515 100644 --- a/src/ObjWriting/Material/MaterialJsonDumper.h.template +++ b/src/ObjWriting/Material/MaterialJsonDumper.h.template @@ -13,15 +13,17 @@ #set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\"" #include GAME_HEADER -namespace GAME::material +#set CLASS_NAME "JsonDumper" + GAME + +namespace material { - class JsonDumper final : public AbstractAssetDumper + class CLASS_NAME final : public AbstractAssetDumper { public: - void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; + void DumpPool(AssetDumpingContext& context, AssetPool* pool) override; protected: - [[nodiscard]] bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + [[nodiscard]] bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace GAME::material +} // namespace material diff --git a/src/ObjWriting/XModel/XModelDumper.cpp.template b/src/ObjWriting/XModel/XModelDumper.cpp.template index f4eabbc6..85dce85b 100644 --- a/src/ObjWriting/XModel/XModelDumper.cpp.template +++ b/src/ObjWriting/XModel/XModelDumper.cpp.template @@ -47,7 +47,8 @@ #include using namespace GAME; -using namespace ::xmodel; + +#set CLASS_NAME "Dumper" + GAME namespace { @@ -831,7 +832,7 @@ namespace void DumpXModelJson(AssetDumpingContext& context, XAssetInfo* asset) { - const auto assetFile = context.OpenAssetFile(GetJsonFileNameForAssetName(asset->m_name)); + const auto assetFile = context.OpenAssetFile(xmodel::GetJsonFileNameForAssetName(asset->m_name)); if (!assetFile) return; @@ -840,14 +841,14 @@ namespace } } // namespace -namespace GAME::xmodel +namespace xmodel { - bool Dumper::ShouldDump(XAssetInfo* asset) + bool CLASS_NAME::ShouldDump(XAssetInfo* asset) { return !asset->m_name.empty() && asset->m_name[0] != ','; } - void Dumper::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) + void CLASS_NAME::DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) { DumpXModelJson(context, asset); DumpXModelSurfs(context, asset); diff --git a/src/ObjWriting/XModel/XModelDumper.h.template b/src/ObjWriting/XModel/XModelDumper.h.template index 81d5a34c..5483e209 100644 --- a/src/ObjWriting/XModel/XModelDumper.h.template +++ b/src/ObjWriting/XModel/XModelDumper.h.template @@ -13,12 +13,14 @@ #include "Dumping/AbstractAssetDumper.h" #include GAME_HEADER -namespace GAME::xmodel +#set CLASS_NAME "Dumper" + GAME + +namespace xmodel { - class Dumper final : public AbstractAssetDumper + class CLASS_NAME final : public AbstractAssetDumper { protected: - bool ShouldDump(XAssetInfo* asset) override; - void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; + bool ShouldDump(XAssetInfo* asset) override; + void DumpAsset(AssetDumpingContext& context, XAssetInfo* asset) override; }; -} // namespace GAME +} // namespace xmodel diff --git a/test/ObjCompilingTests/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6Test.cpp b/test/ObjCompilingTests/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6Test.cpp index dc771218..c80dece3 100644 --- a/test/ObjCompilingTests/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6Test.cpp +++ b/test/ObjCompilingTests/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6Test.cpp @@ -26,13 +26,13 @@ namespace m_creators(m_zone), m_ignored_assets(), m_context(m_zone, &m_creators, &m_ignored_assets), - m_kvp_creator(m_zone_states.GetZoneAssetCreationState<::key_value_pairs::Creator>()) + m_kvp_creator(m_zone_states.GetZoneAssetCreationState()) { } std::unique_ptr CreateSut() { - return T6::key_value_pairs::CreateCompiler(m_memory, m_zone, m_zone_definition, m_zone_states); + return key_value_pairs::CreateCompilerT6(m_memory, m_zone, m_zone_definition, m_zone_states); } TestMemoryManager m_memory; diff --git a/test/ObjLoadingTests/Game/IW3/Material/LoaderMaterialIW3Test.cpp b/test/ObjLoadingTests/Game/IW3/Material/LoaderMaterialIW3Test.cpp index 76c8c87c..7f36ca46 100644 --- a/test/ObjLoadingTests/Game/IW3/Material/LoaderMaterialIW3Test.cpp +++ b/test/ObjLoadingTests/Game/IW3/Material/LoaderMaterialIW3Test.cpp @@ -286,7 +286,7 @@ namespace GivenImage("ch_plasterwall_long_col", context, memory); GivenTechset("wc_l_sm_r0c0n0s0", context, memory); - auto loader = material::CreateLoader(memory, searchPath); + auto loader = material::CreateLoaderIW3(memory, searchPath); auto result = loader->CreateAsset("wc/ch_plasterwall_long", context); REQUIRE(result.HasBeenSuccessful()); diff --git a/test/ObjLoadingTests/Game/IW3/StringTable/AssetLoaderStringTableIW3Test.cpp b/test/ObjLoadingTests/Game/IW3/StringTable/AssetLoaderStringTableIW3Test.cpp index 22195105..84894dd3 100644 --- a/test/ObjLoadingTests/Game/IW3/StringTable/AssetLoaderStringTableIW3Test.cpp +++ b/test/ObjLoadingTests/Game/IW3/StringTable/AssetLoaderStringTableIW3Test.cpp @@ -27,7 +27,7 @@ namespace IgnoredAssetLookup ignoredAssetLookup; AssetCreationContext context(zone, &creatorCollection, &ignoredAssetLookup); - auto loader = string_table::CreateLoader(memory, searchPath); + auto loader = string_table::CreateLoaderIW3(memory, searchPath); auto result = loader->CreateAsset("mp/cooltable.csv", context); REQUIRE(result.HasBeenSuccessful()); diff --git a/test/ObjLoadingTests/Game/IW4/AssetLoaders/LoaderStringTableIW4Test.cpp b/test/ObjLoadingTests/Game/IW4/AssetLoaders/LoaderStringTableIW4Test.cpp index ff4c5c56..d311f141 100644 --- a/test/ObjLoadingTests/Game/IW4/AssetLoaders/LoaderStringTableIW4Test.cpp +++ b/test/ObjLoadingTests/Game/IW4/AssetLoaders/LoaderStringTableIW4Test.cpp @@ -27,7 +27,7 @@ namespace IgnoredAssetLookup ignoredAssetLookup; AssetCreationContext context(zone, &creatorCollection, &ignoredAssetLookup); - auto loader = string_table::CreateLoader(memory, searchPath); + auto loader = string_table::CreateLoaderIW4(memory, searchPath); auto result = loader->CreateAsset("mp/cooltable.csv", context); REQUIRE(result.HasBeenSuccessful()); diff --git a/test/ObjLoadingTests/Game/IW4/Material/LoaderMaterialIW4Test.cpp b/test/ObjLoadingTests/Game/IW4/Material/LoaderMaterialIW4Test.cpp index 6af6297d..bde4133c 100644 --- a/test/ObjLoadingTests/Game/IW4/Material/LoaderMaterialIW4Test.cpp +++ b/test/ObjLoadingTests/Game/IW4/Material/LoaderMaterialIW4Test.cpp @@ -289,7 +289,7 @@ namespace GivenImage("ch_rubble01_col", context, memory); GivenTechset("mc_l_sm_r0c0n0s0", context, memory); - auto loader = material::CreateLoader(memory, searchPath); + auto loader = material::CreateLoaderIW4(memory, searchPath); auto result = loader->CreateAsset("mc/ch_rubble01", context); REQUIRE(result.HasBeenSuccessful()); diff --git a/test/ObjLoadingTests/Game/IW4/Menu/LoaderMenuListIW4Test.cpp b/test/ObjLoadingTests/Game/IW4/Menu/LoaderMenuListIW4Test.cpp index d246deb2..f55bf421 100644 --- a/test/ObjLoadingTests/Game/IW4/Menu/LoaderMenuListIW4Test.cpp +++ b/test/ObjLoadingTests/Game/IW4/Menu/LoaderMenuListIW4Test.cpp @@ -11,7 +11,6 @@ #include #include -using namespace ::menu; using namespace IW4; using namespace std::literals; using namespace Catch::Matchers; @@ -36,7 +35,7 @@ namespace test::game::iw4::menu::parsing::it m_ignored_asset_lookup(), m_context(m_zone, &m_creator_collection, &m_ignored_asset_lookup) { - m_asset_creator = IW4::menu::CreateMenuListLoader(m_zone.Memory(), m_search_path); + m_asset_creator = ::menu::CreateMenuListLoaderIW4(m_zone.Memory(), m_search_path); } void AddFile(std::string fileName, std::string data) diff --git a/test/ObjLoadingTests/Game/IW5/AssetLoaders/LoaderStringTableIW5Test.cpp b/test/ObjLoadingTests/Game/IW5/AssetLoaders/LoaderStringTableIW5Test.cpp index 08a7b464..32546c9c 100644 --- a/test/ObjLoadingTests/Game/IW5/AssetLoaders/LoaderStringTableIW5Test.cpp +++ b/test/ObjLoadingTests/Game/IW5/AssetLoaders/LoaderStringTableIW5Test.cpp @@ -26,7 +26,7 @@ namespace IgnoredAssetLookup ignoredAssetLookup; AssetCreationContext context(zone, &creatorCollection, &ignoredAssetLookup); - auto loader = string_table::CreateLoader(memory, searchPath); + auto loader = string_table::CreateLoaderIW5(memory, searchPath); auto result = loader->CreateAsset("mp/cooltable.csv", context); REQUIRE(result.HasBeenSuccessful()); diff --git a/test/ObjLoadingTests/Game/IW5/Material/LoaderMaterialIW5Test.cpp b/test/ObjLoadingTests/Game/IW5/Material/LoaderMaterialIW5Test.cpp index 960f119d..de7b30c1 100644 --- a/test/ObjLoadingTests/Game/IW5/Material/LoaderMaterialIW5Test.cpp +++ b/test/ObjLoadingTests/Game/IW5/Material/LoaderMaterialIW5Test.cpp @@ -313,7 +313,7 @@ namespace GivenImage("me_metal_rusty02_col", context, memory); GivenTechset("wc_l_sm_r0c0n0s0", context, memory); - auto loader = material::CreateLoader(memory, searchPath); + auto loader = material::CreateLoaderIW5(memory, searchPath); auto result = loader->CreateAsset("wc/me_metal_rust_02", context); REQUIRE(result.HasBeenSuccessful()); diff --git a/test/ObjLoadingTests/Game/T5/AssetLoaders/LoaderStringTableT5Test.cpp b/test/ObjLoadingTests/Game/T5/AssetLoaders/LoaderStringTableT5Test.cpp index ca346aa3..43e9c481 100644 --- a/test/ObjLoadingTests/Game/T5/AssetLoaders/LoaderStringTableT5Test.cpp +++ b/test/ObjLoadingTests/Game/T5/AssetLoaders/LoaderStringTableT5Test.cpp @@ -26,7 +26,7 @@ namespace IgnoredAssetLookup ignoredAssetLookup; AssetCreationContext context(zone, &creatorCollection, &ignoredAssetLookup); - auto loader = string_table::CreateLoader(memory, searchPath); + auto loader = string_table::CreateLoaderT5(memory, searchPath); auto result = loader->CreateAsset("mp/cooltable.csv", context); REQUIRE(result.HasBeenSuccessful()); diff --git a/test/ObjLoadingTests/Game/T5/Material/LoaderMaterialT5Test.cpp b/test/ObjLoadingTests/Game/T5/Material/LoaderMaterialT5Test.cpp index e2aaedcb..9e183566 100644 --- a/test/ObjLoadingTests/Game/T5/Material/LoaderMaterialT5Test.cpp +++ b/test/ObjLoadingTests/Game/T5/Material/LoaderMaterialT5Test.cpp @@ -370,7 +370,7 @@ namespace GivenImage("~-gjun_art_brick_foundation_c", context, memory); GivenTechset("mc_l_sm_r0c0n0s0", context, memory); - auto loader = material::CreateLoader(memory, searchPath); + auto loader = material::CreateLoaderT5(memory, searchPath); auto result = loader->CreateAsset("mc/jun_art_brick_foundation", context); REQUIRE(result.HasBeenSuccessful()); diff --git a/test/ObjLoadingTests/Game/T6/AssetLoaders/LoaderStringTableT6Test.cpp b/test/ObjLoadingTests/Game/T6/AssetLoaders/LoaderStringTableT6Test.cpp index 163a4575..2e075e9f 100644 --- a/test/ObjLoadingTests/Game/T6/AssetLoaders/LoaderStringTableT6Test.cpp +++ b/test/ObjLoadingTests/Game/T6/AssetLoaders/LoaderStringTableT6Test.cpp @@ -26,7 +26,7 @@ namespace IgnoredAssetLookup ignoredAssetLookup; AssetCreationContext context(zone, &creatorCollection, &ignoredAssetLookup); - auto loader = string_table::CreateLoader(memory, searchPath); + auto loader = string_table::CreateLoaderT6(memory, searchPath); auto result = loader->CreateAsset("mp/cooltable.csv", context); REQUIRE(result.HasBeenSuccessful()); diff --git a/test/ObjLoadingTests/Game/T6/FontIcon/JsonLoaderFontIconT6Test.cpp b/test/ObjLoadingTests/Game/T6/FontIcon/JsonLoaderFontIconT6Test.cpp index d61e4096..a92851d6 100644 --- a/test/ObjLoadingTests/Game/T6/FontIcon/JsonLoaderFontIconT6Test.cpp +++ b/test/ObjLoadingTests/Game/T6/FontIcon/JsonLoaderFontIconT6Test.cpp @@ -90,7 +90,7 @@ namespace GivenMaterial("ui_button_xenon_lstick_anim_d", context, memory); GivenMaterial("xenonbutton_ls", context, memory); - auto loader = font_icon::CreateJsonLoader(memory, searchPath); + auto loader = font_icon::CreateJsonLoaderT6(memory, searchPath); auto result = loader->CreateAsset("fonticon/test.csv", context); REQUIRE(result.HasBeenSuccessful()); diff --git a/test/ObjLoadingTests/Game/T6/Material/LoaderMaterialT6Test.cpp b/test/ObjLoadingTests/Game/T6/Material/LoaderMaterialT6Test.cpp index 609c5200..94ee5b62 100644 --- a/test/ObjLoadingTests/Game/T6/Material/LoaderMaterialT6Test.cpp +++ b/test/ObjLoadingTests/Game/T6/Material/LoaderMaterialT6Test.cpp @@ -253,7 +253,7 @@ namespace GivenImage("~-gmetal_ac_duct_c", context, memory); GivenTechset("wpc_lit_sm_r0c0n0s0_1zzj1138", context, memory); - auto loader = material::CreateLoader(memory, searchPath); + auto loader = material::CreateLoaderT6(memory, searchPath); auto result = loader->CreateAsset("wpc/metal_ac_duct", context); REQUIRE(result.HasBeenSuccessful()); diff --git a/test/ObjWritingTests/Game/IW3/Material/MaterialJsonDumperIW3.cpp b/test/ObjWritingTests/Game/IW3/Material/MaterialJsonDumperIW3Test.cpp similarity index 99% rename from test/ObjWritingTests/Game/IW3/Material/MaterialJsonDumperIW3.cpp rename to test/ObjWritingTests/Game/IW3/Material/MaterialJsonDumperIW3Test.cpp index e09856ba..44980cdc 100644 --- a/test/ObjWritingTests/Game/IW3/Material/MaterialJsonDumperIW3.cpp +++ b/test/ObjWritingTests/Game/IW3/Material/MaterialJsonDumperIW3Test.cpp @@ -562,7 +562,7 @@ namespace GivenMaterial("wc/ch_plasterwall_long", materialPool, memory); - material::JsonDumper dumper; + material::JsonDumperIW3 dumper; dumper.DumpPool(context, &materialPool); const auto* file = mockOutput.GetMockedFile("materials/wc/ch_plasterwall_long.json"); diff --git a/test/ObjWritingTests/Game/IW4/Material/MaterialJsonDumperIW4.cpp b/test/ObjWritingTests/Game/IW4/Material/MaterialJsonDumperIW4Test.cpp similarity index 99% rename from test/ObjWritingTests/Game/IW4/Material/MaterialJsonDumperIW4.cpp rename to test/ObjWritingTests/Game/IW4/Material/MaterialJsonDumperIW4Test.cpp index c2268aff..c16ec19d 100644 --- a/test/ObjWritingTests/Game/IW4/Material/MaterialJsonDumperIW4.cpp +++ b/test/ObjWritingTests/Game/IW4/Material/MaterialJsonDumperIW4Test.cpp @@ -543,7 +543,7 @@ namespace GivenMaterial("mc/ch_rubble01", materialPool, memory); - material::JsonDumper dumper; + material::JsonDumperIW4 dumper; dumper.DumpPool(context, &materialPool); const auto* file = mockOutput.GetMockedFile("materials/mc/ch_rubble01.json"); diff --git a/test/ObjWritingTests/Game/IW5/Material/MaterialJsonDumperIW5.cpp b/test/ObjWritingTests/Game/IW5/Material/MaterialJsonDumperIW5Test.cpp similarity index 99% rename from test/ObjWritingTests/Game/IW5/Material/MaterialJsonDumperIW5.cpp rename to test/ObjWritingTests/Game/IW5/Material/MaterialJsonDumperIW5Test.cpp index a40a1e2e..f70a9daf 100644 --- a/test/ObjWritingTests/Game/IW5/Material/MaterialJsonDumperIW5.cpp +++ b/test/ObjWritingTests/Game/IW5/Material/MaterialJsonDumperIW5Test.cpp @@ -596,7 +596,7 @@ namespace GivenMaterial("wc/me_metal_rust_02", materialPool, memory); - material::JsonDumper dumper; + material::JsonDumperIW5 dumper; dumper.DumpPool(context, &materialPool); const auto* file = mockOutput.GetMockedFile("materials/wc/me_metal_rust_02.json"); diff --git a/test/ObjWritingTests/Game/T5/Material/MaterialJsonDumperT5.cpp b/test/ObjWritingTests/Game/T5/Material/MaterialJsonDumperT5Test.cpp similarity index 99% rename from test/ObjWritingTests/Game/T5/Material/MaterialJsonDumperT5.cpp rename to test/ObjWritingTests/Game/T5/Material/MaterialJsonDumperT5Test.cpp index aa5d230b..5513c96f 100644 --- a/test/ObjWritingTests/Game/T5/Material/MaterialJsonDumperT5.cpp +++ b/test/ObjWritingTests/Game/T5/Material/MaterialJsonDumperT5Test.cpp @@ -625,7 +625,7 @@ namespace GivenMaterial("mc/ch_rubble01", materialPool, memory); - material::JsonDumper dumper; + material::JsonDumperT5 dumper; dumper.DumpPool(context, &materialPool); const auto* file = mockOutput.GetMockedFile("materials/mc/ch_rubble01.json"); diff --git a/test/ObjWritingTests/Game/T6/FontIcon/FontIconJsonDumperT6Test.cpp b/test/ObjWritingTests/Game/T6/FontIcon/FontIconJsonDumperT6Test.cpp index 04bf8440..1755ff9d 100644 --- a/test/ObjWritingTests/Game/T6/FontIcon/FontIconJsonDumperT6Test.cpp +++ b/test/ObjWritingTests/Game/T6/FontIcon/FontIconJsonDumperT6Test.cpp @@ -151,7 +151,7 @@ namespace AssetPoolDynamic fontIconPool(0); GivenFontIcon("fonticon/test.csv", fontIconPool, memory); - font_icon::JsonDumper dumper; + font_icon::JsonDumperT6 dumper; dumper.DumpPool(context, &fontIconPool); const auto* file = mockOutput.GetMockedFile("fonticon/test.json"); diff --git a/test/ObjWritingTests/Game/T6/Material/MaterialJsonDumperT6Test.cpp b/test/ObjWritingTests/Game/T6/Material/MaterialJsonDumperT6Test.cpp index db8dc42a..c75d73be 100644 --- a/test/ObjWritingTests/Game/T6/Material/MaterialJsonDumperT6Test.cpp +++ b/test/ObjWritingTests/Game/T6/Material/MaterialJsonDumperT6Test.cpp @@ -472,7 +472,7 @@ namespace AssetPoolDynamic materialPool(0); GivenMaterial("wpc/metal_ac_duct", materialPool, memory); - material::JsonDumper dumper; + material::JsonDumperT6 dumper; dumper.DumpPool(context, &materialPool); const auto* file = mockOutput.GetMockedFile("materials/wpc/metal_ac_duct.json"); From fdef6797aaa4cde0e9833bae5b858009ecfef7d7 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Wed, 6 Aug 2025 00:31:52 +0100 Subject: [PATCH 35/35] fix: messed up kvp compiler reference --- .../Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.cpp | 4 ++-- src/ObjLoading/Asset/IZoneAssetCreationState.h | 5 +++-- .../Game/T6/KeyValuePairs/KeyValuePairsCompilerT6Test.cpp | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.cpp b/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.cpp index 92be6c06..35724a68 100644 --- a/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.cpp +++ b/src/ObjCompiling/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6.cpp @@ -18,7 +18,7 @@ namespace : m_memory(memory), m_zone(zone), m_zone_definition(zoneDefinition), - m_kvp_creator(zoneStates.GetZoneAssetCreationState<::key_value_pairs::Creator>()) + m_kvp_creator(zoneStates.GetZoneAssetCreationState()) { } @@ -67,7 +67,7 @@ namespace MemoryManager& m_memory; const Zone& m_zone; const ZoneDefinition& m_zone_definition; - ::key_value_pairs::Creator m_kvp_creator; + key_value_pairs::Creator& m_kvp_creator; }; } // namespace diff --git a/src/ObjLoading/Asset/IZoneAssetCreationState.h b/src/ObjLoading/Asset/IZoneAssetCreationState.h index c63b1861..5692f553 100644 --- a/src/ObjLoading/Asset/IZoneAssetCreationState.h +++ b/src/ObjLoading/Asset/IZoneAssetCreationState.h @@ -52,14 +52,15 @@ public: static_assert(std::is_base_of_v, "T must inherit IZoneAssetCreationState"); // T must also have a public default constructor - const auto foundEntry = m_zone_asset_creation_states.find(typeid(T)); + std::type_index typeId = typeid(T); + const auto foundEntry = m_zone_asset_creation_states.find(typeId); if (foundEntry != m_zone_asset_creation_states.end()) return *dynamic_cast(foundEntry->second.get()); auto newState = std::make_unique(); newState->Inject(m_injection); auto* newStatePtr = newState.get(); - m_zone_asset_creation_states.emplace(std::make_pair>(typeid(T), std::move(newState))); + m_zone_asset_creation_states.emplace(std::move(typeId), std::move(newState)); return *newStatePtr; } diff --git a/test/ObjCompilingTests/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6Test.cpp b/test/ObjCompilingTests/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6Test.cpp index c80dece3..3a94a2df 100644 --- a/test/ObjCompilingTests/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6Test.cpp +++ b/test/ObjCompilingTests/Game/T6/KeyValuePairs/KeyValuePairsCompilerT6Test.cpp @@ -43,7 +43,7 @@ namespace IgnoredAssetLookup m_ignored_assets; AssetCreationContext m_context; - ::key_value_pairs::Creator& m_kvp_creator; + key_value_pairs::Creator& m_kvp_creator; }; } // namespace @@ -81,7 +81,7 @@ namespace test::game::t6::keyvaluepairs TestContext testContext; const auto sut = testContext.CreateSut(); - testContext.m_kvp_creator.AddKeyValuePair(::key_value_pairs::CommonKeyValuePair("ipak_read", "test_ipak")); + testContext.m_kvp_creator.AddKeyValuePair(key_value_pairs::CommonKeyValuePair("ipak_read", "test_ipak")); sut->FinalizeZone(testContext.m_context); @@ -107,7 +107,7 @@ namespace test::game::t6::keyvaluepairs TestContext testContext; const auto sut = testContext.CreateSut(); - testContext.m_kvp_creator.AddKeyValuePair(::key_value_pairs::CommonKeyValuePair(0xDDEEFFAA, "hello_there")); + testContext.m_kvp_creator.AddKeyValuePair(key_value_pairs::CommonKeyValuePair(0xDDEEFFAA, "hello_there")); sut->FinalizeZone(testContext.m_context);