android port
This commit is contained in:
@@ -295,5 +295,5 @@ void CAssetManager::UnrefPhysics( HFunnyPhysics hPhysics )
|
||||
|
||||
|
||||
|
||||
static CAssetManager s_assetmgr;
|
||||
IAssetManager *g_pAssetManager = &s_assetmgr;
|
||||
static CAssetManager s_server_assetmgr;
|
||||
IAssetManager *g_pServerAssetManager = &s_server_assetmgr;
|
||||
|
||||
@@ -58,6 +58,6 @@ public:
|
||||
virtual void UnrefPhysics( HFunnyPhysics hPhysics ) = 0;
|
||||
};
|
||||
|
||||
extern IAssetManager *g_pAssetManager;
|
||||
extern IAssetManager *g_pServerAssetManager;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,8 +21,7 @@ void CBaseModelEntity::Think( float fDelta )
|
||||
{
|
||||
if (V_strncmp(m_szModel, m_szCurrentModel, 256))
|
||||
{
|
||||
V_memset(m_szCurrentModel, 0, 256);
|
||||
V_strncpy(m_szCurrentModel, m_szModel, 255);
|
||||
V_memcpy(m_szCurrentModel, m_szModel, 256);
|
||||
OnModelChanged(m_szCurrentModel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ public:
|
||||
virtual void OnModelChanged( const char *szName );
|
||||
void Think( float fDelta );
|
||||
char m_szModel[256] = {};
|
||||
private:
|
||||
char m_szCurrentModel[256] = {};
|
||||
};
|
||||
|
||||
|
||||
@@ -63,14 +63,14 @@ CBaseEntity *CEntitySystem::CreateByClassname( const char *szName, int *pOutputI
|
||||
int i;
|
||||
int iSelectedSlot;
|
||||
|
||||
pFactory = GetFactoryByClassname(szName);
|
||||
if ( !pFactory )
|
||||
return NULL;
|
||||
|
||||
// We do not want to have more than MAX_EDICT entities
|
||||
if ( m_nEntityCount >= MAX_EDICTS-1 )
|
||||
return NULL;
|
||||
|
||||
pFactory = GetFactoryByClassname(szName);
|
||||
if ( !pFactory )
|
||||
return NULL;
|
||||
|
||||
// Search for space
|
||||
// Could be more efficient but nobody cares
|
||||
for ( i = 0; i < MAX_EDICTS; i++ )
|
||||
@@ -112,7 +112,6 @@ IEntityFactory *CEntitySystem::GetFactoryByClassname( const char *szName )
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CEntitySystem::Think( float fDelta )
|
||||
{
|
||||
CBaseEntity *pEntity;
|
||||
@@ -120,7 +119,6 @@ void CEntitySystem::Think( float fDelta )
|
||||
|
||||
for ( i = 0; i < MAX_EDICTS; i++ )
|
||||
{
|
||||
|
||||
pEntity = m_pEntities[i];
|
||||
if ( pEntity == NULL )
|
||||
continue;
|
||||
@@ -150,6 +148,23 @@ searchIndex:
|
||||
return NULL;
|
||||
|
||||
}
|
||||
static netfield_t *UTIL_GetNetMapField( CBaseEntity *pEntity, netmap_t *pMap, uint32_t uIndex )
|
||||
{
|
||||
netmap_t *pCurrentMap = pMap;
|
||||
uint32_t uCurrentIndex = uIndex;
|
||||
searchIndex:
|
||||
if ( pCurrentMap )
|
||||
{
|
||||
if (uCurrentIndex >= pCurrentMap->m_uFieldCount)
|
||||
{
|
||||
uCurrentIndex -= pCurrentMap->m_uFieldCount;
|
||||
pCurrentMap = pCurrentMap->m_pBase;
|
||||
goto searchIndex;
|
||||
}
|
||||
return &pCurrentMap->m_pFields[uCurrentIndex];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CEntitySystem::NetRecvPacket( NetPacket_t *pPacket )
|
||||
{
|
||||
@@ -182,9 +197,13 @@ void CEntitySystem::NetRecvPacket( NetPacket_t *pPacket )
|
||||
// this shall be reworked
|
||||
for ( uint32_t u = 0; u < pPlayerPacket->m_entityData.m_uCount; u++ )
|
||||
{
|
||||
netfield_t *pnf = UTIL_GetNetMapField(
|
||||
pEntity,
|
||||
pEntity->GetRecvMap(),
|
||||
pcSyncValue->m_uVariableIndex);
|
||||
|
||||
uint32_t uVariableSize = pcSyncValue->m_uVariableSize;
|
||||
void *pValueData = (float*)UTIL_GetNetMapData(
|
||||
void *pValueData = UTIL_GetNetMapData(
|
||||
pEntity,
|
||||
pEntity->GetRecvMap(),
|
||||
pcSyncValue->m_uVariableIndex);
|
||||
|
||||
@@ -34,8 +34,8 @@ public:
|
||||
virtual void NetSendThink( INetworkBase *pBase );
|
||||
virtual void SetAllowedEntityForPlayer( uint64_t ullPlayer, CBaseEntity *pEntity );
|
||||
private:
|
||||
CBaseEntity *m_pEntities[MAX_EDICTS];
|
||||
int m_nEntityCount;
|
||||
CBaseEntity *m_pEntities[MAX_EDICTS] = {};
|
||||
int m_nEntityCount = 0;
|
||||
};
|
||||
|
||||
CEntitySystem *EntitySystem();
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "steam/steam_gameserver.h"
|
||||
#endif
|
||||
|
||||
class CFunnyGameBridge: public IEngineBridge
|
||||
class CServerGameBridge: public IEngineBridge
|
||||
{
|
||||
virtual void Init() override;
|
||||
virtual void Tick( float fDelta ) override;
|
||||
@@ -24,13 +24,13 @@ class CFunnyGameBridge: public IEngineBridge
|
||||
|
||||
};
|
||||
|
||||
IEngineBridge *EngineBridge()
|
||||
IEngineBridge *ServerEngineBridge()
|
||||
{
|
||||
static CFunnyGameBridge s_bridge;
|
||||
static CServerGameBridge s_bridge;
|
||||
return &s_bridge;
|
||||
}
|
||||
|
||||
EXPOSE_INTERFACE_FN(EngineBridge, IEngineBridge, ENGINE_BRIDGE_INTERFACE_VERSION)
|
||||
EXPOSE_INTERFACE_FN(ServerEngineBridge, IServerEngineBridge, SERVER_ENGINE_BRIDGE_INTERFACE_VERSION)
|
||||
|
||||
uint32_t NET_ServerCallback( NetCallback_t *pCallback )
|
||||
{
|
||||
@@ -97,7 +97,7 @@ uint32_t NET_ServerCallback( NetCallback_t *pCallback )
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CFunnyGameBridge::Init()
|
||||
void CServerGameBridge::Init()
|
||||
{
|
||||
if (g_pEngineConstants->m_bIsDedicated == false)
|
||||
g_pClientBridge = g_pEngineConstants->LaunchLocalBridge(0);
|
||||
@@ -145,7 +145,7 @@ void CFunnyGameBridge::Init()
|
||||
}
|
||||
|
||||
|
||||
void CFunnyGameBridge::Tick( float fDelta )
|
||||
void CServerGameBridge::Tick( float fDelta )
|
||||
{
|
||||
|
||||
}
|
||||
@@ -196,7 +196,7 @@ void NET_ProcessPacket( INetworkBase *pBase )
|
||||
pBase->RecievePacket();
|
||||
}
|
||||
|
||||
void CFunnyGameBridge::Frame( float fDelta )
|
||||
void CServerGameBridge::Frame( float fDelta )
|
||||
{
|
||||
g_pEngineVars->m_fTime += fDelta;
|
||||
g_pEngineVars->m_fDeltaTime = fDelta;
|
||||
@@ -242,13 +242,13 @@ void CFunnyGameBridge::Frame( float fDelta )
|
||||
|
||||
}
|
||||
|
||||
void CFunnyGameBridge::Shutdown()
|
||||
void CServerGameBridge::Shutdown()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#define CONNECT_INTERFACE(szName, pGlobal) if (!V_strcmp(psz, szName)) { pGlobal = (typeof(pGlobal))pInterface; return; }
|
||||
void CFunnyGameBridge::ConnectInterface( const char *psz, void *pInterface )
|
||||
void CServerGameBridge::ConnectInterface( const char *psz, void *pInterface )
|
||||
{
|
||||
CONNECT_INTERFACE(FILESYSTEM_INTERFACE_VERSION, filesystem);
|
||||
CONNECT_INTERFACE("EngineConstants", g_pEngineConstants)
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
CMOBAPlayer::CMOBAPlayer()
|
||||
{
|
||||
m_hCuboid = g_pPhysics->CreateCube({1,1,1});
|
||||
}
|
||||
|
||||
CMOBAPlayer::~CMOBAPlayer()
|
||||
@@ -19,6 +18,8 @@ void CMOBAPlayer::Spawn()
|
||||
SetModel("game/core/models/sphere.fmdl");
|
||||
SetAbsOrigin({0,-11.5, 0});
|
||||
SetThink(Think);
|
||||
|
||||
m_hCuboid = g_pPhysics->CreateCube({1,1,1});
|
||||
|
||||
m_pLeftHand = EntitySystem()->CreateByClassname("player_hand_controller", &m_leftHandId);
|
||||
m_pRightHand = EntitySystem()->CreateByClassname("player_hand_controller", &m_rightHandId);
|
||||
|
||||
@@ -61,11 +61,11 @@ void CPhysicsProp::OnModelChanged( const char *szName )
|
||||
{
|
||||
if (m_hModel)
|
||||
{
|
||||
g_pAssetManager->UnrefModel(m_hModel);
|
||||
g_pServerAssetManager->UnrefModel(m_hModel);
|
||||
}
|
||||
m_hModel = g_pAssetManager->LoadModel(szName);
|
||||
m_pModel = g_pAssetManager->GetModelByIndex(m_hModel);
|
||||
m_pPhysics = g_pAssetManager->GetPhysicsByIndex(m_pModel->m_hPhysics);
|
||||
m_hModel = g_pServerAssetManager->LoadModel(szName);
|
||||
m_pModel = g_pServerAssetManager->GetModelByIndex(m_hModel);
|
||||
m_pPhysics = g_pServerAssetManager->GetPhysicsByIndex(m_pModel->m_hPhysics);
|
||||
m_hCollider = g_pPhysics->CreateCollider(m_pPhysics->m_hShape);
|
||||
m_pBody = g_pPhysicsWorld->CreateRigidBody(m_hCollider, m_eCurrentPhysicsType);
|
||||
m_pBody->SetPosition(GetAbsOrigin());
|
||||
|
||||
Reference in New Issue
Block a user