Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

189 lines
7.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. // protocol.h -- communications protocols
  9. #ifndef PROTOCOL_H
  10. #define PROTOCOL_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. // Used to classify entity update types in DeltaPacketEntities.
  15. enum UpdateType
  16. {
  17. EnterPVS = 0, // Entity came back into pvs, create new entity if one doesn't exist
  18. LeavePVS, // Entity left pvs
  19. DeltaEnt, // There is a delta for this entity.
  20. PreserveEnt, // Entity stays alive but no delta ( could be LOD, or just unchanged )
  21. Finished, // finished parsing entities successfully
  22. Failed, // parsing error occured while reading entities
  23. };
  24. // Flags for delta encoding header
  25. enum
  26. {
  27. FHDR_ZERO = 0x0000,
  28. FHDR_LEAVEPVS = 0x0001,
  29. FHDR_DELETE = 0x0002,
  30. FHDR_ENTERPVS = 0x0004,
  31. };
  32. #define INSTANCE_BASELINE_TABLENAME "instancebaseline"
  33. #define LIGHT_STYLES_TABLENAME "lightstyles"
  34. #define USER_INFO_TABLENAME "userinfo"
  35. #define SERVER_STARTUP_DATA_TABLENAME "server_query_info" // the name is a remnant...
  36. //#define CURRENT_PROTOCOL 1
  37. #define DELTA_OFFSET_BITS 5
  38. #define DELTA_OFFSET_MAX ( ( 1 << DELTA_OFFSET_BITS ) - 1 )
  39. #define DELTASIZE_BITS 20 // must be: 2^DELTASIZE_BITS > (NET_MAX_PAYLOAD * 8)
  40. // Largest # of commands to send in a packet
  41. #define NUM_NEW_COMMAND_BITS 4
  42. #define MAX_NEW_COMMANDS ((1 << NUM_NEW_COMMAND_BITS)-1)
  43. // Max number of history commands to send ( 2 by default ) in case of dropped packets
  44. #define NUM_BACKUP_COMMAND_BITS 3
  45. #define MAX_BACKUP_COMMANDS ((1 << NUM_BACKUP_COMMAND_BITS)-1)
  46. #define PROTOCOL_AUTHCERTIFICATE 0x01 // Connection from client is using a WON authenticated certificate
  47. #define PROTOCOL_HASHEDCDKEY 0x02 // Connection from client is using hashed CD key because WON comm. channel was unreachable
  48. #define PROTOCOL_STEAM 0x03 // Steam certificates
  49. #define PROTOCOL_LASTVALID 0x03 // Last valid protocol
  50. #define CONNECTIONLESS_HEADER 0xFFFFFFFF // all OOB packet start with this sequence
  51. #define STEAM_KEYSIZE 2048 // max size needed to contain a steam authentication key (both server and client)
  52. // each channel packet has 1 byte of FLAG bits
  53. #define PACKET_FLAG_RELIABLE (1<<0) // packet contains subchannel stream data
  54. #define PACKET_FLAG_COMPRESSED (1<<1) // packet is compressed
  55. #define PACKET_FLAG_ENCRYPTED (1<<2) // packet is encrypted
  56. #define PACKET_FLAG_SPLIT (1<<3) // packet is split
  57. #define PACKET_FLAG_CHOKED (1<<4) // packet was choked by sender
  58. #define PACKET_FLAG_CHALLENGE (1<<5) // packet contains challenge number, use to prevent packet injection
  59. // NOTE: Bits 5, 6, and 7 are used to specify the # of padding bits at the end of the packet!!!
  60. #define ENCODE_PAD_BITS( x ) ( ( x << 5 ) & 0xff )
  61. #define DECODE_PAD_BITS( x ) ( ( x >> 5 ) & 0xff )
  62. // shared commands used by all streams, handled by stream layer, TODO
  63. #define net_NOP 0 // nop command used for padding
  64. #define net_Disconnect 1 // disconnect, last message in connection
  65. #define net_File 2 // file transmission message request/deny
  66. #define net_Tick 3 // send last world tick
  67. #define net_StringCmd 4 // a string command
  68. #define net_SetConVar 5 // sends one/multiple convar settings
  69. #define net_SignonState 6 // signals current signon state
  70. //
  71. // server to client
  72. //
  73. #define svc_Print 7 // print text to console
  74. #define svc_ServerInfo 8 // first message from server about game, map etc
  75. #define svc_SendTable 9 // sends a sendtable description for a game class
  76. #define svc_ClassInfo 10 // Info about classes (first byte is a CLASSINFO_ define).
  77. #define svc_SetPause 11 // tells client if server paused or unpaused
  78. #define svc_CreateStringTable 12 // inits shared string tables
  79. #define svc_UpdateStringTable 13 // updates a string table
  80. #define svc_VoiceInit 14 // inits used voice codecs & quality
  81. #define svc_VoiceData 15 // Voicestream data from the server
  82. // #define svc_HLTV 16 // HLTV control messages
  83. #define svc_Sounds 17 // starts playing sound
  84. #define svc_SetView 18 // sets entity as point of view
  85. #define svc_FixAngle 19 // sets/corrects players viewangle
  86. #define svc_CrosshairAngle 20 // adjusts crosshair in auto aim mode to lock on traget
  87. #define svc_BSPDecal 21 // add a static decal to the worl BSP
  88. // NOTE: This is now unused!
  89. //#define svc_TerrainMod 22 // modification to the terrain/displacement
  90. // Message from server side to client side entity
  91. #define svc_UserMessage 23 // a game specific message
  92. #define svc_EntityMessage 24 // a message for an entity
  93. #define svc_GameEvent 25 // global game event fired
  94. #define svc_PacketEntities 26 // non-delta compressed entities
  95. #define svc_TempEntities 27 // non-reliable event object
  96. #define svc_Prefetch 28 // only sound indices for now
  97. #define svc_Menu 29 // display a menu from a plugin
  98. #define svc_GameEventList 30 // list of known games events and fields
  99. #define svc_GetCvarValue 31 // Server wants to know the value of a cvar on the client
  100. #define svc_CmdKeyValues 32 // Server submits KeyValues command for the client
  101. #define svc_SetPauseTimed 33 // Timed pause - to avoid breaking demos
  102. #define SVC_LASTMSG 33 // last known server messages
  103. //
  104. // client to server
  105. //
  106. #define clc_ClientInfo 8 // client info (table CRC etc)
  107. #define clc_Move 9 // [CUserCmd]
  108. #define clc_VoiceData 10 // Voicestream data from a client
  109. #define clc_BaselineAck 11 // client acknowledges a new baseline seqnr
  110. #define clc_ListenEvents 12 // client acknowledges a new baseline seqnr
  111. #define clc_RespondCvarValue 13 // client is responding to a svc_GetCvarValue message.
  112. #define clc_FileCRCCheck 14 // client is sending a file's CRC to the server to be verified.
  113. #define clc_SaveReplay 15 // client is sending a save replay request to the server.
  114. #define clc_CmdKeyValues 16
  115. #define clc_FileMD5Check 17 // client is sending a file's MD5 to the server to be verified.
  116. #define CLC_LASTMSG 17 // last known client message
  117. #define RES_FATALIFMISSING (1<<0) // Disconnect if we can't get this file.
  118. #define RES_PRELOAD (1<<1) // Load on client rather than just reserving name
  119. #define SIGNONSTATE_NONE 0 // no state yet, about to connect
  120. #define SIGNONSTATE_CHALLENGE 1 // client challenging server, all OOB packets
  121. #define SIGNONSTATE_CONNECTED 2 // client is connected to server, netchans ready
  122. #define SIGNONSTATE_NEW 3 // just got serverinfo and string tables
  123. #define SIGNONSTATE_PRESPAWN 4 // received signon buffers
  124. #define SIGNONSTATE_SPAWN 5 // ready to receive entity packets
  125. #define SIGNONSTATE_FULL 6 // we are fully connected, first non-delta packet received
  126. #define SIGNONSTATE_CHANGELEVEL 7 // server is changing level, please wait
  127. //
  128. // matchmaking
  129. //
  130. #define mm_Heartbeat 16 // send a mm_Heartbeat
  131. #define mm_ClientInfo 17 // information about a player
  132. #define mm_JoinResponse 18 // response to a matchmaking join request
  133. #define mm_RegisterResponse 19 // response to a matchmaking join request
  134. #define mm_Migrate 20 // tell a client to migrate
  135. #define mm_Mutelist 21 // send mutelist info to other clients
  136. #define mm_Checkpoint 22 // game state checkpoints (start, connect, etc)
  137. #define MM_LASTMSG 22 // last known matchmaking message
  138. #endif // PROTOCOL_H