iw4x-client/src/Components/Modules/ZoneBuilder.hpp

86 lines
2.2 KiB
C++
Raw Normal View History

2016-01-04 18:49:34 -05:00
#define XFILE_MAGIC_UNSIGNED 0x3030317566665749
#define XFILE_VERSION 276
2016-06-27 19:03:37 -04:00
#define XFILE_VERSION_IW4X 0x78345749 // 'IW4x'
2016-01-04 18:49:34 -05:00
namespace Components
{
class ZoneBuilder : public Component
{
public:
class Zone
{
public:
Zone(std::string zoneName);
~Zone();
2016-01-05 19:23:43 -05:00
void Build();
Utils::Stream* GetBuffer();
Utils::Memory::Allocator* GetAllocator();
2016-01-05 19:23:43 -05:00
bool HasPointer(const void* pointer);
void StorePointer(const void* pointer);
template<typename T>
T* GetPointer(const T* pointer) { return reinterpret_cast<T*>(SafeGetPointer(pointer)); }
int FindAsset(Game::XAssetType type, std::string name);
2016-01-05 19:23:43 -05:00
Game::XAsset* GetAsset(int index);
uint32_t GetAssetOffset(int index);
Game::XAssetHeader RequireAsset(Game::XAssetType type, const char* name);
bool LoadAsset(Game::XAssetType type, std::string name);
int AddScriptString(unsigned short gameIndex);
2016-01-22 07:18:26 -05:00
int AddScriptString(std::string str);
2016-01-05 19:23:43 -05:00
int FindScriptString(std::string str);
void MapScriptString(unsigned short* gameIndex);
void RenameAsset(Game::XAssetType type, std::string asset, std::string newName);
std::string GetAssetName(Game::XAssetType type, std::string asset);
2016-01-04 18:49:34 -05:00
2016-01-26 10:12:41 -05:00
void Store(Game::XAssetHeader header);
2016-01-04 18:49:34 -05:00
private:
2016-01-05 19:23:43 -05:00
void LoadFastFiles();
bool LoadAssets();
bool LoadAsset(std::string type, std::string name);
void SaveData();
void WriteZone();
void AddBranding();
uint32_t SafeGetPointer(const void* pointer);
int IndexStart;
Utils::Stream Buffer;
2016-01-04 18:49:34 -05:00
std::string ZoneName;
2016-01-05 19:23:43 -05:00
Utils::CSV DataMap;
Utils::Memory::Allocator MemAllocator;
2016-01-22 05:59:43 -05:00
std::vector<Game::XAsset> LoadedAssets;
2016-01-05 19:23:43 -05:00
std::vector<std::string> ScriptStrings;
std::map<unsigned short, unsigned int> ScriptStringMap;
std::map<std::string, std::string> RenameMap[Game::XAssetType::ASSET_TYPE_COUNT];
std::map<const void*, uint32_t> PointerMap;
2016-01-24 15:08:14 -05:00
Game::RawFile Branding;
2016-01-04 18:49:34 -05:00
};
ZoneBuilder();
const char* GetName() { return "ZoneBuilder"; };
static bool IsEnabled();
2016-05-16 09:38:58 -04:00
static std::string TraceZone;
static std::vector<std::pair<Game::XAssetType, std::string>> TraceAssets;
static void BeginAssetTrace(std::string zone);
static std::vector<std::pair<Game::XAssetType, std::string>> EndAssetTrace();
2016-01-04 18:49:34 -05:00
};
}