From c07bfe8bd936136758778be2bd1f6fad306a1c33 Mon Sep 17 00:00:00 2001 From: Diavolo Date: Wed, 22 Jun 2022 17:36:06 +0200 Subject: [PATCH] [General] Stop nonsense with asset handler header files --- src/Components/Modules/AssetHandler.cpp | 33 + src/Components/Modules/AssetHandler.hpp | 34 - .../Modules/AssetInterfaces/IComWorld.cpp | 1 + .../Modules/AssetInterfaces/IComWorld.hpp | 8 +- .../Modules/AssetInterfaces/IFont_s.cpp | 1 + .../Modules/AssetInterfaces/IFont_s.hpp | 8 +- .../Modules/AssetInterfaces/IFxEffectDef.cpp | 1 + .../Modules/AssetInterfaces/IFxEffectDef.hpp | 8 +- .../Modules/AssetInterfaces/IFxWorld.cpp | 1 + .../Modules/AssetInterfaces/IFxWorld.hpp | 8 +- .../Modules/AssetInterfaces/IGameWorldMp.cpp | 1 + .../Modules/AssetInterfaces/IGameWorldMp.hpp | 4 +- .../Modules/AssetInterfaces/IGameWorldSp.cpp | 1 + .../Modules/AssetInterfaces/IGameWorldSp.hpp | 6 +- .../Modules/AssetInterfaces/IGfxImage.cpp | 1 + .../Modules/AssetInterfaces/IGfxImage.hpp | 6 +- .../Modules/AssetInterfaces/IGfxLightDef.cpp | 1 + .../Modules/AssetInterfaces/IGfxLightDef.hpp | 8 +- .../Modules/AssetInterfaces/IGfxWorld.cpp | 3 +- .../Modules/AssetInterfaces/IGfxWorld.hpp | 9 +- .../Modules/AssetInterfaces/ILoadedSound.cpp | 1 + .../Modules/AssetInterfaces/ILoadedSound.hpp | 6 +- .../AssetInterfaces/ILocalizeEntry.cpp | 1 + .../AssetInterfaces/ILocalizeEntry.hpp | 4 +- .../Modules/AssetInterfaces/IMapEnts.cpp | 1 + .../Modules/AssetInterfaces/IMapEnts.hpp | 8 +- .../Modules/AssetInterfaces/IMaterial.cpp | 1 + .../Modules/AssetInterfaces/IMaterial.hpp | 8 +- .../AssetInterfaces/IMaterialPixelShader.cpp | 75 +- .../AssetInterfaces/IMaterialPixelShader.hpp | 10 +- .../AssetInterfaces/IMaterialTechniqueSet.cpp | 209 +-- .../AssetInterfaces/IMaterialTechniqueSet.hpp | 14 +- .../IMaterialVertexDeclaration.cpp | 67 +- .../IMaterialVertexDeclaration.hpp | 10 +- .../AssetInterfaces/IMaterialVertexShader.cpp | 77 +- .../AssetInterfaces/IMaterialVertexShader.hpp | 10 +- .../Modules/AssetInterfaces/IMenuList.cpp | 49 +- .../Modules/AssetInterfaces/IMenuList.hpp | 8 +- .../Modules/AssetInterfaces/IPhysCollmap.cpp | 1 + .../Modules/AssetInterfaces/IPhysCollmap.hpp | 4 +- .../Modules/AssetInterfaces/IPhysPreset.cpp | 1 + .../Modules/AssetInterfaces/IPhysPreset.hpp | 4 +- .../Modules/AssetInterfaces/IRawFile.cpp | 1 + .../Modules/AssetInterfaces/IRawFile.hpp | 6 +- .../Modules/AssetInterfaces/ISndCurve.cpp | 1 + .../Modules/AssetInterfaces/ISndCurve.hpp | 4 +- .../Modules/AssetInterfaces/IStringTable.cpp | 1 + .../Modules/AssetInterfaces/IStringTable.hpp | 4 +- .../AssetInterfaces/IStructuredDataDefSet.cpp | 1 + .../AssetInterfaces/IStructuredDataDefSet.hpp | 4 +- .../Modules/AssetInterfaces/ITracerDef.cpp | 63 +- .../Modules/AssetInterfaces/ITracerDef.hpp | 16 +- .../Modules/AssetInterfaces/IWeapon.cpp | 1421 +++++++++-------- .../Modules/AssetInterfaces/IWeapon.hpp | 8 +- .../Modules/AssetInterfaces/IXAnimParts.cpp | 1 + .../Modules/AssetInterfaces/IXAnimParts.hpp | 8 +- .../Modules/AssetInterfaces/IXModel.cpp | 27 +- .../Modules/AssetInterfaces/IXModel.hpp | 10 +- .../Modules/AssetInterfaces/IXModelSurfs.cpp | 21 +- .../Modules/AssetInterfaces/IXModelSurfs.hpp | 4 +- .../Modules/AssetInterfaces/IclipMap_t.cpp | 1 + .../Modules/AssetInterfaces/IclipMap_t.hpp | 8 +- .../Modules/AssetInterfaces/ImenuDef_t.cpp | 77 +- .../Modules/AssetInterfaces/ImenuDef_t.hpp | 10 +- .../AssetInterfaces/Isnd_alias_list_t.cpp | 1 + .../AssetInterfaces/Isnd_alias_list_t.hpp | 8 +- src/Utils/String.hpp | 2 +- 67 files changed, 1226 insertions(+), 1194 deletions(-) diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index b853b070..a65259e2 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -1,5 +1,38 @@ #include +#include "AssetInterfaces/IFont_s.hpp" +#include "AssetInterfaces/IWeapon.hpp" +#include "AssetInterfaces/IXModel.hpp" +#include "AssetInterfaces/IFxWorld.hpp" +#include "AssetInterfaces/IMapEnts.hpp" +#include "AssetInterfaces/IRawFile.hpp" +#include "AssetInterfaces/IComWorld.hpp" +#include "AssetInterfaces/IGfxImage.hpp" +#include "AssetInterfaces/IGfxWorld.hpp" +#include "AssetInterfaces/IMaterial.hpp" +#include "AssetInterfaces/ISndCurve.hpp" +#include "AssetInterfaces/IMenuList.hpp" +#include "AssetInterfaces/IclipMap_t.hpp" +#include "AssetInterfaces/ImenuDef_t.hpp" +#include "AssetInterfaces/ITracerDef.hpp" +#include "AssetInterfaces/IPhysPreset.hpp" +#include "AssetInterfaces/IXAnimParts.hpp" +#include "AssetInterfaces/IFxEffectDef.hpp" +#include "AssetInterfaces/IGameWorldMp.hpp" +#include "AssetInterfaces/IGameWorldSp.hpp" +#include "AssetInterfaces/IGfxLightDef.hpp" +#include "AssetInterfaces/ILoadedSound.hpp" +#include "AssetInterfaces/IPhysCollmap.hpp" +#include "AssetInterfaces/IStringTable.hpp" +#include "AssetInterfaces/IXModelSurfs.hpp" +#include "AssetInterfaces/ILocalizeEntry.hpp" +#include "AssetInterfaces/Isnd_alias_list_t.hpp" +#include "AssetInterfaces/IMaterialPixelShader.hpp" +#include "AssetInterfaces/IMaterialTechniqueSet.hpp" +#include "AssetInterfaces/IMaterialVertexShader.hpp" +#include "AssetInterfaces/IStructuredDataDefSet.hpp" +#include "AssetInterfaces/IMaterialVertexDeclaration.hpp" + namespace Components { thread_local int AssetHandler::BypassState = 0; diff --git a/src/Components/Modules/AssetHandler.hpp b/src/Components/Modules/AssetHandler.hpp index 5d0426b2..238c3611 100644 --- a/src/Components/Modules/AssetHandler.hpp +++ b/src/Components/Modules/AssetHandler.hpp @@ -78,37 +78,3 @@ namespace Components void reallocateEntryPool(); }; } - -#include "AssetInterfaces/IFont_s.hpp" -#include "AssetInterfaces/IWeapon.hpp" -#include "AssetInterfaces/IXModel.hpp" -#include "AssetInterfaces/IFxWorld.hpp" -#include "AssetInterfaces/IMapEnts.hpp" -#include "AssetInterfaces/IRawFile.hpp" -#include "AssetInterfaces/IComWorld.hpp" -#include "AssetInterfaces/IGfxImage.hpp" -#include "AssetInterfaces/IGfxWorld.hpp" -#include "AssetInterfaces/IMaterial.hpp" -#include "AssetInterfaces/ISndCurve.hpp" -#include "AssetInterfaces/IMenuList.hpp" -#include "AssetInterfaces/IclipMap_t.hpp" -#include "AssetInterfaces/ImenuDef_t.hpp" -#include "AssetInterfaces/ITracerDef.hpp" -#include "AssetInterfaces/IPhysPreset.hpp" -#include "AssetInterfaces/IXAnimParts.hpp" -#include "AssetInterfaces/IFxEffectDef.hpp" -#include "AssetInterfaces/IGameWorldMp.hpp" -#include "AssetInterfaces/IGameWorldSp.hpp" -#include "AssetInterfaces/IGfxLightDef.hpp" -#include "AssetInterfaces/ILoadedSound.hpp" -#include "AssetInterfaces/IPhysCollmap.hpp" -#include "AssetInterfaces/IStringTable.hpp" -#include "AssetInterfaces/IXModelSurfs.hpp" -#include "AssetInterfaces/ILocalizeEntry.hpp" -#include "AssetInterfaces/Isnd_alias_list_t.hpp" -#include "AssetInterfaces/IMaterialPixelShader.hpp" -#include "AssetInterfaces/IMaterialTechniqueSet.hpp" -#include "AssetInterfaces/IMaterialVertexShader.hpp" -#include "AssetInterfaces/IStructuredDataDefSet.hpp" -#include "AssetInterfaces/IMaterialVertexDeclaration.hpp" - diff --git a/src/Components/Modules/AssetInterfaces/IComWorld.cpp b/src/Components/Modules/AssetInterfaces/IComWorld.cpp index e8d795b5..bb01b757 100644 --- a/src/Components/Modules/AssetInterfaces/IComWorld.cpp +++ b/src/Components/Modules/AssetInterfaces/IComWorld.cpp @@ -1,4 +1,5 @@ #include +#include "IComWorld.hpp" #define IW4X_COMMAP_VERSION 0 diff --git a/src/Components/Modules/AssetInterfaces/IComWorld.hpp b/src/Components/Modules/AssetInterfaces/IComWorld.hpp index ef6f37d4..49048400 100644 --- a/src/Components/Modules/AssetInterfaces/IComWorld.hpp +++ b/src/Components/Modules/AssetInterfaces/IComWorld.hpp @@ -5,10 +5,10 @@ namespace Assets class IComWorld : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_COMWORLD; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_COMWORLD; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; }; } diff --git a/src/Components/Modules/AssetInterfaces/IFont_s.cpp b/src/Components/Modules/AssetInterfaces/IFont_s.cpp index d757254b..22a57d50 100644 --- a/src/Components/Modules/AssetInterfaces/IFont_s.cpp +++ b/src/Components/Modules/AssetInterfaces/IFont_s.cpp @@ -1,4 +1,5 @@ #include +#include "IFont_s.hpp" #define STB_TRUETYPE_IMPLEMENTATION #include diff --git a/src/Components/Modules/AssetInterfaces/IFont_s.hpp b/src/Components/Modules/AssetInterfaces/IFont_s.hpp index 1a6161cb..7596656d 100644 --- a/src/Components/Modules/AssetInterfaces/IFont_s.hpp +++ b/src/Components/Modules/AssetInterfaces/IFont_s.hpp @@ -5,10 +5,10 @@ namespace Assets class IFont_s : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_FONT; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_FONT; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; }; } diff --git a/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp b/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp index 97f0876a..80778bb6 100644 --- a/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp +++ b/src/Components/Modules/AssetInterfaces/IFxEffectDef.cpp @@ -1,4 +1,5 @@ #include +#include "IFxEffectDef.hpp" #define IW4X_FX_VERSION 1 diff --git a/src/Components/Modules/AssetInterfaces/IFxEffectDef.hpp b/src/Components/Modules/AssetInterfaces/IFxEffectDef.hpp index 4fcc5e4d..9a877050 100644 --- a/src/Components/Modules/AssetInterfaces/IFxEffectDef.hpp +++ b/src/Components/Modules/AssetInterfaces/IFxEffectDef.hpp @@ -5,11 +5,11 @@ namespace Assets class IFxEffectDef : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_FX; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_FX; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; private: void markFxElemVisuals(Game::FxElemVisuals* visuals, char elemType, Components::ZoneBuilder::Zone* builder); diff --git a/src/Components/Modules/AssetInterfaces/IFxWorld.cpp b/src/Components/Modules/AssetInterfaces/IFxWorld.cpp index e3bddb0d..cec5b4dc 100644 --- a/src/Components/Modules/AssetInterfaces/IFxWorld.cpp +++ b/src/Components/Modules/AssetInterfaces/IFxWorld.cpp @@ -1,4 +1,5 @@ #include +#include "IFxWorld.hpp" namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IFxWorld.hpp b/src/Components/Modules/AssetInterfaces/IFxWorld.hpp index 6cca8769..a19ddf56 100644 --- a/src/Components/Modules/AssetInterfaces/IFxWorld.hpp +++ b/src/Components/Modules/AssetInterfaces/IFxWorld.hpp @@ -5,10 +5,10 @@ namespace Assets class IFxWorld : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_FXWORLD; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_FXWORLD; }; - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; }; } diff --git a/src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp b/src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp index 17c7702e..64c53039 100644 --- a/src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp +++ b/src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp @@ -1,4 +1,5 @@ #include +#include "IGameWorldMp.hpp" namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IGameWorldMp.hpp b/src/Components/Modules/AssetInterfaces/IGameWorldMp.hpp index ccb740d2..243378ef 100644 --- a/src/Components/Modules/AssetInterfaces/IGameWorldMp.hpp +++ b/src/Components/Modules/AssetInterfaces/IGameWorldMp.hpp @@ -5,8 +5,8 @@ namespace Assets class IGameWorldMp : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_GAMEWORLD_MP; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_GAMEWORLD_MP; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; }; } diff --git a/src/Components/Modules/AssetInterfaces/IGameWorldSp.cpp b/src/Components/Modules/AssetInterfaces/IGameWorldSp.cpp index 04fba9c2..56205bce 100644 --- a/src/Components/Modules/AssetInterfaces/IGameWorldSp.cpp +++ b/src/Components/Modules/AssetInterfaces/IGameWorldSp.cpp @@ -1,4 +1,5 @@ #include +#include "IGameWorldSp.hpp" namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IGameWorldSp.hpp b/src/Components/Modules/AssetInterfaces/IGameWorldSp.hpp index d7a28505..4abc33f2 100644 --- a/src/Components/Modules/AssetInterfaces/IGameWorldSp.hpp +++ b/src/Components/Modules/AssetInterfaces/IGameWorldSp.hpp @@ -5,10 +5,10 @@ namespace Assets class IGameWorldSp : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_GAMEWORLD_SP; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_GAMEWORLD_SP; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; private: void savepathnode_tree_info_t(Game::pathnode_tree_t* nodeTree, Game::pathnode_tree_t* destNodeTree, Components::ZoneBuilder::Zone* builder); diff --git a/src/Components/Modules/AssetInterfaces/IGfxImage.cpp b/src/Components/Modules/AssetInterfaces/IGfxImage.cpp index e01732a2..e7be7614 100644 --- a/src/Components/Modules/AssetInterfaces/IGfxImage.cpp +++ b/src/Components/Modules/AssetInterfaces/IGfxImage.cpp @@ -1,4 +1,5 @@ #include +#include "IGfxImage.hpp" #define IW4X_IMG_VERSION "0" diff --git a/src/Components/Modules/AssetInterfaces/IGfxImage.hpp b/src/Components/Modules/AssetInterfaces/IGfxImage.hpp index 209991e1..6b28cd19 100644 --- a/src/Components/Modules/AssetInterfaces/IGfxImage.hpp +++ b/src/Components/Modules/AssetInterfaces/IGfxImage.hpp @@ -5,9 +5,9 @@ namespace Assets class IGfxImage : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_IMAGE; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_IMAGE; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; }; } diff --git a/src/Components/Modules/AssetInterfaces/IGfxLightDef.cpp b/src/Components/Modules/AssetInterfaces/IGfxLightDef.cpp index a9785457..6347f993 100644 --- a/src/Components/Modules/AssetInterfaces/IGfxLightDef.cpp +++ b/src/Components/Modules/AssetInterfaces/IGfxLightDef.cpp @@ -1,4 +1,5 @@ #include +#include "IGfxLightDef.hpp" #define IW4X_LIGHT_VERSION "0" diff --git a/src/Components/Modules/AssetInterfaces/IGfxLightDef.hpp b/src/Components/Modules/AssetInterfaces/IGfxLightDef.hpp index d1386831..f07708a5 100644 --- a/src/Components/Modules/AssetInterfaces/IGfxLightDef.hpp +++ b/src/Components/Modules/AssetInterfaces/IGfxLightDef.hpp @@ -5,10 +5,10 @@ namespace Assets class IGfxLightDef : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_LIGHT_DEF; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_LIGHT_DEF; } - virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; }; } diff --git a/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp b/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp index 3b0752d1..556303be 100644 --- a/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp +++ b/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp @@ -1,4 +1,5 @@ #include +#include "IGfxWorld.hpp" #define IW4X_GFXMAP_VERSION 1 @@ -950,7 +951,7 @@ namespace Assets } buffer->popBlock(); - SaveLogExit(); + SaveLogExit(); } void IGfxWorld::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) diff --git a/src/Components/Modules/AssetInterfaces/IGfxWorld.hpp b/src/Components/Modules/AssetInterfaces/IGfxWorld.hpp index 344af3a9..24e3a71d 100644 --- a/src/Components/Modules/AssetInterfaces/IGfxWorld.hpp +++ b/src/Components/Modules/AssetInterfaces/IGfxWorld.hpp @@ -5,11 +5,12 @@ namespace Assets class IGfxWorld : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_GFXWORLD; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_GFXWORLD; }; + + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; private: void saveGfxWorldDpvsPlanes(Game::GfxWorld* world, Game::GfxWorldDpvsPlanes* asset, Game::GfxWorldDpvsPlanes* dest, Components::ZoneBuilder::Zone* builder); void saveGfxWorldDraw(Game::GfxWorldDraw* asset, Game::GfxWorldDraw* dest, Components::ZoneBuilder::Zone* builder); diff --git a/src/Components/Modules/AssetInterfaces/ILoadedSound.cpp b/src/Components/Modules/AssetInterfaces/ILoadedSound.cpp index 69e4989d..6e282c15 100644 --- a/src/Components/Modules/AssetInterfaces/ILoadedSound.cpp +++ b/src/Components/Modules/AssetInterfaces/ILoadedSound.cpp @@ -1,4 +1,5 @@ #include +#include "ILoadedSound.hpp" namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/ILoadedSound.hpp b/src/Components/Modules/AssetInterfaces/ILoadedSound.hpp index 6e7ee497..8e2ae56b 100644 --- a/src/Components/Modules/AssetInterfaces/ILoadedSound.hpp +++ b/src/Components/Modules/AssetInterfaces/ILoadedSound.hpp @@ -5,9 +5,9 @@ namespace Assets class ILoadedSound : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_LOADED_SOUND; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_LOADED_SOUND; }; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; }; } diff --git a/src/Components/Modules/AssetInterfaces/ILocalizeEntry.cpp b/src/Components/Modules/AssetInterfaces/ILocalizeEntry.cpp index 9a906b47..e126101d 100644 --- a/src/Components/Modules/AssetInterfaces/ILocalizeEntry.cpp +++ b/src/Components/Modules/AssetInterfaces/ILocalizeEntry.cpp @@ -1,4 +1,5 @@ #include +#include "ILocalizeEntry.hpp" namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/ILocalizeEntry.hpp b/src/Components/Modules/AssetInterfaces/ILocalizeEntry.hpp index 47683073..dfb12894 100644 --- a/src/Components/Modules/AssetInterfaces/ILocalizeEntry.hpp +++ b/src/Components/Modules/AssetInterfaces/ILocalizeEntry.hpp @@ -5,8 +5,8 @@ namespace Assets class ILocalizeEntry : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_LOCALIZE_ENTRY; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_LOCALIZE_ENTRY; }; - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; }; } diff --git a/src/Components/Modules/AssetInterfaces/IMapEnts.cpp b/src/Components/Modules/AssetInterfaces/IMapEnts.cpp index 0b639a58..9cd343a0 100644 --- a/src/Components/Modules/AssetInterfaces/IMapEnts.cpp +++ b/src/Components/Modules/AssetInterfaces/IMapEnts.cpp @@ -1,4 +1,5 @@ #include +#include "IMapEnts.hpp" namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IMapEnts.hpp b/src/Components/Modules/AssetInterfaces/IMapEnts.hpp index 0c4628c1..37286311 100644 --- a/src/Components/Modules/AssetInterfaces/IMapEnts.hpp +++ b/src/Components/Modules/AssetInterfaces/IMapEnts.hpp @@ -5,10 +5,10 @@ namespace Assets class IMapEnts : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_MAP_ENTS; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_MAP_ENTS; } - virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; }; } diff --git a/src/Components/Modules/AssetInterfaces/IMaterial.cpp b/src/Components/Modules/AssetInterfaces/IMaterial.cpp index 0c1ce956..d12c153b 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterial.cpp +++ b/src/Components/Modules/AssetInterfaces/IMaterial.cpp @@ -1,4 +1,5 @@ #include +#include "IMaterial.hpp" #define IW4X_MAT_VERSION "1" diff --git a/src/Components/Modules/AssetInterfaces/IMaterial.hpp b/src/Components/Modules/AssetInterfaces/IMaterial.hpp index 3556b2fa..54c10449 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterial.hpp +++ b/src/Components/Modules/AssetInterfaces/IMaterial.hpp @@ -5,11 +5,11 @@ namespace Assets class IMaterial : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_MATERIAL; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_MATERIAL; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; void loadJson(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder); void loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder); void loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder); diff --git a/src/Components/Modules/AssetInterfaces/IMaterialPixelShader.cpp b/src/Components/Modules/AssetInterfaces/IMaterialPixelShader.cpp index c3a93270..fd91bae6 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterialPixelShader.cpp +++ b/src/Components/Modules/AssetInterfaces/IMaterialPixelShader.cpp @@ -1,56 +1,57 @@ #include +#include "IMaterialPixelShader.hpp" #define IW4X_TECHSET_VERSION "0" namespace Assets { - void IMaterialPixelShader::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) - { - if (!header->data) this->loadNative(header, name, builder); // Check if there is a native one - if (!header->data) this->loadBinary(header, name, builder); // Check if we need to import a new one into the game - } + void IMaterialPixelShader::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) + { + if (!header->data) this->loadNative(header, name, builder); // Check if there is a native one + if (!header->data) this->loadBinary(header, name, builder); // Check if we need to import a new one into the game + } - void IMaterialPixelShader::loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/) - { - header->pixelShader = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).pixelShader; - } + void IMaterialPixelShader::loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/) + { + header->pixelShader = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).pixelShader; + } - void IMaterialPixelShader::loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) - { - Components::FileSystem::File psFile(Utils::String::VA("ps/%s.iw4xPS", name.data())); - if (!psFile.exists()) return; + void IMaterialPixelShader::loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) + { + Components::FileSystem::File psFile(Utils::String::VA("ps/%s.iw4xPS", name.data())); + if (!psFile.exists()) return; - Utils::Stream::Reader reader(builder->getAllocator(), psFile.getBuffer()); + Utils::Stream::Reader reader(builder->getAllocator(), psFile.getBuffer()); - char* magic = reader.readArray(8); - if (std::memcmp(magic, "IW4xPIXL", 8)) - { - Components::Logger::Error(Game::ERR_FATAL, "Reading pixel shader '{}' failed, header is invalid!", name); - } + char* magic = reader.readArray(8); + if (std::memcmp(magic, "IW4xPIXL", 8)) + { + Components::Logger::Error(Game::ERR_FATAL, "Reading pixel shader '{}' failed, header is invalid!", name); + } - std::string version; - version.push_back(reader.read()); - if (version != IW4X_TECHSET_VERSION) - { - Components::Logger::Error(Game::ERR_FATAL, - "Reading pixel shader '{}' failed, expected version is {}, but it was {}!", name, IW4X_TECHSET_VERSION, version); - } + std::string version; + version.push_back(reader.read()); + if (version != IW4X_TECHSET_VERSION) + { + Components::Logger::Error(Game::ERR_FATAL, + "Reading pixel shader '{}' failed, expected version is {}, but it was {}!", name, IW4X_TECHSET_VERSION, version); + } - Game::MaterialPixelShader* asset = reader.readObject(); + Game::MaterialPixelShader* asset = reader.readObject(); - if (asset->name) - { - asset->name = reader.readCString(); - } + if (asset->name) + { + asset->name = reader.readCString(); + } - if (asset->prog.loadDef.program) - { - asset->prog.loadDef.program = reader.readArray(asset->prog.loadDef.programSize); - } + if (asset->prog.loadDef.program) + { + asset->prog.loadDef.program = reader.readArray(asset->prog.loadDef.programSize); + } - header->pixelShader = asset; - } + header->pixelShader = asset; + } void IMaterialPixelShader::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) { diff --git a/src/Components/Modules/AssetInterfaces/IMaterialPixelShader.hpp b/src/Components/Modules/AssetInterfaces/IMaterialPixelShader.hpp index 914f9bc2..3705dce1 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterialPixelShader.hpp +++ b/src/Components/Modules/AssetInterfaces/IMaterialPixelShader.hpp @@ -5,12 +5,12 @@ namespace Assets class IMaterialPixelShader : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_PIXELSHADER; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_PIXELSHADER; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; - void loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder); - void loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder); + void loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder); + void loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder); }; } diff --git a/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.cpp b/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.cpp index 1ca15ff1..30364266 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.cpp +++ b/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.cpp @@ -1,143 +1,144 @@ #include +#include "IMaterialTechniqueSet.hpp" #define IW4X_TECHSET_VERSION "0" namespace Assets { - void IMaterialTechniqueSet::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) - { - if (!header->data) this->loadNative(header, name, builder); // Check if there is a native one - if (!header->data) this->loadBinary(header, name, builder); // Check if we need to import a new one into the game - } + void IMaterialTechniqueSet::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) + { + if (!header->data) this->loadNative(header, name, builder); // Check if there is a native one + if (!header->data) this->loadBinary(header, name, builder); // Check if we need to import a new one into the game + } - void IMaterialTechniqueSet::loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/) - { - header->techniqueSet = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).techniqueSet; - } + void IMaterialTechniqueSet::loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/) + { + header->techniqueSet = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).techniqueSet; + } - void IMaterialTechniqueSet::loadBinaryTechnique(Game::MaterialTechnique** tech, const std::string& name, Components::ZoneBuilder::Zone* builder) - { - AssertSize(Game::MaterialPass, 20); + void IMaterialTechniqueSet::loadBinaryTechnique(Game::MaterialTechnique** tech, const std::string& name, Components::ZoneBuilder::Zone* builder) + { + AssertSize(Game::MaterialPass, 20); - Components::FileSystem::File techFile(Utils::String::VA("techniques/%s.iw4xTech", name.data())); - if (!techFile.exists()) { - *tech = nullptr; - Components::Logger::Warning(Game::CON_CHANNEL_DONT_FILTER, "Missing technique '{}'\n", name); - return; - } + Components::FileSystem::File techFile(Utils::String::VA("techniques/%s.iw4xTech", name.data())); + if (!techFile.exists()) { + *tech = nullptr; + Components::Logger::Warning(Game::CON_CHANNEL_DONT_FILTER, "Missing technique '{}'\n", name); + return; + } - Utils::Stream::Reader reader(builder->getAllocator(), techFile.getBuffer()); + Utils::Stream::Reader reader(builder->getAllocator(), techFile.getBuffer()); - char* magic = reader.readArray(8); - if (std::memcmp(magic, "IW4xTECH", 8)) - { - Components::Logger::Error(Game::ERR_FATAL, "Reading technique '{}' failed, header is invalid!", name); - } + char* magic = reader.readArray(8); + if (std::memcmp(magic, "IW4xTECH", 8)) + { + Components::Logger::Error(Game::ERR_FATAL, "Reading technique '{}' failed, header is invalid!", name); + } - std::string version; - version.push_back(reader.read()); - if (version != IW4X_TECHSET_VERSION) - { - Components::Logger::Error(Game::ERR_FATAL, + std::string version; + version.push_back(reader.read()); + if (version != IW4X_TECHSET_VERSION) + { + Components::Logger::Error(Game::ERR_FATAL, "Reading technique '{}' failed, expected version is {}, but it was {}!", name, IW4X_TECHSET_VERSION, version.data()); - } + } - unsigned short flags = reader.read(); - unsigned short passCount = reader.read(); + unsigned short flags = reader.read(); + unsigned short passCount = reader.read(); - Game::MaterialTechnique* asset = (Game::MaterialTechnique*)builder->getAllocator()->allocateArray(sizeof(Game::MaterialTechnique) + (sizeof(Game::MaterialPass) * (passCount - 1))); + Game::MaterialTechnique* asset = (Game::MaterialTechnique*)builder->getAllocator()->allocateArray(sizeof(Game::MaterialTechnique) + (sizeof(Game::MaterialPass) * (passCount - 1))); - asset->name = builder->getAllocator()->duplicateString(name); - asset->flags = flags; - asset->passCount = passCount; + asset->name = builder->getAllocator()->duplicateString(name); + asset->flags = flags; + asset->passCount = passCount; - Game::MaterialPass* passes = reader.readArray(passCount); - std::memcpy(asset->passArray, passes, sizeof(Game::MaterialPass) * passCount); + Game::MaterialPass* passes = reader.readArray(passCount); + std::memcpy(asset->passArray, passes, sizeof(Game::MaterialPass) * passCount); - for (unsigned short i = 0; i < asset->passCount; i++) - { - Game::MaterialPass* pass = &asset->passArray[i]; + for (unsigned short i = 0; i < asset->passCount; i++) + { + Game::MaterialPass* pass = &asset->passArray[i]; - if (pass->vertexDecl) - { - const char* declName = reader.readCString(); - pass->vertexDecl = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_VERTEXDECL, declName, builder).vertexDecl; - } + if (pass->vertexDecl) + { + const char* declName = reader.readCString(); + pass->vertexDecl = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_VERTEXDECL, declName, builder).vertexDecl; + } - if (pass->vertexShader) - { - const char* vsName = reader.readCString(); - pass->vertexShader = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_VERTEXSHADER, vsName, builder).vertexShader; + if (pass->vertexShader) + { + const char* vsName = reader.readCString(); + pass->vertexShader = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_VERTEXSHADER, vsName, builder).vertexShader; - } + } - if (pass->pixelShader) - { - const char* psName = reader.readCString(); - pass->pixelShader = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_PIXELSHADER, psName, builder).pixelShader; - } + if (pass->pixelShader) + { + const char* psName = reader.readCString(); + pass->pixelShader = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_PIXELSHADER, psName, builder).pixelShader; + } - pass->args = reader.readArray(pass->perPrimArgCount + pass->perObjArgCount + pass->stableArgCount); + pass->args = reader.readArray(pass->perPrimArgCount + pass->perObjArgCount + pass->stableArgCount); - for (int j = 0; j < pass->perPrimArgCount + pass->perObjArgCount + pass->stableArgCount; j++) - { - if (pass->args[j].type == 1 || pass->args[j].type == 7) - { - pass->args[j].u.literalConst = reader.readArray(4); - } + for (int j = 0; j < pass->perPrimArgCount + pass->perObjArgCount + pass->stableArgCount; j++) + { + if (pass->args[j].type == 1 || pass->args[j].type == 7) + { + pass->args[j].u.literalConst = reader.readArray(4); + } - if (pass->args[j].type == 3 || pass->args[j].type == 5) - { - pass->args[j].u.codeConst.index = *reader.readObject(); - pass->args[j].u.codeConst.firstRow = *reader.readObject(); - pass->args[j].u.codeConst.rowCount = *reader.readObject(); - } - } - } + if (pass->args[j].type == 3 || pass->args[j].type == 5) + { + pass->args[j].u.codeConst.index = *reader.readObject(); + pass->args[j].u.codeConst.firstRow = *reader.readObject(); + pass->args[j].u.codeConst.rowCount = *reader.readObject(); + } + } + } - *tech = asset; - } + *tech = asset; + } - void IMaterialTechniqueSet::loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) - { - Components::FileSystem::File tsFile(Utils::String::VA("techsets/%s.iw4xTS", name.data())); - if (!tsFile.exists()) return; + void IMaterialTechniqueSet::loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) + { + Components::FileSystem::File tsFile(Utils::String::VA("techsets/%s.iw4xTS", name.data())); + if (!tsFile.exists()) return; - Utils::Stream::Reader reader(builder->getAllocator(), tsFile.getBuffer()); + Utils::Stream::Reader reader(builder->getAllocator(), tsFile.getBuffer()); - char* magic = reader.readArray(8); - if (std::memcmp(magic, "IW4xTSET", 8)) - { - Components::Logger::Error(Game::ERR_FATAL, "Reading techset '{}' failed, header is invalid!", name); - } + char* magic = reader.readArray(8); + if (std::memcmp(magic, "IW4xTSET", 8)) + { + Components::Logger::Error(Game::ERR_FATAL, "Reading techset '{}' failed, header is invalid!", name); + } - std::string version; - version.push_back(reader.read()); - if (version != IW4X_TECHSET_VERSION) - { - Components::Logger::Error(Game::ERR_FATAL, "Reading techset '{}' failed, expected version is {}, but it was {}!", + std::string version; + version.push_back(reader.read()); + if (version != IW4X_TECHSET_VERSION) + { + Components::Logger::Error(Game::ERR_FATAL, "Reading techset '{}' failed, expected version is {}, but it was {}!", name, IW4X_TECHSET_VERSION, version); - } + } - Game::MaterialTechniqueSet* asset = reader.readObject(); + Game::MaterialTechniqueSet* asset = reader.readObject(); - if (asset->name) - { - asset->name = reader.readCString(); - } + if (asset->name) + { + asset->name = reader.readCString(); + } - for (int i = 0; i < 48; i++) - { - if (asset->techniques[i]) - { - const char* techName = reader.readCString(); - this->loadBinaryTechnique(&asset->techniques[i], techName, builder); - } - } + for (int i = 0; i < 48; i++) + { + if (asset->techniques[i]) + { + const char* techName = reader.readCString(); + this->loadBinaryTechnique(&asset->techniques[i], techName, builder); + } + } - header->techniqueSet = asset; - } + header->techniqueSet = asset; + } void IMaterialTechniqueSet::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) { diff --git a/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.hpp b/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.hpp index d5453249..9978b6cd 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.hpp +++ b/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.hpp @@ -5,15 +5,15 @@ namespace Assets class IMaterialTechniqueSet : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_TECHNIQUE_SET; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_TECHNIQUE_SET; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; - void loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder); - void loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder); + void loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder); + void loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder); - void loadBinaryTechnique(Game::MaterialTechnique** tech, const std::string& name, Components::ZoneBuilder::Zone* builder); + void loadBinaryTechnique(Game::MaterialTechnique** tech, const std::string& name, Components::ZoneBuilder::Zone* builder); }; } diff --git a/src/Components/Modules/AssetInterfaces/IMaterialVertexDeclaration.cpp b/src/Components/Modules/AssetInterfaces/IMaterialVertexDeclaration.cpp index 5fceac6d..2b506f05 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterialVertexDeclaration.cpp +++ b/src/Components/Modules/AssetInterfaces/IMaterialVertexDeclaration.cpp @@ -1,50 +1,51 @@ #include +#include "IMaterialVertexDeclaration.hpp" #define IW4X_TECHSET_VERSION "0" namespace Assets { - void IMaterialVertexDeclaration::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) - { - if (!header->data) this->loadNative(header, name, builder); // Check if there is a native one - if (!header->data) this->loadBinary(header, name, builder); // Check if we need to import a new one into the game - } + void IMaterialVertexDeclaration::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) + { + if (!header->data) this->loadNative(header, name, builder); // Check if there is a native one + if (!header->data) this->loadBinary(header, name, builder); // Check if we need to import a new one into the game + } - void IMaterialVertexDeclaration::loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/) - { - header->vertexDecl = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).vertexDecl; - } + void IMaterialVertexDeclaration::loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/) + { + header->vertexDecl = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).vertexDecl; + } - void IMaterialVertexDeclaration::loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) - { - Components::FileSystem::File declFile(Utils::String::VA("decl/%s.iw4xDECL", name.data())); - if (!declFile.exists()) return; + void IMaterialVertexDeclaration::loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) + { + Components::FileSystem::File declFile(Utils::String::VA("decl/%s.iw4xDECL", name.data())); + if (!declFile.exists()) return; - Utils::Stream::Reader reader(builder->getAllocator(), declFile.getBuffer()); + Utils::Stream::Reader reader(builder->getAllocator(), declFile.getBuffer()); - char* magic = reader.readArray(8); - if (std::memcmp(magic, "IW4xDECL", 8)) - { - Components::Logger::Error(Game::ERR_FATAL, "Reading vertex declaration '{}' failed, header is invalid!", name); - } + char* magic = reader.readArray(8); + if (std::memcmp(magic, "IW4xDECL", 8)) + { + Components::Logger::Error(Game::ERR_FATAL, "Reading vertex declaration '{}' failed, header is invalid!", name); + } - std::string version; - version.push_back(reader.read()); - if (version != IW4X_TECHSET_VERSION) - { - Components::Logger::Error(Game::ERR_FATAL, "Reading vertex declaration '{}' failed, expected version is {}, but it was {}!", - name, IW4X_TECHSET_VERSION, version.data()); - } + std::string version; + version.push_back(reader.read()); + if (version != IW4X_TECHSET_VERSION) + { + Components::Logger::Error(Game::ERR_FATAL, "Reading vertex declaration '{}' failed, expected version is {}, but it was {}!", + name, IW4X_TECHSET_VERSION, version.data()); + } - Game::MaterialVertexDeclaration* asset = reader.readObject(); + Game::MaterialVertexDeclaration* asset = reader.readObject(); - if (asset->name) - { - asset->name = reader.readCString(); - } + if (asset->name) + { + asset->name = reader.readCString(); + } - header->vertexDecl = asset; - } + header->vertexDecl = asset; + } void IMaterialVertexDeclaration::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) { diff --git a/src/Components/Modules/AssetInterfaces/IMaterialVertexDeclaration.hpp b/src/Components/Modules/AssetInterfaces/IMaterialVertexDeclaration.hpp index d774f05a..e4bce229 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterialVertexDeclaration.hpp +++ b/src/Components/Modules/AssetInterfaces/IMaterialVertexDeclaration.hpp @@ -5,12 +5,12 @@ namespace Assets class IMaterialVertexDeclaration : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_VERTEXDECL; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_VERTEXDECL; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; - void loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder); - void loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder); + void loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder); + void loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder); }; } diff --git a/src/Components/Modules/AssetInterfaces/IMaterialVertexShader.cpp b/src/Components/Modules/AssetInterfaces/IMaterialVertexShader.cpp index a8fd5d1d..bf786e52 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterialVertexShader.cpp +++ b/src/Components/Modules/AssetInterfaces/IMaterialVertexShader.cpp @@ -1,55 +1,56 @@ -#include +#include +#include "IMaterialVertexShader.hpp" #define IW4X_TECHSET_VERSION "0" namespace Assets { - void IMaterialVertexShader::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) - { - if (!header->data) this->loadNative(header, name, builder); // Check if there is a native one - if (!header->data) this->loadBinary(header, name, builder); // Check if we need to import a new one into the game - } + void IMaterialVertexShader::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) + { + if (!header->data) this->loadNative(header, name, builder); // Check if there is a native one + if (!header->data) this->loadBinary(header, name, builder); // Check if we need to import a new one into the game + } - void IMaterialVertexShader::loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/) - { - header->vertexShader = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).vertexShader; - } + void IMaterialVertexShader::loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/) + { + header->vertexShader = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).vertexShader; + } - void IMaterialVertexShader::loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) - { - Components::FileSystem::File vsFile(Utils::String::VA("vs/%s.iw4xVS", name.data())); - if (!vsFile.exists()) return; + void IMaterialVertexShader::loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) + { + Components::FileSystem::File vsFile(Utils::String::VA("vs/%s.iw4xVS", name.data())); + if (!vsFile.exists()) return; - Utils::Stream::Reader reader(builder->getAllocator(), vsFile.getBuffer()); + Utils::Stream::Reader reader(builder->getAllocator(), vsFile.getBuffer()); - char* magic = reader.readArray(8); - if (std::memcmp(magic, "IW4xVERT", 8)) - { - Components::Logger::Error(Game::ERR_FATAL, "Reading vertex shader '{}' failed, header is invalid!", name); - } + char* magic = reader.readArray(8); + if (std::memcmp(magic, "IW4xVERT", 8)) + { + Components::Logger::Error(Game::ERR_FATAL, "Reading vertex shader '{}' failed, header is invalid!", name); + } - std::string version; - version.push_back(reader.read()); - if (version != IW4X_TECHSET_VERSION) - { - Components::Logger::Error(Game::ERR_FATAL, "Reading vertex shader '{}' failed, expected version is {}, but it was {}!", - name, IW4X_TECHSET_VERSION, version); - } + std::string version; + version.push_back(reader.read()); + if (version != IW4X_TECHSET_VERSION) + { + Components::Logger::Error(Game::ERR_FATAL, "Reading vertex shader '{}' failed, expected version is {}, but it was {}!", + name, IW4X_TECHSET_VERSION, version); + } - Game::MaterialVertexShader* asset = reader.readObject(); + Game::MaterialVertexShader* asset = reader.readObject(); - if (asset->name) - { - asset->name = reader.readCString(); - } + if (asset->name) + { + asset->name = reader.readCString(); + } - if (asset->prog.loadDef.program) - { - asset->prog.loadDef.program = reader.readArray(asset->prog.loadDef.programSize); - } + if (asset->prog.loadDef.program) + { + asset->prog.loadDef.program = reader.readArray(asset->prog.loadDef.programSize); + } - header->vertexShader = asset; - } + header->vertexShader = asset; + } void IMaterialVertexShader::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) { diff --git a/src/Components/Modules/AssetInterfaces/IMaterialVertexShader.hpp b/src/Components/Modules/AssetInterfaces/IMaterialVertexShader.hpp index 25150635..f84eda27 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterialVertexShader.hpp +++ b/src/Components/Modules/AssetInterfaces/IMaterialVertexShader.hpp @@ -5,12 +5,12 @@ namespace Assets class IMaterialVertexShader : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_VERTEXSHADER; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_VERTEXSHADER; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; - void loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder); - void loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder); + void loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder); + void loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder); }; } diff --git a/src/Components/Modules/AssetInterfaces/IMenuList.cpp b/src/Components/Modules/AssetInterfaces/IMenuList.cpp index 44c7e5d9..dd9fd1fe 100644 --- a/src/Components/Modules/AssetInterfaces/IMenuList.cpp +++ b/src/Components/Modules/AssetInterfaces/IMenuList.cpp @@ -1,37 +1,38 @@ #include +#include "IMenuList.hpp" namespace Assets { - void IMenuList::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) - { - Utils::Memory::Allocator* allocator = builder->getAllocator(); + void IMenuList::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) + { + Utils::Memory::Allocator* allocator = builder->getAllocator(); - // actually gets the whole list - auto menus = Components::Menus::LoadMenu(name); - if (menus.empty()) return; + // actually gets the whole list + auto menus = Components::Menus::LoadMenu(name); + if (menus.empty()) return; - // Allocate new menu list - Game::MenuList* newList = allocator->allocate(); - if (!newList) return; + // Allocate new menu list + Game::MenuList* newList = allocator->allocate(); + if (!newList) return; - newList->menus = allocator->allocateArray(menus.size()); - if (!newList->menus) - { - allocator->free(newList); - return; - } + newList->menus = allocator->allocateArray(menus.size()); + if (!newList->menus) + { + allocator->free(newList); + return; + } - newList->name = allocator->duplicateString(name); - newList->menuCount = menus.size(); + newList->name = allocator->duplicateString(name); + newList->menuCount = menus.size(); - // Copy new menus - for (unsigned int i = 0; i < menus.size(); ++i) - { - newList->menus[i] = menus[i].second; - } + // Copy new menus + for (unsigned int i = 0; i < menus.size(); ++i) + { + newList->menus[i] = menus[i].second; + } - header->menuList = newList; - } + header->menuList = newList; + } void IMenuList::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) { Game::MenuList *asset = header.menuList; diff --git a/src/Components/Modules/AssetInterfaces/IMenuList.hpp b/src/Components/Modules/AssetInterfaces/IMenuList.hpp index fd0a72f9..23c60695 100644 --- a/src/Components/Modules/AssetInterfaces/IMenuList.hpp +++ b/src/Components/Modules/AssetInterfaces/IMenuList.hpp @@ -5,10 +5,10 @@ namespace Assets class IMenuList : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_MENULIST; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_MENULIST; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; }; } diff --git a/src/Components/Modules/AssetInterfaces/IPhysCollmap.cpp b/src/Components/Modules/AssetInterfaces/IPhysCollmap.cpp index ed5c9c0c..2dd01716 100644 --- a/src/Components/Modules/AssetInterfaces/IPhysCollmap.cpp +++ b/src/Components/Modules/AssetInterfaces/IPhysCollmap.cpp @@ -1,4 +1,5 @@ #include +#include "IPhysCollmap.hpp" namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IPhysCollmap.hpp b/src/Components/Modules/AssetInterfaces/IPhysCollmap.hpp index 1dcac3ea..fd42c7e1 100644 --- a/src/Components/Modules/AssetInterfaces/IPhysCollmap.hpp +++ b/src/Components/Modules/AssetInterfaces/IPhysCollmap.hpp @@ -5,9 +5,9 @@ namespace Assets class IPhysCollmap : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_PHYSCOLLMAP; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_PHYSCOLLMAP; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; private: void savePhysGeomInfoArray(Components::ZoneBuilder::Zone* builder, Game::PhysGeomInfo* geoms, unsigned int count); diff --git a/src/Components/Modules/AssetInterfaces/IPhysPreset.cpp b/src/Components/Modules/AssetInterfaces/IPhysPreset.cpp index 998ba165..ad753a5c 100644 --- a/src/Components/Modules/AssetInterfaces/IPhysPreset.cpp +++ b/src/Components/Modules/AssetInterfaces/IPhysPreset.cpp @@ -1,4 +1,5 @@ #include +#include "IPhysPreset.hpp" namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IPhysPreset.hpp b/src/Components/Modules/AssetInterfaces/IPhysPreset.hpp index 4cbfeb6f..f3939a08 100644 --- a/src/Components/Modules/AssetInterfaces/IPhysPreset.hpp +++ b/src/Components/Modules/AssetInterfaces/IPhysPreset.hpp @@ -5,8 +5,8 @@ namespace Assets class IPhysPreset : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_PHYSPRESET; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_PHYSPRESET; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; }; } diff --git a/src/Components/Modules/AssetInterfaces/IRawFile.cpp b/src/Components/Modules/AssetInterfaces/IRawFile.cpp index 19638490..109d9a26 100644 --- a/src/Components/Modules/AssetInterfaces/IRawFile.cpp +++ b/src/Components/Modules/AssetInterfaces/IRawFile.cpp @@ -1,4 +1,5 @@ #include +#include "IRawFile.hpp" namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IRawFile.hpp b/src/Components/Modules/AssetInterfaces/IRawFile.hpp index f441a613..b4c1b818 100644 --- a/src/Components/Modules/AssetInterfaces/IRawFile.hpp +++ b/src/Components/Modules/AssetInterfaces/IRawFile.hpp @@ -5,9 +5,9 @@ namespace Assets class IRawFile : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_RAWFILE; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_RAWFILE; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; }; } diff --git a/src/Components/Modules/AssetInterfaces/ISndCurve.cpp b/src/Components/Modules/AssetInterfaces/ISndCurve.cpp index 205fe210..1a7d0f01 100644 --- a/src/Components/Modules/AssetInterfaces/ISndCurve.cpp +++ b/src/Components/Modules/AssetInterfaces/ISndCurve.cpp @@ -1,4 +1,5 @@ #include +#include "ISndCurve.hpp" namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/ISndCurve.hpp b/src/Components/Modules/AssetInterfaces/ISndCurve.hpp index 69609f5c..0b0d7564 100644 --- a/src/Components/Modules/AssetInterfaces/ISndCurve.hpp +++ b/src/Components/Modules/AssetInterfaces/ISndCurve.hpp @@ -5,8 +5,8 @@ namespace Assets class ISndCurve : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_SOUND_CURVE; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_SOUND_CURVE; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; }; } diff --git a/src/Components/Modules/AssetInterfaces/IStringTable.cpp b/src/Components/Modules/AssetInterfaces/IStringTable.cpp index c6c1d4cc..e7997114 100644 --- a/src/Components/Modules/AssetInterfaces/IStringTable.cpp +++ b/src/Components/Modules/AssetInterfaces/IStringTable.cpp @@ -1,4 +1,5 @@ #include +#include "IStringTable.hpp" namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IStringTable.hpp b/src/Components/Modules/AssetInterfaces/IStringTable.hpp index eaf829cc..5f221333 100644 --- a/src/Components/Modules/AssetInterfaces/IStringTable.hpp +++ b/src/Components/Modules/AssetInterfaces/IStringTable.hpp @@ -5,9 +5,9 @@ namespace Assets class IStringTable : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_STRINGTABLE; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_STRINGTABLE; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; private: void saveStringTableCellArray(Components::ZoneBuilder::Zone* builder, Game::StringTableCell* values, int count); diff --git a/src/Components/Modules/AssetInterfaces/IStructuredDataDefSet.cpp b/src/Components/Modules/AssetInterfaces/IStructuredDataDefSet.cpp index d96757a6..4f6ea2e0 100644 --- a/src/Components/Modules/AssetInterfaces/IStructuredDataDefSet.cpp +++ b/src/Components/Modules/AssetInterfaces/IStructuredDataDefSet.cpp @@ -1,4 +1,5 @@ #include +#include "IStructuredDataDefSet.hpp" namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/IStructuredDataDefSet.hpp b/src/Components/Modules/AssetInterfaces/IStructuredDataDefSet.hpp index b1ecf921..7b5912bc 100644 --- a/src/Components/Modules/AssetInterfaces/IStructuredDataDefSet.hpp +++ b/src/Components/Modules/AssetInterfaces/IStructuredDataDefSet.hpp @@ -5,9 +5,9 @@ namespace Assets class IStructuredDataDefSet : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_STRUCTURED_DATA_DEF; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_STRUCTURED_DATA_DEF; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; void saveStructuredDataEnumArray(Game::StructuredDataEnum* enums, int numEnums, Components::ZoneBuilder::Zone* builder); void saveStructuredDataStructArray(Game::StructuredDataStruct* structs, int numStructs, Components::ZoneBuilder::Zone* builder); diff --git a/src/Components/Modules/AssetInterfaces/ITracerDef.cpp b/src/Components/Modules/AssetInterfaces/ITracerDef.cpp index e94fb86a..98962180 100644 --- a/src/Components/Modules/AssetInterfaces/ITracerDef.cpp +++ b/src/Components/Modules/AssetInterfaces/ITracerDef.cpp @@ -1,44 +1,45 @@ #include +#include "ITracerDef.hpp" namespace Assets { - void ITracerDef::load(Game::XAssetHeader* /*header*/, const std::string& /*name*/, Components::ZoneBuilder::Zone* /*builder*/) - { - return; // don't load from filesystem right now - } + void ITracerDef::load(Game::XAssetHeader* /*header*/, const std::string& /*name*/, Components::ZoneBuilder::Zone* /*builder*/) + { + // don't load from filesystem right now + } - void ITracerDef::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) - { - Game::TracerDef* asset = header.tracerDef; + void ITracerDef::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) + { + Game::TracerDef* asset = header.tracerDef; - if (asset->material) - { - builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->material); - } - } + if (asset->material) + { + builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->material); + } + } - void ITracerDef::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) - { - AssertSize(Game::TracerDef, 0x70); + void ITracerDef::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) + { + AssertSize(Game::TracerDef, 0x70); - Utils::Stream* buffer = builder->getBuffer(); - Game::TracerDef* asset = header.tracerDef; - Game::TracerDef* dest = buffer->dest(); - buffer->save(asset); + Utils::Stream* buffer = builder->getBuffer(); + Game::TracerDef* asset = header.tracerDef; + Game::TracerDef* dest = buffer->dest(); + buffer->save(asset); - buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL); + buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL); - if (asset->name) - { - buffer->saveString(builder->getAssetName(this->getType(), asset->name)); - Utils::Stream::ClearPointer(&dest->name); - } + if (asset->name) + { + buffer->saveString(builder->getAssetName(this->getType(), asset->name)); + Utils::Stream::ClearPointer(&dest->name); + } - if (asset->material) - { - dest->material = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->material).material; - } + if (asset->material) + { + dest->material = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->material).material; + } - buffer->popBlock(); - } + buffer->popBlock(); + } } diff --git a/src/Components/Modules/AssetInterfaces/ITracerDef.hpp b/src/Components/Modules/AssetInterfaces/ITracerDef.hpp index cb78484b..0028d628 100644 --- a/src/Components/Modules/AssetInterfaces/ITracerDef.hpp +++ b/src/Components/Modules/AssetInterfaces/ITracerDef.hpp @@ -2,13 +2,13 @@ namespace Assets { - class ITracerDef : public Components::AssetHandler::IAsset - { - public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_TRACER; }; + class ITracerDef : public Components::AssetHandler::IAsset + { + public: + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_TRACER; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; - }; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + }; } diff --git a/src/Components/Modules/AssetInterfaces/IWeapon.cpp b/src/Components/Modules/AssetInterfaces/IWeapon.cpp index abc6f5d3..be6f6946 100644 --- a/src/Components/Modules/AssetInterfaces/IWeapon.cpp +++ b/src/Components/Modules/AssetInterfaces/IWeapon.cpp @@ -1,695 +1,696 @@ #include +#include "IWeapon.hpp" namespace Assets { void IWeapon::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/) { - // Try loading raw weapon - if (Components::FileSystem::File(Utils::String::VA("weapons/mp/%s", name.data())).exists()) - { - // let the function see temporary assets when calling DB_FindXAssetHeader during the loading function - // otherwise it fails to link things properly - Components::AssetHandler::ExposeTemporaryAssets(true); - header->data = Game::BG_LoadWeaponDef_LoadObj(name.data()); - Components::AssetHandler::ExposeTemporaryAssets(false); - } + // Try loading raw weapon + if (Components::FileSystem::File(Utils::String::VA("weapons/mp/%s", name.data())).exists()) + { + // let the function see temporary assets when calling DB_FindXAssetHeader during the loading function + // otherwise it fails to link things properly + Components::AssetHandler::ExposeTemporaryAssets(true); + header->data = Game::BG_LoadWeaponDef_LoadObj(name.data()); + Components::AssetHandler::ExposeTemporaryAssets(false); + } } - void IWeapon::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) - { - Game::WeaponCompleteDef* asset = header.weapon; + void IWeapon::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) + { + Game::WeaponCompleteDef* asset = header.weapon; - // convert all script strings - if (asset->hideTags) - { - for (char i = 0; i < 32; ++i) - { - if (asset->hideTags[i] == NULL) break; // no more strings - builder->addScriptString(asset->hideTags[i]); - } - } + // convert all script strings + if (asset->hideTags) + { + for (char i = 0; i < 32; ++i) + { + if (asset->hideTags[i] == NULL) break; // no more strings + builder->addScriptString(asset->hideTags[i]); + } + } - if (asset->weapDef->notetrackSoundMapKeys) - { - for (char i = 0; i < 16; ++i) - { - if (asset->weapDef->notetrackSoundMapKeys[i] == NULL) break; // no more strings - builder->addScriptString(asset->weapDef->notetrackSoundMapKeys[i]); - } - } + if (asset->weapDef->notetrackSoundMapKeys) + { + for (char i = 0; i < 16; ++i) + { + if (asset->weapDef->notetrackSoundMapKeys[i] == NULL) break; // no more strings + builder->addScriptString(asset->weapDef->notetrackSoundMapKeys[i]); + } + } - if (asset->weapDef->notetrackSoundMapValues) - { - for (char i = 0; i < 16; ++i) - { - if (asset->weapDef->notetrackSoundMapValues[i] == NULL) break; // no more strings - builder->addScriptString(asset->weapDef->notetrackSoundMapValues[i]); - } - } + if (asset->weapDef->notetrackSoundMapValues) + { + for (char i = 0; i < 16; ++i) + { + if (asset->weapDef->notetrackSoundMapValues[i] == NULL) break; // no more strings + builder->addScriptString(asset->weapDef->notetrackSoundMapValues[i]); + } + } - if (asset->weapDef->notetrackRumbleMapKeys) - { - for (char i = 0; i < 16; ++i) - { - if (asset->weapDef->notetrackRumbleMapKeys[i] == NULL) break; // no more strings - builder->addScriptString(asset->weapDef->notetrackRumbleMapKeys[i]); - } - } + if (asset->weapDef->notetrackRumbleMapKeys) + { + for (char i = 0; i < 16; ++i) + { + if (asset->weapDef->notetrackRumbleMapKeys[i] == NULL) break; // no more strings + builder->addScriptString(asset->weapDef->notetrackRumbleMapKeys[i]); + } + } - if (asset->weapDef->notetrackRumbleMapValues) - { - for (char i = 0; i < 16; ++i) - { - if (asset->weapDef->notetrackRumbleMapValues[i] == NULL) break; // no more strings - builder->addScriptString(asset->weapDef->notetrackRumbleMapValues[i]); - } - } + if (asset->weapDef->notetrackRumbleMapValues) + { + for (char i = 0; i < 16; ++i) + { + if (asset->weapDef->notetrackRumbleMapValues[i] == NULL) break; // no more strings + builder->addScriptString(asset->weapDef->notetrackRumbleMapValues[i]); + } + } - // now load all sub-assets properly - if (asset->killIcon) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->killIcon); - if (asset->dpadIcon) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->dpadIcon); - if (asset->weapDef->reticleCenter) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->weapDef->reticleCenter); - if (asset->weapDef->reticleSide) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->weapDef->reticleSide); - if (asset->weapDef->hudIcon) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->weapDef->hudIcon); - if (asset->weapDef->pickupIcon) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->weapDef->pickupIcon); - if (asset->weapDef->ammoCounterIcon) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->weapDef->ammoCounterIcon); - if (asset->weapDef->overlayMaterial) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->weapDef->overlayMaterial); - if (asset->weapDef->overlayMaterialLowRes) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->weapDef->overlayMaterialLowRes); - if (asset->weapDef->overlayMaterialEMP) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->weapDef->overlayMaterialEMP); - if (asset->weapDef->overlayMaterialEMPLowRes) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->weapDef->overlayMaterialEMPLowRes); + // now load all sub-assets properly + if (asset->killIcon) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->killIcon); + if (asset->dpadIcon) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->dpadIcon); + if (asset->weapDef->reticleCenter) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->weapDef->reticleCenter); + if (asset->weapDef->reticleSide) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->weapDef->reticleSide); + if (asset->weapDef->hudIcon) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->weapDef->hudIcon); + if (asset->weapDef->pickupIcon) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->weapDef->pickupIcon); + if (asset->weapDef->ammoCounterIcon) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->weapDef->ammoCounterIcon); + if (asset->weapDef->overlayMaterial) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->weapDef->overlayMaterial); + if (asset->weapDef->overlayMaterialLowRes) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->weapDef->overlayMaterialLowRes); + if (asset->weapDef->overlayMaterialEMP) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->weapDef->overlayMaterialEMP); + if (asset->weapDef->overlayMaterialEMPLowRes) builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->weapDef->overlayMaterialEMPLowRes); - if (asset->weapDef->gunXModel) - { - for (int i = 0; i < 16; i++) - { - if (asset->weapDef->gunXModel[i]) builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, asset->weapDef->gunXModel[i]); - } - } + if (asset->weapDef->gunXModel) + { + for (int i = 0; i < 16; i++) + { + if (asset->weapDef->gunXModel[i]) builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, asset->weapDef->gunXModel[i]); + } + } - if (asset->weapDef->handXModel) builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, asset->weapDef->handXModel); + if (asset->weapDef->handXModel) builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, asset->weapDef->handXModel); - if (asset->weapDef->worldModel) - { - for (int i = 0; i < 16; i++) - { - if (asset->weapDef->worldModel[i]) builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, asset->weapDef->worldModel[i]); - } - } + if (asset->weapDef->worldModel) + { + for (int i = 0; i < 16; i++) + { + if (asset->weapDef->worldModel[i]) builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, asset->weapDef->worldModel[i]); + } + } - if (asset->weapDef->worldClipModel) builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, asset->weapDef->worldClipModel); - if (asset->weapDef->rocketModel) builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, asset->weapDef->rocketModel); - if (asset->weapDef->knifeModel) builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, asset->weapDef->knifeModel); - if (asset->weapDef->worldKnifeModel) builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, asset->weapDef->worldKnifeModel); - if (asset->weapDef->projectileModel) builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, asset->weapDef->projectileModel); + if (asset->weapDef->worldClipModel) builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, asset->weapDef->worldClipModel); + if (asset->weapDef->rocketModel) builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, asset->weapDef->rocketModel); + if (asset->weapDef->knifeModel) builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, asset->weapDef->knifeModel); + if (asset->weapDef->worldKnifeModel) builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, asset->weapDef->worldKnifeModel); + if (asset->weapDef->projectileModel) builder->loadAsset(Game::XAssetType::ASSET_TYPE_XMODEL, asset->weapDef->projectileModel); - if (asset->weapDef->physCollmap) builder->loadAsset(Game::XAssetType::ASSET_TYPE_PHYSCOLLMAP, asset->weapDef->physCollmap); + if (asset->weapDef->physCollmap) builder->loadAsset(Game::XAssetType::ASSET_TYPE_PHYSCOLLMAP, asset->weapDef->physCollmap); - if (asset->weapDef->tracerType) builder->loadAsset(Game::XAssetType::ASSET_TYPE_TRACER, asset->weapDef->tracerType); + if (asset->weapDef->tracerType) builder->loadAsset(Game::XAssetType::ASSET_TYPE_TRACER, asset->weapDef->tracerType); - if (asset->weapDef->viewFlashEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->viewFlashEffect); - if (asset->weapDef->worldFlashEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->worldFlashEffect); - if (asset->weapDef->viewShellEjectEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->viewShellEjectEffect); - if (asset->weapDef->worldShellEjectEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->worldShellEjectEffect); - if (asset->weapDef->viewLastShotEjectEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->viewLastShotEjectEffect); - if (asset->weapDef->worldLastShotEjectEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->worldLastShotEjectEffect); - if (asset->weapDef->projExplosionEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->projExplosionEffect); - if (asset->weapDef->projDudEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->projDudEffect); - if (asset->weapDef->projTrailEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->projTrailEffect); - if (asset->weapDef->projBeaconEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->projBeaconEffect); - if (asset->weapDef->projIgnitionEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->projIgnitionEffect); - if (asset->weapDef->turretOverheatEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->turretOverheatEffect); + if (asset->weapDef->viewFlashEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->viewFlashEffect); + if (asset->weapDef->worldFlashEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->worldFlashEffect); + if (asset->weapDef->viewShellEjectEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->viewShellEjectEffect); + if (asset->weapDef->worldShellEjectEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->worldShellEjectEffect); + if (asset->weapDef->viewLastShotEjectEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->viewLastShotEjectEffect); + if (asset->weapDef->worldLastShotEjectEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->worldLastShotEjectEffect); + if (asset->weapDef->projExplosionEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->projExplosionEffect); + if (asset->weapDef->projDudEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->projDudEffect); + if (asset->weapDef->projTrailEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->projTrailEffect); + if (asset->weapDef->projBeaconEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->projBeaconEffect); + if (asset->weapDef->projIgnitionEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->projIgnitionEffect); + if (asset->weapDef->turretOverheatEffect) builder->loadAsset(Game::XAssetType::ASSET_TYPE_FX, asset->weapDef->turretOverheatEffect); #define LoadWeapSound(sound) if (asset->weapDef->##sound##) builder->loadAsset(Game::XAssetType::ASSET_TYPE_SOUND, asset->weapDef->##sound##) - LoadWeapSound(pickupSound); - LoadWeapSound(pickupSoundPlayer); - LoadWeapSound(ammoPickupSound); - LoadWeapSound(ammoPickupSoundPlayer); - LoadWeapSound(projectileSound); - LoadWeapSound(pullbackSound); - LoadWeapSound(pullbackSoundPlayer); - LoadWeapSound(fireSound); - LoadWeapSound(fireSoundPlayer); - LoadWeapSound(fireSoundPlayerAkimbo); - LoadWeapSound(fireLoopSound); - LoadWeapSound(fireLoopSoundPlayer); - LoadWeapSound(fireStopSound); - LoadWeapSound(fireStopSoundPlayer); - LoadWeapSound(fireLastSound); - LoadWeapSound(fireLastSoundPlayer); - LoadWeapSound(emptyFireSound); - LoadWeapSound(emptyFireSoundPlayer); - LoadWeapSound(meleeSwipeSound); - LoadWeapSound(meleeSwipeSoundPlayer); - LoadWeapSound(meleeHitSound); - LoadWeapSound(meleeMissSound); - LoadWeapSound(rechamberSound); - LoadWeapSound(rechamberSoundPlayer); - LoadWeapSound(reloadSound); - LoadWeapSound(reloadSoundPlayer); - LoadWeapSound(reloadEmptySound); - LoadWeapSound(reloadEmptySoundPlayer); - LoadWeapSound(reloadStartSound); - LoadWeapSound(reloadStartSoundPlayer); - LoadWeapSound(reloadEndSound); - LoadWeapSound(reloadEndSoundPlayer); - LoadWeapSound(detonateSound); - LoadWeapSound(detonateSoundPlayer); - LoadWeapSound(nightVisionWearSound); - LoadWeapSound(nightVisionWearSoundPlayer); - LoadWeapSound(nightVisionRemoveSound); - LoadWeapSound(nightVisionRemoveSoundPlayer); - LoadWeapSound(altSwitchSound); - LoadWeapSound(altSwitchSoundPlayer); - LoadWeapSound(raiseSound); - LoadWeapSound(raiseSoundPlayer); - LoadWeapSound(firstRaiseSound); - LoadWeapSound(firstRaiseSoundPlayer); - LoadWeapSound(putawaySound); - LoadWeapSound(putawaySoundPlayer); - LoadWeapSound(scanSound); - - if (asset->weapDef->bounceSound) - { - for (size_t i = 0; i < 31; i++) - { - LoadWeapSound(bounceSound[i]); - } - } - - LoadWeapSound(projExplosionSound); - LoadWeapSound(projDudSound); - LoadWeapSound(projIgnitionSound); - LoadWeapSound(turretOverheatSound); - LoadWeapSound(turretBarrelSpinMaxSnd); - - for (size_t i = 0; i < 4; i++) - { - LoadWeapSound(turretBarrelSpinUpSnd[i]); - LoadWeapSound(turretBarrelSpinDownSnd[i]); - } - - LoadWeapSound(missileConeSoundAlias); - LoadWeapSound(missileConeSoundAliasAtBase); - } - - void IWeapon::writeWeaponDef(Game::WeaponDef* def, Components::ZoneBuilder::Zone* builder, Utils::Stream* buffer) - { - AssertSize(Game::WeaponDef, 0x684); - - Game::WeaponDef* dest = buffer->dest(); - buffer->save(def); - - if (def->szOverlayName) - { - buffer->saveString(def->szOverlayName); - Utils::Stream::ClearPointer(&dest->szOverlayName); - } - - if (def->gunXModel) - { - buffer->align(Utils::Stream::ALIGN_4); - Game::XModel** pointerTable = buffer->dest(); - buffer->saveMax(16 * sizeof(Game::XModel*)); - for (int i = 0; i < 16; i++) - { - if (!def->gunXModel[i]) - { - pointerTable[i] = NULL; - continue; - } - pointerTable[i] = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, def->gunXModel[i]).model; - } - Utils::Stream::ClearPointer(&dest->gunXModel); - } - - if (def->handXModel) - { - dest->handXModel = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, def->handXModel).model; - } - - if (def->szXAnimsRightHanded) - { - buffer->align(Utils::Stream::ALIGN_4); - int* poinerTable = buffer->dest(); - buffer->saveMax(37 * sizeof(char*)); // array of 37 string pointers - for (int i = 0; i < 37; i++) - { - if (!def->szXAnimsRightHanded[i]) { - poinerTable[i] = 0; // clear poiner if there isn't a string here - continue; - } - - // save string if it is present - buffer->saveString(def->szXAnimsRightHanded[i]); - } - - Utils::Stream::ClearPointer(&dest->szXAnimsRightHanded); - } - - if (def->szXAnimsLeftHanded) - { - buffer->align(Utils::Stream::ALIGN_4); - int* poinerTable = buffer->dest(); - buffer->saveMax(37 * sizeof(char*)); // array of 37 string pointers - for (int i = 0; i < 37; i++) - { - if (!def->szXAnimsLeftHanded[i]) { - poinerTable[i] = 0; // clear poiner if there isn't a string here - continue; - } - - // save string if it is present - buffer->saveString(def->szXAnimsLeftHanded[i]); - } - - Utils::Stream::ClearPointer(&dest->szXAnimsLeftHanded); - } - - if (def->szModeName) - { - buffer->saveString(def->szModeName); - Utils::Stream::ClearPointer(&dest->szModeName); - } - - if (def->notetrackSoundMapKeys) - { - buffer->align(Utils::Stream::ALIGN_2); - unsigned short* scriptStringTable = buffer->dest(); - buffer->saveArray(def->notetrackSoundMapKeys, 16); - for (int i = 0; i < 16; i++) { - builder->mapScriptString(&scriptStringTable[i]); - } - - Utils::Stream::ClearPointer(&dest->notetrackSoundMapKeys); - } - - if (def->notetrackSoundMapValues) - { - buffer->align(Utils::Stream::ALIGN_2); - unsigned short* scriptStringTable = buffer->dest(); - buffer->saveArray(def->notetrackSoundMapValues, 16); - for (int i = 0; i < 16; i++) { - builder->mapScriptString(&scriptStringTable[i]); - } - - Utils::Stream::ClearPointer(&dest->notetrackSoundMapValues); - } - - if (def->notetrackRumbleMapKeys) - { - buffer->align(Utils::Stream::ALIGN_2); - unsigned short* scriptStringTable = buffer->dest(); - buffer->saveArray(def->notetrackRumbleMapKeys, 16); - for (int i = 0; i < 16; i++) { - builder->mapScriptString(&scriptStringTable[i]); - } - - Utils::Stream::ClearPointer(&dest->notetrackRumbleMapKeys); - } - - if (def->notetrackRumbleMapValues) - { - buffer->align(Utils::Stream::ALIGN_2); - unsigned short* scriptStringTable = buffer->dest(); - buffer->saveArray(def->notetrackRumbleMapValues, 16); - for (int i = 0; i < 16; i++) { - builder->mapScriptString(&scriptStringTable[i]); - } - - Utils::Stream::ClearPointer(&dest->notetrackRumbleMapValues); - } - - if (def->viewFlashEffect) - { - dest->viewFlashEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->viewFlashEffect).fx; - } - - if (def->worldFlashEffect) - { - dest->worldFlashEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->worldFlashEffect).fx; - } - - // This is compressed because I don't want to write the same piece of code 47 times - // TODO: verify that this is saving the aliases correctly because the old code looks wrong and this looks right but the old code worked so go figure - Game::snd_alias_list_t ** allSounds = &def->pickupSound; - Game::snd_alias_list_t ** allSoundsDest = &dest->pickupSound; - for (int i = 0; i < 47; i++) { - if (!allSounds[i]) continue; - buffer->align(Utils::Stream::ALIGN_4); - buffer->saveMax(sizeof(Game::snd_alias_list_t*)); - buffer->saveString(allSounds[i]->aliasName); - Utils::Stream::ClearPointer(&allSoundsDest[i]); - } - - if (def->bounceSound) - { - buffer->align(Utils::Stream::ALIGN_4); - int* ptrs = buffer->dest(); - buffer->saveMax(31 * sizeof(Game::snd_alias_list_t*)); - - for (int i = 0; i < 31; i++) - { - if (!def->bounceSound[i]) - { - ptrs[i] = 0; - continue; - } - - buffer->saveMax(sizeof(Game::snd_alias_list_t*)); - buffer->saveString(def->bounceSound[i]->aliasName); - } - - Utils::Stream::ClearPointer(&dest->bounceSound); - } - - if (def->viewShellEjectEffect) - { - dest->viewShellEjectEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->viewShellEjectEffect).fx; - } - - if (def->worldShellEjectEffect) - { - dest->worldShellEjectEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->worldShellEjectEffect).fx; - } - - if (def->viewLastShotEjectEffect) - { - dest->viewLastShotEjectEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->viewLastShotEjectEffect).fx; - } - - if (def->worldLastShotEjectEffect) - { - dest->worldLastShotEjectEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->worldLastShotEjectEffect).fx; - } - - if (def->reticleCenter) - { - dest->reticleCenter = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, def->reticleCenter).material; - } - - if (def->reticleSide) - { - dest->reticleSide = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, def->reticleSide).material; - } - - if (def->worldModel) - { - buffer->align(Utils::Stream::ALIGN_4); - Game::XModel** pointerTable = buffer->dest(); - buffer->saveMax(16 * sizeof(Game::XModel*)); - for (int i = 0; i < 16; i++) - { - if (!def->worldModel[i]) - { - pointerTable[i] = NULL; - continue; - } - pointerTable[i] = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, def->worldModel[i]).model; - } - Utils::Stream::ClearPointer(&dest->worldModel); - } - - if (def->worldClipModel) - { - dest->worldClipModel = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, def->worldClipModel).model; - } - - if (def->rocketModel) - { - dest->rocketModel = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, def->rocketModel).model; - } - - if (def->knifeModel) - { - dest->knifeModel = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, def->knifeModel).model; - } - - if (def->worldKnifeModel) - { - dest->worldKnifeModel = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, def->worldKnifeModel).model; - } - - if (def->hudIcon) - { - dest->hudIcon = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, def->hudIcon).material; - } - - if (def->pickupIcon) - { - dest->pickupIcon = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, def->pickupIcon).material; - } - - if (def->ammoCounterIcon) - { - dest->ammoCounterIcon = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, def->ammoCounterIcon).material; - } - - if (def->szAmmoName) - { - buffer->saveString(def->szAmmoName); - Utils::Stream::ClearPointer(&dest->szAmmoName); - } - - if (def->szClipName) - { - buffer->saveString(def->szClipName); - Utils::Stream::ClearPointer(&dest->szClipName); - } - - if (def->szSharedAmmoCapName) - { - buffer->saveString(def->szSharedAmmoCapName); - Utils::Stream::ClearPointer(&dest->szSharedAmmoCapName); - } - - if (def->overlayMaterial) - { - dest->overlayMaterial = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, def->overlayMaterial).material; - } - - if (def->overlayMaterialLowRes) - { - dest->overlayMaterialLowRes = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, def->overlayMaterialLowRes).material; - } - - if (def->overlayMaterialEMP) - { - dest->overlayMaterialEMP = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, def->overlayMaterialEMP).material; - } - - if (def->overlayMaterialEMPLowRes) - { - dest->overlayMaterialEMPLowRes = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, def->overlayMaterialEMPLowRes).material; - } - - if (def->physCollmap) - { - dest->physCollmap = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_PHYSCOLLMAP, def->overlayMaterialEMPLowRes).physCollmap; - } - - if (def->projectileModel) - { - dest->projectileModel = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, def->projectileModel).model; - } - - if (def->projExplosionEffect) - { - dest->projExplosionEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->projExplosionEffect).fx; - } - - if (def->projDudEffect) - { - dest->projDudEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->projDudEffect).fx; - } - - if (def->projExplosionSound) - { - buffer->align(Utils::Stream::ALIGN_4); - buffer->saveMax(sizeof(Game::snd_alias_list_t*)); - buffer->saveString(def->projExplosionSound->aliasName); - Utils::Stream::ClearPointer(&dest->projExplosionSound); - } - - if (def->projDudSound) - { - buffer->align(Utils::Stream::ALIGN_4); - buffer->saveMax(sizeof(Game::snd_alias_list_t*)); - buffer->saveString(def->projDudSound->aliasName); - Utils::Stream::ClearPointer(&dest->projDudSound); - } - - if (def->parallelBounce) - { - buffer->align(Utils::Stream::ALIGN_4); - buffer->saveArray(def->parallelBounce, 31); - Utils::Stream::ClearPointer(&dest->parallelBounce); - } - - if (def->perpendicularBounce) - { - buffer->align(Utils::Stream::ALIGN_4); - buffer->saveArray(def->perpendicularBounce, 31); - Utils::Stream::ClearPointer(&dest->perpendicularBounce); - } - - if (def->projTrailEffect) - { - dest->projTrailEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->projTrailEffect).fx; - } - - if (def->projBeaconEffect) - { - dest->projBeaconEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->projBeaconEffect).fx; - } - - if (def->projIgnitionEffect) - { - dest->projIgnitionEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->projIgnitionEffect).fx; - } - - if (def->projIgnitionSound) - { - buffer->align(Utils::Stream::ALIGN_4); - buffer->saveMax(sizeof(Game::snd_alias_list_t*)); - buffer->saveString(def->projIgnitionSound->aliasName); - Utils::Stream::ClearPointer(&dest->projIgnitionSound); - } - - if (def->accuracyGraphName[0]) - { - buffer->saveString(def->accuracyGraphName[0]); - Utils::Stream::ClearPointer(&dest->accuracyGraphName[0]); - } - - if (def->originalAccuracyGraphKnots[0]) - { - buffer->align(Utils::Stream::ALIGN_4); - buffer->saveArray(def->originalAccuracyGraphKnots[0], def->originalAccuracyGraphKnotCount[0]); - Utils::Stream::ClearPointer(&dest->originalAccuracyGraphKnots[0]); - } - - if (def->accuracyGraphName[1]) - { - buffer->saveString(def->accuracyGraphName[1]); - Utils::Stream::ClearPointer(&dest->accuracyGraphName[1]); - } - - if (def->originalAccuracyGraphKnots[1]) - { - buffer->align(Utils::Stream::ALIGN_4); - buffer->saveArray(def->originalAccuracyGraphKnots[1], def->originalAccuracyGraphKnotCount[1]); - Utils::Stream::ClearPointer(&dest->originalAccuracyGraphKnots[1]); - } - - if (def->szUseHintString) - { - buffer->saveString(def->szUseHintString); - Utils::Stream::ClearPointer(&dest->szUseHintString); - } - - if (def->dropHintString) - { - buffer->saveString(def->dropHintString); - Utils::Stream::ClearPointer(&dest->dropHintString); - } - - if (def->szScript) - { - buffer->saveString(def->szScript); - Utils::Stream::ClearPointer(&dest->szScript); - } - - if (def->locationDamageMultipliers) - { - buffer->align(Utils::Stream::ALIGN_4); - buffer->saveArray(def->locationDamageMultipliers, 20); - Utils::Stream::ClearPointer(&dest->locationDamageMultipliers); - } - - if (def->fireRumble) - { - buffer->saveString(def->fireRumble); - Utils::Stream::ClearPointer(&dest->fireRumble); - } - - if (def->meleeImpactRumble) - { - buffer->saveString(def->meleeImpactRumble); - Utils::Stream::ClearPointer(&dest->meleeImpactRumble); - } - - if (def->tracerType) - { - dest->tracerType = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_TRACER, def->tracerType).tracerDef; - } - - if (def->turretOverheatSound) - { - buffer->align(Utils::Stream::ALIGN_4); - buffer->saveMax(sizeof(Game::snd_alias_list_t*)); - buffer->saveString(def->turretOverheatSound->aliasName); - Utils::Stream::ClearPointer(&dest->turretOverheatSound); - } - - if (def->turretOverheatEffect) - { - dest->turretOverheatEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->turretOverheatEffect).fx; - } - - if (def->turretBarrelSpinRumble) - { - buffer->saveString(def->turretBarrelSpinRumble); - Utils::Stream::ClearPointer(&dest->turretBarrelSpinRumble); - } - - if (def->turretBarrelSpinMaxSnd) - { - buffer->align(Utils::Stream::ALIGN_4); - buffer->saveMax(sizeof(Game::snd_alias_list_t*)); - buffer->saveString(def->turretBarrelSpinMaxSnd->aliasName); - Utils::Stream::ClearPointer(&dest->turretBarrelSpinMaxSnd); - } - - for (int i = 0; i < 4; i++) { - if (!def->turretBarrelSpinUpSnd[i]) continue; - - buffer->align(Utils::Stream::ALIGN_4); - buffer->saveMax(sizeof(Game::snd_alias_list_t*)); - buffer->saveString(def->turretBarrelSpinUpSnd[i]->aliasName); - Utils::Stream::ClearPointer(&dest->turretBarrelSpinUpSnd[i]); - } - - for (int i = 0; i < 4; i++) { - if (!def->turretBarrelSpinDownSnd[i]) continue; - - buffer->align(Utils::Stream::ALIGN_4); - buffer->saveMax(sizeof(Game::snd_alias_list_t*)); - buffer->saveString(def->turretBarrelSpinDownSnd[i]->aliasName); - Utils::Stream::ClearPointer(&dest->turretBarrelSpinDownSnd[i]); - } - - if (def->missileConeSoundAlias) - { - buffer->align(Utils::Stream::ALIGN_4); - buffer->saveMax(sizeof(Game::snd_alias_list_t*)); - buffer->saveString(def->missileConeSoundAlias->aliasName); - Utils::Stream::ClearPointer(&dest->missileConeSoundAlias); - } - - if (def->missileConeSoundAliasAtBase) - { - buffer->align(Utils::Stream::ALIGN_4); - buffer->saveMax(sizeof(Game::snd_alias_list_t*)); - buffer->saveString(def->missileConeSoundAliasAtBase->aliasName); - Utils::Stream::ClearPointer(&dest->missileConeSoundAliasAtBase); - } - } + LoadWeapSound(pickupSound); + LoadWeapSound(pickupSoundPlayer); + LoadWeapSound(ammoPickupSound); + LoadWeapSound(ammoPickupSoundPlayer); + LoadWeapSound(projectileSound); + LoadWeapSound(pullbackSound); + LoadWeapSound(pullbackSoundPlayer); + LoadWeapSound(fireSound); + LoadWeapSound(fireSoundPlayer); + LoadWeapSound(fireSoundPlayerAkimbo); + LoadWeapSound(fireLoopSound); + LoadWeapSound(fireLoopSoundPlayer); + LoadWeapSound(fireStopSound); + LoadWeapSound(fireStopSoundPlayer); + LoadWeapSound(fireLastSound); + LoadWeapSound(fireLastSoundPlayer); + LoadWeapSound(emptyFireSound); + LoadWeapSound(emptyFireSoundPlayer); + LoadWeapSound(meleeSwipeSound); + LoadWeapSound(meleeSwipeSoundPlayer); + LoadWeapSound(meleeHitSound); + LoadWeapSound(meleeMissSound); + LoadWeapSound(rechamberSound); + LoadWeapSound(rechamberSoundPlayer); + LoadWeapSound(reloadSound); + LoadWeapSound(reloadSoundPlayer); + LoadWeapSound(reloadEmptySound); + LoadWeapSound(reloadEmptySoundPlayer); + LoadWeapSound(reloadStartSound); + LoadWeapSound(reloadStartSoundPlayer); + LoadWeapSound(reloadEndSound); + LoadWeapSound(reloadEndSoundPlayer); + LoadWeapSound(detonateSound); + LoadWeapSound(detonateSoundPlayer); + LoadWeapSound(nightVisionWearSound); + LoadWeapSound(nightVisionWearSoundPlayer); + LoadWeapSound(nightVisionRemoveSound); + LoadWeapSound(nightVisionRemoveSoundPlayer); + LoadWeapSound(altSwitchSound); + LoadWeapSound(altSwitchSoundPlayer); + LoadWeapSound(raiseSound); + LoadWeapSound(raiseSoundPlayer); + LoadWeapSound(firstRaiseSound); + LoadWeapSound(firstRaiseSoundPlayer); + LoadWeapSound(putawaySound); + LoadWeapSound(putawaySoundPlayer); + LoadWeapSound(scanSound); + + if (asset->weapDef->bounceSound) + { + for (size_t i = 0; i < 31; i++) + { + LoadWeapSound(bounceSound[i]); + } + } + + LoadWeapSound(projExplosionSound); + LoadWeapSound(projDudSound); + LoadWeapSound(projIgnitionSound); + LoadWeapSound(turretOverheatSound); + LoadWeapSound(turretBarrelSpinMaxSnd); + + for (size_t i = 0; i < 4; i++) + { + LoadWeapSound(turretBarrelSpinUpSnd[i]); + LoadWeapSound(turretBarrelSpinDownSnd[i]); + } + + LoadWeapSound(missileConeSoundAlias); + LoadWeapSound(missileConeSoundAliasAtBase); + } + + void IWeapon::writeWeaponDef(Game::WeaponDef* def, Components::ZoneBuilder::Zone* builder, Utils::Stream* buffer) + { + AssertSize(Game::WeaponDef, 0x684); + + Game::WeaponDef* dest = buffer->dest(); + buffer->save(def); + + if (def->szOverlayName) + { + buffer->saveString(def->szOverlayName); + Utils::Stream::ClearPointer(&dest->szOverlayName); + } + + if (def->gunXModel) + { + buffer->align(Utils::Stream::ALIGN_4); + Game::XModel** pointerTable = buffer->dest(); + buffer->saveMax(16 * sizeof(Game::XModel*)); + for (int i = 0; i < 16; i++) + { + if (!def->gunXModel[i]) + { + pointerTable[i] = NULL; + continue; + } + pointerTable[i] = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, def->gunXModel[i]).model; + } + Utils::Stream::ClearPointer(&dest->gunXModel); + } + + if (def->handXModel) + { + dest->handXModel = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, def->handXModel).model; + } + + if (def->szXAnimsRightHanded) + { + buffer->align(Utils::Stream::ALIGN_4); + int* poinerTable = buffer->dest(); + buffer->saveMax(37 * sizeof(char*)); // array of 37 string pointers + for (int i = 0; i < 37; i++) + { + if (!def->szXAnimsRightHanded[i]) { + poinerTable[i] = 0; // clear poiner if there isn't a string here + continue; + } + + // save string if it is present + buffer->saveString(def->szXAnimsRightHanded[i]); + } + + Utils::Stream::ClearPointer(&dest->szXAnimsRightHanded); + } + + if (def->szXAnimsLeftHanded) + { + buffer->align(Utils::Stream::ALIGN_4); + int* poinerTable = buffer->dest(); + buffer->saveMax(37 * sizeof(char*)); // array of 37 string pointers + for (int i = 0; i < 37; i++) + { + if (!def->szXAnimsLeftHanded[i]) { + poinerTable[i] = 0; // clear poiner if there isn't a string here + continue; + } + + // save string if it is present + buffer->saveString(def->szXAnimsLeftHanded[i]); + } + + Utils::Stream::ClearPointer(&dest->szXAnimsLeftHanded); + } + + if (def->szModeName) + { + buffer->saveString(def->szModeName); + Utils::Stream::ClearPointer(&dest->szModeName); + } + + if (def->notetrackSoundMapKeys) + { + buffer->align(Utils::Stream::ALIGN_2); + unsigned short* scriptStringTable = buffer->dest(); + buffer->saveArray(def->notetrackSoundMapKeys, 16); + for (int i = 0; i < 16; i++) { + builder->mapScriptString(&scriptStringTable[i]); + } + + Utils::Stream::ClearPointer(&dest->notetrackSoundMapKeys); + } + + if (def->notetrackSoundMapValues) + { + buffer->align(Utils::Stream::ALIGN_2); + unsigned short* scriptStringTable = buffer->dest(); + buffer->saveArray(def->notetrackSoundMapValues, 16); + for (int i = 0; i < 16; i++) { + builder->mapScriptString(&scriptStringTable[i]); + } + + Utils::Stream::ClearPointer(&dest->notetrackSoundMapValues); + } + + if (def->notetrackRumbleMapKeys) + { + buffer->align(Utils::Stream::ALIGN_2); + unsigned short* scriptStringTable = buffer->dest(); + buffer->saveArray(def->notetrackRumbleMapKeys, 16); + for (int i = 0; i < 16; i++) { + builder->mapScriptString(&scriptStringTable[i]); + } + + Utils::Stream::ClearPointer(&dest->notetrackRumbleMapKeys); + } + + if (def->notetrackRumbleMapValues) + { + buffer->align(Utils::Stream::ALIGN_2); + unsigned short* scriptStringTable = buffer->dest(); + buffer->saveArray(def->notetrackRumbleMapValues, 16); + for (int i = 0; i < 16; i++) { + builder->mapScriptString(&scriptStringTable[i]); + } + + Utils::Stream::ClearPointer(&dest->notetrackRumbleMapValues); + } + + if (def->viewFlashEffect) + { + dest->viewFlashEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->viewFlashEffect).fx; + } + + if (def->worldFlashEffect) + { + dest->worldFlashEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->worldFlashEffect).fx; + } + + // This is compressed because I don't want to write the same piece of code 47 times + // TODO: verify that this is saving the aliases correctly because the old code looks wrong and this looks right but the old code worked so go figure + Game::snd_alias_list_t ** allSounds = &def->pickupSound; + Game::snd_alias_list_t ** allSoundsDest = &dest->pickupSound; + for (int i = 0; i < 47; i++) { + if (!allSounds[i]) continue; + buffer->align(Utils::Stream::ALIGN_4); + buffer->saveMax(sizeof(Game::snd_alias_list_t*)); + buffer->saveString(allSounds[i]->aliasName); + Utils::Stream::ClearPointer(&allSoundsDest[i]); + } + + if (def->bounceSound) + { + buffer->align(Utils::Stream::ALIGN_4); + int* ptrs = buffer->dest(); + buffer->saveMax(31 * sizeof(Game::snd_alias_list_t*)); + + for (int i = 0; i < 31; i++) + { + if (!def->bounceSound[i]) + { + ptrs[i] = 0; + continue; + } + + buffer->saveMax(sizeof(Game::snd_alias_list_t*)); + buffer->saveString(def->bounceSound[i]->aliasName); + } + + Utils::Stream::ClearPointer(&dest->bounceSound); + } + + if (def->viewShellEjectEffect) + { + dest->viewShellEjectEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->viewShellEjectEffect).fx; + } + + if (def->worldShellEjectEffect) + { + dest->worldShellEjectEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->worldShellEjectEffect).fx; + } + + if (def->viewLastShotEjectEffect) + { + dest->viewLastShotEjectEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->viewLastShotEjectEffect).fx; + } + + if (def->worldLastShotEjectEffect) + { + dest->worldLastShotEjectEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->worldLastShotEjectEffect).fx; + } + + if (def->reticleCenter) + { + dest->reticleCenter = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, def->reticleCenter).material; + } + + if (def->reticleSide) + { + dest->reticleSide = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, def->reticleSide).material; + } + + if (def->worldModel) + { + buffer->align(Utils::Stream::ALIGN_4); + Game::XModel** pointerTable = buffer->dest(); + buffer->saveMax(16 * sizeof(Game::XModel*)); + for (int i = 0; i < 16; i++) + { + if (!def->worldModel[i]) + { + pointerTable[i] = NULL; + continue; + } + pointerTable[i] = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, def->worldModel[i]).model; + } + Utils::Stream::ClearPointer(&dest->worldModel); + } + + if (def->worldClipModel) + { + dest->worldClipModel = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, def->worldClipModel).model; + } + + if (def->rocketModel) + { + dest->rocketModel = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, def->rocketModel).model; + } + + if (def->knifeModel) + { + dest->knifeModel = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, def->knifeModel).model; + } + + if (def->worldKnifeModel) + { + dest->worldKnifeModel = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, def->worldKnifeModel).model; + } + + if (def->hudIcon) + { + dest->hudIcon = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, def->hudIcon).material; + } + + if (def->pickupIcon) + { + dest->pickupIcon = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, def->pickupIcon).material; + } + + if (def->ammoCounterIcon) + { + dest->ammoCounterIcon = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, def->ammoCounterIcon).material; + } + + if (def->szAmmoName) + { + buffer->saveString(def->szAmmoName); + Utils::Stream::ClearPointer(&dest->szAmmoName); + } + + if (def->szClipName) + { + buffer->saveString(def->szClipName); + Utils::Stream::ClearPointer(&dest->szClipName); + } + + if (def->szSharedAmmoCapName) + { + buffer->saveString(def->szSharedAmmoCapName); + Utils::Stream::ClearPointer(&dest->szSharedAmmoCapName); + } + + if (def->overlayMaterial) + { + dest->overlayMaterial = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, def->overlayMaterial).material; + } + + if (def->overlayMaterialLowRes) + { + dest->overlayMaterialLowRes = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, def->overlayMaterialLowRes).material; + } + + if (def->overlayMaterialEMP) + { + dest->overlayMaterialEMP = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, def->overlayMaterialEMP).material; + } + + if (def->overlayMaterialEMPLowRes) + { + dest->overlayMaterialEMPLowRes = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, def->overlayMaterialEMPLowRes).material; + } + + if (def->physCollmap) + { + dest->physCollmap = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_PHYSCOLLMAP, def->overlayMaterialEMPLowRes).physCollmap; + } + + if (def->projectileModel) + { + dest->projectileModel = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_XMODEL, def->projectileModel).model; + } + + if (def->projExplosionEffect) + { + dest->projExplosionEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->projExplosionEffect).fx; + } + + if (def->projDudEffect) + { + dest->projDudEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->projDudEffect).fx; + } + + if (def->projExplosionSound) + { + buffer->align(Utils::Stream::ALIGN_4); + buffer->saveMax(sizeof(Game::snd_alias_list_t*)); + buffer->saveString(def->projExplosionSound->aliasName); + Utils::Stream::ClearPointer(&dest->projExplosionSound); + } + + if (def->projDudSound) + { + buffer->align(Utils::Stream::ALIGN_4); + buffer->saveMax(sizeof(Game::snd_alias_list_t*)); + buffer->saveString(def->projDudSound->aliasName); + Utils::Stream::ClearPointer(&dest->projDudSound); + } + + if (def->parallelBounce) + { + buffer->align(Utils::Stream::ALIGN_4); + buffer->saveArray(def->parallelBounce, 31); + Utils::Stream::ClearPointer(&dest->parallelBounce); + } + + if (def->perpendicularBounce) + { + buffer->align(Utils::Stream::ALIGN_4); + buffer->saveArray(def->perpendicularBounce, 31); + Utils::Stream::ClearPointer(&dest->perpendicularBounce); + } + + if (def->projTrailEffect) + { + dest->projTrailEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->projTrailEffect).fx; + } + + if (def->projBeaconEffect) + { + dest->projBeaconEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->projBeaconEffect).fx; + } + + if (def->projIgnitionEffect) + { + dest->projIgnitionEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->projIgnitionEffect).fx; + } + + if (def->projIgnitionSound) + { + buffer->align(Utils::Stream::ALIGN_4); + buffer->saveMax(sizeof(Game::snd_alias_list_t*)); + buffer->saveString(def->projIgnitionSound->aliasName); + Utils::Stream::ClearPointer(&dest->projIgnitionSound); + } + + if (def->accuracyGraphName[0]) + { + buffer->saveString(def->accuracyGraphName[0]); + Utils::Stream::ClearPointer(&dest->accuracyGraphName[0]); + } + + if (def->originalAccuracyGraphKnots[0]) + { + buffer->align(Utils::Stream::ALIGN_4); + buffer->saveArray(def->originalAccuracyGraphKnots[0], def->originalAccuracyGraphKnotCount[0]); + Utils::Stream::ClearPointer(&dest->originalAccuracyGraphKnots[0]); + } + + if (def->accuracyGraphName[1]) + { + buffer->saveString(def->accuracyGraphName[1]); + Utils::Stream::ClearPointer(&dest->accuracyGraphName[1]); + } + + if (def->originalAccuracyGraphKnots[1]) + { + buffer->align(Utils::Stream::ALIGN_4); + buffer->saveArray(def->originalAccuracyGraphKnots[1], def->originalAccuracyGraphKnotCount[1]); + Utils::Stream::ClearPointer(&dest->originalAccuracyGraphKnots[1]); + } + + if (def->szUseHintString) + { + buffer->saveString(def->szUseHintString); + Utils::Stream::ClearPointer(&dest->szUseHintString); + } + + if (def->dropHintString) + { + buffer->saveString(def->dropHintString); + Utils::Stream::ClearPointer(&dest->dropHintString); + } + + if (def->szScript) + { + buffer->saveString(def->szScript); + Utils::Stream::ClearPointer(&dest->szScript); + } + + if (def->locationDamageMultipliers) + { + buffer->align(Utils::Stream::ALIGN_4); + buffer->saveArray(def->locationDamageMultipliers, 20); + Utils::Stream::ClearPointer(&dest->locationDamageMultipliers); + } + + if (def->fireRumble) + { + buffer->saveString(def->fireRumble); + Utils::Stream::ClearPointer(&dest->fireRumble); + } + + if (def->meleeImpactRumble) + { + buffer->saveString(def->meleeImpactRumble); + Utils::Stream::ClearPointer(&dest->meleeImpactRumble); + } + + if (def->tracerType) + { + dest->tracerType = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_TRACER, def->tracerType).tracerDef; + } + + if (def->turretOverheatSound) + { + buffer->align(Utils::Stream::ALIGN_4); + buffer->saveMax(sizeof(Game::snd_alias_list_t*)); + buffer->saveString(def->turretOverheatSound->aliasName); + Utils::Stream::ClearPointer(&dest->turretOverheatSound); + } + + if (def->turretOverheatEffect) + { + dest->turretOverheatEffect = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_FX, def->turretOverheatEffect).fx; + } + + if (def->turretBarrelSpinRumble) + { + buffer->saveString(def->turretBarrelSpinRumble); + Utils::Stream::ClearPointer(&dest->turretBarrelSpinRumble); + } + + if (def->turretBarrelSpinMaxSnd) + { + buffer->align(Utils::Stream::ALIGN_4); + buffer->saveMax(sizeof(Game::snd_alias_list_t*)); + buffer->saveString(def->turretBarrelSpinMaxSnd->aliasName); + Utils::Stream::ClearPointer(&dest->turretBarrelSpinMaxSnd); + } + + for (int i = 0; i < 4; i++) { + if (!def->turretBarrelSpinUpSnd[i]) continue; + + buffer->align(Utils::Stream::ALIGN_4); + buffer->saveMax(sizeof(Game::snd_alias_list_t*)); + buffer->saveString(def->turretBarrelSpinUpSnd[i]->aliasName); + Utils::Stream::ClearPointer(&dest->turretBarrelSpinUpSnd[i]); + } + + for (int i = 0; i < 4; i++) { + if (!def->turretBarrelSpinDownSnd[i]) continue; + + buffer->align(Utils::Stream::ALIGN_4); + buffer->saveMax(sizeof(Game::snd_alias_list_t*)); + buffer->saveString(def->turretBarrelSpinDownSnd[i]->aliasName); + Utils::Stream::ClearPointer(&dest->turretBarrelSpinDownSnd[i]); + } + + if (def->missileConeSoundAlias) + { + buffer->align(Utils::Stream::ALIGN_4); + buffer->saveMax(sizeof(Game::snd_alias_list_t*)); + buffer->saveString(def->missileConeSoundAlias->aliasName); + Utils::Stream::ClearPointer(&dest->missileConeSoundAlias); + } + + if (def->missileConeSoundAliasAtBase) + { + buffer->align(Utils::Stream::ALIGN_4); + buffer->saveMax(sizeof(Game::snd_alias_list_t*)); + buffer->saveString(def->missileConeSoundAliasAtBase->aliasName); + Utils::Stream::ClearPointer(&dest->missileConeSoundAliasAtBase); + } + } void IWeapon::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) { - AssertSize(Game::WeaponCompleteDef, 0x74); + AssertSize(Game::WeaponCompleteDef, 0x74); Utils::Stream* buffer = builder->getBuffer(); Game::WeaponCompleteDef* asset = header.weapon; @@ -707,63 +708,63 @@ namespace Assets if (asset->weapDef) { buffer->align(Utils::Stream::ALIGN_4); - IWeapon::writeWeaponDef(asset->weapDef, builder, buffer); + IWeapon::writeWeaponDef(asset->weapDef, builder, buffer); Utils::Stream::ClearPointer(&dest->weapDef); } - if (asset->szDisplayName) - { - buffer->saveString(asset->szDisplayName); - Utils::Stream::ClearPointer(&dest->szDisplayName); - } + if (asset->szDisplayName) + { + buffer->saveString(asset->szDisplayName); + Utils::Stream::ClearPointer(&dest->szDisplayName); + } - if (asset->hideTags) - { - buffer->align(Utils::Stream::ALIGN_2); - unsigned short* scriptStringTable = buffer->dest(); - buffer->saveArray(asset->hideTags, 32); - for (int i = 0; i < 32; i++) { - builder->mapScriptString(&scriptStringTable[i]); - } + if (asset->hideTags) + { + buffer->align(Utils::Stream::ALIGN_2); + unsigned short* scriptStringTable = buffer->dest(); + buffer->saveArray(asset->hideTags, 32); + for (int i = 0; i < 32; i++) { + builder->mapScriptString(&scriptStringTable[i]); + } - Utils::Stream::ClearPointer(&dest->hideTags); - } + Utils::Stream::ClearPointer(&dest->hideTags); + } if (asset->szXAnims) { buffer->align(Utils::Stream::ALIGN_4); - int* poinerTable = buffer->dest(); - buffer->saveMax(37 * sizeof(char*)); // array of 37 string pointers - for (int i = 0; i < 37; i++) - { - if (!asset->szXAnims[i]) { - poinerTable[i] = 0; // clear poiner if there isn't a string here - continue; - } + int* poinerTable = buffer->dest(); + buffer->saveMax(37 * sizeof(char*)); // array of 37 string pointers + for (int i = 0; i < 37; i++) + { + if (!asset->szXAnims[i]) { + poinerTable[i] = 0; // clear poiner if there isn't a string here + continue; + } - // save string if it is present - buffer->saveString(asset->szXAnims[i]); - } + // save string if it is present + buffer->saveString(asset->szXAnims[i]); + } Utils::Stream::ClearPointer(&dest->szXAnims); } - if (asset->szAltWeaponName) - { - buffer->saveString(asset->szAltWeaponName); - Utils::Stream::ClearPointer(&dest->szAltWeaponName); - } + if (asset->szAltWeaponName) + { + buffer->saveString(asset->szAltWeaponName); + Utils::Stream::ClearPointer(&dest->szAltWeaponName); + } - if (asset->killIcon) - { - dest->killIcon = builder->saveSubAsset(Game::ASSET_TYPE_MATERIAL, asset->killIcon).material; - } + if (asset->killIcon) + { + dest->killIcon = builder->saveSubAsset(Game::ASSET_TYPE_MATERIAL, asset->killIcon).material; + } - if (asset->dpadIcon) - { - dest->dpadIcon = builder->saveSubAsset(Game::ASSET_TYPE_MATERIAL, asset->dpadIcon).material; - } + if (asset->dpadIcon) + { + dest->dpadIcon = builder->saveSubAsset(Game::ASSET_TYPE_MATERIAL, asset->dpadIcon).material; + } if (asset->accuracyGraphKnots[0]) { @@ -772,12 +773,12 @@ namespace Assets Utils::Stream::ClearPointer(&dest->accuracyGraphKnots[0]); } - if (asset->accuracyGraphKnots[1]) - { - buffer->align(Utils::Stream::ALIGN_4); - buffer->saveArray(asset->accuracyGraphKnots[1], asset->accuracyGraphKnotCount[1]); - Utils::Stream::ClearPointer(&dest->accuracyGraphKnots[1]); - } + if (asset->accuracyGraphKnots[1]) + { + buffer->align(Utils::Stream::ALIGN_4); + buffer->saveArray(asset->accuracyGraphKnots[1], asset->accuracyGraphKnotCount[1]); + Utils::Stream::ClearPointer(&dest->accuracyGraphKnots[1]); + } buffer->popBlock(); } diff --git a/src/Components/Modules/AssetInterfaces/IWeapon.hpp b/src/Components/Modules/AssetInterfaces/IWeapon.hpp index 82c38085..e9f05d5b 100644 --- a/src/Components/Modules/AssetInterfaces/IWeapon.hpp +++ b/src/Components/Modules/AssetInterfaces/IWeapon.hpp @@ -5,11 +5,11 @@ namespace Assets class IWeapon : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_WEAPON; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_WEAPON; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; private: void writeWeaponDef(Game::WeaponDef* def, Components::ZoneBuilder::Zone* builder, Utils::Stream* buffer); diff --git a/src/Components/Modules/AssetInterfaces/IXAnimParts.cpp b/src/Components/Modules/AssetInterfaces/IXAnimParts.cpp index d92af4fe..736b0a40 100644 --- a/src/Components/Modules/AssetInterfaces/IXAnimParts.cpp +++ b/src/Components/Modules/AssetInterfaces/IXAnimParts.cpp @@ -1,4 +1,5 @@ #include +#include "IXAnimParts.hpp" #define IW4X_ANIM_VERSION 1 diff --git a/src/Components/Modules/AssetInterfaces/IXAnimParts.hpp b/src/Components/Modules/AssetInterfaces/IXAnimParts.hpp index b5b1f62a..8a973216 100644 --- a/src/Components/Modules/AssetInterfaces/IXAnimParts.hpp +++ b/src/Components/Modules/AssetInterfaces/IXAnimParts.hpp @@ -5,11 +5,11 @@ namespace Assets class IXAnimParts : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_XANIMPARTS; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_XANIMPARTS; } - virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; private: void saveXAnimDeltaPart(Game::XAnimDeltaPart* delta, unsigned short framecount, Components::ZoneBuilder::Zone* builder); diff --git a/src/Components/Modules/AssetInterfaces/IXModel.cpp b/src/Components/Modules/AssetInterfaces/IXModel.cpp index ff3a75bb..c10751fd 100644 --- a/src/Components/Modules/AssetInterfaces/IXModel.cpp +++ b/src/Components/Modules/AssetInterfaces/IXModel.cpp @@ -1,4 +1,5 @@ #include +#include "IXModel.hpp" #define IW4X_MODEL_VERSION 5 @@ -48,20 +49,20 @@ namespace Assets } // Access index block - if (surf->triIndices) - { - void* oldPtr = surf->triIndices; - surf->triIndices = reader->readArray(surf->triCount * 3); + if (surf->triIndices) + { + void* oldPtr = surf->triIndices; + surf->triIndices = reader->readArray(surf->triCount * 3); - if (builder->getAllocator()->isPointerMapped(oldPtr)) - { - surf->triIndices = builder->getAllocator()->getPointer(oldPtr); - } - else - { - builder->getAllocator()->mapPointer(oldPtr, surf->triIndices); - } - } + if (builder->getAllocator()->isPointerMapped(oldPtr)) + { + surf->triIndices = builder->getAllocator()->getPointer(oldPtr); + } + else + { + builder->getAllocator()->mapPointer(oldPtr, surf->triIndices); + } + } } void IXModel::loadXModelSurfs(Game::XModelSurfs* asset, Utils::Stream::Reader* reader, Components::ZoneBuilder::Zone* builder) diff --git a/src/Components/Modules/AssetInterfaces/IXModel.hpp b/src/Components/Modules/AssetInterfaces/IXModel.hpp index 8f0fec30..44388f3d 100644 --- a/src/Components/Modules/AssetInterfaces/IXModel.hpp +++ b/src/Components/Modules/AssetInterfaces/IXModel.hpp @@ -5,14 +5,14 @@ namespace Assets class IXModel : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_XMODEL; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_XMODEL; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; private: - std::map triIndicies; + std::map triIndicies; void loadXModelSurfs(Game::XModelSurfs* asset, Utils::Stream::Reader* reader, Components::ZoneBuilder::Zone* builder); void loadXSurface(Game::XSurface* surf, Utils::Stream::Reader* reader, Components::ZoneBuilder::Zone* builder); void loadXSurfaceCollisionTree(Game::XSurfaceCollisionTree* entry, Utils::Stream::Reader* reader); diff --git a/src/Components/Modules/AssetInterfaces/IXModelSurfs.cpp b/src/Components/Modules/AssetInterfaces/IXModelSurfs.cpp index 686eb3b0..bbe4b96a 100644 --- a/src/Components/Modules/AssetInterfaces/IXModelSurfs.cpp +++ b/src/Components/Modules/AssetInterfaces/IXModelSurfs.cpp @@ -1,4 +1,5 @@ #include +#include "IXModelSurfs.hpp" namespace Assets { @@ -81,16 +82,16 @@ namespace Assets // Access index block buffer->pushBlock(Game::XFILE_BLOCK_INDEX); - if (builder->hasPointer(surf->triIndices)) - { - destSurf->triIndices = builder->getPointer(surf->triIndices); - } - else - { - buffer->align(Utils::Stream::ALIGN_16); - buffer->saveArray(surf->triIndices, surf->triCount * 3); - Utils::Stream::ClearPointer(&destSurf->triIndices); - } + if (builder->hasPointer(surf->triIndices)) + { + destSurf->triIndices = builder->getPointer(surf->triIndices); + } + else + { + buffer->align(Utils::Stream::ALIGN_16); + buffer->saveArray(surf->triIndices, surf->triCount * 3); + Utils::Stream::ClearPointer(&destSurf->triIndices); + } buffer->popBlock(); } diff --git a/src/Components/Modules/AssetInterfaces/IXModelSurfs.hpp b/src/Components/Modules/AssetInterfaces/IXModelSurfs.hpp index 90517091..e43f009d 100644 --- a/src/Components/Modules/AssetInterfaces/IXModelSurfs.hpp +++ b/src/Components/Modules/AssetInterfaces/IXModelSurfs.hpp @@ -5,9 +5,9 @@ namespace Assets class IXModelSurfs : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_XMODEL_SURFS; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_XMODEL_SURFS; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; private: void saveXSurface(Game::XSurface* surf, Game::XSurface* destSurf, Components::ZoneBuilder::Zone* builder); diff --git a/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp b/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp index 17b07d9c..ae28d788 100644 --- a/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp +++ b/src/Components/Modules/AssetInterfaces/IclipMap_t.cpp @@ -1,4 +1,5 @@ #include +#include "IclipMap_t.hpp" #define IW4X_CLIPMAP_VERSION 2 diff --git a/src/Components/Modules/AssetInterfaces/IclipMap_t.hpp b/src/Components/Modules/AssetInterfaces/IclipMap_t.hpp index 777933d4..fbd5e307 100644 --- a/src/Components/Modules/AssetInterfaces/IclipMap_t.hpp +++ b/src/Components/Modules/AssetInterfaces/IclipMap_t.hpp @@ -5,11 +5,11 @@ namespace Assets class IclipMap_t : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_CLIPMAP_MP; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_CLIPMAP_MP; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; private: class SModelQuadtree diff --git a/src/Components/Modules/AssetInterfaces/ImenuDef_t.cpp b/src/Components/Modules/AssetInterfaces/ImenuDef_t.cpp index 9b451411..c9b6fc8e 100644 --- a/src/Components/Modules/AssetInterfaces/ImenuDef_t.cpp +++ b/src/Components/Modules/AssetInterfaces/ImenuDef_t.cpp @@ -1,20 +1,21 @@ -#include +#include +#include "ImenuDef_t.hpp" namespace Assets { - std::unordered_map ImenuDef_t::LoadedMenus; + std::unordered_map ImenuDef_t::LoadedMenus; - void ImenuDef_t::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/) - { - // load from disk - auto menus = Components::Menus::LoadMenu(Utils::String::VA("ui_mp/%s.menu", name.data())); + void ImenuDef_t::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/) + { + // load from disk + auto menus = Components::Menus::LoadMenu(Utils::String::VA("ui_mp/%s.menu", name.data())); - if (menus.size() == 0) return; - if (menus.size() > 1) Components::Logger::Print("Menu '{}' on disk has more than one menudef in it. Only saving the first one\n", name); + if (menus.size() == 0) return; + if (menus.size() > 1) Components::Logger::Print("Menu '{}' on disk has more than one menudef in it. Only saving the first one\n", name); - header->menu = menus[0].second; - } + header->menu = menus[0].second; + } void ImenuDef_t::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) @@ -53,7 +54,7 @@ namespace Assets Utils::Stream* buffer = builder->getBuffer(); #ifdef WRITE_LOGS - buffer->enterStruct("ExpressionSupportingData"); + buffer->enterStruct("ExpressionSupportingData"); #endif buffer->align(Utils::Stream::ALIGN_4); @@ -127,18 +128,18 @@ namespace Assets } } #ifdef WRITE_LOGS - buffer->leaveStruct(); + buffer->leaveStruct(); #endif } void ImenuDef_t::save_Statement_s(Game::Statement_s* asset, Components::ZoneBuilder::Zone* builder) { AssertSize(Game::Statement_s, 24); - AssertSize(Game::expressionEntry, 12); + AssertSize(Game::expressionEntry, 12); Utils::Stream* buffer = builder->getBuffer(); #ifdef WRITE_LOGS - buffer->enterStruct("Statement_s"); + buffer->enterStruct("Statement_s"); #endif // Write header data @@ -149,7 +150,7 @@ namespace Assets if (asset->entries) { #ifdef WRITE_LOGS - buffer->enterStruct("statement entries"); + buffer->enterStruct("statement entries"); #endif buffer->align(Utils::Stream::ALIGN_4); @@ -161,7 +162,7 @@ namespace Assets for (int i = 0; i < asset->numEntries; ++i) { #ifdef WRITE_LOGS - buffer->enterStruct("entry"); + buffer->enterStruct("entry"); #endif if (asset->entries[i].type) { @@ -193,11 +194,11 @@ namespace Assets } } #ifdef WRITE_LOGS - buffer->leaveStruct(); + buffer->leaveStruct(); #endif } #ifdef WRITE_LOGS - buffer->leaveStruct(); + buffer->leaveStruct(); #endif } @@ -207,7 +208,7 @@ namespace Assets Utils::Stream::ClearPointer(&dest->supportingData); } #ifdef WRITE_LOGS - buffer->leaveStruct(); + buffer->leaveStruct(); #endif } @@ -217,7 +218,7 @@ namespace Assets Utils::Stream* buffer = builder->getBuffer(); #ifdef WRITE_LOGS - buffer->enterStruct("MenuEventHandlerSet"); + buffer->enterStruct("MenuEventHandlerSet"); #endif // Write header data @@ -239,7 +240,7 @@ namespace Assets { buffer->align(Utils::Stream::ALIGN_4); #ifdef WRITE_LOGS - buffer->enterStruct("MenuEventHandler"); + buffer->enterStruct("MenuEventHandler"); #endif // Write menu event handler @@ -329,7 +330,7 @@ namespace Assets break; } #ifdef WRITE_LOGS - buffer->leaveStruct(); + buffer->leaveStruct(); #endif } } @@ -337,7 +338,7 @@ namespace Assets Utils::Stream::ClearPointer(&destset->eventHandlers); } #ifdef WRITE_LOGS - buffer->leaveStruct(); + buffer->leaveStruct(); #endif } @@ -347,7 +348,7 @@ namespace Assets Utils::Stream* buffer = builder->getBuffer(); #ifdef WRITE_LOGS - buffer->enterStruct("ItemKeyHandler"); + buffer->enterStruct("ItemKeyHandler"); #endif while (asset) @@ -374,7 +375,7 @@ namespace Assets asset = asset->next; } #ifdef WRITE_LOGS - buffer->leaveStruct(); + buffer->leaveStruct(); #endif } @@ -404,7 +405,7 @@ namespace Assets Utils::Stream* buffer = builder->getBuffer(); #ifdef WRITE_LOGS - buffer->enterStruct("itemDefData_t"); + buffer->enterStruct("itemDefData_t"); #endif // feeder @@ -490,7 +491,7 @@ namespace Assets Utils::Stream::ClearPointer(&dest->typeData.data); #ifdef WRITE_LOGS - buffer->leaveStruct(); + buffer->leaveStruct(); #endif } @@ -502,12 +503,12 @@ namespace Assets Game::itemDef_s* dest = buffer->dest(); #ifdef WRITE_LOGS - if (asset->window.name) - buffer->enterStruct(Utils::String::VA("itemDef_s: name = '%s'", asset->window.name)); - else if (asset->window.background) - buffer->enterStruct(Utils::String::VA("itemDef_s: bg = '%s'", asset->window.background->info.name)); - else - buffer->enterStruct("itemDef_s"); + if (asset->window.name) + buffer->enterStruct(Utils::String::VA("itemDef_s: name = '%s'", asset->window.name)); + else if (asset->window.background) + buffer->enterStruct(Utils::String::VA("itemDef_s: bg = '%s'", asset->window.background->info.name)); + else + buffer->enterStruct("itemDef_s"); #endif buffer->save(asset); @@ -583,7 +584,7 @@ namespace Assets { buffer->align(Utils::Stream::ALIGN_4); #ifdef WRITE_LOGS - buffer->enterStruct("floatExpressions"); + buffer->enterStruct("floatExpressions"); #endif Game::ItemFloatExpression* destExp = buffer->dest(); @@ -599,7 +600,7 @@ namespace Assets Utils::Stream::ClearPointer(&dest->floatExpressions); #ifdef WRITE_LOGS - buffer->leaveStruct(); + buffer->leaveStruct(); #endif } @@ -610,7 +611,7 @@ namespace Assets STATEMENT(materialExp); #ifdef WRITE_LOGS - buffer->leaveStruct(); + buffer->leaveStruct(); #endif } @@ -619,7 +620,7 @@ namespace Assets AssertSize(Game::menuDef_t, 400); #ifdef WRITE_LOGS - buffer->enterStruct("ImenuDef_t"); + buffer->enterStruct("ImenuDef_t"); #endif Utils::Stream* buffer = builder->getBuffer(); @@ -700,7 +701,7 @@ namespace Assets } } #ifdef WRITE_LOGS - buffer->leaveStruct(); + buffer->leaveStruct(); #endif buffer->popBlock(); diff --git a/src/Components/Modules/AssetInterfaces/ImenuDef_t.hpp b/src/Components/Modules/AssetInterfaces/ImenuDef_t.hpp index b9e38cc4..33daafba 100644 --- a/src/Components/Modules/AssetInterfaces/ImenuDef_t.hpp +++ b/src/Components/Modules/AssetInterfaces/ImenuDef_t.hpp @@ -5,13 +5,13 @@ namespace Assets class ImenuDef_t : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_MENU; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_MENU; } - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; - static std::unordered_map LoadedMenus; + static std::unordered_map LoadedMenus; private: template void save_windowDef_t(Game::windowDef_t* asset, T* dest, Components::ZoneBuilder::Zone* builder) diff --git a/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp b/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp index 2c2e90c7..86cc1dd7 100644 --- a/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp +++ b/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp @@ -1,4 +1,5 @@ #include +#include "Isnd_alias_list_t.hpp" namespace Assets { diff --git a/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.hpp b/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.hpp index 14330120..d7f2337b 100644 --- a/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.hpp +++ b/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.hpp @@ -5,10 +5,10 @@ namespace Assets class Isnd_alias_list_t : public Components::AssetHandler::IAsset { public: - virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_SOUND; }; + Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_SOUND; } - virtual void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; - virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; - virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override; + void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; + void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; }; } diff --git a/src/Utils/String.hpp b/src/Utils/String.hpp index 72af16e6..90422c29 100644 --- a/src/Utils/String.hpp +++ b/src/Utils/String.hpp @@ -77,7 +77,7 @@ namespace Utils int IsSpace(int c); std::string ToLower(std::string text); std::string ToUpper(std::string text); - std::vector Split(const std::string& str, const char delim); + std::vector Split(const std::string& str, char delim); void Replace(std::string& string, const std::string& find, const std::string& replace); bool StartsWith(const std::string& haystack, const std::string& needle); bool EndsWith(const std::string& haystack, const std::string& needle);