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

@@ -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
{
}
}