[ZoneBuilder] Correct XAssetHeader struct

This commit is contained in:
momo5502 2016-12-21 17:26:16 +01:00
parent fac7f0ef4c
commit 3e69704aed
16 changed files with 79 additions and 54 deletions

View File

@ -136,11 +136,11 @@ namespace Components
{ {
for (int i = 0; i < 48; i++) for (int i = 0; i < 48; i++)
{ {
if (asset.materialTechset->techniques[i]) if (asset.techniqueSet->techniques[i])
{ {
for (int j = 0; j < asset.materialTechset->techniques[i]->numPasses; j++) for (int j = 0; j < asset.techniqueSet->techniques[i]->numPasses; j++)
{ {
Game::MaterialPass* pass = &asset.materialTechset->techniques[i]->passes[j]; Game::MaterialPass* pass = &asset.techniqueSet->techniques[i]->passes[j];
for (int k = 0; k < (pass->argCount1 + pass->argCount2 + pass->argCount3); k++) for (int k = 0; k < (pass->argCount1 + pass->argCount2 + pass->argCount3); k++)
{ {
@ -404,7 +404,7 @@ namespace Components
AssetHandler::RegisterInterface(new Assets::IPhysCollmap()); AssetHandler::RegisterInterface(new Assets::IPhysCollmap());
AssetHandler::RegisterInterface(new Assets::IStringTable()); AssetHandler::RegisterInterface(new Assets::IStringTable());
//AssetHandler::RegisterInterface(new Assets::IXModelSurfs()); //AssetHandler::RegisterInterface(new Assets::IXModelSurfs());
AssetHandler::RegisterInterface(new Assets::ILocalizedEntry()); AssetHandler::RegisterInterface(new Assets::ILocalizeEntry());
AssetHandler::RegisterInterface(new Assets::Isnd_alias_list_t()); AssetHandler::RegisterInterface(new Assets::Isnd_alias_list_t());
AssetHandler::RegisterInterface(new Assets::IMaterialPixelShader()); AssetHandler::RegisterInterface(new Assets::IMaterialPixelShader());
AssetHandler::RegisterInterface(new Assets::IMaterialTechniqueSet()); AssetHandler::RegisterInterface(new Assets::IMaterialTechniqueSet());

View File

@ -86,7 +86,7 @@ namespace Components
#include "AssetInterfaces\IPhysCollmap.hpp" #include "AssetInterfaces\IPhysCollmap.hpp"
#include "AssetInterfaces\IStringTable.hpp" #include "AssetInterfaces\IStringTable.hpp"
#include "AssetInterfaces\IXModelSurfs.hpp" #include "AssetInterfaces\IXModelSurfs.hpp"
#include "AssetInterfaces\ILocalizedEntry.hpp" #include "AssetInterfaces\ILocalizeEntry.hpp"
#include "AssetInterfaces\Isnd_alias_list_t.hpp" #include "AssetInterfaces\Isnd_alias_list_t.hpp"
#include "AssetInterfaces\IMaterialPixelShader.hpp" #include "AssetInterfaces\IMaterialPixelShader.hpp"
#include "AssetInterfaces\IMaterialTechniqueSet.hpp" #include "AssetInterfaces\IMaterialTechniqueSet.hpp"

View File

@ -7,7 +7,7 @@ namespace Assets
AssertSize(Game::GameWorldMp, 8); AssertSize(Game::GameWorldMp, 8);
Utils::Stream* buffer = builder->getBuffer(); Utils::Stream* buffer = builder->getBuffer();
Game::GameWorldMp* asset = header.gameMapMP; Game::GameWorldMp* asset = header.gameWorldMp;
Game::GameWorldMp* dest = buffer->dest<Game::GameWorldMp>(); Game::GameWorldMp* dest = buffer->dest<Game::GameWorldMp>();
buffer->save(asset); buffer->save(asset);

View File

@ -4,7 +4,7 @@ namespace Assets
{ {
void IGfxWorld::load(Game::XAssetHeader* /*header*/, std::string name, Components::ZoneBuilder::Zone* /*builder*/) void IGfxWorld::load(Game::XAssetHeader* /*header*/, std::string name, Components::ZoneBuilder::Zone* /*builder*/)
{ {
Game::GfxWorld* map = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_GFX_MAP, name.data()).gfxMap; Game::GfxWorld* map = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_GFX_MAP, name.data()).gfxWorld;
if (map) return; if (map) return;
Components::Logger::Error("Missing GfxMap %s... you can't make them yet you idiot.", name.data()); Components::Logger::Error("Missing GfxMap %s... you can't make them yet you idiot.", name.data());
@ -12,7 +12,7 @@ namespace Assets
void IGfxWorld::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) void IGfxWorld::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{ {
Game::GfxWorld* asset = header.gfxMap; Game::GfxWorld* asset = header.gfxWorld;
if(asset->worldDraw.reflectionImages) if(asset->worldDraw.reflectionImages)
{ {
@ -498,7 +498,7 @@ namespace Assets
AssertSize(Game::GfxWorld, 0x274); AssertSize(Game::GfxWorld, 0x274);
Utils::Stream* buffer = builder->getBuffer(); Utils::Stream* buffer = builder->getBuffer();
Game::GfxWorld* asset = header.gfxMap; Game::GfxWorld* asset = header.gfxWorld;
Game::GfxWorld* dest = buffer->dest<Game::GfxWorld>(); Game::GfxWorld* dest = buffer->dest<Game::GfxWorld>();
buffer->save(asset); buffer->save(asset);

View File

@ -7,7 +7,7 @@ namespace Assets
AssertSize(Game::LoadedSound, 44); AssertSize(Game::LoadedSound, 44);
Utils::Stream* buffer = builder->getBuffer(); Utils::Stream* buffer = builder->getBuffer();
Game::LoadedSound* asset = header.sound; Game::LoadedSound* asset = header.loadSnd;
Game::LoadedSound* dest = buffer->dest<Game::LoadedSound>(); Game::LoadedSound* dest = buffer->dest<Game::LoadedSound>();
buffer->save(asset); buffer->save(asset);

View File

@ -2,13 +2,13 @@
namespace Assets namespace Assets
{ {
void ILocalizedEntry::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) void ILocalizeEntry::save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{ {
AssertSize(Game::LocalizedEntry, 8); AssertSize(Game::LocalizeEntry, 8);
Utils::Stream* buffer = builder->getBuffer(); Utils::Stream* buffer = builder->getBuffer();
Game::LocalizedEntry* asset = header.localize; Game::LocalizeEntry* asset = header.localize;
Game::LocalizedEntry* dest = buffer->dest<Game::LocalizedEntry>(); Game::LocalizeEntry* dest = buffer->dest<Game::LocalizeEntry>();
buffer->save(asset); buffer->save(asset);
buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL); buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL);

View File

@ -1,6 +1,6 @@
namespace Assets namespace Assets
{ {
class ILocalizedEntry : public Components::AssetHandler::IAsset class ILocalizeEntry : public Components::AssetHandler::IAsset
{ {
public: public:
virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_LOCALIZE; }; virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_LOCALIZE; };

View File

@ -212,7 +212,7 @@ namespace Assets
if (asset->techniqueSet) if (asset->techniqueSet)
{ {
dest->techniqueSet = builder->requireAsset(Game::XAssetType::ASSET_TYPE_TECHSET, asset->techniqueSet->name).materialTechset; dest->techniqueSet = builder->requireAsset(Game::XAssetType::ASSET_TYPE_TECHSET, asset->techniqueSet->name).techniqueSet;
} }
if (asset->textureTable) if (asset->textureTable)

View File

@ -4,7 +4,7 @@ namespace Assets
{ {
void IMaterialTechniqueSet::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) void IMaterialTechniqueSet::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{ {
Game::MaterialTechniqueSet* asset = header.materialTechset; Game::MaterialTechniqueSet* asset = header.techniqueSet;
for (int i = 0; i < ARRAYSIZE(Game::MaterialTechniqueSet::techniques); ++i) for (int i = 0; i < ARRAYSIZE(Game::MaterialTechniqueSet::techniques); ++i)
{ {
@ -39,7 +39,7 @@ namespace Assets
AssertSize(Game::MaterialTechniqueSet, 204); AssertSize(Game::MaterialTechniqueSet, 204);
Utils::Stream* buffer = builder->getBuffer(); Utils::Stream* buffer = builder->getBuffer();
Game::MaterialTechniqueSet* asset = header.materialTechset; Game::MaterialTechniqueSet* asset = header.techniqueSet;
Game::MaterialTechniqueSet* dest = buffer->dest<Game::MaterialTechniqueSet>(); Game::MaterialTechniqueSet* dest = buffer->dest<Game::MaterialTechniqueSet>();
buffer->save(asset); buffer->save(asset);

View File

@ -98,14 +98,14 @@ namespace Assets
Components::Logger::Error(0, "Reading animation '%s' failed, remaining raw data found!", name.data()); Components::Logger::Error(0, "Reading animation '%s' failed, remaining raw data found!", name.data());
} }
header->xanim = xanim; header->parts = xanim;
} }
} }
} }
void IXAnimParts::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) void IXAnimParts::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{ {
Game::XAnimParts* asset = header.xanim; Game::XAnimParts* asset = header.parts;
if (asset->tagnames) if (asset->tagnames)
{ {
@ -241,7 +241,7 @@ namespace Assets
AssertSize(Game::XAnimParts, 88); AssertSize(Game::XAnimParts, 88);
Utils::Stream* buffer = builder->getBuffer(); Utils::Stream* buffer = builder->getBuffer();
Game::XAnimParts* asset = header.xanim; Game::XAnimParts* asset = header.parts;
Game::XAnimParts* dest = buffer->dest<Game::XAnimParts>(); Game::XAnimParts* dest = buffer->dest<Game::XAnimParts>();
buffer->save(asset, sizeof(Game::XAnimParts)); buffer->save(asset, sizeof(Game::XAnimParts));

View File

@ -4,7 +4,7 @@ namespace Assets
{ {
void Isnd_alias_list_t::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) void Isnd_alias_list_t::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{ {
Game::snd_alias_list_t* asset = header.aliasList; Game::snd_alias_list_t* asset = header.sound;
for (int i = 0; i < asset->count; ++i) for (int i = 0; i < asset->count; ++i)
{ {
@ -27,7 +27,7 @@ namespace Assets
AssertSize(Game::snd_alias_list_t, 12); AssertSize(Game::snd_alias_list_t, 12);
Utils::Stream* buffer = builder->getBuffer(); Utils::Stream* buffer = builder->getBuffer();
Game::snd_alias_list_t* asset = header.aliasList; Game::snd_alias_list_t* asset = header.sound;
Game::snd_alias_list_t* dest = buffer->dest<Game::snd_alias_list_t>(); Game::snd_alias_list_t* dest = buffer->dest<Game::snd_alias_list_t>();
buffer->save(asset); buffer->save(asset);
@ -110,7 +110,7 @@ namespace Assets
{ {
if (alias->soundFile->type == Game::snd_alias_type_t::SAT_LOADED) if (alias->soundFile->type == Game::snd_alias_type_t::SAT_LOADED)
{ {
destSoundFile->data.loaded = builder->requireAsset(Game::XAssetType::ASSET_TYPE_LOADED_SOUND, alias->soundFile->data.loaded->name).sound; destSoundFile->data.loaded = builder->requireAsset(Game::XAssetType::ASSET_TYPE_LOADED_SOUND, alias->soundFile->data.loaded->name).loadSnd;
} }
else else
{ {

View File

@ -5,8 +5,8 @@ namespace Components
std::mutex Localization::LocalizeMutex; std::mutex Localization::LocalizeMutex;
Dvar::Var Localization::UseLocalization; Dvar::Var Localization::UseLocalization;
Utils::Memory::Allocator Localization::MemAllocator; Utils::Memory::Allocator Localization::MemAllocator;
std::unordered_map<std::string, Game::LocalizedEntry*> Localization::LocalizeMap; std::unordered_map<std::string, Game::LocalizeEntry*> Localization::LocalizeMap;
std::unordered_map<std::string, Game::LocalizedEntry*> Localization::TempLocalizeMap; std::unordered_map<std::string, Game::LocalizeEntry*> Localization::TempLocalizeMap;
void Localization::Set(std::string key, std::string value) void Localization::Set(std::string key, std::string value)
{ {
@ -14,7 +14,7 @@ namespace Components
if (Localization::LocalizeMap.find(key) != Localization::LocalizeMap.end()) if (Localization::LocalizeMap.find(key) != Localization::LocalizeMap.end())
{ {
Game::LocalizedEntry* entry = Localization::LocalizeMap[key]; Game::LocalizeEntry* entry = Localization::LocalizeMap[key];
char* newStaticValue = Localization::MemAllocator.duplicateString(value); char* newStaticValue = Localization::MemAllocator.duplicateString(value);
if (!newStaticValue) return; if (!newStaticValue) return;
@ -23,7 +23,7 @@ namespace Components
return; return;
} }
Game::LocalizedEntry* entry = Localization::MemAllocator.allocate<Game::LocalizedEntry>(); Game::LocalizeEntry* entry = Localization::MemAllocator.allocate<Game::LocalizeEntry>();
if (!entry) return; if (!entry) return;
entry->name = Localization::MemAllocator.duplicateString(key); entry->name = Localization::MemAllocator.duplicateString(key);
@ -48,7 +48,7 @@ namespace Components
{ {
if (!Localization::UseLocalization.get<bool>()) return key; if (!Localization::UseLocalization.get<bool>()) return key;
Game::LocalizedEntry* entry = nullptr; Game::LocalizeEntry* entry = nullptr;
std::lock_guard<std::mutex> _(Localization::LocalizeMutex); std::lock_guard<std::mutex> _(Localization::LocalizeMutex);
if (Localization::TempLocalizeMap.find(key) != Localization::TempLocalizeMap.end()) if (Localization::TempLocalizeMap.find(key) != Localization::TempLocalizeMap.end())
@ -81,13 +81,13 @@ namespace Components
if (Localization::TempLocalizeMap.find(key) != Localization::TempLocalizeMap.end()) if (Localization::TempLocalizeMap.find(key) != Localization::TempLocalizeMap.end())
{ {
Game::LocalizedEntry* entry = Localization::TempLocalizeMap[key]; Game::LocalizeEntry* entry = Localization::TempLocalizeMap[key];
if(entry->value) Localization::MemAllocator.free(entry->value); if(entry->value) Localization::MemAllocator.free(entry->value);
entry->value = Localization::MemAllocator.duplicateString(value); entry->value = Localization::MemAllocator.duplicateString(value);
} }
else else
{ {
Game::LocalizedEntry* entry = Localization::MemAllocator.allocate<Game::LocalizedEntry>(); Game::LocalizeEntry* entry = Localization::MemAllocator.allocate<Game::LocalizeEntry>();
if (!entry) return; if (!entry) return;
entry->name = Localization::MemAllocator.duplicateString(key); entry->name = Localization::MemAllocator.duplicateString(key);

View File

@ -19,8 +19,8 @@ namespace Components
private: private:
static std::mutex LocalizeMutex; static std::mutex LocalizeMutex;
static Utils::Memory::Allocator MemAllocator; static Utils::Memory::Allocator MemAllocator;
static std::unordered_map<std::string, Game::LocalizedEntry*> LocalizeMap; static std::unordered_map<std::string, Game::LocalizeEntry*> LocalizeMap;
static std::unordered_map<std::string, Game::LocalizedEntry*> TempLocalizeMap; static std::unordered_map<std::string, Game::LocalizeEntry*> TempLocalizeMap;
static Dvar::Var UseLocalization; static Dvar::Var UseLocalization;
static void __stdcall SetStringStub(const char* key, const char* value, bool isEnglish); static void __stdcall SetStringStub(const char* key, const char* value, bool isEnglish);

View File

@ -158,11 +158,11 @@ namespace Components
{ {
if (!Utils::String::StartsWith(Maps::CurrentMainZone, "mp_") || Maps::IsSPMap) if (!Utils::String::StartsWith(Maps::CurrentMainZone, "mp_") || Maps::IsSPMap)
{ {
return Game::DB_XAssetPool[Game::XAssetType::ASSET_TYPE_GAME_MAP_SP].gameMapSP[0].data; return Game::DB_XAssetPool[Game::XAssetType::ASSET_TYPE_GAME_MAP_SP].gameWorldSp[0].data;
} }
else else
{ {
return Game::DB_XAssetPool[Game::XAssetType::ASSET_TYPE_GAME_MAP_MP].gameMapMP[0].data; return Game::DB_XAssetPool[Game::XAssetType::ASSET_TYPE_GAME_MAP_MP].gameWorldMp[0].data;
} }
} }
@ -597,7 +597,7 @@ namespace Components
Game::GfxWorld* world = nullptr; Game::GfxWorld* world = nullptr;
Game::DB_EnumXAssets(Game::XAssetType::ASSET_TYPE_GFX_MAP, [] (Game::XAssetHeader header, void* world) Game::DB_EnumXAssets(Game::XAssetType::ASSET_TYPE_GFX_MAP, [] (Game::XAssetHeader header, void* world)
{ {
*reinterpret_cast<Game::GfxWorld**>(world) = header.gfxMap; *reinterpret_cast<Game::GfxWorld**>(world) = header.gfxWorld;
}, &world, false); }, &world, false);
if (world) if (world)

View File

@ -15,7 +15,7 @@ namespace Components
if (MusicalTalent::SoundAliasList.find(Utils::String::ToLower(filename)) != MusicalTalent::SoundAliasList.end()) if (MusicalTalent::SoundAliasList.find(Utils::String::ToLower(filename)) != MusicalTalent::SoundAliasList.end())
{ {
Game::snd_alias_list_t* aliases = Game::DB_FindXAssetHeader(type, filename.data()).aliasList; Game::snd_alias_list_t* aliases = Game::DB_FindXAssetHeader(type, filename.data()).sound;
if (aliases) if (aliases)
{ {
@ -24,7 +24,7 @@ namespace Components
aliases->head->soundFile->data.stream.name = MusicalTalent::SoundAliasList[Utils::String::ToLower(filename)]; aliases->head->soundFile->data.stream.name = MusicalTalent::SoundAliasList[Utils::String::ToLower(filename)];
} }
header.aliasList = aliases; header.sound = aliases;
} }
} }

View File

@ -1213,7 +1213,7 @@ namespace Game
UILocalVarContext localVars; UILocalVarContext localVars;
}; };
struct LocalizedEntry struct LocalizeEntry
{ {
const char* value; const char* value;
const char* name; const char* name;
@ -3200,42 +3200,67 @@ namespace Game
GfxWorld* world; GfxWorld* world;
}; };
struct ComPrimaryLight
{
char type;
char canUseShadowMap;
char exponent;
char unused;
float color[3];
float dir[3];
float origin[3];
float radius;
float cosHalfFovOuter;
float cosHalfFovInner;
float cosHalfFovExpanded;
float rotationLimit;
float translationLimit;
char* name;
};
struct ComWorld
{
char *name;
int isInUse;
int lightCount;
ComPrimaryLight* lights;
};
union XAssetHeader union XAssetHeader
{ {
void *data; void *data;
// This is only for debugging
const char* string;
MenuList *menuList; MenuList *menuList;
menuDef_t *menu; menuDef_t *menu;
Material *material; Material *material;
snd_alias_list_t *aliasList; snd_alias_list_t* sound;
LocalizedEntry *localize; LocalizeEntry* localize;
StringTable *stringTable; StringTable* stringTable;
MapEnts* mapEnts; MapEnts* mapEnts;
RawFile* rawfile; RawFile* rawfile;
GfxImage* image; GfxImage* image;
Font* font; Font* font;
MaterialTechniqueSet *materialTechset; MaterialTechniqueSet* techniqueSet;
MaterialVertexDeclaration *vertexDecl; MaterialVertexDeclaration* vertexDecl;
MaterialVertexShader *vertexShader; MaterialVertexShader* vertexShader;
MaterialPixelShader *pixelShader; MaterialPixelShader* pixelShader;
StructuredDataDefSet* structuredData; StructuredDataDefSet* structuredData;
XModel* model; XModel* model;
PhysPreset* physPreset; PhysPreset* physPreset;
PhysCollmap* physCollmap; PhysCollmap* physCollmap;
XModelSurfs* surfaces; XModelSurfs* surfaces;
XAnimParts* xanim; XAnimParts* parts;
clipMap_t* clipMap; clipMap_t* clipMap;
FxEffectDef* fx; FxEffectDef* fx;
GameWorldMp* gameMapMP; GameWorldMp* gameWorldMp;
GameWorldSp* gameMapSP; GameWorldSp* gameWorldSp;
TracerDef* tracer; TracerDef* tracer;
VehicleDef* vehicle; VehicleDef* vehicle;
GfxWorld* gfxMap; GfxWorld* gfxWorld;
GfxLightDef* lightDef;
SndCurve* sndCurve; SndCurve* sndCurve;
LoadedSound* sound; LoadedSound* loadSnd;
ComWorld* comWorld;
}; };
struct XAsset struct XAsset