From 345c8e5a98e08978cf30e42dc9dab89b53be77b5 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sat, 27 May 2017 20:50:22 +0200 Subject: [PATCH] [Maps] Delay material sorting --- src/Components/Modules/Maps.cpp | 29 +++++++++++++++++++++++++++++ src/Components/Modules/Maps.hpp | 2 ++ 2 files changed, 31 insertions(+) diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index 3b390ee5..577a87f5 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -848,6 +848,31 @@ namespace Components } } + int Maps::DatabaseReadyDelayed() +{ + static bool ready = false; + static Utils::Time::Interval interval; + + if(Game::Sys_IsDatabaseReady()) + { + if(!ready) + { + ready = true; + interval.update(); + } + else if(interval.elapsed(2s)) + { + return 1; + } + } + else + { + ready = false; + } + + return 0; + } + Maps::Maps() { Dvar::OnInit([]() @@ -928,8 +953,12 @@ namespace Components // Allow loading raw suns Utils::Hook(0x51B46A, Maps::LoadRawSun, HOOK_CALL).install()->quick(); + // Disable distortion on custom maps Utils::Hook(0x50AA47, Maps::SetDistortionStub, HOOK_CALL).install()->quick(); + // Delay material sorting + Utils::Hook(0x50AAE6, Maps::DatabaseReadyDelayed, HOOK_CALL).install()->quick(); + // Intercept map loading for usermap initialization Utils::Hook(0x6245E3, Maps::SpawnServerStub, HOOK_CALL).install()->quick(); Utils::Hook(0x62493E, Maps::SpawnServerStub, HOOK_CALL).install()->quick(); diff --git a/src/Components/Modules/Maps.hpp b/src/Components/Modules/Maps.hpp index 643db4cf..ef174c42 100644 --- a/src/Components/Modules/Maps.hpp +++ b/src/Components/Modules/Maps.hpp @@ -123,6 +123,8 @@ namespace Components static Game::dvar_t* GetDistortionDvar(); static void SetDistortionStub(); + static int DatabaseReadyDelayed(); + void reallocateEntryPool(); }; }