some stuff

This commit is contained in:
2026-03-05 21:25:59 +02:00
parent 2da75ebdd8
commit 99f68e655f
41 changed files with 706 additions and 324 deletions

View File

@@ -10,6 +10,8 @@
#include "string.h"
#include "stdlib.h"
#include "netprotocol.h"
CEntitySystem *EntitySystem()
{
@@ -155,7 +157,96 @@ void CEntitySystem::Think()
}
}
static void *UTIL_GetNetMapData(C_BaseEntity *pEntity, netmap_t *pMap, uint32_t uIndex )
{
netmap_t *pCurrentMap = pMap;
uint32_t uCurrentIndex = uIndex;
searchIndex:
if (uCurrentIndex >= pCurrentMap->m_uFieldCount || pCurrentMap->m_pBase )
{
uCurrentIndex -= pCurrentMap->m_uFieldCount;
pCurrentMap = pCurrentMap->m_pBase;
if (!pCurrentMap)
return NULL;
goto searchIndex;
}
return (char*)pEntity+pCurrentMap->m_pFields[uCurrentIndex].m_uOffset;
}
static C_BaseEntity *s_pLocalEntity;
void CEntitySystem::NetRecvPacket( NetPacket_t *pPacket )
{
PlayerPacket_t *pPlayerPacket = (PlayerPacket_t*)pPacket->pData;
C_BaseEntity *pEntity;
switch (pPlayerPacket->m_eType)
{
case MESSAGE_ENTITY_CLASS_SYNC:
V_printf("MESSAGE_ENTITY_CLASS_SYNC: %u = %s\n",
(uint32_t)pPlayerPacket->m_entityClass.m_uIndex,
pPlayerPacket->m_entityClass.m_szEntityName);
pEntity = CreateByClassnameWithIndex(
(char*)pPlayerPacket->m_entityClass.m_szEntityName,
pPlayerPacket->m_entityClass.m_uIndex
);
if (pEntity == NULL)
break;
pEntity->Spawn();
break;
case MESSAGE_ENTITY_DATA_SYNC:
pEntity = m_pEntities[pPlayerPacket->m_entityData.m_uIndex];
if (pEntity == NULL)
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;
case k_EMessage_PlayerSetLocalEntity:
V_printf("k_EMessage_PlayerSetLocalEntity: %u\n",(uint32_t)pPlayerPacket->m_setLocalEntity.m_uIndex);
if (pPlayerPacket->m_setLocalEntity.m_uIndex > MAX_EDICTS)
break;
s_pLocalEntity = m_pEntities[pPlayerPacket->m_setLocalEntity.m_uIndex];
default:
break;
}
}
void CEntitySystem::NetSendThink()
{
}
C_BaseEntity **CEntitySystem::GetEntities()
{
return m_pEntities;
};
C_BaseEntity *UTIL_GetLocalPlayer()
{
return s_pLocalEntity;
}