Files
funnygame/game/shared/netprotocol.h
2026-03-16 15:35:31 +02:00

87 lines
1.5 KiB
C++

#ifndef NET_PROTOCOL_H
#define NET_PROTOCOL_H
#include "stdint.h"
#include "tier0/network.h"
class CNetworkProtocolUInt32
{
public:
CNetworkProtocolUInt32() : m_uValue(0) {}
CNetworkProtocolUInt32( uint32_t uValue ) : m_uValue(htonl(uValue)) {}
operator uint32_t() const {
return htonl(m_uValue);
}
uint32_t m_uValue;
};
enum EMessageType: uint32_t
{
MESSAGE_PLAYER_JOINED,
MESSAGE_PLAYER_JOINED_CALLBACK,
MESSAGE_PLAYER_LEFT,
MESSAGE_ENTITY_CLASS_SYNC,
MESSAGE_ENTITY_DATA_SYNC,
k_EMessage_PlayerSetLocalEntity,
k_EMessage_ResetEntities,
};
struct PlayerJoined_t
{
EMessageType m_eType;
int8_t m_szPlayerName[256];
};
struct PlayerJoinedCallback_t
{
EMessageType m_eType;
CNetworkProtocolUInt32 m_uPlayerIndex;
};
struct PlayerLeft_t
{
EMessageType m_eType;
CNetworkProtocolUInt32 m_uPlayerIndex;
};
struct EntityClass_t
{
EMessageType m_eType;
CNetworkProtocolUInt32 m_uIndex;
int8_t m_szEntityName[256];
};
struct EntityDataSync_t
{
EMessageType m_eType;
CNetworkProtocolUInt32 m_uIndex;
CNetworkProtocolUInt32 m_uCount;
};
struct EntityDataSyncValue_t
{
CNetworkProtocolUInt32 m_uVariableIndex;
CNetworkProtocolUInt32 m_uVariableSize;
};
struct SetLocalEntity_t
{
EMessageType m_eType;
CNetworkProtocolUInt32 m_uIndex;
};
union PlayerPacket_t
{
EMessageType m_eType;
PlayerJoined_t m_playerJoined;
PlayerJoinedCallback_t m_playerJoinedCallback;
PlayerLeft_t m_playerLeft;
EntityClass_t m_entityClass;
EntityDataSync_t m_entityData;
SetLocalEntity_t m_setLocalEntity;
};
#endif