android port
This commit is contained in:
+28
-28
@@ -13,7 +13,7 @@
|
||||
#define MAX_FONT_COUNT 128
|
||||
|
||||
template<typename T, uint32_t nCount>
|
||||
class CAssetArc
|
||||
class C_AssetArc
|
||||
{
|
||||
struct ObjectHandle_t
|
||||
{
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class CAssetManager: public IAssetManager
|
||||
class C_AssetManager: public IAssetManager
|
||||
{
|
||||
public:
|
||||
virtual HFunnyModel LoadModel( const char *szName ) override;
|
||||
@@ -105,37 +105,37 @@ public:
|
||||
|
||||
void LoadMaterialData( CBaseMaterial *pMaterial, IJSONObject *pObj );
|
||||
|
||||
CAssetArc<FunnyModel_t, MAX_MODEL_COUNT> m_models = {};
|
||||
CAssetArc<FunnyMesh_t, MAX_MESH_COUNT> m_meshes = {};
|
||||
CAssetArc<FunnyMaterial_t, MAX_MATERIAL_COUNT> m_materials = {};
|
||||
CAssetArc<FunnyTexture_t, MAX_TEXTURE_COUNT> m_textures = {};
|
||||
CAssetArc<IShader*, MAX_SHADER_COUNT> m_shaders = {};
|
||||
CAssetArc<FunnyPhysics_t, MAX_PHYSICS_COUNT> m_physics = {};
|
||||
C_AssetArc<FunnyModel_t, MAX_MODEL_COUNT> m_models = {};
|
||||
C_AssetArc<FunnyMesh_t, MAX_MESH_COUNT> m_meshes = {};
|
||||
C_AssetArc<FunnyMaterial_t, MAX_MATERIAL_COUNT> m_materials = {};
|
||||
C_AssetArc<FunnyTexture_t, MAX_TEXTURE_COUNT> m_textures = {};
|
||||
C_AssetArc<IShader*, MAX_SHADER_COUNT> m_shaders = {};
|
||||
C_AssetArc<FunnyPhysics_t, MAX_PHYSICS_COUNT> m_physics = {};
|
||||
|
||||
};
|
||||
|
||||
FunnyModel_t *CAssetManager::GetModelByIndex( uint32_t uIndex )
|
||||
FunnyModel_t *C_AssetManager::GetModelByIndex( uint32_t uIndex )
|
||||
{
|
||||
return m_models.GetObjectPtr(uIndex);
|
||||
}
|
||||
|
||||
FunnyMaterial_t *CAssetManager::GetMaterialByIndex( uint32_t uIndex )
|
||||
FunnyMaterial_t *C_AssetManager::GetMaterialByIndex( uint32_t uIndex )
|
||||
{
|
||||
return m_materials.GetObjectPtr(uIndex);
|
||||
}
|
||||
|
||||
IShader **CAssetManager::GetShaderByIndex( uint32_t uIndex )
|
||||
IShader **C_AssetManager::GetShaderByIndex( uint32_t uIndex )
|
||||
{
|
||||
return m_shaders.GetObjectPtr(uIndex);
|
||||
}
|
||||
|
||||
FunnyMesh_t *CAssetManager::GetMeshByIndex( uint32_t uIndex )
|
||||
FunnyMesh_t *C_AssetManager::GetMeshByIndex( uint32_t uIndex )
|
||||
{
|
||||
return m_meshes.GetObjectPtr(uIndex);
|
||||
}
|
||||
|
||||
|
||||
uint32_t CAssetManager::LoadModel( const char *szName )
|
||||
uint32_t C_AssetManager::LoadModel( const char *szName )
|
||||
{
|
||||
bool bHasBeenCreated = false;
|
||||
HFunnyModel hModel = m_models.GetOrCreateObject(szName, &bHasBeenCreated);
|
||||
@@ -189,12 +189,12 @@ uint32_t CAssetManager::LoadModel( const char *szName )
|
||||
}
|
||||
}
|
||||
|
||||
void CAssetManager::UnrefModel( uint32_t uIndex )
|
||||
void C_AssetManager::UnrefModel( uint32_t uIndex )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CAssetManager::LoadMaterialData( CBaseMaterial *pMaterial, IJSONObject *pObj )
|
||||
void C_AssetManager::LoadMaterialData( CBaseMaterial *pMaterial, IJSONObject *pObj )
|
||||
{
|
||||
for ( int i = 0; i < pMaterial->GetDataMap()->m_iNumFields; i++ )
|
||||
{
|
||||
@@ -236,7 +236,7 @@ void CAssetManager::LoadMaterialData( CBaseMaterial *pMaterial, IJSONObject *pOb
|
||||
|
||||
}
|
||||
|
||||
uint32_t CAssetManager::LoadMaterial( const char *szName )
|
||||
uint32_t C_AssetManager::LoadMaterial( const char *szName )
|
||||
{
|
||||
bool bHasBeenCreated = false;
|
||||
HFunnyMaterial hMaterial = m_materials.GetOrCreateObject(szName, &bHasBeenCreated);
|
||||
@@ -288,12 +288,12 @@ uint32_t CAssetManager::LoadMaterial( const char *szName )
|
||||
return hMaterial;
|
||||
}
|
||||
|
||||
void CAssetManager::UnrefMaterial( uint32_t uIndex )
|
||||
void C_AssetManager::UnrefMaterial( uint32_t uIndex )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
HFunnyMesh CAssetManager::LoadMesh( const char *szName )
|
||||
HFunnyMesh C_AssetManager::LoadMesh( const char *szName )
|
||||
{
|
||||
bool bHasBeenCreated = false;
|
||||
HFunnyMesh hAsset = m_meshes.GetOrCreateObject(szName, &bHasBeenCreated);
|
||||
@@ -322,12 +322,12 @@ HFunnyMesh CAssetManager::LoadMesh( const char *szName )
|
||||
return hAsset;
|
||||
|
||||
}
|
||||
void CAssetManager::UnrefMesh( uint32_t uIndex )
|
||||
void C_AssetManager::UnrefMesh( uint32_t uIndex )
|
||||
{
|
||||
m_meshes.UnrefObject(uIndex);
|
||||
}
|
||||
|
||||
uint32_t CAssetManager::LoadShader( const char *szName )
|
||||
uint32_t C_AssetManager::LoadShader( const char *szName )
|
||||
{
|
||||
bool bHasBeenCreated = false;
|
||||
uint32_t hShader = m_shaders.GetOrCreateObject(szName, &bHasBeenCreated);
|
||||
@@ -347,12 +347,12 @@ uint32_t CAssetManager::LoadShader( const char *szName )
|
||||
return hShader;
|
||||
}
|
||||
|
||||
void CAssetManager::UnrefShader( uint32_t uIndex )
|
||||
void C_AssetManager::UnrefShader( uint32_t uIndex )
|
||||
{
|
||||
m_shaders.UnrefObject(uIndex);
|
||||
}
|
||||
|
||||
HFunnyTexture CAssetManager::LoadTexture( const char *szName )
|
||||
HFunnyTexture C_AssetManager::LoadTexture( const char *szName )
|
||||
{
|
||||
bool bHasBeenCreated = false;
|
||||
uint32_t hTexture = m_textures.GetOrCreateObject(szName, &bHasBeenCreated);
|
||||
@@ -372,18 +372,18 @@ HFunnyTexture CAssetManager::LoadTexture( const char *szName )
|
||||
return hTexture;
|
||||
}
|
||||
|
||||
FunnyTexture_t *CAssetManager::GetTextureByIndex( HFunnyTexture hTexture )
|
||||
FunnyTexture_t *C_AssetManager::GetTextureByIndex( HFunnyTexture hTexture )
|
||||
{
|
||||
return m_textures.GetObjectPtr(hTexture);
|
||||
}
|
||||
|
||||
void CAssetManager::UnrefTexture( uint32_t hTexture )
|
||||
void C_AssetManager::UnrefTexture( uint32_t hTexture )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
HFunnyPhysics CAssetManager::LoadPhysics( const char *szName )
|
||||
HFunnyPhysics C_AssetManager::LoadPhysics( const char *szName )
|
||||
{
|
||||
bool bHasBeenCreated = false;
|
||||
HFunnyPhysics hPhysics = m_physics.GetOrCreateObject(szName, &bHasBeenCreated);
|
||||
@@ -436,12 +436,12 @@ HFunnyPhysics CAssetManager::LoadPhysics( const char *szName )
|
||||
}
|
||||
|
||||
|
||||
FunnyPhysics_t *CAssetManager::GetPhysicsByIndex( HFunnyPhysics hPhysics )
|
||||
FunnyPhysics_t *C_AssetManager::GetPhysicsByIndex( HFunnyPhysics hPhysics )
|
||||
{
|
||||
return m_physics.GetObjectPtr(hPhysics);
|
||||
}
|
||||
|
||||
void CAssetManager::UnrefPhysics( HFunnyPhysics hPhysics )
|
||||
void C_AssetManager::UnrefPhysics( HFunnyPhysics hPhysics )
|
||||
{
|
||||
m_physics.UnrefObject(hPhysics);
|
||||
}
|
||||
@@ -449,5 +449,5 @@ void CAssetManager::UnrefPhysics( HFunnyPhysics hPhysics )
|
||||
|
||||
|
||||
|
||||
static CAssetManager s_assetmgr;
|
||||
static C_AssetManager s_assetmgr;
|
||||
IAssetManager *g_pAssetManager = &s_assetmgr;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
typedef className ThisClass;
|
||||
|
||||
#define LINK_ENTITY_TO_CLASS( mapClassName, DLLClassName) \
|
||||
static CEntityFactory<DLLClassName> g_EntityFactory_##mapClassName( #mapClassName ); \
|
||||
static C_EntityFactory<DLLClassName> g_EntityFactory_##mapClassName( #mapClassName ); \
|
||||
|
||||
class C_BaseEntity;
|
||||
|
||||
@@ -32,12 +32,12 @@ public:
|
||||
|
||||
|
||||
template<class T>
|
||||
class CEntityFactory : public IEntityFactory
|
||||
class C_EntityFactory : public IEntityFactory
|
||||
{
|
||||
public:
|
||||
CEntityFactory( const char *szClassName )
|
||||
C_EntityFactory( const char *szClassName )
|
||||
{
|
||||
EntitySystem()->RegisterEntityClass(this, szClassName);
|
||||
ClientEntitySystem()->RegisterEntityClass(this, szClassName);
|
||||
};
|
||||
virtual C_BaseEntity *Create() {
|
||||
return new T;
|
||||
|
||||
@@ -25,7 +25,7 @@ void C_BaseModelEntity::Think( float fDelta )
|
||||
void C_BaseModelEntity::SetModel( const char *szName )
|
||||
{
|
||||
V_memset(m_szModel, 0, 256);
|
||||
V_strncpy(m_szModel, szName, 255);
|
||||
V_memcpy(m_szModel, szName, 256);
|
||||
}
|
||||
|
||||
void C_BaseModelEntity::UpdateModel()
|
||||
@@ -33,8 +33,7 @@ void C_BaseModelEntity::UpdateModel()
|
||||
if (!V_strncmp(m_szModel, m_szCurrentModel, 256))
|
||||
return;
|
||||
|
||||
V_memset(m_szCurrentModel, 0, 256);
|
||||
V_strncpy(m_szCurrentModel, m_szModel, 255);
|
||||
V_memcpy(m_szCurrentModel, m_szModel, 256);
|
||||
|
||||
if (m_hModelHandle)
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
static C_BaseEntity *s_pLocalEntity;
|
||||
|
||||
C_EntitySystem *EntitySystem()
|
||||
C_EntitySystem *ClientEntitySystem()
|
||||
{
|
||||
static C_EntitySystem s_entitySystem;
|
||||
return &s_entitySystem;
|
||||
@@ -25,7 +25,7 @@ static struct EntityRegistry_t
|
||||
IEntityFactory *m_pFactory;
|
||||
const char *m_szClassName;
|
||||
struct EntityRegistry_t *m_pNext;
|
||||
} *s_pEntitiesRegistry = NULL;
|
||||
} *s_pClientEntitiesRegistry = NULL;
|
||||
|
||||
C_EntitySystem::C_EntitySystem()
|
||||
{
|
||||
@@ -52,9 +52,9 @@ void C_EntitySystem::RegisterEntityClass( IEntityFactory *pEntityFactory, const
|
||||
|
||||
pRegistry = new EntityRegistry_t;
|
||||
pRegistry->m_pFactory = pEntityFactory;
|
||||
pRegistry->m_pNext = s_pEntitiesRegistry;
|
||||
pRegistry->m_pNext = s_pClientEntitiesRegistry;
|
||||
pRegistry->m_szClassName = szClassName;
|
||||
s_pEntitiesRegistry = pRegistry;
|
||||
s_pClientEntitiesRegistry = pRegistry;
|
||||
}
|
||||
|
||||
C_BaseEntity *C_EntitySystem::CreateByClassname( const char *szName )
|
||||
@@ -113,7 +113,7 @@ IEntityFactory *C_EntitySystem::GetFactoryByClassname( const char *szName )
|
||||
{
|
||||
EntityRegistry_t *pEntity;
|
||||
|
||||
for ( pEntity = s_pEntitiesRegistry; pEntity; pEntity = pEntity->m_pNext )
|
||||
for ( pEntity = s_pClientEntitiesRegistry; pEntity; pEntity = pEntity->m_pNext )
|
||||
{
|
||||
if (!strcmp(szName, pEntity->m_szClassName))
|
||||
{
|
||||
|
||||
@@ -43,7 +43,7 @@ private:
|
||||
int m_nEntityCount;
|
||||
};
|
||||
|
||||
C_EntitySystem *EntitySystem();
|
||||
C_EntitySystem *ClientEntitySystem();
|
||||
|
||||
C_BaseEntity *UTIL_GetLocalPlayer();
|
||||
|
||||
|
||||
+15
-16
@@ -15,7 +15,7 @@
|
||||
#include "steam/steam_gameserver.h"
|
||||
#endif
|
||||
|
||||
class CFunnyGameBridge: public IEngineBridge
|
||||
class CClientGameBridge: public IEngineBridge
|
||||
{
|
||||
virtual void Init() override;
|
||||
virtual void Tick( float fDelta ) override;
|
||||
@@ -33,18 +33,18 @@ class CFunnyGameBridge: public IEngineBridge
|
||||
};
|
||||
|
||||
|
||||
IEngineBridge *EngineBridge()
|
||||
IEngineBridge *ClientEngineBridge()
|
||||
{
|
||||
static CFunnyGameBridge s_bridge;
|
||||
static CClientGameBridge s_bridge;
|
||||
return &s_bridge;
|
||||
}
|
||||
|
||||
void XRInputCallback( IXRController *pController, EXRInputType_t eType, const char *szType, EXRInputActionType_t action, EXRInputValue_t value );
|
||||
|
||||
|
||||
EXPOSE_INTERFACE_FN(EngineBridge, IEngineBridge, ENGINE_BRIDGE_INTERFACE_VERSION)
|
||||
EXPOSE_INTERFACE_FN(ClientEngineBridge, IClientEngineBridge, CLIENT_ENGINE_BRIDGE_INTERFACE_VERSION)
|
||||
|
||||
void CFunnyGameBridge::Init()
|
||||
void CClientGameBridge::Init()
|
||||
{
|
||||
Console()->AddCommand("exec game/core/default.cfg\n");
|
||||
Console()->Execute();
|
||||
@@ -121,12 +121,12 @@ void CFunnyGameBridge::Init()
|
||||
*/
|
||||
}
|
||||
|
||||
void CFunnyGameBridge::Tick( float fDelta )
|
||||
void CClientGameBridge::Tick( float fDelta )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void CFunnyGameBridge::TryToConnectToServer()
|
||||
void CClientGameBridge::TryToConnectToServer()
|
||||
{
|
||||
#ifdef STEAM
|
||||
if (g_pEngineConstants->m_bIsSteam)
|
||||
@@ -145,10 +145,10 @@ void CFunnyGameBridge::TryToConnectToServer()
|
||||
if (g_pServerConnection)
|
||||
{
|
||||
m_bIsConnectedToServer = true;
|
||||
C_BaseEntity **ppEntities = EntitySystem()->GetEntities();
|
||||
C_BaseEntity **ppEntities = ClientEntitySystem()->GetEntities();
|
||||
for ( int i = 0; i < MAX_EDICTS; i++ )
|
||||
{
|
||||
EntitySystem()->DestroyEntityByIndex(i);
|
||||
ClientEntitySystem()->DestroyEntityByIndex(i);
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -156,9 +156,8 @@ void CFunnyGameBridge::TryToConnectToServer()
|
||||
#endif
|
||||
}
|
||||
|
||||
void CFunnyGameBridge::Frame( float fDelta )
|
||||
void CClientGameBridge::Frame( float fDelta )
|
||||
{
|
||||
|
||||
if (g_pMainWindow->GetRenderWidth() != m_pMainViewport->GetWidth())
|
||||
if (g_pMainWindow->GetRenderHeight() != m_pMainViewport->GetHeight())
|
||||
m_pMainViewport->UpdateResolution(g_pMainWindow->GetRenderWidth(), g_pMainWindow->GetRenderHeight());
|
||||
@@ -198,7 +197,7 @@ void CFunnyGameBridge::Frame( float fDelta )
|
||||
case MESSAGE_ENTITY_CLASS_SYNC:
|
||||
case MESSAGE_ENTITY_DATA_SYNC:
|
||||
case k_EMessage_PlayerSetLocalEntity:
|
||||
EntitySystem()->NetRecvPacket(&packet);
|
||||
ClientEntitySystem()->NetRecvPacket(&packet);
|
||||
pCurrentServer->RecievePacket();
|
||||
break;
|
||||
default:
|
||||
@@ -209,7 +208,7 @@ void CFunnyGameBridge::Frame( float fDelta )
|
||||
}
|
||||
}
|
||||
|
||||
EntitySystem()->Think();
|
||||
ClientEntitySystem()->Think();
|
||||
|
||||
float fTickRate = 1.0/60.0;
|
||||
m_fNetUpdateTimer += fDelta;
|
||||
@@ -220,19 +219,19 @@ void CFunnyGameBridge::Frame( float fDelta )
|
||||
m_fNetUpdateTimer-=fTickRate;
|
||||
m_fNetUpdateTimer = fmod(m_fNetUpdateTimer, fTickRate);
|
||||
if (pCurrentServer)
|
||||
EntitySystem()->NetSendThink(pCurrentServer);
|
||||
ClientEntitySystem()->NetSendThink(pCurrentServer);
|
||||
}
|
||||
g_pWorldRenderer->Frame(fDelta);
|
||||
g_pMainWindow->SetOutputImage(m_pMainViewport->GetRenderImage());
|
||||
}
|
||||
|
||||
void CFunnyGameBridge::Shutdown()
|
||||
void CClientGameBridge::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 CClientGameBridge::ConnectInterface( const char *psz, void *pInterface )
|
||||
{
|
||||
CONNECT_INTERFACE(FILESYSTEM_INTERFACE_VERSION, filesystem);
|
||||
CONNECT_INTERFACE(RENDER_CONTEXT_INTERFACE_VERSION, g_pRenderContext);
|
||||
|
||||
@@ -26,8 +26,8 @@ void C_MOBAPlayer::Think( float fDelta )
|
||||
if (pPlayerEntity == this)
|
||||
{
|
||||
}
|
||||
m_pLeftHand = (C_MOBAPlayerHandController*)EntitySystem()->GetEntityByIndex(m_leftHandId);
|
||||
m_pRightHand = (C_MOBAPlayerHandController*)EntitySystem()->GetEntityByIndex(m_rightHandId);
|
||||
m_pLeftHand = (C_MOBAPlayerHandController*)ClientEntitySystem()->GetEntityByIndex(m_leftHandId);
|
||||
m_pRightHand = (C_MOBAPlayerHandController*)ClientEntitySystem()->GetEntityByIndex(m_rightHandId);
|
||||
BaseClass::Think(fDelta);
|
||||
};
|
||||
|
||||
@@ -157,10 +157,8 @@ void Game_OnGameAxisDiff( EInputDeviceType eDevice, EInputAxis eAxis, float fVal
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void C_MOBAPlayerHandController::Precache()
|
||||
{
|
||||
|
||||
m_hNormal = g_pAssetManager->LoadModel("game/core/models/hand.fmdl");
|
||||
m_pNormalModel = g_pAssetManager->GetModelByIndex(m_hNormal);
|
||||
m_hSqueezed = g_pAssetManager->LoadModel("game/core/models/sphere.fmdl");
|
||||
|
||||
@@ -367,7 +367,7 @@ void CFunnyWorldRenderer::Frame( float fDelta )
|
||||
v->m_pDepth,
|
||||
LOAD_MODE_CLEAR,
|
||||
STORE_MODE_STORE,
|
||||
{.depth = 0},
|
||||
{.depth = 1},
|
||||
};
|
||||
BeginInfo begin = {};
|
||||
begin.uWidth = uWidth;
|
||||
|
||||
@@ -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