demboyz/demboyz/netmessages.h

115 lines
4.1 KiB
C++

#pragma once
#include <cstdint>
class CBitRead;
typedef void(*NetMsgFn)(CBitRead& bitbuf);
enum constants
{
// was 5
NETMSG_TYPE_BITS = 6, // 2^NETMSG_TYPE_BITS > SVC_LASTMSG
// was 96000
NET_MAX_PAYLOAD = 288000, // largest message size in bytes
// was 17
NET_MAX_PALYLOAD_BITS = 19, // 2^NET_MAX_PALYLOAD_BITS > NET_MAX_PAYLOAD
// table index is sent in log2(MAX_TABLES) bits
MAX_TABLES = 32, // Table id is 4 bits
// How many bits to use to encode an edict.
MAX_EDICT_BITS = 11, // # of bits needed to represent max edicts
// Max # of edicts in a level
MAX_EDICTS = (1<<MAX_EDICT_BITS),
MAX_DECAL_INDEX_BITS = 9,
SP_MODEL_INDEX_BITS = 11,
MAX_SERVER_CLASS_BITS = 9,
MAX_EVENT_NAME_LENGTH = 32,
MAX_EVENT_BITS = 9,
MAX_EVENT_NUMBER = (1 << MAX_EVENT_BITS),
MAX_EVENT_BYTES = 1024,
DELTASIZE_BITS = 20, // must be: 2^DELTASIZE_BITS > (NET_MAX_PAYLOAD * 8)
EVENT_INDEX_BITS = 8,
MAX_SOUND_INDEX_BITS = 13,
SIGNONSTATE_NONE = 0, // no state yet, about to connect
SIGNONSTATE_CHALLENGE = 1, // client challenging server, all OOB packets
SIGNONSTATE_CONNECTED = 2, // client is connected to server, netchans ready
SIGNONSTATE_NEW = 3, // just got serverinfo and string tables
SIGNONSTATE_PRESPAWN = 4, // received signon buffers
SIGNONSTATE_SPAWN = 5, // ready to receive entity packets
SIGNONSTATE_FULL = 6, // we are fully connected, first non-delta packet received
SIGNONSTATE_CHANGELEVEL = 7 // server is changing level, please wait
};
enum class NetMsg: std::uint8_t
{
net_NOP = 0, // nop command used for padding
net_Disconnect = 1, // disconnect, last message in connection
net_File = 2, // file transmission message request/deny
net_Tick = 3, // send last world tick
net_StringCmd = 4, // a string command
net_SetConVar = 5, // sends one/multiple convar settings
net_SignonState = 6, // signals current signon state
//
// server to client
//
svc_Print = 7, // print text to console
svc_ServerInfo = 8, // first message from server about game, map etc
svc_SendTable = 9, // sends a sendtable description for a game class
svc_ClassInfo = 10, // Info about classes (first byte is a CLASSINFO_ define).
svc_SetPause = 11, // tells client if server paused or unpaused
svc_CreateStringTable = 12, // inits shared string tables
svc_UpdateStringTable = 13, // updates a string table
svc_VoiceInit = 14, // inits used voice codecs & quality
svc_VoiceData = 15, // Voicestream data from the server
//svc_HLTV = 16, // HLTV control messages
svc_Sounds = 17, // starts playing sound
svc_SetView = 18, // sets entity as point of view
svc_FixAngle = 19, // sets/corrects players viewangle
svc_CrosshairAngle = 20, // adjusts crosshair in auto aim mode to lock on traget
svc_BSPDecal = 21, // add a static decal to the worl BSP
// NOTE: This is now unused!
// svc_TerrainMod = 22, // modification to the terrain/displacement
// Message from server side to client side entity
svc_UserMessage = 23, // a game specific message
svc_EntityMessage = 24, // a message for an entity
svc_GameEvent = 25, // global game event fired
svc_PacketEntities = 26, // non-delta compressed entities
svc_TempEntities = 27, // non-reliable event object
svc_Prefetch = 28, // only sound indices for now
svc_Menu = 29, // display a menu from a plugin
svc_GameEventList = 30, // list of known games events and fields
svc_GetCvarValue = 31, // Server wants to know the value of a cvar on the client.
SVC_LASTMSG = 31 // last known server messages
};
void ProcessNetMsg(const std::uint32_t msgType, CBitRead& bitbuf);