added keybind

This commit is contained in:
2026-03-06 16:42:16 +02:00
parent 9b4cec7920
commit 1a2a353e03
30 changed files with 338 additions and 53 deletions

View File

@@ -52,10 +52,12 @@ public:
DECLARE_DATADESC_NOBASE()
DECLARE_SERVERCLASS_NOBASE()
typedescription_t *FindDataByName( const char *szName );
typedescription_t *FindDataByMapName( const char *szName );
const char *GetClassName();
void SetNetworkOwner( uint64_t ullPlayer );
virtual ~CBaseEntity();
virtual void Precache();
@@ -77,6 +79,7 @@ public:
fnThink m_pfnThink = NULL;
const char *m_szClassName;
uint64_t m_ullOwner;
private:
Vector m_vPosition;
Quat m_vRotation;

View File

@@ -17,6 +17,7 @@ DECLARE_BUILD_STAGE(Server)
compileProject.m_szName = "server";
compileProject.files = {
"../shared/game.cpp",
"../shared/boneanimation.cpp",
"game.cpp",
"assetmgr.cpp",
@@ -46,16 +47,32 @@ DECLARE_BUILD_STAGE(Server)
}
else
{
if ( GET_PROJECT_VALUE(config, "steam") == "true" ) {
ldProject.libraryDirectories.AppendTail(EXTERNAL"steamworks/redistributable_bin/linux64");
ldProject.libraries.AppendTail("steam_api");
}
ldProject.linkType = ELINK_DYNAMIC_LIBRARY;
ldProject.libraryObjects = {
GET_PROJECT_LIBRARY(tier0, "tier0"),
};
ldProject.objects.AppendTail({GET_PROJECT_LIBRARY(tier1, "tier1")});
ldProject.objects.AppendTail({GET_PROJECT_LIBRARY(tier2, "tier2")});
if ( GET_PROJECT_VALUE(config, "steam") == "true" ) {
ldProject.libraryObjects.AppendTail(GET_PROJECT_OBJECT(config, "steam_lib"));
}
if (ldProject.m_target.kernel & TARGET_KERNEL_WINDOWS_DEVICES)
{
ldProject.libraryDirectories.AppendTail(EXTERNAL"windows");
ldProject.libraries.AppendTail("winpthread-1");
ldProject.libraries.AppendTail("ws2_32");
ldProject.libraries.AppendTail("winmm");
ldProject.libraries.AppendTail("ole32");
ldProject.libraries.AppendTail("gdi32");
ldProject.libraries.AppendTail("oleaut32");
ldProject.libraries.AppendTail("setupapi");
ldProject.libraries.AppendTail("imm32");
ldProject.libraries.AppendTail("version");
ldProject.libraries.AppendTail("shell32");
ldProject.libraries.AppendTail("uuid");
};
}
if (ldProject.m_target.kernel & TARGET_KERNEL_WINDOWS_DEVICES)

View File

@@ -132,12 +132,78 @@ void CEntitySystem::Think()
}
}
static void *UTIL_GetNetMapData(CBaseEntity *pEntity, netmap_t *pMap, uint32_t uIndex )
{
netmap_t *pCurrentMap = pMap;
uint32_t uCurrentIndex = uIndex;
searchIndex:
if ( uCurrentIndex < pCurrentMap->m_uFieldCount )
{
return (char*)pEntity+pCurrentMap->m_pFields[uCurrentIndex].m_uOffset;
}
uCurrentIndex -= pCurrentMap->m_uFieldCount;
pCurrentMap = pCurrentMap->m_pBase;
if (!pCurrentMap)
return NULL;
goto searchIndex;
}
void CEntitySystem::NetRecvPacket( NetPacket_t *pPacket )
{
PlayerPacket_t *pPlayerPacket = (PlayerPacket_t*)pPacket->pData;
CBaseEntity *pEntity;
switch (pPlayerPacket->m_eType)
{
case MESSAGE_ENTITY_DATA_SYNC:
if ( pPlayerPacket->m_entityData.m_uIndex >= MAX_EDICTS )
break;
pEntity = m_pEntities[pPlayerPacket->m_entityData.m_uIndex];
// check for owner being moron
if ( pEntity == NULL )
break;
if ( pEntity->m_ullOwner != pPacket->m_uOwner)
break;
union {
void *pData;
char *pcCurrentData;
EntityDataSyncValue_t *pcSyncValue;
};
pData = pPlayerPacket;
pcCurrentData += sizeof(EntityDataSync_t);
// too bad
// this shall be reworked
for ( uint32_t u = 0; u < pPlayerPacket->m_entityData.m_uCount; u++ )
{
uint32_t uVariableSize = pcSyncValue->m_uVariableSize;
void *pValueData = (float*)UTIL_GetNetMapData(
pEntity,
pEntity->GetRecvMap(),
pcSyncValue->m_uVariableIndex);
pcCurrentData += sizeof(EntityDataSyncValue_t);
if (pValueData)
V_memcpy(pValueData, pcCurrentData, uVariableSize);
pcCurrentData += (uVariableSize+7) & ~7;
}
break;
default:
break;
}
}
//-------------------------------------------------------------------------------
// Purpose: Sends packets to clients.
// Since we are running this on server we can't really accept any packet.
// We only allow packets from the entities sent by a client
//-------------------------------------------------------------------------------
void CEntitySystem::NetThink( INetworkBase *pBase )
void CEntitySystem::NetSendThink( INetworkBase *pBase )
{
CBaseEntity *pEntity;
@@ -159,9 +225,6 @@ void CEntitySystem::NetThink( INetworkBase *pBase )
pEntity = m_pEntities[i];
if ( pEntity == NULL )
continue;
if ( !pEntity->m_pfnThink )
continue;
pNetMap = pEntity->GetSendMap();
uSize = sizeof(EntityDataSyncValue_t);
@@ -202,10 +265,9 @@ void CEntitySystem::NetThink( INetworkBase *pBase )
}
pNetMap = pNetMap->m_pBase;
}
if (g_pCurrentConnection)
g_pCurrentConnection->SendPacket({pData, uSize});
if (pBase)
pBase->SendPacket({pData, uSize});
V_free(pData);
}
}
@@ -213,3 +275,16 @@ CBaseEntity **CEntitySystem::GetEntities()
{
return m_pEntities;
}
void CEntitySystem::SetAllowedEntityForPlayer( uint64_t ullPlayer, CBaseEntity *pEntity )
{
if (pEntity)
{
}
else
{
}
}

View File

@@ -25,8 +25,11 @@ public:
virtual IEntityFactory *GetFactoryByClassname( const char *szName );
virtual void Think();
virtual void NetThink( INetworkBase *pBase );
virtual CBaseEntity **GetEntities();
virtual void NetRecvPacket( NetPacket_t *pPacket );
virtual void NetSendThink( INetworkBase *pBase );
virtual void SetAllowedEntityForPlayer( uint64_t ullPlayer, CBaseEntity *pEntity );
private:
CBaseEntity *m_pEntities[MAX_EDICTS];
int m_nEntityCount;

View File

@@ -68,6 +68,7 @@ uint32_t NET_ServerCallback( NetCallback_t *pCallback )
CBaseEntity *pEntity;
pEntity = EntitySystem()->CreateByClassname("player", &iIndex);
pEntity->Spawn();
pEntity->m_ullOwner = pCallback->m_ullUserConnection;
SetLocalEntity_t stLocalEntity = {
k_EMessage_PlayerSetLocalEntity,
@@ -150,9 +151,9 @@ void NET_ProcessPacket( INetworkBase *pBase )
int iIndex = -1;
V_printf("Hi %s\n",pPacket->m_playerJoined.m_szPlayerName);
pEntity = EntitySystem()->CreateByClassname("player", &iIndex);
pEntity->Spawn();
pEntity->m_ullOwner = 0;
SetLocalEntity_t stLocalEntity = {
k_EMessage_PlayerSetLocalEntity,
@@ -162,7 +163,11 @@ void NET_ProcessPacket( INetworkBase *pBase )
g_pCurrentConnection->SendPacket({&stLocalEntity, sizeof(stLocalEntity), 0, PACKET_MUST_ARRIVE});
}
return;
case MESSAGE_ENTITY_DATA_SYNC:
EntitySystem()->NetRecvPacket(&packet);
pBase->RecievePacket();
default:
pBase->RecievePacket();
break;
}
pBase->RecievePacket();
@@ -204,7 +209,7 @@ void CFunnyGameBridge::Frame( float fDelta )
{
g_pPhysicsWorld->Frame(fTickRate);
EntitySystem()->Think();
EntitySystem()->NetThink(g_pCurrentConnection);
EntitySystem()->NetSendThink(g_pCurrentConnection);
}
}

View File

@@ -14,6 +14,7 @@ void CMOBAPlayer::Spawn()
void CMOBAPlayer::Think( float fDelta )
{
V_printf("%f %f %f\n", m_vMovementVector.x, m_vMovementVector.y, m_vMovementVector.z);
CPhysicsProp::Think(fDelta);
};
@@ -25,4 +26,6 @@ END_DATADESC()
IMPLEMENT_SEND_DT(CMOBAPlayer)
END_SEND_DT()
IMPLEMENT_EMPTY_RECV_DT(CMOBAPlayer)
IMPLEMENT_RECV_DT(CMOBAPlayer)
NetPropFloat3(m_vMovementVector)
END_RECV_DT()

View File

@@ -12,6 +12,8 @@ public:
virtual void Spawn( void ) override;
void Think( float fDelta );
private:
Vector m_vMovementVector = {};
};
#endif