networking i guess
This commit is contained in:
@@ -1,10 +1,18 @@
|
||||
#include "tier2/ifilesystem.h"
|
||||
#include "materialsystem/imaterialsystem.h"
|
||||
#include "entitysystem.h"
|
||||
#include "baseentity.h"
|
||||
#include "enginebridge.h"
|
||||
#include "game.h"
|
||||
#include "inetworkserver.h"
|
||||
#include "netprotocol.h"
|
||||
|
||||
IFileSystem *filesystem;
|
||||
IRenderContext *g_pRenderContext;
|
||||
IGameWindow *g_pMainWindow;
|
||||
static CEngineVars s_vars;
|
||||
CEngineVars *g_pEngineVars = &s_vars;
|
||||
EngineConsts_t *g_pEngineConstants;
|
||||
INetworkBase *g_pClientBridge;
|
||||
|
||||
class CFunnyGameBridge: public IEngineBridge
|
||||
{
|
||||
@@ -13,6 +21,7 @@ class CFunnyGameBridge: public IEngineBridge
|
||||
virtual void Frame( float fDelta ) override;
|
||||
virtual void Shutdown() override;
|
||||
virtual void ConnectInterface( const char *psz, void *pInterface ) override;
|
||||
|
||||
};
|
||||
|
||||
IEngineBridge *EngineBridge()
|
||||
@@ -24,7 +33,8 @@ IEngineBridge *EngineBridge()
|
||||
EXPOSE_INTERFACE_FN(EngineBridge, IEngineBridge, ENGINE_BRIDGE_INTERFACE_VERSION)
|
||||
|
||||
void CFunnyGameBridge::Init()
|
||||
{
|
||||
{
|
||||
g_pClientBridge = g_pEngineConstants->LaunchLocalBridge(0);
|
||||
}
|
||||
|
||||
void CFunnyGameBridge::Tick( float fDelta )
|
||||
@@ -34,6 +44,32 @@ void CFunnyGameBridge::Tick( float fDelta )
|
||||
|
||||
void CFunnyGameBridge::Frame( float fDelta )
|
||||
{
|
||||
g_pEngineVars->m_fTime += fDelta;
|
||||
g_pEngineVars->m_fDeltaTime = fDelta;
|
||||
|
||||
g_pClientBridge->NetThink();
|
||||
while (g_pClientBridge->BHasUpdates())
|
||||
{
|
||||
NetPacket_t packet = g_pClientBridge->PeekPacket();
|
||||
// discard it
|
||||
if (packet.uSize < sizeof (EMessageType))
|
||||
continue;
|
||||
PlayerPacket_t *pPacket = (PlayerPacket_t*)packet.pData;
|
||||
CBaseEntity *pEntity;
|
||||
switch (pPacket->m_eType)
|
||||
{
|
||||
case MESSAGE_PLAYER_JOINED:
|
||||
g_pClientBridge->RecievePacket();
|
||||
V_printf("Hi %s\n",pPacket->m_playerJoined.m_szPlayerName);
|
||||
pEntity = EntitySystem()->CreateByClassname("player");
|
||||
pEntity->Spawn();
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
EntitySystem()->Think();
|
||||
|
||||
}
|
||||
|
||||
@@ -45,5 +81,6 @@ void CFunnyGameBridge::Shutdown()
|
||||
#define CONNECT_INTERFACE(szName, pGlobal) if (!V_strcmp(psz, szName)) { pGlobal = (typeof(pGlobal))pInterface; return; }
|
||||
void CFunnyGameBridge::ConnectInterface( const char *psz, void *pInterface )
|
||||
{
|
||||
CONNECT_INTERFACE("EngineConstants", g_pEngineConstants)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user