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

92 lines
2.3 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();
void build();
2016-01-05 19:23:43 -05:00
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);
2016-01-05 19:23:43 -05:00
template<typename T>
T* getPointer(const T* pointer) { return reinterpret_cast<T*>(this->safeGetPointer(pointer)); }
2016-01-05 19:23:43 -05:00
int findAsset(Game::XAssetType type, std::string name);
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);
2016-01-05 19:23:43 -05:00
int addScriptString(unsigned short gameIndex);
int addScriptString(std::string str);
int findScriptString(std::string str);
2016-01-05 19:23:43 -05:00
void mapScriptString(unsigned short* gameIndex);
2016-01-05 19:23:43 -05:00
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
void store(Game::XAssetHeader header);
2016-01-26 10:12:41 -05:00
void incrementExternalSize(unsigned int size);
2016-01-04 18:49:34 -05:00
private:
void loadFastFiles();
2016-01-05 19:23:43 -05:00
bool loadAssets();
bool loadAsset(std::string type, std::string name);
2016-01-05 19:23:43 -05:00
void saveData();
void writeZone();
2016-01-05 19:23:43 -05:00
void addBranding();
2016-01-05 19:23:43 -05:00
uint32_t safeGetPointer(const void* pointer);
2016-01-05 19:23:43 -05:00
int indexStart;
unsigned int externalSize;
Utils::Stream buffer;
2016-01-05 19:23:43 -05:00
std::string zoneName;
Utils::CSV dataMap;
2016-01-05 19:23:43 -05:00
Utils::Memory::Allocator memAllocator;
std::vector<Game::XAsset> loadedAssets;
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-05 19:23:43 -05:00
Game::RawFile branding;
2016-01-04 18:49:34 -05:00
};
2016-08-15 10:40:30 -04:00
ZoneBuilder();
2016-09-16 05:04:28 -04:00
#if defined(DEBUG) || defined(FORCE_UNIT_TESTS)
const char* getName() { return "ZoneBuilder"; };
2016-08-15 10:40:30 -04:00
#endif
2016-01-04 18:49:34 -05:00
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
};
}