added a gameframe hook

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40537
This commit is contained in:
David Anderson 2007-02-26 04:36:15 +00:00
parent bb69a9f0d2
commit 95e92b25aa
2 changed files with 24 additions and 0 deletions

View File

@ -25,6 +25,7 @@
#include "sm_stringutil.h"
#include "CPlayerManager.h"
#include "CTranslator.h"
#include "ForwardSys.h"
SH_DECL_HOOK6(IServerGameDLL, LevelInit, SH_NOATTRIB, false, bool, const char *, const char *, const char *, const char *, bool, bool);
SH_DECL_HOOK0_void(IServerGameDLL, LevelShutdown, SH_NOATTRIB, false);
@ -40,6 +41,7 @@ IVirtualMachine *g_pVM;
IdentityToken_t *g_pCoreIdent = NULL;
float g_LastTime = 0.0f;
float g_LastAuthCheck = 0.0f;
IForward *g_pOnGameFrame = NULL;
typedef int (*GIVEENGINEPOINTER)(ISourcePawnEngine *);
typedef unsigned int (*GETEXPORTCOUNT)();
@ -203,6 +205,11 @@ bool SourceModBase::LevelInit(char const *pMapName, char const *pMapEntities, ch
g_Admins.DumpAdminCache(AdminCache_Overrides, true);
g_Admins.DumpAdminCache(AdminCache_Groups, true);
if (!g_pOnGameFrame)
{
g_pOnGameFrame = g_Forwards.CreateForward("OnGameFrame", ET_Ignore, 0, NULL);
}
RETURN_META_VALUE(MRES_IGNORED, true);
}
@ -223,6 +230,11 @@ void SourceModBase::GameFrame(bool simulating)
}
g_LastTime = curtime;
}
if (g_pOnGameFrame && g_pOnGameFrame->GetFunctionCount())
{
g_pOnGameFrame->Execute(NULL);
}
}
void SourceModBase::LevelShutdown()
@ -296,6 +308,11 @@ size_t SourceModBase::BuildPath(PathType type, char *buffer, size_t maxlength, c
void SourceModBase::CloseSourceMod()
{
if (g_pOnGameFrame)
{
g_Forwards.ReleaseForward(g_pOnGameFrame);
}
/* Notify! */
SMGlobalClass *pBase = SMGlobalClass::head;
while (pBase)

View File

@ -148,6 +148,13 @@ forward OnClientSettingsChanged(client);
*/
forward OnClientAuthorized(client, const String:auth[]);
/**
* Called before every server frame. Note that you should avoid
* doing expensive computations here, and you should declare large
* local arrays using 'decl' instead of 'new'.
*/
forward OnGameFrame();
/**
* Returns the maximum number of clients allowed on the server.
*