[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++)
{
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++)
{
@ -404,7 +404,7 @@ namespace Components
AssetHandler::RegisterInterface(new Assets::IPhysCollmap());
AssetHandler::RegisterInterface(new Assets::IStringTable());
//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::IMaterialPixelShader());
AssetHandler::RegisterInterface(new Assets::IMaterialTechniqueSet());

View File

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

View File

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

View File

@ -4,7 +4,7 @@ namespace Assets
{
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;
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)
{
Game::GfxWorld* asset = header.gfxMap;
Game::GfxWorld* asset = header.gfxWorld;
if(asset->worldDraw.reflectionImages)
{
@ -498,7 +498,7 @@ namespace Assets
AssertSize(Game::GfxWorld, 0x274);
Utils::Stream* buffer = builder->getBuffer();
Game::GfxWorld* asset = header.gfxMap;
Game::GfxWorld* asset = header.gfxWorld;
Game::GfxWorld* dest = buffer->dest<Game::GfxWorld>();
buffer->save(asset);

View File

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

View File

@ -2,13 +2,13 @@
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();
Game::LocalizedEntry* asset = header.localize;
Game::LocalizedEntry* dest = buffer->dest<Game::LocalizedEntry>();
Game::LocalizeEntry* asset = header.localize;
Game::LocalizeEntry* dest = buffer->dest<Game::LocalizeEntry>();
buffer->save(asset);
buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL);

View File

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

View File

@ -212,7 +212,7 @@ namespace Assets
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)

View File

@ -4,7 +4,7 @@ namespace Assets
{
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)
{
@ -39,7 +39,7 @@ namespace Assets
AssertSize(Game::MaterialTechniqueSet, 204);
Utils::Stream* buffer = builder->getBuffer();
Game::MaterialTechniqueSet* asset = header.materialTechset;
Game::MaterialTechniqueSet* asset = header.techniqueSet;
Game::MaterialTechniqueSet* dest = buffer->dest<Game::MaterialTechniqueSet>();
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());
}
header->xanim = xanim;
header->parts = xanim;
}
}
}
void IXAnimParts::mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
{
Game::XAnimParts* asset = header.xanim;
Game::XAnimParts* asset = header.parts;
if (asset->tagnames)
{
@ -241,7 +241,7 @@ namespace Assets
AssertSize(Game::XAnimParts, 88);
Utils::Stream* buffer = builder->getBuffer();
Game::XAnimParts* asset = header.xanim;
Game::XAnimParts* asset = header.parts;
Game::XAnimParts* dest = buffer->dest<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)
{
Game::snd_alias_list_t* asset = header.aliasList;
Game::snd_alias_list_t* asset = header.sound;
for (int i = 0; i < asset->count; ++i)
{
@ -27,7 +27,7 @@ namespace Assets
AssertSize(Game::snd_alias_list_t, 12);
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>();
buffer->save(asset);
@ -110,7 +110,7 @@ namespace Assets
{
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
{

View File

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

View File

@ -19,8 +19,8 @@ namespace Components
private:
static std::mutex LocalizeMutex;
static Utils::Memory::Allocator MemAllocator;
static std::unordered_map<std::string, Game::LocalizedEntry*> LocalizeMap;
static std::unordered_map<std::string, Game::LocalizedEntry*> TempLocalizeMap;
static std::unordered_map<std::string, Game::LocalizeEntry*> LocalizeMap;
static std::unordered_map<std::string, Game::LocalizeEntry*> TempLocalizeMap;
static Dvar::Var UseLocalization;
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)
{
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
{
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::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);
if (world)

View File

@ -15,7 +15,7 @@ namespace Components
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)
{
@ -24,7 +24,7 @@ namespace Components
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;
};
struct LocalizedEntry
struct LocalizeEntry
{
const char* value;
const char* name;
@ -3200,42 +3200,67 @@ namespace Game
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
{
void *data;
// This is only for debugging
const char* string;
MenuList *menuList;
menuDef_t *menu;
Material *material;
snd_alias_list_t *aliasList;
LocalizedEntry *localize;
StringTable *stringTable;
snd_alias_list_t* sound;
LocalizeEntry* localize;
StringTable* stringTable;
MapEnts* mapEnts;
RawFile* rawfile;
GfxImage* image;
Font* font;
MaterialTechniqueSet *materialTechset;
MaterialVertexDeclaration *vertexDecl;
MaterialVertexShader *vertexShader;
MaterialPixelShader *pixelShader;
MaterialTechniqueSet* techniqueSet;
MaterialVertexDeclaration* vertexDecl;
MaterialVertexShader* vertexShader;
MaterialPixelShader* pixelShader;
StructuredDataDefSet* structuredData;
XModel* model;
PhysPreset* physPreset;
PhysCollmap* physCollmap;
XModelSurfs* surfaces;
XAnimParts* xanim;
XAnimParts* parts;
clipMap_t* clipMap;
FxEffectDef* fx;
GameWorldMp* gameMapMP;
GameWorldSp* gameMapSP;
GameWorldMp* gameWorldMp;
GameWorldSp* gameWorldSp;
TracerDef* tracer;
VehicleDef* vehicle;
GfxWorld* gfxMap;
GfxWorld* gfxWorld;
GfxLightDef* lightDef;
SndCurve* sndCurve;
LoadedSound* sound;
LoadedSound* loadSnd;
ComWorld* comWorld;
};
struct XAsset