[Dedicated] Time wrapping workaround

This commit is contained in:
momo5502 2016-12-08 20:07:24 +01:00
parent 183da91131
commit fb8958d2ea
3 changed files with 30 additions and 1 deletions

View File

@ -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<bool>();
mapname = Dvar::Var("mapname").get<std::string>();
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<bool>())
@ -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<DWORD>(0x62735C, 50'000); // Time wrap after 50 seconds (for testing - i don't want to wait 3 weeks)
if (!ZoneBuilder::IsEnabled())
{
// Post initialization point

View File

@ -36,5 +36,7 @@ namespace Components
static void PreSayStub();
static void PostSayStub();
static void TimeWrapStub(int code, const char* message);
};
}

View File

@ -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, ...);