From fb8958d2ea0f722a0572e201b286a4519ab2c79c Mon Sep 17 00:00:00 2001 From: momo5502 Date: Thu, 8 Dec 2016 20:07:24 +0100 Subject: [PATCH] [Dedicated] Time wrapping workaround --- src/Components/Modules/Dedicated.cpp | 27 +++++++++++++++++++++++++++ src/Components/Modules/Dedicated.hpp | 2 ++ src/Game/Functions.hpp | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/Components/Modules/Dedicated.cpp b/src/Components/Modules/Dedicated.cpp index adb5afd7..abef25a0 100644 --- a/src/Components/Modules/Dedicated.cpp +++ b/src/Components/Modules/Dedicated.cpp @@ -116,6 +116,29 @@ namespace Components } } + void Dedicated::TimeWrapStub(int code, const char* message) + { + static bool partyEnable; + static std::string mapname; + + partyEnable = Dvar::Var("party_enable").get(); + mapname = Dvar::Var("mapname").get(); + + QuickPatch::Once([]() + { + Dvar::Var("party_enable").set(partyEnable); + + if (!partyEnable) // Time wrapping should not occur in party servers, but yeah... + { + if (mapname.empty()) mapname = "mp_rust"; + Command::Execute(fmt::sprintf("map %s", mapname.data()), false); + mapname.clear(); + } + }); + + Game::Com_Error(code, message); + } + void Dedicated::MapRotate() { if (!Dedicated::IsEnabled() && Dvar::Var("sv_dontrotate").get()) @@ -306,6 +329,10 @@ namespace Components Utils::Hook(0x4D00D4, Dedicated::PostSayStub, HOOK_CALL).install()->quick(); Utils::Hook(0x4D0110, Dedicated::PostSayStub, HOOK_CALL).install()->quick(); + // Intercept time wrapping + Utils::Hook(0x62737D, Dedicated::TimeWrapStub, HOOK_CALL).install()->quick(); + //Utils::Hook::Set(0x62735C, 50'000); // Time wrap after 50 seconds (for testing - i don't want to wait 3 weeks) + if (!ZoneBuilder::IsEnabled()) { // Post initialization point diff --git a/src/Components/Modules/Dedicated.hpp b/src/Components/Modules/Dedicated.hpp index 03504676..696e3307 100644 --- a/src/Components/Modules/Dedicated.hpp +++ b/src/Components/Modules/Dedicated.hpp @@ -36,5 +36,7 @@ namespace Components static void PreSayStub(); static void PostSayStub(); + + static void TimeWrapStub(int code, const char* message); }; } diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 6934165e..9334d6aa 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -48,7 +48,7 @@ namespace Game typedef void(__cdecl * Com_ClientPacketEvent_t)(); extern Com_ClientPacketEvent_t Com_ClientPacketEvent; - typedef void(__cdecl * Com_Error_t)(int type, char* message, ...); + typedef void(__cdecl * Com_Error_t)(int type, const char* message, ...); extern Com_Error_t Com_Error; typedef void(__cdecl * Com_Printf_t)(int channel, const char *fmt, ...);