1.1 --- a/core/sourcemod.cpp Wed Feb 07 08:42:48 2007 +0000
1.2 +++ b/core/sourcemod.cpp Wed Feb 07 08:44:48 2007 +0000
1.3 @@ -23,9 +23,11 @@
1.4 #include "ExtensionSys.h"
1.5 #include "AdminCache.h"
1.6 #include "sm_stringutil.h"
1.7 +#include "CPlayerManager.h"
1.8
1.9 SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, false, bool, const char *, const char *, const char *, const char *, bool, bool);
1.10 SH_DECL_HOOK0_void(IServerGameDLL, LevelShutdown, SH_NOATTRIB, false);
1.11 +SH_DECL_HOOK1_void(IServerGameDLL, GameFrame, SH_NOATTRIB, false, bool);
1.12
1.13 SourcePawnEngine g_SourcePawn;
1.14 SourceModBase g_SourceMod;
1.15 @@ -35,6 +37,8 @@
1.16 ISourcePawnEngine *g_pSourcePawn = &g_SourcePawn;
1.17 IVirtualMachine *g_pVM;
1.18 IdentityToken_t *g_pCoreIdent = NULL;
1.19 +float g_LastTime = 0.0f;
1.20 +float g_LastAuthCheck = 0.0f;
1.21
1.22 typedef int (*GIVEENGINEPOINTER)(ISourcePawnEngine *);
1.23 typedef unsigned int (*GETEXPORTCOUNT)();
1.24 @@ -150,6 +154,7 @@
1.25 /* First initialize the global hooks we need */
1.26 SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, this, &SourceModBase::LevelInit, false);
1.27 SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelShutdown, gamedll, this, &SourceModBase::LevelShutdown, false);
1.28 + SH_ADD_HOOK_MEMFUNC(IServerGameDLL, GameFrame, gamedll, this, &SourceModBase::GameFrame, false);
1.29
1.30 /* Notify! */
1.31 SMGlobalClass *pBase = SMGlobalClass::head;
1.32 @@ -178,6 +183,8 @@
1.33 {
1.34 m_IsMapLoading = true;
1.35 m_ExecPluginReload = true;
1.36 + g_LastTime = 0.0f;
1.37 + g_LastAuthCheck = 0.0f;
1.38
1.39 g_Logger.MapChange(pMapName);
1.40
1.41 @@ -191,6 +198,25 @@
1.42 RETURN_META_VALUE(MRES_IGNORED, true);
1.43 }
1.44
1.45 +void SourceModBase::GameFrame(bool simulating)
1.46 +{
1.47 + /**
1.48 + * Note: This is all hardcoded rather than delegated to save
1.49 + * precious CPU cycles.
1.50 + */
1.51 + float curtime = gpGlobals->curtime;
1.52 + if (curtime - g_LastTime > 0.1f)
1.53 + {
1.54 + if (m_CheckingAuth
1.55 + && (gpGlobals->curtime - g_LastAuthCheck > 0.7f))
1.56 + {
1.57 + g_LastAuthCheck = gpGlobals->curtime;
1.58 + g_Players.RunAuthChecks();
1.59 + }
1.60 + g_LastTime = curtime;
1.61 + }
1.62 +}
1.63 +
1.64 void SourceModBase::LevelShutdown()
1.65 {
1.66 if (m_ExecPluginReload)
1.67 @@ -280,6 +306,7 @@
1.68
1.69 SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, this, &SourceModBase::LevelInit, false);
1.70 SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, LevelShutdown, gamedll, this, &SourceModBase::LevelShutdown, false);
1.71 + SH_REMOVE_HOOK_MEMFUNC(IServerGameDLL, GameFrame, gamedll, this, &SourceModBase::GameFrame, false);
1.72
1.73 /* Rest In Peace */
1.74 ShutdownJIT();
1.75 @@ -349,6 +376,11 @@
1.76 m_target = index;
1.77 }
1.78
1.79 +void SourceModBase::SetAuthChecking(bool set)
1.80 +{
1.81 + m_CheckingAuth = set;
1.82 +}
1.83 +
1.84 unsigned int SourceModBase::GetGlobalTarget() const
1.85 {
1.86 return m_target;