From e107b205514d6aa95abc9013acf67c840bdab776 Mon Sep 17 00:00:00 2001 From: Edo Date: Sat, 6 May 2023 15:09:19 +0100 Subject: [PATCH] [StructuredData]: Fix (#1014) --- src/Components/Modules/AssetHandler.cpp | 64 +++++++++---------- .../Modules/AssetInterfaces/IXModel.hpp | 2 +- .../Modules/AssetInterfaces/IXModelSurfs.hpp | 2 +- src/Components/Modules/StructuredData.cpp | 4 +- 4 files changed, 37 insertions(+), 35 deletions(-) diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index 825fb0f0..5995d3c4 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -47,7 +47,7 @@ namespace Components std::vector> AssetHandler::EmptyAssets; - std::map AssetHandler::TemporaryAssets[Game::XAssetType::ASSET_TYPE_COUNT]; + std::map AssetHandler::TemporaryAssets[Game::ASSET_TYPE_COUNT]; void AssetHandler::RegisterInterface(IAsset* iAsset) { @@ -73,7 +73,7 @@ namespace Components void AssetHandler::ClearTemporaryAssets() { - for (int i = 0; i < Game::XAssetType::ASSET_TYPE_COUNT; ++i) + for (int i = 0; i < Game::ASSET_TYPE_COUNT; ++i) { AssetHandler::TemporaryAssets[i].clear(); } @@ -108,7 +108,7 @@ namespace Components Game::XAssetHeader AssetHandler::FindTemporaryAsset(Game::XAssetType type, const char* filename) { Game::XAssetHeader header = { nullptr }; - if (type >= Game::XAssetType::ASSET_TYPE_COUNT) return header; + if (type >= Game::ASSET_TYPE_COUNT) return header; auto tempPool = &AssetHandler::TemporaryAssets[type]; auto entry = tempPool->find(filename); @@ -224,7 +224,7 @@ namespace Components void AssetHandler::ModifyAsset(Game::XAssetType type, Game::XAssetHeader asset, const std::string& name) { - if (type == Game::XAssetType::ASSET_TYPE_MATERIAL && (name == "gfx_distortion_knife_trail" || name == "gfx_distortion_heat_far" || name == "gfx_distortion_ring_light" || name == "gfx_distortion_heat") && asset.material->info.sortKey >= 43) + if (type == Game::ASSET_TYPE_MATERIAL && (name == "gfx_distortion_knife_trail" || name == "gfx_distortion_heat_far" || name == "gfx_distortion_ring_light" || name == "gfx_distortion_heat") && asset.material->info.sortKey >= 43) { if (Zones::Version() >= VERSION_ALPHA2) { @@ -236,18 +236,18 @@ namespace Components } } - if (type == Game::XAssetType::ASSET_TYPE_MATERIAL && (name == "wc/codo_ui_viewer_black_decal3" || name == "wc/codo_ui_viewer_black_decal2" || name == "wc/hint_arrows01" || name == "wc/hint_arrows02")) + if (type == Game::ASSET_TYPE_MATERIAL && (name == "wc/codo_ui_viewer_black_decal3" || name == "wc/codo_ui_viewer_black_decal2" || name == "wc/hint_arrows01" || name == "wc/hint_arrows02")) { asset.material->info.sortKey = 0xE; } - if (type == Game::XAssetType::ASSET_TYPE_VEHICLE && Zones::Version() >= VERSION_ALPHA2) + if (type == Game::ASSET_TYPE_VEHICLE && Zones::Version() >= VERSION_ALPHA2) { asset.vehDef->turretWeapon = nullptr; } // Fix shader const stuff - if (type == Game::XAssetType::ASSET_TYPE_TECHNIQUE_SET && Zones::Version() >= 359 && Zones::Version() < 448) + if (type == Game::ASSET_TYPE_TECHNIQUE_SET && Zones::Version() >= 359 && Zones::Version() < 448) { for (int i = 0; i < 48; ++i) { @@ -272,7 +272,7 @@ namespace Components } } - if (type == Game::XAssetType::ASSET_TYPE_GFXWORLD && Zones::Version() >= 316) + if (type == Game::ASSET_TYPE_GFXWORLD && Zones::Version() >= 316) { asset.gfxWorld->sortKeyEffectDecal = 39; asset.gfxWorld->sortKeyEffectAuto = 48; @@ -408,7 +408,7 @@ namespace Components ZoneBuilder::Zone::AssetRecursionMarker _(builder); Game::XAssetHeader header = { nullptr }; - if (type >= Game::XAssetType::ASSET_TYPE_COUNT) return header; + if (type >= Game::ASSET_TYPE_COUNT) return header; auto tempPool = &AssetHandler::TemporaryAssets[type]; auto entry = tempPool->find(filename); @@ -476,7 +476,7 @@ namespace Components void AssetHandler::MissingAssetError(int severity, const char* format, const char* type, const char* name) { - if (Dedicated::IsEnabled() && Game::DB_GetXAssetNameType(type) == Game::XAssetType::ASSET_TYPE_TECHNIQUE_SET) return; + if (Dedicated::IsEnabled() && Game::DB_GetXAssetNameType(type) == Game::ASSET_TYPE_TECHNIQUE_SET) return; Utils::Hook::Call(0x4F8C70)(severity, format, type, name); // Print error } @@ -571,37 +571,37 @@ namespace Components AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, std::string name, bool*) { - if (Dvar::Var("r_noVoid").get() && type == Game::XAssetType::ASSET_TYPE_XMODEL && name == "void") + if (Dvar::Var("r_noVoid").get() && type == Game::ASSET_TYPE_XMODEL && name == "void") { asset.model->numLods = 0; } }); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_GAMEWORLD_SP, 1); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_IMAGE, ZoneBuilder::IsEnabled() ? 14336 * 2 : 7168); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_LOADED_SOUND, 2700 * 2); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_FX, 1200 * 2); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_LOCALIZE_ENTRY, 14000); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_XANIMPARTS, 8192 * 2); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_XMODEL, 5125 * 2); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_PHYSPRESET, 128); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_PIXELSHADER, ZoneBuilder::IsEnabled() ? 0x4000 : 10000); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_VERTEXSHADER, ZoneBuilder::IsEnabled() ? 0x2000 : 3072); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_MATERIAL, 8192 * 2); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_VERTEXDECL, ZoneBuilder::IsEnabled() ? 0x400 : 196); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_WEAPON, WEAPON_LIMIT); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_STRINGTABLE, 800); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_IMPACT_FX, 8); + Game::ReallocateAssetPool(Game::ASSET_TYPE_GAMEWORLD_SP, 1); + Game::ReallocateAssetPool(Game::ASSET_TYPE_IMAGE, ZoneBuilder::IsEnabled() ? 14336 * 2 : 7168); + Game::ReallocateAssetPool(Game::ASSET_TYPE_LOADED_SOUND, 2700 * 2); + Game::ReallocateAssetPool(Game::ASSET_TYPE_FX, 1200 * 2); + Game::ReallocateAssetPool(Game::ASSET_TYPE_LOCALIZE_ENTRY, 14000); + Game::ReallocateAssetPool(Game::ASSET_TYPE_XANIMPARTS, 8192 * 2); + Game::ReallocateAssetPool(Game::ASSET_TYPE_XMODEL, 5125 * 2); + Game::ReallocateAssetPool(Game::ASSET_TYPE_PHYSPRESET, 128); + Game::ReallocateAssetPool(Game::ASSET_TYPE_PIXELSHADER, ZoneBuilder::IsEnabled() ? 0x4000 : 10000); + Game::ReallocateAssetPool(Game::ASSET_TYPE_VERTEXSHADER, ZoneBuilder::IsEnabled() ? 0x2000 : 3072); + Game::ReallocateAssetPool(Game::ASSET_TYPE_MATERIAL, 8192 * 2); + Game::ReallocateAssetPool(Game::ASSET_TYPE_VERTEXDECL, ZoneBuilder::IsEnabled() ? 0x400 : 196); + Game::ReallocateAssetPool(Game::ASSET_TYPE_WEAPON, WEAPON_LIMIT); + Game::ReallocateAssetPool(Game::ASSET_TYPE_STRINGTABLE, 800); + Game::ReallocateAssetPool(Game::ASSET_TYPE_IMPACT_FX, 8); // Register asset interfaces if (ZoneBuilder::IsEnabled()) { - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_MAP_ENTS, 10); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_XMODEL_SURFS, 8192 * 2); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_TECHNIQUE_SET, 0x2000); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_FONT, 32); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_RAWFILE, 2048); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_LEADERBOARD, 500); + Game::ReallocateAssetPool(Game::ASSET_TYPE_MAP_ENTS, 10); + Game::ReallocateAssetPool(Game::ASSET_TYPE_XMODEL_SURFS, 8192 * 2); + Game::ReallocateAssetPool(Game::ASSET_TYPE_TECHNIQUE_SET, 0x2000); + Game::ReallocateAssetPool(Game::ASSET_TYPE_FONT, 32); + Game::ReallocateAssetPool(Game::ASSET_TYPE_RAWFILE, 2048); + Game::ReallocateAssetPool(Game::ASSET_TYPE_LEADERBOARD, 500); AssetHandler::RegisterInterface(new Assets::IFont_s()); AssetHandler::RegisterInterface(new Assets::IWeapon()); diff --git a/src/Components/Modules/AssetInterfaces/IXModel.hpp b/src/Components/Modules/AssetInterfaces/IXModel.hpp index c43ffec2..2c68489a 100644 --- a/src/Components/Modules/AssetInterfaces/IXModel.hpp +++ b/src/Components/Modules/AssetInterfaces/IXModel.hpp @@ -5,7 +5,7 @@ namespace Assets class IXModel : public Components::AssetHandler::IAsset { public: - Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_XMODEL; } + Game::XAssetType getType() override { return Game::ASSET_TYPE_XMODEL; } void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; diff --git a/src/Components/Modules/AssetInterfaces/IXModelSurfs.hpp b/src/Components/Modules/AssetInterfaces/IXModelSurfs.hpp index e43f009d..b4b3bbcd 100644 --- a/src/Components/Modules/AssetInterfaces/IXModelSurfs.hpp +++ b/src/Components/Modules/AssetInterfaces/IXModelSurfs.hpp @@ -5,7 +5,7 @@ namespace Assets class IXModelSurfs : public Components::AssetHandler::IAsset { public: - Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_XMODEL_SURFS; } + Game::XAssetType getType() override { return Game::ASSET_TYPE_XMODEL_SURFS; } void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override; diff --git a/src/Components/Modules/StructuredData.cpp b/src/Components/Modules/StructuredData.cpp index 121a0f8c..7830dae9 100644 --- a/src/Components/Modules/StructuredData.cpp +++ b/src/Components/Modules/StructuredData.cpp @@ -157,12 +157,14 @@ namespace Components // 15 or more custom classes Utils::Hook::Set(0x60A2FE, NUM_CUSTOM_CLASSES); + + return; } AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, const std::string& filename, bool* /*restrict*/) { // Only intercept playerdatadef loading - if (type != Game::XAssetType::ASSET_TYPE_STRUCTURED_DATA_DEF || filename != "mp/playerdata.def") return; + if (type != Game::ASSET_TYPE_STRUCTURED_DATA_DEF || filename != "mp/playerdata.def") return; // Store asset Game::StructuredDataDefSet* data = asset.structuredDataDefSet;