From 3e69704aed1248b1b557d9726f9f0abc534a5135 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Wed, 21 Dec 2016 17:26:16 +0100 Subject: [PATCH] [ZoneBuilder] Correct XAssetHeader struct --- src/Components/Modules/AssetHandler.cpp | 8 +-- src/Components/Modules/AssetHandler.hpp | 2 +- .../Modules/AssetInterfaces/IGameWorldMp.cpp | 2 +- .../Modules/AssetInterfaces/IGfxWorld.cpp | 6 +- .../Modules/AssetInterfaces/ILoadedSound.cpp | 2 +- ...ILocalizedEntry.cpp => ILocalizeEntry.cpp} | 8 +-- ...ILocalizedEntry.hpp => ILocalizeEntry.hpp} | 2 +- .../Modules/AssetInterfaces/IMaterial.cpp | 2 +- .../AssetInterfaces/IMaterialTechniqueSet.cpp | 4 +- .../Modules/AssetInterfaces/IXAnimParts.cpp | 6 +- .../AssetInterfaces/Isnd_alias_list_t.cpp | 6 +- src/Components/Modules/Localization.cpp | 14 ++--- src/Components/Modules/Localization.hpp | 4 +- src/Components/Modules/Maps.cpp | 6 +- src/Components/Modules/MusicalTalent.cpp | 4 +- src/Game/Structs.hpp | 57 +++++++++++++------ 16 files changed, 79 insertions(+), 54 deletions(-) rename src/Components/Modules/AssetInterfaces/{ILocalizedEntry.cpp => ILocalizeEntry.cpp} (64%) rename src/Components/Modules/AssetInterfaces/{ILocalizedEntry.hpp => ILocalizeEntry.hpp} (78%) diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index 34f8e018..7af142ac 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -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()); diff --git a/src/Components/Modules/AssetHandler.hpp b/src/Components/Modules/AssetHandler.hpp index 63427db4..27309d88 100644 --- a/src/Components/Modules/AssetHandler.hpp +++ b/src/Components/Modules/AssetHandler.hpp @@ -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" diff --git a/src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp b/src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp index 771a0233..f6ff1344 100644 --- a/src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp +++ b/src/Components/Modules/AssetInterfaces/IGameWorldMp.cpp @@ -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(); buffer->save(asset); diff --git a/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp b/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp index 0b30a1e9..c72822d5 100644 --- a/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp +++ b/src/Components/Modules/AssetInterfaces/IGfxWorld.cpp @@ -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(); buffer->save(asset); diff --git a/src/Components/Modules/AssetInterfaces/ILoadedSound.cpp b/src/Components/Modules/AssetInterfaces/ILoadedSound.cpp index 561dcfdf..5c9db108 100644 --- a/src/Components/Modules/AssetInterfaces/ILoadedSound.cpp +++ b/src/Components/Modules/AssetInterfaces/ILoadedSound.cpp @@ -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(); buffer->save(asset); diff --git a/src/Components/Modules/AssetInterfaces/ILocalizedEntry.cpp b/src/Components/Modules/AssetInterfaces/ILocalizeEntry.cpp similarity index 64% rename from src/Components/Modules/AssetInterfaces/ILocalizedEntry.cpp rename to src/Components/Modules/AssetInterfaces/ILocalizeEntry.cpp index 66f1d2f6..9a906b47 100644 --- a/src/Components/Modules/AssetInterfaces/ILocalizedEntry.cpp +++ b/src/Components/Modules/AssetInterfaces/ILocalizeEntry.cpp @@ -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::LocalizeEntry* asset = header.localize; + Game::LocalizeEntry* dest = buffer->dest(); buffer->save(asset); buffer->pushBlock(Game::XFILE_BLOCK_VIRTUAL); diff --git a/src/Components/Modules/AssetInterfaces/ILocalizedEntry.hpp b/src/Components/Modules/AssetInterfaces/ILocalizeEntry.hpp similarity index 78% rename from src/Components/Modules/AssetInterfaces/ILocalizedEntry.hpp rename to src/Components/Modules/AssetInterfaces/ILocalizeEntry.hpp index 3ee1f0db..8bf8858a 100644 --- a/src/Components/Modules/AssetInterfaces/ILocalizedEntry.hpp +++ b/src/Components/Modules/AssetInterfaces/ILocalizeEntry.hpp @@ -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; }; diff --git a/src/Components/Modules/AssetInterfaces/IMaterial.cpp b/src/Components/Modules/AssetInterfaces/IMaterial.cpp index 04defb46..0a1b63b5 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterial.cpp +++ b/src/Components/Modules/AssetInterfaces/IMaterial.cpp @@ -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) diff --git a/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.cpp b/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.cpp index 710cf3a8..46b5fcaf 100644 --- a/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.cpp +++ b/src/Components/Modules/AssetInterfaces/IMaterialTechniqueSet.cpp @@ -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(); buffer->save(asset); diff --git a/src/Components/Modules/AssetInterfaces/IXAnimParts.cpp b/src/Components/Modules/AssetInterfaces/IXAnimParts.cpp index ce45fada..a79ee152 100644 --- a/src/Components/Modules/AssetInterfaces/IXAnimParts.cpp +++ b/src/Components/Modules/AssetInterfaces/IXAnimParts.cpp @@ -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(); buffer->save(asset, sizeof(Game::XAnimParts)); diff --git a/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp b/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp index da87c85b..ab03fa17 100644 --- a/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp +++ b/src/Components/Modules/AssetInterfaces/Isnd_alias_list_t.cpp @@ -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(); 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 { diff --git a/src/Components/Modules/Localization.cpp b/src/Components/Modules/Localization.cpp index 8d195e90..e37df2e2 100644 --- a/src/Components/Modules/Localization.cpp +++ b/src/Components/Modules/Localization.cpp @@ -5,8 +5,8 @@ namespace Components std::mutex Localization::LocalizeMutex; Dvar::Var Localization::UseLocalization; Utils::Memory::Allocator Localization::MemAllocator; - std::unordered_map Localization::LocalizeMap; - std::unordered_map Localization::TempLocalizeMap; + std::unordered_map Localization::LocalizeMap; + std::unordered_map 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::LocalizeEntry* entry = Localization::MemAllocator.allocate(); if (!entry) return; entry->name = Localization::MemAllocator.duplicateString(key); @@ -48,7 +48,7 @@ namespace Components { if (!Localization::UseLocalization.get()) return key; - Game::LocalizedEntry* entry = nullptr; + Game::LocalizeEntry* entry = nullptr; std::lock_guard _(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::LocalizeEntry* entry = Localization::MemAllocator.allocate(); if (!entry) return; entry->name = Localization::MemAllocator.duplicateString(key); diff --git a/src/Components/Modules/Localization.hpp b/src/Components/Modules/Localization.hpp index 70d42464..a67a3dfe 100644 --- a/src/Components/Modules/Localization.hpp +++ b/src/Components/Modules/Localization.hpp @@ -19,8 +19,8 @@ namespace Components private: static std::mutex LocalizeMutex; static Utils::Memory::Allocator MemAllocator; - static std::unordered_map LocalizeMap; - static std::unordered_map TempLocalizeMap; + static std::unordered_map LocalizeMap; + static std::unordered_map TempLocalizeMap; static Dvar::Var UseLocalization; static void __stdcall SetStringStub(const char* key, const char* value, bool isEnglish); diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index f9d0a462..ecd1a6bb 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -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(world) = header.gfxMap; + *reinterpret_cast(world) = header.gfxWorld; }, &world, false); if (world) diff --git a/src/Components/Modules/MusicalTalent.cpp b/src/Components/Modules/MusicalTalent.cpp index e1da9e59..238c5e6d 100644 --- a/src/Components/Modules/MusicalTalent.cpp +++ b/src/Components/Modules/MusicalTalent.cpp @@ -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; } } diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index 883fc545..4509d0c8 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -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