cstrike: Fix wrong timeleft calculation (#1072)

* Fix wrong timeleft calculation

* reorder function calls
This commit is contained in:
BotoX 2019-09-03 00:33:28 +02:00 committed by Kyle Sanderson
parent 207584818f
commit d93f6984cc
3 changed files with 16 additions and 1 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -58,7 +58,19 @@ void TimeLeftEvents::FireGameEvent(IGameEvent *event)
if (get_new_timeleft_offset || !round_end_found)
{
get_new_timeleft_offset = false;
timersys->NotifyOfGameStart();
float flGameStartTime = gpGlobals->curtime;
uintptr_t gamerules = (uintptr_t)g_pSDKTools->GetGameRules();
if (gamerules)
{
sm_sendprop_info_t info;
if (gamehelpers->FindSendPropInfo("CCSGameRulesProxy", "m_flGameStartTime", &info))
{
flGameStartTime = *(float *)(gamerules + info.actual_offset);
}
}
timersys->NotifyOfGameStart(flGameStartTime - gpGlobals->curtime);
timersys->MapTimeLeftChanged();
}
round_end_found = false;