From 2fdb11ef1e6b73d557223f3f1780caadd87797c3 Mon Sep 17 00:00:00 2001 From: BotoX Date: Sat, 4 Mar 2017 00:08:10 +0100 Subject: [PATCH] Fix wrong timeleft calculation --- extensions/cstrike/extension.cpp | 2 ++ extensions/cstrike/extension.h | 1 + extensions/cstrike/timeleft.cpp | 12 +++++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/extensions/cstrike/extension.cpp b/extensions/cstrike/extension.cpp index 1abcb4a2..80de1fcc 100644 --- a/extensions/cstrike/extension.cpp +++ b/extensions/cstrike/extension.cpp @@ -51,6 +51,7 @@ IGameConfig *g_pGameConf = NULL; IGameEventManager2 *gameevents = NULL; bool hooked_everything = false; int g_msgHintText = -1; +CGlobalVars *gpGlobals; SMEXT_LINK(&g_CStrike); @@ -107,6 +108,7 @@ bool CStrike::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool { GET_V_IFACE_CURRENT(GetEngineFactory, gameevents, IGameEventManager2, INTERFACEVERSION_GAMEEVENTSMANAGER2); GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER); + gpGlobals = ismm->GetCGlobals(); return true; } diff --git a/extensions/cstrike/extension.h b/extensions/cstrike/extension.h index e4d706ba..8671efb5 100644 --- a/extensions/cstrike/extension.h +++ b/extensions/cstrike/extension.h @@ -166,6 +166,7 @@ private: extern IBinTools *g_pBinTools; extern IGameConfig *g_pGameConf; extern ISDKTools *g_pSDKTools; +extern CGlobalVars *gpGlobals; extern int g_msgHintText; extern bool g_pIgnoreTerminateDetour; extern bool g_pIgnoreCSWeaponDropDetour; diff --git a/extensions/cstrike/timeleft.cpp b/extensions/cstrike/timeleft.cpp index 5a28f491..2cf7ee08 100644 --- a/extensions/cstrike/timeleft.cpp +++ b/extensions/cstrike/timeleft.cpp @@ -58,7 +58,17 @@ void TimeLeftEvents::FireGameEvent(IGameEvent *event) if (get_new_timeleft_offset || !round_end_found) { get_new_timeleft_offset = false; - timersys->NotifyOfGameStart(); + + float flGameStartTime = gpGlobals->curtime; + sm_sendprop_info_t info; + if (gamehelpers->FindSendPropInfo("CCSGameRulesProxy", "m_flGameStartTime", &info)) + { + uintptr_t gamerules = (uintptr_t)g_pSDKTools->GetGameRules(); + if (gamerules) + flGameStartTime = *(float *)(gamerules + info.actual_offset); + } + + timersys->NotifyOfGameStart(flGameStartTime - gpGlobals->curtime); timersys->MapTimeLeftChanged(); } round_end_found = false;