[General] Stop nonsense with asset handler header files

This commit is contained in:
Diavolo 2022-06-22 17:36:06 +02:00
parent 1ba9db613d
commit c07bfe8bd9
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
67 changed files with 1226 additions and 1194 deletions

View File

@ -1,5 +1,38 @@
#include <StdInclude.hpp> #include <StdInclude.hpp>
#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 namespace Components
{ {
thread_local int AssetHandler::BypassState = 0; thread_local int AssetHandler::BypassState = 0;

View File

@ -78,37 +78,3 @@ namespace Components
void reallocateEntryPool(); 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"

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IComWorld.hpp"
#define IW4X_COMMAP_VERSION 0 #define IW4X_COMMAP_VERSION 0

View File

@ -5,10 +5,10 @@ namespace Assets
class IComWorld : public Components::AssetHandler::IAsset class IComWorld : public Components::AssetHandler::IAsset
{ {
public: 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; void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; 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 load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
}; };
} }

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IFont_s.hpp"
#define STB_TRUETYPE_IMPLEMENTATION #define STB_TRUETYPE_IMPLEMENTATION
#include <stb_truetype.h> #include <stb_truetype.h>

View File

@ -5,10 +5,10 @@ namespace Assets
class IFont_s : public Components::AssetHandler::IAsset class IFont_s : public Components::AssetHandler::IAsset
{ {
public: 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; void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; 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 load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
}; };
} }

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IFxEffectDef.hpp"
#define IW4X_FX_VERSION 1 #define IW4X_FX_VERSION 1

View File

@ -5,11 +5,11 @@ namespace Assets
class IFxEffectDef : public Components::AssetHandler::IAsset class IFxEffectDef : public Components::AssetHandler::IAsset
{ {
public: 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; void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; 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 load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
private: private:
void markFxElemVisuals(Game::FxElemVisuals* visuals, char elemType, Components::ZoneBuilder::Zone* builder); void markFxElemVisuals(Game::FxElemVisuals* visuals, char elemType, Components::ZoneBuilder::Zone* builder);

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IFxWorld.hpp"
namespace Assets namespace Assets
{ {

View File

@ -5,10 +5,10 @@ namespace Assets
class IFxWorld : public Components::AssetHandler::IAsset class IFxWorld : public Components::AssetHandler::IAsset
{ {
public: 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; void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; 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 load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
}; };
} }

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IGameWorldMp.hpp"
namespace Assets namespace Assets
{ {

View File

@ -5,8 +5,8 @@ namespace Assets
class IGameWorldMp : public Components::AssetHandler::IAsset class IGameWorldMp : public Components::AssetHandler::IAsset
{ {
public: 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;
}; };
} }

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IGameWorldSp.hpp"
namespace Assets namespace Assets
{ {

View File

@ -5,10 +5,10 @@ namespace Assets
class IGameWorldSp : public Components::AssetHandler::IAsset class IGameWorldSp : public Components::AssetHandler::IAsset
{ {
public: 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; void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
private: private:
void savepathnode_tree_info_t(Game::pathnode_tree_t* nodeTree, Game::pathnode_tree_t* destNodeTree, Components::ZoneBuilder::Zone* builder); void savepathnode_tree_info_t(Game::pathnode_tree_t* nodeTree, Game::pathnode_tree_t* destNodeTree, Components::ZoneBuilder::Zone* builder);

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IGfxImage.hpp"
#define IW4X_IMG_VERSION "0" #define IW4X_IMG_VERSION "0"

View File

@ -5,9 +5,9 @@ namespace Assets
class IGfxImage : public Components::AssetHandler::IAsset class IGfxImage : public Components::AssetHandler::IAsset
{ {
public: 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; 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 load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
}; };
} }

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IGfxLightDef.hpp"
#define IW4X_LIGHT_VERSION "0" #define IW4X_LIGHT_VERSION "0"

View File

@ -5,10 +5,10 @@ namespace Assets
class IGfxLightDef : public Components::AssetHandler::IAsset class IGfxLightDef : public Components::AssetHandler::IAsset
{ {
public: 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; void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; 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 load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
}; };
} }

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IGfxWorld.hpp"
#define IW4X_GFXMAP_VERSION 1 #define IW4X_GFXMAP_VERSION 1
@ -950,7 +951,7 @@ namespace Assets
} }
buffer->popBlock(); buffer->popBlock();
SaveLogExit(); SaveLogExit();
} }
void IGfxWorld::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) void IGfxWorld::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)

View File

@ -5,11 +5,12 @@ namespace Assets
class IGfxWorld : public Components::AssetHandler::IAsset class IGfxWorld : public Components::AssetHandler::IAsset
{ {
public: 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: private:
void saveGfxWorldDpvsPlanes(Game::GfxWorld* world, Game::GfxWorldDpvsPlanes* asset, Game::GfxWorldDpvsPlanes* dest, Components::ZoneBuilder::Zone* builder); 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); void saveGfxWorldDraw(Game::GfxWorldDraw* asset, Game::GfxWorldDraw* dest, Components::ZoneBuilder::Zone* builder);

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "ILoadedSound.hpp"
namespace Assets namespace Assets
{ {

View File

@ -5,9 +5,9 @@ namespace Assets
class ILoadedSound : public Components::AssetHandler::IAsset class ILoadedSound : public Components::AssetHandler::IAsset
{ {
public: 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; 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 save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
}; };
} }

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "ILocalizeEntry.hpp"
namespace Assets namespace Assets
{ {

View File

@ -5,8 +5,8 @@ namespace Assets
class ILocalizeEntry : public Components::AssetHandler::IAsset class ILocalizeEntry : public Components::AssetHandler::IAsset
{ {
public: 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;
}; };
} }

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IMapEnts.hpp"
namespace Assets namespace Assets
{ {

View File

@ -5,10 +5,10 @@ namespace Assets
class IMapEnts : public Components::AssetHandler::IAsset class IMapEnts : public Components::AssetHandler::IAsset
{ {
public: 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; void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; 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 load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
}; };
} }

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IMaterial.hpp"
#define IW4X_MAT_VERSION "1" #define IW4X_MAT_VERSION "1"

View File

@ -5,11 +5,11 @@ namespace Assets
class IMaterial : public Components::AssetHandler::IAsset class IMaterial : public Components::AssetHandler::IAsset
{ {
public: 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; void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; 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 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 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 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 loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder);

View File

@ -1,56 +1,57 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IMaterialPixelShader.hpp"
#define IW4X_TECHSET_VERSION "0" #define IW4X_TECHSET_VERSION "0"
namespace Assets namespace Assets
{ {
void IMaterialPixelShader::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) 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->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 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*/) void IMaterialPixelShader::loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/)
{ {
header->pixelShader = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).pixelShader; header->pixelShader = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).pixelShader;
} }
void IMaterialPixelShader::loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) 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())); Components::FileSystem::File psFile(Utils::String::VA("ps/%s.iw4xPS", name.data()));
if (!psFile.exists()) return; if (!psFile.exists()) return;
Utils::Stream::Reader reader(builder->getAllocator(), psFile.getBuffer()); Utils::Stream::Reader reader(builder->getAllocator(), psFile.getBuffer());
char* magic = reader.readArray<char>(8); char* magic = reader.readArray<char>(8);
if (std::memcmp(magic, "IW4xPIXL", 8)) if (std::memcmp(magic, "IW4xPIXL", 8))
{ {
Components::Logger::Error(Game::ERR_FATAL, "Reading pixel shader '{}' failed, header is invalid!", name); Components::Logger::Error(Game::ERR_FATAL, "Reading pixel shader '{}' failed, header is invalid!", name);
} }
std::string version; std::string version;
version.push_back(reader.read<char>()); version.push_back(reader.read<char>());
if (version != IW4X_TECHSET_VERSION) if (version != IW4X_TECHSET_VERSION)
{ {
Components::Logger::Error(Game::ERR_FATAL, Components::Logger::Error(Game::ERR_FATAL,
"Reading pixel shader '{}' failed, expected version is {}, but it was {}!", name, IW4X_TECHSET_VERSION, version); "Reading pixel shader '{}' failed, expected version is {}, but it was {}!", name, IW4X_TECHSET_VERSION, version);
} }
Game::MaterialPixelShader* asset = reader.readObject<Game::MaterialPixelShader>(); Game::MaterialPixelShader* asset = reader.readObject<Game::MaterialPixelShader>();
if (asset->name) if (asset->name)
{ {
asset->name = reader.readCString(); asset->name = reader.readCString();
} }
if (asset->prog.loadDef.program) if (asset->prog.loadDef.program)
{ {
asset->prog.loadDef.program = reader.readArray<unsigned int>(asset->prog.loadDef.programSize); asset->prog.loadDef.program = reader.readArray<unsigned int>(asset->prog.loadDef.programSize);
} }
header->pixelShader = asset; header->pixelShader = asset;
} }
void IMaterialPixelShader::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) void IMaterialPixelShader::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{ {

View File

@ -5,12 +5,12 @@ namespace Assets
class IMaterialPixelShader : public Components::AssetHandler::IAsset class IMaterialPixelShader : public Components::AssetHandler::IAsset
{ {
public: 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; 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 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 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 loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder);
}; };
} }

View File

@ -1,143 +1,144 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IMaterialTechniqueSet.hpp"
#define IW4X_TECHSET_VERSION "0" #define IW4X_TECHSET_VERSION "0"
namespace Assets namespace Assets
{ {
void IMaterialTechniqueSet::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) 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->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 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*/) void IMaterialTechniqueSet::loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/)
{ {
header->techniqueSet = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).techniqueSet; header->techniqueSet = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).techniqueSet;
} }
void IMaterialTechniqueSet::loadBinaryTechnique(Game::MaterialTechnique** tech, const std::string& name, Components::ZoneBuilder::Zone* builder) void IMaterialTechniqueSet::loadBinaryTechnique(Game::MaterialTechnique** tech, const std::string& name, Components::ZoneBuilder::Zone* builder)
{ {
AssertSize(Game::MaterialPass, 20); AssertSize(Game::MaterialPass, 20);
Components::FileSystem::File techFile(Utils::String::VA("techniques/%s.iw4xTech", name.data())); Components::FileSystem::File techFile(Utils::String::VA("techniques/%s.iw4xTech", name.data()));
if (!techFile.exists()) { if (!techFile.exists()) {
*tech = nullptr; *tech = nullptr;
Components::Logger::Warning(Game::CON_CHANNEL_DONT_FILTER, "Missing technique '{}'\n", name); Components::Logger::Warning(Game::CON_CHANNEL_DONT_FILTER, "Missing technique '{}'\n", name);
return; return;
} }
Utils::Stream::Reader reader(builder->getAllocator(), techFile.getBuffer()); Utils::Stream::Reader reader(builder->getAllocator(), techFile.getBuffer());
char* magic = reader.readArray<char>(8); char* magic = reader.readArray<char>(8);
if (std::memcmp(magic, "IW4xTECH", 8)) if (std::memcmp(magic, "IW4xTECH", 8))
{ {
Components::Logger::Error(Game::ERR_FATAL, "Reading technique '{}' failed, header is invalid!", name); Components::Logger::Error(Game::ERR_FATAL, "Reading technique '{}' failed, header is invalid!", name);
} }
std::string version; std::string version;
version.push_back(reader.read<char>()); version.push_back(reader.read<char>());
if (version != IW4X_TECHSET_VERSION) if (version != IW4X_TECHSET_VERSION)
{ {
Components::Logger::Error(Game::ERR_FATAL, Components::Logger::Error(Game::ERR_FATAL,
"Reading technique '{}' failed, expected version is {}, but it was {}!", name, IW4X_TECHSET_VERSION, version.data()); "Reading technique '{}' failed, expected version is {}, but it was {}!", name, IW4X_TECHSET_VERSION, version.data());
} }
unsigned short flags = reader.read<unsigned short>(); unsigned short flags = reader.read<unsigned short>();
unsigned short passCount = reader.read<unsigned short>(); unsigned short passCount = reader.read<unsigned short>();
Game::MaterialTechnique* asset = (Game::MaterialTechnique*)builder->getAllocator()->allocateArray<unsigned char>(sizeof(Game::MaterialTechnique) + (sizeof(Game::MaterialPass) * (passCount - 1))); Game::MaterialTechnique* asset = (Game::MaterialTechnique*)builder->getAllocator()->allocateArray<unsigned char>(sizeof(Game::MaterialTechnique) + (sizeof(Game::MaterialPass) * (passCount - 1)));
asset->name = builder->getAllocator()->duplicateString(name); asset->name = builder->getAllocator()->duplicateString(name);
asset->flags = flags; asset->flags = flags;
asset->passCount = passCount; asset->passCount = passCount;
Game::MaterialPass* passes = reader.readArray<Game::MaterialPass>(passCount); Game::MaterialPass* passes = reader.readArray<Game::MaterialPass>(passCount);
std::memcpy(asset->passArray, passes, sizeof(Game::MaterialPass) * passCount); std::memcpy(asset->passArray, passes, sizeof(Game::MaterialPass) * passCount);
for (unsigned short i = 0; i < asset->passCount; i++) for (unsigned short i = 0; i < asset->passCount; i++)
{ {
Game::MaterialPass* pass = &asset->passArray[i]; Game::MaterialPass* pass = &asset->passArray[i];
if (pass->vertexDecl) if (pass->vertexDecl)
{ {
const char* declName = reader.readCString(); const char* declName = reader.readCString();
pass->vertexDecl = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_VERTEXDECL, declName, builder).vertexDecl; pass->vertexDecl = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_VERTEXDECL, declName, builder).vertexDecl;
} }
if (pass->vertexShader) if (pass->vertexShader)
{ {
const char* vsName = reader.readCString(); const char* vsName = reader.readCString();
pass->vertexShader = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_VERTEXSHADER, vsName, builder).vertexShader; pass->vertexShader = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_VERTEXSHADER, vsName, builder).vertexShader;
} }
if (pass->pixelShader) if (pass->pixelShader)
{ {
const char* psName = reader.readCString(); const char* psName = reader.readCString();
pass->pixelShader = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_PIXELSHADER, psName, builder).pixelShader; pass->pixelShader = Components::AssetHandler::FindAssetForZone(Game::XAssetType::ASSET_TYPE_PIXELSHADER, psName, builder).pixelShader;
} }
pass->args = reader.readArray<Game::MaterialShaderArgument>(pass->perPrimArgCount + pass->perObjArgCount + pass->stableArgCount); pass->args = reader.readArray<Game::MaterialShaderArgument>(pass->perPrimArgCount + pass->perObjArgCount + pass->stableArgCount);
for (int j = 0; j < pass->perPrimArgCount + pass->perObjArgCount + pass->stableArgCount; j++) for (int j = 0; j < pass->perPrimArgCount + pass->perObjArgCount + pass->stableArgCount; j++)
{ {
if (pass->args[j].type == 1 || pass->args[j].type == 7) if (pass->args[j].type == 1 || pass->args[j].type == 7)
{ {
pass->args[j].u.literalConst = reader.readArray<float>(4); pass->args[j].u.literalConst = reader.readArray<float>(4);
} }
if (pass->args[j].type == 3 || pass->args[j].type == 5) if (pass->args[j].type == 3 || pass->args[j].type == 5)
{ {
pass->args[j].u.codeConst.index = *reader.readObject<unsigned short>(); pass->args[j].u.codeConst.index = *reader.readObject<unsigned short>();
pass->args[j].u.codeConst.firstRow = *reader.readObject<unsigned char>(); pass->args[j].u.codeConst.firstRow = *reader.readObject<unsigned char>();
pass->args[j].u.codeConst.rowCount = *reader.readObject<unsigned char>(); pass->args[j].u.codeConst.rowCount = *reader.readObject<unsigned char>();
} }
} }
} }
*tech = asset; *tech = asset;
} }
void IMaterialTechniqueSet::loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) 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())); Components::FileSystem::File tsFile(Utils::String::VA("techsets/%s.iw4xTS", name.data()));
if (!tsFile.exists()) return; if (!tsFile.exists()) return;
Utils::Stream::Reader reader(builder->getAllocator(), tsFile.getBuffer()); Utils::Stream::Reader reader(builder->getAllocator(), tsFile.getBuffer());
char* magic = reader.readArray<char>(8); char* magic = reader.readArray<char>(8);
if (std::memcmp(magic, "IW4xTSET", 8)) if (std::memcmp(magic, "IW4xTSET", 8))
{ {
Components::Logger::Error(Game::ERR_FATAL, "Reading techset '{}' failed, header is invalid!", name); Components::Logger::Error(Game::ERR_FATAL, "Reading techset '{}' failed, header is invalid!", name);
} }
std::string version; std::string version;
version.push_back(reader.read<char>()); version.push_back(reader.read<char>());
if (version != IW4X_TECHSET_VERSION) if (version != IW4X_TECHSET_VERSION)
{ {
Components::Logger::Error(Game::ERR_FATAL, "Reading techset '{}' failed, expected version is {}, but it was {}!", Components::Logger::Error(Game::ERR_FATAL, "Reading techset '{}' failed, expected version is {}, but it was {}!",
name, IW4X_TECHSET_VERSION, version); name, IW4X_TECHSET_VERSION, version);
} }
Game::MaterialTechniqueSet* asset = reader.readObject<Game::MaterialTechniqueSet>(); Game::MaterialTechniqueSet* asset = reader.readObject<Game::MaterialTechniqueSet>();
if (asset->name) if (asset->name)
{ {
asset->name = reader.readCString(); asset->name = reader.readCString();
} }
for (int i = 0; i < 48; i++) for (int i = 0; i < 48; i++)
{ {
if (asset->techniques[i]) if (asset->techniques[i])
{ {
const char* techName = reader.readCString(); const char* techName = reader.readCString();
this->loadBinaryTechnique(&asset->techniques[i], techName, builder); this->loadBinaryTechnique(&asset->techniques[i], techName, builder);
} }
} }
header->techniqueSet = asset; header->techniqueSet = asset;
} }
void IMaterialTechniqueSet::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) void IMaterialTechniqueSet::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{ {

View File

@ -5,15 +5,15 @@ namespace Assets
class IMaterialTechniqueSet : public Components::AssetHandler::IAsset class IMaterialTechniqueSet : public Components::AssetHandler::IAsset
{ {
public: 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; void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; 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 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 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 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);
}; };
} }

View File

@ -1,50 +1,51 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IMaterialVertexDeclaration.hpp"
#define IW4X_TECHSET_VERSION "0" #define IW4X_TECHSET_VERSION "0"
namespace Assets namespace Assets
{ {
void IMaterialVertexDeclaration::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) 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->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 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*/) void IMaterialVertexDeclaration::loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/)
{ {
header->vertexDecl = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).vertexDecl; header->vertexDecl = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).vertexDecl;
} }
void IMaterialVertexDeclaration::loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) 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())); Components::FileSystem::File declFile(Utils::String::VA("decl/%s.iw4xDECL", name.data()));
if (!declFile.exists()) return; if (!declFile.exists()) return;
Utils::Stream::Reader reader(builder->getAllocator(), declFile.getBuffer()); Utils::Stream::Reader reader(builder->getAllocator(), declFile.getBuffer());
char* magic = reader.readArray<char>(8); char* magic = reader.readArray<char>(8);
if (std::memcmp(magic, "IW4xDECL", 8)) if (std::memcmp(magic, "IW4xDECL", 8))
{ {
Components::Logger::Error(Game::ERR_FATAL, "Reading vertex declaration '{}' failed, header is invalid!", name); Components::Logger::Error(Game::ERR_FATAL, "Reading vertex declaration '{}' failed, header is invalid!", name);
} }
std::string version; std::string version;
version.push_back(reader.read<char>()); version.push_back(reader.read<char>());
if (version != IW4X_TECHSET_VERSION) if (version != IW4X_TECHSET_VERSION)
{ {
Components::Logger::Error(Game::ERR_FATAL, "Reading vertex declaration '{}' failed, expected version is {}, but it was {}!", Components::Logger::Error(Game::ERR_FATAL, "Reading vertex declaration '{}' failed, expected version is {}, but it was {}!",
name, IW4X_TECHSET_VERSION, version.data()); name, IW4X_TECHSET_VERSION, version.data());
} }
Game::MaterialVertexDeclaration* asset = reader.readObject<Game::MaterialVertexDeclaration>(); Game::MaterialVertexDeclaration* asset = reader.readObject<Game::MaterialVertexDeclaration>();
if (asset->name) if (asset->name)
{ {
asset->name = reader.readCString(); asset->name = reader.readCString();
} }
header->vertexDecl = asset; header->vertexDecl = asset;
} }
void IMaterialVertexDeclaration::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) void IMaterialVertexDeclaration::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{ {

View File

@ -5,12 +5,12 @@ namespace Assets
class IMaterialVertexDeclaration : public Components::AssetHandler::IAsset class IMaterialVertexDeclaration : public Components::AssetHandler::IAsset
{ {
public: 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; 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 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 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 loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder);
}; };
} }

View File

@ -1,55 +1,56 @@
#include <StdInclude.hpp> #include <STDInclude.hpp>
#include "IMaterialVertexShader.hpp"
#define IW4X_TECHSET_VERSION "0" #define IW4X_TECHSET_VERSION "0"
namespace Assets namespace Assets
{ {
void IMaterialVertexShader::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) 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->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 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*/) void IMaterialVertexShader::loadNative(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/)
{ {
header->vertexShader = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).vertexShader; header->vertexShader = Components::AssetHandler::FindOriginalAsset(this->getType(), name.data()).vertexShader;
} }
void IMaterialVertexShader::loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) 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())); Components::FileSystem::File vsFile(Utils::String::VA("vs/%s.iw4xVS", name.data()));
if (!vsFile.exists()) return; if (!vsFile.exists()) return;
Utils::Stream::Reader reader(builder->getAllocator(), vsFile.getBuffer()); Utils::Stream::Reader reader(builder->getAllocator(), vsFile.getBuffer());
char* magic = reader.readArray<char>(8); char* magic = reader.readArray<char>(8);
if (std::memcmp(magic, "IW4xVERT", 8)) if (std::memcmp(magic, "IW4xVERT", 8))
{ {
Components::Logger::Error(Game::ERR_FATAL, "Reading vertex shader '{}' failed, header is invalid!", name); Components::Logger::Error(Game::ERR_FATAL, "Reading vertex shader '{}' failed, header is invalid!", name);
} }
std::string version; std::string version;
version.push_back(reader.read<char>()); version.push_back(reader.read<char>());
if (version != IW4X_TECHSET_VERSION) if (version != IW4X_TECHSET_VERSION)
{ {
Components::Logger::Error(Game::ERR_FATAL, "Reading vertex shader '{}' failed, expected version is {}, but it was {}!", Components::Logger::Error(Game::ERR_FATAL, "Reading vertex shader '{}' failed, expected version is {}, but it was {}!",
name, IW4X_TECHSET_VERSION, version); name, IW4X_TECHSET_VERSION, version);
} }
Game::MaterialVertexShader* asset = reader.readObject<Game::MaterialVertexShader>(); Game::MaterialVertexShader* asset = reader.readObject<Game::MaterialVertexShader>();
if (asset->name) if (asset->name)
{ {
asset->name = reader.readCString(); asset->name = reader.readCString();
} }
if (asset->prog.loadDef.program) if (asset->prog.loadDef.program)
{ {
asset->prog.loadDef.program = reader.readArray<unsigned int>(asset->prog.loadDef.programSize); asset->prog.loadDef.program = reader.readArray<unsigned int>(asset->prog.loadDef.programSize);
} }
header->vertexShader = asset; header->vertexShader = asset;
} }
void IMaterialVertexShader::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) void IMaterialVertexShader::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{ {

View File

@ -5,12 +5,12 @@ namespace Assets
class IMaterialVertexShader : public Components::AssetHandler::IAsset class IMaterialVertexShader : public Components::AssetHandler::IAsset
{ {
public: 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; 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 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 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 loadBinary(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder);
}; };
} }

View File

@ -1,37 +1,38 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IMenuList.hpp"
namespace Assets namespace Assets
{ {
void IMenuList::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) void IMenuList::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder)
{ {
Utils::Memory::Allocator* allocator = builder->getAllocator(); Utils::Memory::Allocator* allocator = builder->getAllocator();
// actually gets the whole list // actually gets the whole list
auto menus = Components::Menus::LoadMenu(name); auto menus = Components::Menus::LoadMenu(name);
if (menus.empty()) return; if (menus.empty()) return;
// Allocate new menu list // Allocate new menu list
Game::MenuList* newList = allocator->allocate<Game::MenuList>(); Game::MenuList* newList = allocator->allocate<Game::MenuList>();
if (!newList) return; if (!newList) return;
newList->menus = allocator->allocateArray<Game::menuDef_t*>(menus.size()); newList->menus = allocator->allocateArray<Game::menuDef_t*>(menus.size());
if (!newList->menus) if (!newList->menus)
{ {
allocator->free(newList); allocator->free(newList);
return; return;
} }
newList->name = allocator->duplicateString(name); newList->name = allocator->duplicateString(name);
newList->menuCount = menus.size(); newList->menuCount = menus.size();
// Copy new menus // Copy new menus
for (unsigned int i = 0; i < menus.size(); ++i) for (unsigned int i = 0; i < menus.size(); ++i)
{ {
newList->menus[i] = menus[i].second; newList->menus[i] = menus[i].second;
} }
header->menuList = newList; header->menuList = newList;
} }
void IMenuList::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) void IMenuList::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{ {
Game::MenuList *asset = header.menuList; Game::MenuList *asset = header.menuList;

View File

@ -5,10 +5,10 @@ namespace Assets
class IMenuList : public Components::AssetHandler::IAsset class IMenuList : public Components::AssetHandler::IAsset
{ {
public: 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; void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; 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 load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
}; };
} }

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IPhysCollmap.hpp"
namespace Assets namespace Assets
{ {

View File

@ -5,9 +5,9 @@ namespace Assets
class IPhysCollmap : public Components::AssetHandler::IAsset class IPhysCollmap : public Components::AssetHandler::IAsset
{ {
public: 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: private:
void savePhysGeomInfoArray(Components::ZoneBuilder::Zone* builder, Game::PhysGeomInfo* geoms, unsigned int count); void savePhysGeomInfoArray(Components::ZoneBuilder::Zone* builder, Game::PhysGeomInfo* geoms, unsigned int count);

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IPhysPreset.hpp"
namespace Assets namespace Assets
{ {

View File

@ -5,8 +5,8 @@ namespace Assets
class IPhysPreset : public Components::AssetHandler::IAsset class IPhysPreset : public Components::AssetHandler::IAsset
{ {
public: 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;
}; };
} }

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IRawFile.hpp"
namespace Assets namespace Assets
{ {

View File

@ -5,9 +5,9 @@ namespace Assets
class IRawFile : public Components::AssetHandler::IAsset class IRawFile : public Components::AssetHandler::IAsset
{ {
public: 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; 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 load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
}; };
} }

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "ISndCurve.hpp"
namespace Assets namespace Assets
{ {

View File

@ -5,8 +5,8 @@ namespace Assets
class ISndCurve : public Components::AssetHandler::IAsset class ISndCurve : public Components::AssetHandler::IAsset
{ {
public: 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;
}; };
} }

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IStringTable.hpp"
namespace Assets namespace Assets
{ {

View File

@ -5,9 +5,9 @@ namespace Assets
class IStringTable : public Components::AssetHandler::IAsset class IStringTable : public Components::AssetHandler::IAsset
{ {
public: 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: private:
void saveStringTableCellArray(Components::ZoneBuilder::Zone* builder, Game::StringTableCell* values, int count); void saveStringTableCellArray(Components::ZoneBuilder::Zone* builder, Game::StringTableCell* values, int count);

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IStructuredDataDefSet.hpp"
namespace Assets namespace Assets
{ {

View File

@ -5,9 +5,9 @@ namespace Assets
class IStructuredDataDefSet : public Components::AssetHandler::IAsset class IStructuredDataDefSet : public Components::AssetHandler::IAsset
{ {
public: 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 saveStructuredDataEnumArray(Game::StructuredDataEnum* enums, int numEnums, Components::ZoneBuilder::Zone* builder);
void saveStructuredDataStructArray(Game::StructuredDataStruct* structs, int numStructs, Components::ZoneBuilder::Zone* builder); void saveStructuredDataStructArray(Game::StructuredDataStruct* structs, int numStructs, Components::ZoneBuilder::Zone* builder);

View File

@ -1,44 +1,45 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "ITracerDef.hpp"
namespace Assets namespace Assets
{ {
void ITracerDef::load(Game::XAssetHeader* /*header*/, const std::string& /*name*/, Components::ZoneBuilder::Zone* /*builder*/) void ITracerDef::load(Game::XAssetHeader* /*header*/, const std::string& /*name*/, Components::ZoneBuilder::Zone* /*builder*/)
{ {
return; // don't load from filesystem right now // don't load from filesystem right now
} }
void ITracerDef::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) void ITracerDef::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{ {
Game::TracerDef* asset = header.tracerDef; Game::TracerDef* asset = header.tracerDef;
if (asset->material) if (asset->material)
{ {
builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->material); builder->loadAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->material);
} }
} }
void ITracerDef::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) void ITracerDef::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{ {
AssertSize(Game::TracerDef, 0x70); AssertSize(Game::TracerDef, 0x70);
Utils::Stream* buffer = builder->getBuffer(); Utils::Stream* buffer = builder->getBuffer();
Game::TracerDef* asset = header.tracerDef; Game::TracerDef* asset = header.tracerDef;
Game::TracerDef* dest = buffer->dest<Game::TracerDef>(); Game::TracerDef* dest = buffer->dest<Game::TracerDef>();
buffer->save(asset); buffer->save(asset);
buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL); buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL);
if (asset->name) if (asset->name)
{ {
buffer->saveString(builder->getAssetName(this->getType(), asset->name)); buffer->saveString(builder->getAssetName(this->getType(), asset->name));
Utils::Stream::ClearPointer(&dest->name); Utils::Stream::ClearPointer(&dest->name);
} }
if (asset->material) if (asset->material)
{ {
dest->material = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->material).material; dest->material = builder->saveSubAsset(Game::XAssetType::ASSET_TYPE_MATERIAL, asset->material).material;
} }
buffer->popBlock(); buffer->popBlock();
} }
} }

View File

@ -2,13 +2,13 @@
namespace Assets namespace Assets
{ {
class ITracerDef : public Components::AssetHandler::IAsset class ITracerDef : public Components::AssetHandler::IAsset
{ {
public: public:
virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_TRACER; }; Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_TRACER; }
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; 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 load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
}; };
} }

File diff suppressed because it is too large Load Diff

View File

@ -5,11 +5,11 @@ namespace Assets
class IWeapon : public Components::AssetHandler::IAsset class IWeapon : public Components::AssetHandler::IAsset
{ {
public: 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; void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; 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 load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
private: private:
void writeWeaponDef(Game::WeaponDef* def, Components::ZoneBuilder::Zone* builder, Utils::Stream* buffer); void writeWeaponDef(Game::WeaponDef* def, Components::ZoneBuilder::Zone* builder, Utils::Stream* buffer);

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IXAnimParts.hpp"
#define IW4X_ANIM_VERSION 1 #define IW4X_ANIM_VERSION 1

View File

@ -5,11 +5,11 @@ namespace Assets
class IXAnimParts : public Components::AssetHandler::IAsset class IXAnimParts : public Components::AssetHandler::IAsset
{ {
public: 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; void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; 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 load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
private: private:
void saveXAnimDeltaPart(Game::XAnimDeltaPart* delta, unsigned short framecount, Components::ZoneBuilder::Zone* builder); void saveXAnimDeltaPart(Game::XAnimDeltaPart* delta, unsigned short framecount, Components::ZoneBuilder::Zone* builder);

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IXModel.hpp"
#define IW4X_MODEL_VERSION 5 #define IW4X_MODEL_VERSION 5
@ -48,20 +49,20 @@ namespace Assets
} }
// Access index block // Access index block
if (surf->triIndices) if (surf->triIndices)
{ {
void* oldPtr = surf->triIndices; void* oldPtr = surf->triIndices;
surf->triIndices = reader->readArray<unsigned short>(surf->triCount * 3); surf->triIndices = reader->readArray<unsigned short>(surf->triCount * 3);
if (builder->getAllocator()->isPointerMapped(oldPtr)) if (builder->getAllocator()->isPointerMapped(oldPtr))
{ {
surf->triIndices = builder->getAllocator()->getPointer<unsigned short>(oldPtr); surf->triIndices = builder->getAllocator()->getPointer<unsigned short>(oldPtr);
} }
else else
{ {
builder->getAllocator()->mapPointer(oldPtr, surf->triIndices); builder->getAllocator()->mapPointer(oldPtr, surf->triIndices);
} }
} }
} }
void IXModel::loadXModelSurfs(Game::XModelSurfs* asset, Utils::Stream::Reader* reader, Components::ZoneBuilder::Zone* builder) void IXModel::loadXModelSurfs(Game::XModelSurfs* asset, Utils::Stream::Reader* reader, Components::ZoneBuilder::Zone* builder)

View File

@ -5,14 +5,14 @@ namespace Assets
class IXModel : public Components::AssetHandler::IAsset class IXModel : public Components::AssetHandler::IAsset
{ {
public: 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; void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; 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 load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
private: private:
std::map<void*, void*> triIndicies; std::map<void*, void*> triIndicies;
void loadXModelSurfs(Game::XModelSurfs* asset, Utils::Stream::Reader* reader, Components::ZoneBuilder::Zone* builder); 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 loadXSurface(Game::XSurface* surf, Utils::Stream::Reader* reader, Components::ZoneBuilder::Zone* builder);
void loadXSurfaceCollisionTree(Game::XSurfaceCollisionTree* entry, Utils::Stream::Reader* reader); void loadXSurfaceCollisionTree(Game::XSurfaceCollisionTree* entry, Utils::Stream::Reader* reader);

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IXModelSurfs.hpp"
namespace Assets namespace Assets
{ {
@ -81,16 +82,16 @@ namespace Assets
// Access index block // Access index block
buffer->pushBlock(Game::XFILE_BLOCK_INDEX); buffer->pushBlock(Game::XFILE_BLOCK_INDEX);
if (builder->hasPointer(surf->triIndices)) if (builder->hasPointer(surf->triIndices))
{ {
destSurf->triIndices = builder->getPointer(surf->triIndices); destSurf->triIndices = builder->getPointer(surf->triIndices);
} }
else else
{ {
buffer->align(Utils::Stream::ALIGN_16); buffer->align(Utils::Stream::ALIGN_16);
buffer->saveArray(surf->triIndices, surf->triCount * 3); buffer->saveArray(surf->triIndices, surf->triCount * 3);
Utils::Stream::ClearPointer(&destSurf->triIndices); Utils::Stream::ClearPointer(&destSurf->triIndices);
} }
buffer->popBlock(); buffer->popBlock();
} }

View File

@ -5,9 +5,9 @@ namespace Assets
class IXModelSurfs : public Components::AssetHandler::IAsset class IXModelSurfs : public Components::AssetHandler::IAsset
{ {
public: 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: private:
void saveXSurface(Game::XSurface* surf, Game::XSurface* destSurf, Components::ZoneBuilder::Zone* builder); void saveXSurface(Game::XSurface* surf, Game::XSurface* destSurf, Components::ZoneBuilder::Zone* builder);

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "IclipMap_t.hpp"
#define IW4X_CLIPMAP_VERSION 2 #define IW4X_CLIPMAP_VERSION 2

View File

@ -5,11 +5,11 @@ namespace Assets
class IclipMap_t : public Components::AssetHandler::IAsset class IclipMap_t : public Components::AssetHandler::IAsset
{ {
public: 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; void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; 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 load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
private: private:
class SModelQuadtree class SModelQuadtree

View File

@ -1,20 +1,21 @@
#include <StdInclude.hpp> #include <STDInclude.hpp>
#include "ImenuDef_t.hpp"
namespace Assets namespace Assets
{ {
std::unordered_map<std::string, Game::menuDef_t*> ImenuDef_t::LoadedMenus; std::unordered_map<std::string, Game::menuDef_t*> ImenuDef_t::LoadedMenus;
void ImenuDef_t::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/) void ImenuDef_t::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* /*builder*/)
{ {
// load from disk // load from disk
auto menus = Components::Menus::LoadMenu(Utils::String::VA("ui_mp/%s.menu", name.data())); auto menus = Components::Menus::LoadMenu(Utils::String::VA("ui_mp/%s.menu", name.data()));
if (menus.size() == 0) return; 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() > 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) void ImenuDef_t::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
@ -53,7 +54,7 @@ namespace Assets
Utils::Stream* buffer = builder->getBuffer(); Utils::Stream* buffer = builder->getBuffer();
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->enterStruct("ExpressionSupportingData"); buffer->enterStruct("ExpressionSupportingData");
#endif #endif
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
@ -127,18 +128,18 @@ namespace Assets
} }
} }
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->leaveStruct(); buffer->leaveStruct();
#endif #endif
} }
void ImenuDef_t::save_Statement_s(Game::Statement_s* asset, Components::ZoneBuilder::Zone* builder) void ImenuDef_t::save_Statement_s(Game::Statement_s* asset, Components::ZoneBuilder::Zone* builder)
{ {
AssertSize(Game::Statement_s, 24); AssertSize(Game::Statement_s, 24);
AssertSize(Game::expressionEntry, 12); AssertSize(Game::expressionEntry, 12);
Utils::Stream* buffer = builder->getBuffer(); Utils::Stream* buffer = builder->getBuffer();
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->enterStruct("Statement_s"); buffer->enterStruct("Statement_s");
#endif #endif
// Write header data // Write header data
@ -149,7 +150,7 @@ namespace Assets
if (asset->entries) if (asset->entries)
{ {
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->enterStruct("statement entries"); buffer->enterStruct("statement entries");
#endif #endif
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
@ -161,7 +162,7 @@ namespace Assets
for (int i = 0; i < asset->numEntries; ++i) for (int i = 0; i < asset->numEntries; ++i)
{ {
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->enterStruct("entry"); buffer->enterStruct("entry");
#endif #endif
if (asset->entries[i].type) if (asset->entries[i].type)
{ {
@ -193,11 +194,11 @@ namespace Assets
} }
} }
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->leaveStruct(); buffer->leaveStruct();
#endif #endif
} }
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->leaveStruct(); buffer->leaveStruct();
#endif #endif
} }
@ -207,7 +208,7 @@ namespace Assets
Utils::Stream::ClearPointer(&dest->supportingData); Utils::Stream::ClearPointer(&dest->supportingData);
} }
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->leaveStruct(); buffer->leaveStruct();
#endif #endif
} }
@ -217,7 +218,7 @@ namespace Assets
Utils::Stream* buffer = builder->getBuffer(); Utils::Stream* buffer = builder->getBuffer();
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->enterStruct("MenuEventHandlerSet"); buffer->enterStruct("MenuEventHandlerSet");
#endif #endif
// Write header data // Write header data
@ -239,7 +240,7 @@ namespace Assets
{ {
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->enterStruct("MenuEventHandler"); buffer->enterStruct("MenuEventHandler");
#endif #endif
// Write menu event handler // Write menu event handler
@ -329,7 +330,7 @@ namespace Assets
break; break;
} }
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->leaveStruct(); buffer->leaveStruct();
#endif #endif
} }
} }
@ -337,7 +338,7 @@ namespace Assets
Utils::Stream::ClearPointer(&destset->eventHandlers); Utils::Stream::ClearPointer(&destset->eventHandlers);
} }
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->leaveStruct(); buffer->leaveStruct();
#endif #endif
} }
@ -347,7 +348,7 @@ namespace Assets
Utils::Stream* buffer = builder->getBuffer(); Utils::Stream* buffer = builder->getBuffer();
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->enterStruct("ItemKeyHandler"); buffer->enterStruct("ItemKeyHandler");
#endif #endif
while (asset) while (asset)
@ -374,7 +375,7 @@ namespace Assets
asset = asset->next; asset = asset->next;
} }
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->leaveStruct(); buffer->leaveStruct();
#endif #endif
} }
@ -404,7 +405,7 @@ namespace Assets
Utils::Stream* buffer = builder->getBuffer(); Utils::Stream* buffer = builder->getBuffer();
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->enterStruct("itemDefData_t"); buffer->enterStruct("itemDefData_t");
#endif #endif
// feeder // feeder
@ -490,7 +491,7 @@ namespace Assets
Utils::Stream::ClearPointer(&dest->typeData.data); Utils::Stream::ClearPointer(&dest->typeData.data);
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->leaveStruct(); buffer->leaveStruct();
#endif #endif
} }
@ -502,12 +503,12 @@ namespace Assets
Game::itemDef_s* dest = buffer->dest<Game::itemDef_s>(); Game::itemDef_s* dest = buffer->dest<Game::itemDef_s>();
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
if (asset->window.name) if (asset->window.name)
buffer->enterStruct(Utils::String::VA("itemDef_s: name = '%s'", asset->window.name)); buffer->enterStruct(Utils::String::VA("itemDef_s: name = '%s'", asset->window.name));
else if (asset->window.background) else if (asset->window.background)
buffer->enterStruct(Utils::String::VA("itemDef_s: bg = '%s'", asset->window.background->info.name)); buffer->enterStruct(Utils::String::VA("itemDef_s: bg = '%s'", asset->window.background->info.name));
else else
buffer->enterStruct("itemDef_s"); buffer->enterStruct("itemDef_s");
#endif #endif
buffer->save(asset); buffer->save(asset);
@ -583,7 +584,7 @@ namespace Assets
{ {
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->enterStruct("floatExpressions"); buffer->enterStruct("floatExpressions");
#endif #endif
Game::ItemFloatExpression* destExp = buffer->dest<Game::ItemFloatExpression>(); Game::ItemFloatExpression* destExp = buffer->dest<Game::ItemFloatExpression>();
@ -599,7 +600,7 @@ namespace Assets
Utils::Stream::ClearPointer(&dest->floatExpressions); Utils::Stream::ClearPointer(&dest->floatExpressions);
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->leaveStruct(); buffer->leaveStruct();
#endif #endif
} }
@ -610,7 +611,7 @@ namespace Assets
STATEMENT(materialExp); STATEMENT(materialExp);
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->leaveStruct(); buffer->leaveStruct();
#endif #endif
} }
@ -619,7 +620,7 @@ namespace Assets
AssertSize(Game::menuDef_t, 400); AssertSize(Game::menuDef_t, 400);
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->enterStruct("ImenuDef_t"); buffer->enterStruct("ImenuDef_t");
#endif #endif
Utils::Stream* buffer = builder->getBuffer(); Utils::Stream* buffer = builder->getBuffer();
@ -700,7 +701,7 @@ namespace Assets
} }
} }
#ifdef WRITE_LOGS #ifdef WRITE_LOGS
buffer->leaveStruct(); buffer->leaveStruct();
#endif #endif
buffer->popBlock(); buffer->popBlock();

View File

@ -5,13 +5,13 @@ namespace Assets
class ImenuDef_t : public Components::AssetHandler::IAsset class ImenuDef_t : public Components::AssetHandler::IAsset
{ {
public: 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; void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; 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 load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder) override;
static std::unordered_map<std::string, Game::menuDef_t*> LoadedMenus; static std::unordered_map<std::string, Game::menuDef_t*> LoadedMenus;
private: private:
template <typename T> void save_windowDef_t(Game::windowDef_t* asset, T* dest, Components::ZoneBuilder::Zone* builder) template <typename T> void save_windowDef_t(Game::windowDef_t* asset, T* dest, Components::ZoneBuilder::Zone* builder)

View File

@ -1,4 +1,5 @@
#include <STDInclude.hpp> #include <STDInclude.hpp>
#include "Isnd_alias_list_t.hpp"
namespace Assets namespace Assets
{ {

View File

@ -5,10 +5,10 @@ namespace Assets
class Isnd_alias_list_t : public Components::AssetHandler::IAsset class Isnd_alias_list_t : public Components::AssetHandler::IAsset
{ {
public: 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; 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 save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
}; };
} }

View File

@ -77,7 +77,7 @@ namespace Utils
int IsSpace(int c); int IsSpace(int c);
std::string ToLower(std::string text); std::string ToLower(std::string text);
std::string ToUpper(std::string text); std::string ToUpper(std::string text);
std::vector<std::string> Split(const std::string& str, const char delim); std::vector<std::string> Split(const std::string& str, char delim);
void Replace(std::string& string, const std::string& find, const std::string& replace); void Replace(std::string& string, const std::string& find, const std::string& replace);
bool StartsWith(const std::string& haystack, const std::string& needle); bool StartsWith(const std::string& haystack, const std::string& needle);
bool EndsWith(const std::string& haystack, const std::string& needle); bool EndsWith(const std::string& haystack, const std::string& needle);