This reverts commit b383302128
.
This commit is contained in:
parent
f503139fae
commit
a7af242453
@ -35,7 +35,6 @@
|
|||||||
#include "frame_hooks.h"
|
#include "frame_hooks.h"
|
||||||
#include "ConVarManager.h"
|
#include "ConVarManager.h"
|
||||||
#include "logic_bridge.h"
|
#include "logic_bridge.h"
|
||||||
#include <bridge/include/IProviderCallbacks.h>
|
|
||||||
|
|
||||||
#define TIMER_MIN_ACCURACY 0.1
|
#define TIMER_MIN_ACCURACY 0.1
|
||||||
|
|
||||||
@ -171,8 +170,9 @@ void ITimer::Initialize(ITimedEvent *pCallbacks, float fInterval, float fToExec,
|
|||||||
TimerSystem::TimerSystem()
|
TimerSystem::TimerSystem()
|
||||||
{
|
{
|
||||||
m_pMapTimer = NULL;
|
m_pMapTimer = NULL;
|
||||||
|
m_bHasMapTickedYet = false;
|
||||||
|
m_bHasMapSimulatedYet = false;
|
||||||
m_fLastTickedTime = 0.0f;
|
m_fLastTickedTime = 0.0f;
|
||||||
OnSourceModLevelEnd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TimerSystem::~TimerSystem()
|
TimerSystem::~TimerSystem()
|
||||||
@ -213,28 +213,29 @@ void TimerSystem::OnSourceModLevelEnd()
|
|||||||
{
|
{
|
||||||
m_bHasMapTickedYet = false;
|
m_bHasMapTickedYet = false;
|
||||||
m_bHasMapSimulatedYet = false;
|
m_bHasMapSimulatedYet = false;
|
||||||
m_bWasSimulating = false;
|
|
||||||
m_uFramesAhead = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Think is called before gpGlobals is updated every frame, even if the server is hibernating */
|
void TimerSystem::GameFrame(bool simulating)
|
||||||
void TimerSystem::Think(bool unused)
|
|
||||||
{
|
{
|
||||||
m_uFramesAhead++;
|
if (simulating && m_bHasMapTickedYet)
|
||||||
bool simulating = m_bWasSimulating && m_uFramesAhead == 1;
|
{
|
||||||
|
g_fUniversalTime += gpGlobals->curtime - m_fLastTickedTime;
|
||||||
if (m_bHasMapTickedYet) {
|
if (!m_bHasMapSimulatedYet)
|
||||||
g_fUniversalTime += gpGlobals->realtime - m_fLastTickedTime;
|
{
|
||||||
} else {
|
m_bHasMapSimulatedYet = true;
|
||||||
|
MapTimeLeftChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
g_fUniversalTime += gpGlobals->interval_per_tick;
|
g_fUniversalTime += gpGlobals->interval_per_tick;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_fLastTickedTime = gpGlobals->realtime;
|
m_fLastTickedTime = gpGlobals->curtime;
|
||||||
m_bHasMapTickedYet = true;
|
m_bHasMapTickedYet = true;
|
||||||
|
|
||||||
logicore.callbacks->OnThink(simulating);
|
if (g_fUniversalTime >= g_fTimerThink)
|
||||||
|
{
|
||||||
if (g_fUniversalTime >= g_fTimerThink) {
|
|
||||||
RunFrame();
|
RunFrame();
|
||||||
|
|
||||||
g_fTimerThink = CalcNextThink(g_fTimerThink, TIMER_MIN_ACCURACY);
|
g_fTimerThink = CalcNextThink(g_fTimerThink, TIMER_MIN_ACCURACY);
|
||||||
@ -242,19 +243,9 @@ void TimerSystem::Think(bool unused)
|
|||||||
|
|
||||||
RunFrameHooks(simulating);
|
RunFrameHooks(simulating);
|
||||||
|
|
||||||
m_pOnGameFrame->Execute();
|
if (m_pOnGameFrame->GetFunctionCount())
|
||||||
}
|
|
||||||
|
|
||||||
/* GameFrame is called after gpGlobals is updated, and may not be called when the server is hibernating */
|
|
||||||
void TimerSystem::GameFrame(bool simulating)
|
|
||||||
{
|
|
||||||
m_bWasSimulating = simulating;
|
|
||||||
m_uFramesAhead = 0;
|
|
||||||
|
|
||||||
if (simulating && !m_bHasMapSimulatedYet)
|
|
||||||
{
|
{
|
||||||
m_bHasMapSimulatedYet = true;
|
m_pOnGameFrame->Execute(NULL);
|
||||||
MapTimeLeftChanged();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,6 @@ public: //ITimerSystem
|
|||||||
public:
|
public:
|
||||||
void RunFrame();
|
void RunFrame();
|
||||||
void RemoveMapChangeTimers();
|
void RemoveMapChangeTimers();
|
||||||
void Think(bool unused);
|
|
||||||
void GameFrame(bool simulating);
|
void GameFrame(bool simulating);
|
||||||
private:
|
private:
|
||||||
List<ITimer *> m_SingleTimers;
|
List<ITimer *> m_SingleTimers;
|
||||||
@ -93,8 +92,6 @@ private:
|
|||||||
/* This is stuff for our manual ticking escapades. */
|
/* This is stuff for our manual ticking escapades. */
|
||||||
bool m_bHasMapTickedYet; /** Has the map ticked yet? */
|
bool m_bHasMapTickedYet; /** Has the map ticked yet? */
|
||||||
bool m_bHasMapSimulatedYet; /** Has the map simulated yet? */
|
bool m_bHasMapSimulatedYet; /** Has the map simulated yet? */
|
||||||
bool m_bWasSimulating; /** Was the last GameFrame simulating */
|
|
||||||
unsigned m_uFramesAhead; /** Number of frames Think is ahead of GameFrame */
|
|
||||||
float m_fLastTickedTime; /** Last time that the game currently gave
|
float m_fLastTickedTime; /** Last time that the game currently gave
|
||||||
us while ticking.
|
us while ticking.
|
||||||
*/
|
*/
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include <amtl/os/am-path.h>
|
#include <amtl/os/am-path.h>
|
||||||
#include <bridge/include/IExtensionBridge.h>
|
#include <bridge/include/IExtensionBridge.h>
|
||||||
#include <bridge/include/IScriptManager.h>
|
#include <bridge/include/IScriptManager.h>
|
||||||
|
#include <bridge/include/IProviderCallbacks.h>
|
||||||
#include <bridge/include/ILogger.h>
|
#include <bridge/include/ILogger.h>
|
||||||
|
|
||||||
SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, false, bool, const char *, const char *, const char *, const char *, bool, bool);
|
SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, false, bool, const char *, const char *, const char *, const char *, bool, bool);
|
||||||
@ -290,7 +291,6 @@ bool SourceModBase::InitializeSourceMod(char *error, size_t maxlength, bool late
|
|||||||
void SourceModBase::StartSourceMod(bool late)
|
void SourceModBase::StartSourceMod(bool late)
|
||||||
{
|
{
|
||||||
SH_ADD_HOOK(IServerGameDLL, LevelShutdown, gamedll, SH_MEMBER(this, &SourceModBase::LevelShutdown), false);
|
SH_ADD_HOOK(IServerGameDLL, LevelShutdown, gamedll, SH_MEMBER(this, &SourceModBase::LevelShutdown), false);
|
||||||
SH_ADD_HOOK(IServerGameDLL, Think, gamedll, SH_MEMBER(&g_Timers, &TimerSystem::Think), false);
|
|
||||||
SH_ADD_HOOK(IServerGameDLL, GameFrame, gamedll, SH_MEMBER(&g_Timers, &TimerSystem::GameFrame), false);
|
SH_ADD_HOOK(IServerGameDLL, GameFrame, gamedll, SH_MEMBER(&g_Timers, &TimerSystem::GameFrame), false);
|
||||||
|
|
||||||
enginePatch = SH_GET_CALLCLASS(engine);
|
enginePatch = SH_GET_CALLCLASS(engine);
|
||||||
@ -362,6 +362,8 @@ void SourceModBase::StartSourceMod(bool late)
|
|||||||
{
|
{
|
||||||
g_pSourcePawn2->InstallWatchdogTimer(atoi(timeout) * 1000);
|
g_pSourcePawn2->InstallWatchdogTimer(atoi(timeout) * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SH_ADD_HOOK(IServerGameDLL, Think, gamedll, SH_MEMBER(logicore.callbacks, &IProviderCallbacks::OnThink), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool g_LevelEndBarrier = false;
|
static bool g_LevelEndBarrier = false;
|
||||||
@ -596,8 +598,8 @@ void SourceModBase::ShutdownServices()
|
|||||||
}
|
}
|
||||||
|
|
||||||
SH_REMOVE_HOOK(IServerGameDLL, LevelShutdown, gamedll, SH_MEMBER(this, &SourceModBase::LevelShutdown), false);
|
SH_REMOVE_HOOK(IServerGameDLL, LevelShutdown, gamedll, SH_MEMBER(this, &SourceModBase::LevelShutdown), false);
|
||||||
SH_REMOVE_HOOK(IServerGameDLL, Think, gamedll, SH_MEMBER(&g_Timers, &TimerSystem::Think), false);
|
|
||||||
SH_REMOVE_HOOK(IServerGameDLL, GameFrame, gamedll, SH_MEMBER(&g_Timers, &TimerSystem::GameFrame), false);
|
SH_REMOVE_HOOK(IServerGameDLL, GameFrame, gamedll, SH_MEMBER(&g_Timers, &TimerSystem::GameFrame), false);
|
||||||
|
SH_REMOVE_HOOK(IServerGameDLL, Think, gamedll, SH_MEMBER(logicore.callbacks, &IProviderCallbacks::OnThink), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SourceModBase::LogMessage(IExtension *pExt, const char *format, ...)
|
void SourceModBase::LogMessage(IExtension *pExt, const char *format, ...)
|
||||||
|
Loading…
Reference in New Issue
Block a user