99 lines
1.8 KiB
C++
99 lines
1.8 KiB
C++
#include "tier1/commandline.h"
|
|
#include "tier1/utlstring.h"
|
|
#include "tier0/lib.h"
|
|
#include "console.h"
|
|
#include "filesystem.h"
|
|
#include "rendering.h"
|
|
#include "engine.h"
|
|
#include "baseentity.h"
|
|
#include "server.h"
|
|
#include "physics.h"
|
|
#include "signal.h"
|
|
|
|
double fPrev = 0;
|
|
double fCurrent = 0;
|
|
|
|
funnyphysics *px;
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: Engine entry point
|
|
//-----------------------------------------------------------------------------
|
|
extern "C" void FunnyMain( int argc, char **argv ) {
|
|
|
|
ICommandLine::CreateCommandLine(argc, argv);
|
|
IEngine::Init();
|
|
for (;;)
|
|
{
|
|
fPrev = fCurrent;
|
|
fCurrent = Plat_GetTime();
|
|
IEngine::Frame(fCurrent-fPrev);
|
|
};
|
|
/* deinit is handled explicitly */
|
|
};
|
|
|
|
void IEngine_Signal(int sig)
|
|
{
|
|
printf("Trapped signal %i\n",sig);
|
|
switch (sig)
|
|
{
|
|
case SIGSEGV:
|
|
case SIGILL:
|
|
case SIGABRT:
|
|
printf("Consider running app with debugger attached\n");
|
|
Plat_Backtrace();
|
|
break;
|
|
default:
|
|
break;
|
|
};
|
|
IEngine::Shutdown();
|
|
_exit(0);
|
|
};
|
|
|
|
|
|
void IEngine::Init()
|
|
{
|
|
/* trap signals */
|
|
|
|
IFileSystem::InitFilesystem();
|
|
IVideo::Init();
|
|
px = px_init();
|
|
IServer::LoadGame("funnygame");
|
|
};
|
|
|
|
void IEngine::Frame(float fDelta)
|
|
{
|
|
IServer::Think(fDelta);
|
|
IVideo::Frame(fDelta);
|
|
};
|
|
|
|
void IEngine::Shutdown()
|
|
{
|
|
|
|
};
|
|
|
|
CBaseEntity *IIEngine::SpawnEntity( const char *szName )
|
|
{
|
|
V_printf("%s\n", szName);
|
|
for (auto &entity: g_RegisteredEntities)
|
|
{
|
|
if (!V_strcmp(entity->m_szName, szName))
|
|
{
|
|
CBaseEntity *pEnt = entity->m_pfn();
|
|
pEnt->Spawn();
|
|
g_entities.AppendTail(pEnt);
|
|
if (entity->m_pClientfn)
|
|
{
|
|
pEnt->pClientEntity = entity->m_pClientfn();
|
|
pEnt->pClientEntity->Spawn();
|
|
pEnt->pClientEntity->pEntity = pEnt;
|
|
}
|
|
return pEnt;
|
|
}
|
|
}
|
|
return 0;
|
|
};
|
|
|
|
void IIEngine::DestroyEntity( CBaseEntity *pEntity )
|
|
{
|
|
|
|
};
|