init
This commit is contained in:
38
engine/server.cpp
Normal file
38
engine/server.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "server.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include "baseentity.h"
|
||||
#include "console.h"
|
||||
|
||||
void *g_serverdll;
|
||||
|
||||
void IServer::LoadGame( const char *psz )
|
||||
{
|
||||
g_serverdll = Plat_LoadLibrary(CUtlString("%s/bin/libserver.so", psz));
|
||||
void (*GameLoadfn)() = (void(*)())Plat_GetProc(g_serverdll, "IGame_Load");
|
||||
if (!GameLoadfn)
|
||||
Plat_FatalErrorFunc("IGame_Load not found in libserver.so\n");
|
||||
GameLoadfn();
|
||||
};
|
||||
|
||||
ConVar g_tickrate("tickrate","64",FCVAR_PROTECTED);
|
||||
float g_fAccumulator = 0;
|
||||
|
||||
void IServer::Think( float fDelta )
|
||||
{
|
||||
g_fAccumulator += fDelta;
|
||||
float fTickrate = 1.0/g_tickrate.GetInt();
|
||||
/* tickrate */
|
||||
while(g_fAccumulator>=fTickrate)
|
||||
{
|
||||
for (auto &entity: g_entities)
|
||||
{
|
||||
entity->Think(fTickrate);
|
||||
g_fAccumulator-=fTickrate;
|
||||
}
|
||||
}
|
||||
for (auto &entity: g_entities)
|
||||
{
|
||||
if (entity->pClientEntity)
|
||||
entity->pClientEntity->Think(fDelta);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user