protocol.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. /*
  2. Copyright (C) 1996-1997 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. // protocol.h -- communications protocols
  16. #define PROTOCOL_VERSION 28
  17. #define QW_CHECK_HASH 0x5157
  18. //=========================================
  19. #define PORT_CLIENT 27001
  20. #define PORT_MASTER 27000
  21. #define PORT_SERVER 27500
  22. //=========================================
  23. // out of band message id bytes
  24. // M = master, S = server, C = client, A = any
  25. // the second character will allways be \n if the message isn't a single
  26. // byte long (?? not true anymore?)
  27. #define S2C_CHALLENGE 'c'
  28. #define S2C_CONNECTION 'j'
  29. #define A2A_PING 'k' // respond with an A2A_ACK
  30. #define A2A_ACK 'l' // general acknowledgement without info
  31. #define A2A_NACK 'm' // [+ comment] general failure
  32. #define A2A_ECHO 'e' // for echoing
  33. #define A2C_PRINT 'n' // print a message on client
  34. #define S2M_HEARTBEAT 'a' // + serverinfo + userlist + fraglist
  35. #define A2C_CLIENT_COMMAND 'B' // + command line
  36. #define S2M_SHUTDOWN 'C'
  37. //==================
  38. // note that there are some defs.qc that mirror to these numbers
  39. // also related to svc_strings[] in cl_parse
  40. //==================
  41. //
  42. // server to client
  43. //
  44. #define svc_bad 0
  45. #define svc_nop 1
  46. #define svc_disconnect 2
  47. #define svc_updatestat 3 // [byte] [byte]
  48. //define svc_version 4 // [long] server version
  49. #define svc_setview 5 // [short] entity number
  50. #define svc_sound 6 // <see code>
  51. //define svc_time 7 // [float] server time
  52. #define svc_print 8 // [byte] id [string] null terminated string
  53. #define svc_stufftext 9 // [string] stuffed into client's console buffer
  54. // the string should be \n terminated
  55. #define svc_setangle 10 // [angle3] set the view angle to this absolute value
  56. #define svc_serverdata 11 // [long] protocol ...
  57. #define svc_lightstyle 12 // [byte] [string]
  58. //define svc_updatename 13 // [byte] [string]
  59. #define svc_updatefrags 14 // [byte] [short]
  60. //define svc_clientdata 15 // <shortbits + data>
  61. #define svc_stopsound 16 // <see code>
  62. //define svc_updatecolors 17 // [byte] [byte] [byte]
  63. //define svc_particle 18 // [vec3] <variable>
  64. #define svc_damage 19
  65. #define svc_spawnstatic 20
  66. // svc_spawnbinary 21
  67. #define svc_spawnbaseline 22
  68. #define svc_temp_entity 23 // variable
  69. #define svc_setpause 24 // [byte] on / off
  70. // svc_signonnum 25 // [byte] used for the signon sequence
  71. #define svc_centerprint 26 // [string] to put in center of the screen
  72. #define svc_killedmonster 27
  73. #define svc_foundsecret 28
  74. #define svc_spawnstaticsound 29 // [coord3] [byte] samp [byte] vol [byte] aten
  75. #define svc_intermission 30 // [vec3_t] origin [vec3_t] angle
  76. #define svc_finale 31 // [string] text
  77. #define svc_cdtrack 32 // [byte] track
  78. #define svc_sellscreen 33
  79. #define svc_smallkick 34 // set client punchangle to 2
  80. #define svc_bigkick 35 // set client punchangle to 4
  81. #define svc_updateping 36 // [byte] [short]
  82. #define svc_updateentertime 37 // [byte] [float]
  83. #define svc_updatestatlong 38 // [byte] [long]
  84. #define svc_muzzleflash 39 // [short] entity
  85. #define svc_updateuserinfo 40 // [byte] slot [long] uid
  86. // [string] userinfo
  87. #define svc_download 41 // [short] size [size bytes]
  88. #define svc_playerinfo 42 // variable
  89. #define svc_nails 43 // [byte] num [48 bits] xyzpy 12 12 12 4 8
  90. #define svc_chokecount 44 // [byte] packets choked
  91. #define svc_modellist 45 // [strings]
  92. #define svc_soundlist 46 // [strings]
  93. #define svc_packetentities 47 // [...]
  94. #define svc_deltapacketentities 48 // [...]
  95. #define svc_maxspeed 49 // maxspeed change, for prediction
  96. #define svc_entgravity 50 // gravity change, for prediction
  97. #define svc_setinfo 51 // setinfo on a client
  98. #define svc_serverinfo 52 // serverinfo
  99. #define svc_updatepl 53 // [byte] [byte]
  100. //==============================================
  101. //
  102. // client to server
  103. //
  104. #define clc_bad 0
  105. #define clc_nop 1
  106. //define clc_doublemove 2
  107. #define clc_move 3 // [[usercmd_t]
  108. #define clc_stringcmd 4 // [string] message
  109. #define clc_delta 5 // [byte] sequence number, requests delta compression of message
  110. #define clc_tmove 6 // teleport request, spectator only
  111. #define clc_upload 7 // teleport request, spectator only
  112. //==============================================
  113. // playerinfo flags from server
  114. // playerinfo allways sends: playernum, flags, origin[] and framenumber
  115. #define PF_MSEC (1<<0)
  116. #define PF_COMMAND (1<<1)
  117. #define PF_VELOCITY1 (1<<2)
  118. #define PF_VELOCITY2 (1<<3)
  119. #define PF_VELOCITY3 (1<<4)
  120. #define PF_MODEL (1<<5)
  121. #define PF_SKINNUM (1<<6)
  122. #define PF_EFFECTS (1<<7)
  123. #define PF_WEAPONFRAME (1<<8) // only sent for view player
  124. #define PF_DEAD (1<<9) // don't block movement any more
  125. #define PF_GIB (1<<10) // offset the view height differently
  126. #define PF_NOGRAV (1<<11) // don't apply gravity for prediction
  127. //==============================================
  128. // if the high bit of the client to server byte is set, the low bits are
  129. // client move cmd bits
  130. // ms and angle2 are allways sent, the others are optional
  131. #define CM_ANGLE1 (1<<0)
  132. #define CM_ANGLE3 (1<<1)
  133. #define CM_FORWARD (1<<2)
  134. #define CM_SIDE (1<<3)
  135. #define CM_UP (1<<4)
  136. #define CM_BUTTONS (1<<5)
  137. #define CM_IMPULSE (1<<6)
  138. #define CM_ANGLE2 (1<<7)
  139. //==============================================
  140. // the first 16 bits of a packetentities update holds 9 bits
  141. // of entity number and 7 bits of flags
  142. #define U_ORIGIN1 (1<<9)
  143. #define U_ORIGIN2 (1<<10)
  144. #define U_ORIGIN3 (1<<11)
  145. #define U_ANGLE2 (1<<12)
  146. #define U_FRAME (1<<13)
  147. #define U_REMOVE (1<<14) // REMOVE this entity, don't add it
  148. #define U_MOREBITS (1<<15)
  149. // if MOREBITS is set, these additional flags are read in next
  150. #define U_ANGLE1 (1<<0)
  151. #define U_ANGLE3 (1<<1)
  152. #define U_MODEL (1<<2)
  153. #define U_COLORMAP (1<<3)
  154. #define U_SKIN (1<<4)
  155. #define U_EFFECTS (1<<5)
  156. #define U_SOLID (1<<6) // the entity should be solid for prediction
  157. //==============================================
  158. // a sound with no channel is a local only sound
  159. // the sound field has bits 0-2: channel, 3-12: entity
  160. #define SND_VOLUME (1<<15) // a byte
  161. #define SND_ATTENUATION (1<<14) // a byte
  162. #define DEFAULT_SOUND_PACKET_VOLUME 255
  163. #define DEFAULT_SOUND_PACKET_ATTENUATION 1.0
  164. // svc_print messages have an id, so messages can be filtered
  165. #define PRINT_LOW 0
  166. #define PRINT_MEDIUM 1
  167. #define PRINT_HIGH 2
  168. #define PRINT_CHAT 3 // also go to chat buffer
  169. //
  170. // temp entity events
  171. //
  172. #define TE_SPIKE 0
  173. #define TE_SUPERSPIKE 1
  174. #define TE_GUNSHOT 2
  175. #define TE_EXPLOSION 3
  176. #define TE_TAREXPLOSION 4
  177. #define TE_LIGHTNING1 5
  178. #define TE_LIGHTNING2 6
  179. #define TE_WIZSPIKE 7
  180. #define TE_KNIGHTSPIKE 8
  181. #define TE_LIGHTNING3 9
  182. #define TE_LAVASPLASH 10
  183. #define TE_TELEPORT 11
  184. #define TE_BLOOD 12
  185. #define TE_LIGHTNINGBLOOD 13
  186. /*
  187. ==========================================================
  188. ELEMENTS COMMUNICATED ACROSS THE NET
  189. ==========================================================
  190. */
  191. #define MAX_CLIENTS 32
  192. #define UPDATE_BACKUP 64 // copies of entity_state_t to keep buffered
  193. // must be power of two
  194. #define UPDATE_MASK (UPDATE_BACKUP-1)
  195. // entity_state_t is the information conveyed from the server
  196. // in an update message
  197. typedef struct
  198. {
  199. int number; // edict index
  200. int flags; // nolerp, etc
  201. vec3_t origin;
  202. vec3_t angles;
  203. int modelindex;
  204. int frame;
  205. int colormap;
  206. int skinnum;
  207. int effects;
  208. } entity_state_t;
  209. #define MAX_PACKET_ENTITIES 64 // doesn't count nails
  210. typedef struct
  211. {
  212. int num_entities;
  213. entity_state_t entities[MAX_PACKET_ENTITIES];
  214. } packet_entities_t;
  215. typedef struct usercmd_s
  216. {
  217. byte msec;
  218. vec3_t angles;
  219. short forwardmove, sidemove, upmove;
  220. byte buttons;
  221. byte impulse;
  222. } usercmd_t;