From c9e26c05af24bedaae9c01d76f0a3a695415d1f5 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Thu, 27 Oct 2016 18:01:51 +0200 Subject: [PATCH] Shipment patches --- deps/mongoose | 2 +- src/Components/Modules/Maps.cpp | 53 +++++++++------------------ src/Components/Modules/Maps.hpp | 4 +- src/Components/Modules/Party.cpp | 6 --- src/Components/Modules/ServerInfo.cpp | 6 --- 5 files changed, 20 insertions(+), 51 deletions(-) diff --git a/deps/mongoose b/deps/mongoose index 900bbe72..a3e2a418 160000 --- a/deps/mongoose +++ b/deps/mongoose @@ -1 +1 @@ -Subproject commit 900bbe724ab87c863050a90a5b5b20d69b5c09d9 +Subproject commit a3e2a41834a6b9d8cdd5b6f993cb31d5ea81694d diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index 60a8e4cd..8ab766d4 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -2,6 +2,7 @@ namespace Components { + std::string Maps::CurrentMainZone; std::vector> Maps::DependencyList; std::vector Maps::CurrentDependencies; @@ -11,6 +12,8 @@ namespace Components { if (!zoneInfo) return; + Maps::CurrentMainZone = zoneInfo->name; + Maps::CurrentDependencies.clear(); for (auto i = Maps::DependencyList.begin(); i != Maps::DependencyList.end(); ++i) { @@ -69,7 +72,8 @@ namespace Components void Maps::LoadAssetRestrict(Game::XAssetType type, Game::XAssetHeader asset, std::string name, bool* restrict) { - if (std::find(Maps::CurrentDependencies.begin(), Maps::CurrentDependencies.end(), FastFiles::Current()) != Maps::CurrentDependencies.end()) + if (std::find(Maps::CurrentDependencies.begin(), Maps::CurrentDependencies.end(), FastFiles::Current()) != Maps::CurrentDependencies.end() + && (FastFiles::Current() != "mp_shipment_long" || Maps::CurrentMainZone != "mp_shipment")) // Shipment is a special case { if (type == Game::XAssetType::ASSET_TYPE_GAME_MAP_MP || type == Game::XAssetType::ASSET_TYPE_COL_MAP_MP || type == Game::XAssetType::ASSET_TYPE_GFX_MAP || type == Game::XAssetType::ASSET_TYPE_MAP_ENTS || type == Game::XAssetType::ASSET_TYPE_COM_MAP || type == Game::XAssetType::ASSET_TYPE_FX_MAP) { @@ -137,6 +141,12 @@ namespace Components format = "maps/%s.d3dbsp"; } + // Redirect shipment to shipment long + if (mapname == "mp_shipment"s) + { + mapname = "mp_shipment_long"; + } + bool handleAsSp = false; for (auto dependency : Maps::DependencyList) @@ -185,35 +195,6 @@ namespace Components return (Utils::String::StartsWith(entity, "dyn_") || Utils::String::StartsWith(entity, "node_") || Utils::String::StartsWith(entity, "actor_")); } - void Maps::PatchMapLoad(const char** mapnamePtr) - { - if (!strcmp(*mapnamePtr, "mp_shipment")) - { - *mapnamePtr = "mp_shipment_long"; - Dvar::Var("sv_shortmap").SetRaw(1); - } - else if (!strcmp(*mapnamePtr, "mp_shipment_long")) - { - Dvar::Var("sv_shortmap").SetRaw(0); - } - } - - __declspec(naked) void Maps::MapLoadStub() - { - __asm - { - lea eax, [esp + 4h] - push eax - call Maps::PatchMapLoad - add esp, 4h - - sub esp, 84h - - push 6244B6h - retn - } - } - #if defined(DEBUG) && defined(ENABLE_DXSDK) // Credit to SE2Dev, as we shouldn't share the code, keep that in debug mode! void Maps::ExportMap(Game::GfxWorld* world) @@ -392,8 +373,6 @@ namespace Components Maps::Maps() { - Dvar::Register("sv_shortmap", false, Game::dvar_flag::DVAR_FLAG_WRITEPROTECTED, ""); - // Restrict asset loading AssetHandler::OnLoad(Maps::LoadAssetRestrict); @@ -410,9 +389,6 @@ namespace Components // Ignore SP entities Utils::Hook(0x444810, Maps::IgnoreEntityStub, HOOK_JUMP).Install()->Quick(); - // Shipment patches - Utils::Hook(0x6244B0, Maps::MapLoadStub, HOOK_JUMP).Install()->Quick(); - Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_GAME_MAP_SP, 1); Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_IMAGE, 7168); Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_LOADED_SOUND, 2700); @@ -452,6 +428,9 @@ namespace Components Maps::AddDependency("mp_rust_long", "iw4x_dependencies_mp"); Maps::AddDependency("mp_ambush_sh", "iw4x_dependencies_mp"); + Maps::AddDependency("mp_shipment", "mp_shipment_long"); + Maps::AddDependency("mp_shipment", "iw4x_dependencies_mp"); + #if defined(DEBUG) && defined(ENABLE_DXSDK) Command::Add("dumpmap", [] (Command::Params) { @@ -482,6 +461,10 @@ namespace Components Maps::~Maps() { + Maps::DependencyList.clear(); + Maps::CurrentMainZone.clear(); + Maps::CurrentDependencies.clear(); + Maps::EntryPool.clear(); } } diff --git a/src/Components/Modules/Maps.hpp b/src/Components/Modules/Maps.hpp index 74ab27f7..03d7b659 100644 --- a/src/Components/Modules/Maps.hpp +++ b/src/Components/Modules/Maps.hpp @@ -15,6 +15,7 @@ namespace Components private: static std::vector EntryPool; + static std::string CurrentMainZone; static std::vector> DependencyList; static std::vector CurrentDependencies; @@ -26,9 +27,6 @@ namespace Components static int IgnoreEntityStub(const char* entity); - static void PatchMapLoad(const char** mapnamePtr); - static void MapLoadStub(); - #if defined(DEBUG) && defined(ENABLE_DXSDK) static void ExportMap(Game::GfxWorld* world); #endif diff --git a/src/Components/Modules/Party.cpp b/src/Components/Modules/Party.cpp index b8048d5c..9cb6fbd2 100644 --- a/src/Components/Modules/Party.cpp +++ b/src/Components/Modules/Party.cpp @@ -325,12 +325,6 @@ namespace Components info.Set("mapname", Dvar::Var("ui_mapname").Get()); } - // Shipment patches - if (info.Get("mapname") == "mp_shipment_long" && Dvar::Var("sv_shortmap").Get()) - { - info.Set("mapname", "mp_shipment"); - } - // Set matchtype // 0 - No match, connecting not possible // 1 - Party, use Steam_JoinLobby to connect diff --git a/src/Components/Modules/ServerInfo.cpp b/src/Components/Modules/ServerInfo.cpp index 0db21410..c928017e 100644 --- a/src/Components/Modules/ServerInfo.cpp +++ b/src/Components/Modules/ServerInfo.cpp @@ -130,12 +130,6 @@ namespace Components info.Set("mapname", Dvar::Var("ui_mapname").Get()); } - // Shipment patches - if (info.Get("mapname") == "mp_shipment_long" && Dvar::Var("sv_shortmap").Get()) - { - info.Set("mapname", "mp_shipment"); - } - // Set matchtype // 0 - No match, connecting not possible // 1 - Party, use Steam_JoinLobby to connect