1 /* 2 Copyright (C) 1996-2001 Id Software, Inc. 3 Copyright (C) 2002-2009 John Fitzgibbons and others 4 Copyright (C) 2010-2014 QuakeSpasm developers 5 6 This program is free software; you can redistribute it and/or 7 modify it under the terms of the GNU General Public License 8 as published by the Free Software Foundation; either version 2 9 of the License, or (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 15 See the GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 21 */ 22 23 #ifndef _QUAKE_PROTOCOL_H 24 #define _QUAKE_PROTOCOL_H 25 26 // protocol.h -- communications protocols 27 28 #define PROTOCOL_NETQUAKE 15 //johnfitz -- standard quake protocol 29 #define PROTOCOL_FITZQUAKE 666 //johnfitz -- added new protocol for fitzquake 0.85 30 #define PROTOCOL_RMQ 999 31 #define PROTOCOL_FTE_PEXT1 (('F'<<0) + ('T'<<8) + ('E'<<16) + ('X' << 24)) //fte extensions, provides extensions to the underlying base protocol (like 666 or even 15). 32 #define PROTOCOL_FTE_PEXT2 (('F'<<0) + ('T'<<8) + ('E'<<16) + ('2' << 24)) //fte extensions, provides extensions to the underlying base protocol (like 666 or even 15). 33 34 // PROTOCOL_RMQ protocol flags 35 #define PRFL_SHORTANGLE (1 << 1) 36 #define PRFL_FLOATANGLE (1 << 2) 37 #define PRFL_24BITCOORD (1 << 3) 38 #define PRFL_FLOATCOORD (1 << 4) 39 #define PRFL_EDICTSCALE (1 << 5) 40 #define PRFL_ALPHASANITY (1 << 6) // cleanup insanity with alpha 41 #define PRFL_INT32COORD (1 << 7) 42 #define PRFL_MOREFLAGS (1 << 31) // not supported 43 // PROTOCOL_FTE_PEXT1 flags 44 #define PEXT1_CSQC 0x40000000 //(full)csqc additions, required for csqc ents+events. 45 #define PEXT1_SUPPORTED_CLIENT (PEXT1_CSQC) //pext1 flags that we advertise to servers (aka: full support) 46 #define PEXT1_SUPPORTED_SERVER (PEXT1_CSQC) //pext1 flags that we accept from clients. 47 #define PEXT1_ACCEPTED_CLIENT (PEXT1_SUPPORTED_CLIENT) 48 // PROTOCOL_FTE_PEXT2 flags 49 #define PEXT2_REPLACEMENTDELTAS 0x00000008 //more compact entity deltas (can also be split across multiple packets) 50 #define PEXT2_PREDINFO 0x00000020 //provides input acks and reworks stats such that clc_clientdata becomes redundant. 51 #define PEXT2_SUPPORTED_CLIENT (PEXT2_REPLACEMENTDELTAS|PEXT2_PREDINFO) //pext2 flags that we understand+support 52 #define PEXT2_SUPPORTED_SERVER (PEXT2_REPLACEMENTDELTAS|PEXT2_PREDINFO) 53 #define PEXT2_ACCEPTED_CLIENT (PEXT2_SUPPORTED_CLIENT) //pext2 flags that we can parse, but don't want to advertise 54 55 // if the high bit of the servercmd is set, the low bits are fast update flags: 56 #define U_MOREBITS (1<<0) 57 #define U_ORIGIN1 (1<<1) 58 #define U_ORIGIN2 (1<<2) 59 #define U_ORIGIN3 (1<<3) 60 #define U_ANGLE2 (1<<4) 61 #define U_STEP (1<<5) //johnfitz -- was U_NOLERP, renamed since it's only used for MOVETYPE_STEP 62 #define U_FRAME (1<<6) 63 #define U_SIGNAL (1<<7) // just differentiates from other updates 64 65 // svc_update can pass all of the fast update bits, plus more 66 #define U_ANGLE1 (1<<8) 67 #define U_ANGLE3 (1<<9) 68 #define U_MODEL (1<<10) 69 #define U_COLORMAP (1<<11) 70 #define U_SKIN (1<<12) 71 #define U_EFFECTS (1<<13) 72 #define U_LONGENTITY (1<<14) 73 //johnfitz -- PROTOCOL_FITZQUAKE -- new bits 74 #define U_EXTEND1 (1<<15) 75 #define U_ALPHA (1<<16) // 1 byte, uses ENTALPHA_ENCODE, not sent if equal to baseline 76 #define U_FRAME2 (1<<17) // 1 byte, this is .frame & 0xFF00 (second byte) 77 #define U_MODEL2 (1<<18) // 1 byte, this is .modelindex & 0xFF00 (second byte) 78 #define U_LERPFINISH (1<<19) // 1 byte, 0.0-1.0 maps to 0-255, not sent if exactly 0.1, this is ent->v.nextthink - sv.time, used for lerping 79 #define U_SCALE (1<<20) // 1 byte, for PROTOCOL_RMQ PRFL_EDICTSCALE, currently read but ignored 80 #define U_UNUSED21 (1<<21) 81 #define U_UNUSED22 (1<<22) 82 #define U_EXTEND2 (1<<23) // another byte to follow, future expansion 83 //johnfitz 84 85 //johnfitz -- PROTOCOL_NEHAHRA transparency 86 #define U_TRANS (1<<15) 87 //johnfitz 88 89 //spike -- FTE Replacement Deltas 90 //first byte contains the stuff that's most likely to change constantly 91 #define UF_FRAME (1u<<0) 92 #define UF_ORIGINXY (1u<<1) 93 #define UF_ORIGINZ (1u<<2) 94 #define UF_ANGLESXZ (1u<<3) 95 #define UF_ANGLESY (1u<<4) 96 #define UF_EFFECTS (1u<<5) 97 #define UF_PREDINFO (1u<<6) /*ent is predicted, probably a player*/ 98 #define UF_EXTEND1 (1u<<7) 99 100 /*stuff which is common on ent spawning*/ 101 #define UF_RESET (1u<<8) 102 #define UF_16BIT (1u<<9) /*within this update, frame/skin/model is 16bit, not part of the deltaing itself*/ 103 #define UF_MODEL (1u<<10) 104 #define UF_SKIN (1u<<11) 105 #define UF_COLORMAP (1u<<12) 106 #define UF_SOLID (1u<<13) /*encodes the size of the entity, so prediction can bump against it*/ 107 #define UF_FLAGS (1u<<14) /*some extra flags like viewmodelforclient*/ 108 #define UF_EXTEND2 (1u<<15) 109 110 /*the rest is optional extensions*/ 111 #define UF_ALPHA (1u<<16) /*transparency*/ 112 #define UF_SCALE (1u<<17) /*rescaling stuff, 1/16th*/ 113 #define UF_BONEDATA (1u<<18) /*for ssqc control over skeletal models*/ 114 #define UF_DRAWFLAGS (1u<<19) /*scale offsets and things*/ 115 #define UF_TAGINFO (1u<<20) /*simple entity attachments, generally needs either md3s or skeletal models*/ 116 #define UF_LIGHT (1u<<21) /*attaching rtlights to dynamic entities from ssqc*/ 117 #define UF_TRAILEFFECT (1u<<22) /*attaches custom particle trails to entities, woo.*/ 118 #define UF_EXTEND3 (1u<<23) 119 120 #define UF_COLORMOD (1u<<24) /*rgb tints. 1/16th*/ 121 #define UF_GLOW (1u<<25) /*tbh only useful as an extra 'renderable' field for csqc...*/ 122 #define UF_FATNESS (1u<<26) /*push the entity's normals out by this distance*/ 123 #define UF_MODELINDEX2 (1u<<27) /*for lame visible weapon models, like q2. just adds a second ent at the same point*/ 124 #define UF_GRAVITYDIR (1u<<28) /*yay prediction*/ 125 #define UF_EFFECTS2 (1u<<29) /*effects is 16bit, or if both effects flags are set then 32bit*/ 126 #define UF_UNUSED2 (1u<<30) 127 #define UF_UNUSED1 (1u<<31) 128 129 /*these flags are generally not deltaed as they're changing constantly*/ 130 #define UFP_FORWARD (1u<<0) 131 #define UFP_SIDE (1u<<1) 132 #define UFP_UP (1u<<2) 133 #define UFP_MOVETYPE (1u<<3) /*deltaed*/ 134 #define UFP_VELOCITYXY (1u<<4) 135 #define UFP_VELOCITYZ (1u<<5) 136 #define UFP_MSEC (1u<<6) 137 #define UFP_WEAPONFRAME_OLD (1u<<7) //no longer used. just a stat now that I rewrote stat deltas. 138 #define UFP_VIEWANGLE (1u<<7) 139 //spike 140 141 #define SU_VIEWHEIGHT (1<<0) 142 #define SU_IDEALPITCH (1<<1) 143 #define SU_PUNCH1 (1<<2) 144 #define SU_PUNCH2 (1<<3) 145 #define SU_PUNCH3 (1<<4) 146 #define SU_VELOCITY1 (1<<5) 147 #define SU_VELOCITY2 (1<<6) 148 #define SU_VELOCITY3 (1<<7) 149 #define SU_UNUSED8 (1<<8) //AVAILABLE BIT 150 #define SU_ITEMS (1<<9) 151 #define SU_ONGROUND (1<<10) // no data follows, the bit is it 152 #define SU_INWATER (1<<11) // no data follows, the bit is it 153 #define SU_WEAPONFRAME (1<<12) 154 #define SU_ARMOR (1<<13) 155 #define SU_WEAPON (1<<14) 156 //johnfitz -- PROTOCOL_FITZQUAKE -- new bits 157 #define SU_EXTEND1 (1<<15) // another byte to follow 158 #define SU_WEAPON2 (1<<16) // 1 byte, this is .weaponmodel & 0xFF00 (second byte) 159 #define SU_ARMOR2 (1<<17) // 1 byte, this is .armorvalue & 0xFF00 (second byte) 160 #define SU_AMMO2 (1<<18) // 1 byte, this is .currentammo & 0xFF00 (second byte) 161 #define SU_SHELLS2 (1<<19) // 1 byte, this is .ammo_shells & 0xFF00 (second byte) 162 #define SU_NAILS2 (1<<20) // 1 byte, this is .ammo_nails & 0xFF00 (second byte) 163 #define SU_ROCKETS2 (1<<21) // 1 byte, this is .ammo_rockets & 0xFF00 (second byte) 164 #define SU_CELLS2 (1<<22) // 1 byte, this is .ammo_cells & 0xFF00 (second byte) 165 #define SU_EXTEND2 (1<<23) // another byte to follow 166 #define SU_WEAPONFRAME2 (1<<24) // 1 byte, this is .weaponframe & 0xFF00 (second byte) 167 #define SU_WEAPONALPHA (1<<25) // 1 byte, this is alpha for weaponmodel, uses ENTALPHA_ENCODE, not sent if ENTALPHA_DEFAULT 168 #define SU_UNUSED26 (1<<26) 169 #define SU_UNUSED27 (1<<27) 170 #define SU_UNUSED28 (1<<28) 171 #define SU_UNUSED29 (1<<29) 172 #define SU_UNUSED30 (1<<30) 173 #define SU_EXTEND3 (1<<31) // another byte to follow, future expansion 174 //johnfitz 175 176 // a sound with no channel is a local only sound 177 #define SND_VOLUME (1<<0) // a byte 178 #define SND_ATTENUATION (1<<1) // a byte 179 #define SND_LOOPING (1<<2) // a long 180 181 #define DEFAULT_SOUND_PACKET_VOLUME 255 182 #define DEFAULT_SOUND_PACKET_ATTENUATION 1.0 183 184 //johnfitz -- PROTOCOL_FITZQUAKE -- new bits 185 #define SND_LARGEENTITY (1<<3) // a short + byte (instead of just a short) 186 #define SND_LARGESOUND (1<<4) // a short soundindex (instead of a byte) 187 //johnfitz 188 //spike -- parsing, but not using at this time 189 #define SND_FTE_MOREFLAGS (1<<2) // a byte, for channel flags 190 #define SND_DP_PITCH (1<<5) //dp uses this for pitch... 191 #define SND_FTE_TIMEOFS (1<<6) //signed short, in milliseconds. 192 #define SND_FTE_PITCHADJ (1<<7) //a byte (speed percent (0=100%)) 193 #define SND_FTE_VELOCITY (1<<8) //3 shorts (1/8th), for doppler or whatever. 194 //spike 195 196 //johnfitz -- PROTOCOL_FITZQUAKE -- flags for entity baseline messages 197 #define B_LARGEMODEL (1<<0) // modelindex is short instead of byte 198 #define B_LARGEFRAME (1<<1) // frame is short instead of byte 199 #define B_ALPHA (1<<2) // 1 byte, uses ENTALPHA_ENCODE, not sent if ENTALPHA_DEFAULT 200 //johnfitz 201 202 //johnfitz -- PROTOCOL_FITZQUAKE -- alpha encoding 203 #define ENTALPHA_DEFAULT 0 //entity's alpha is "default" (i.e. water obeys r_wateralpha) -- must be zero so zeroed out memory works 204 #define ENTALPHA_ZERO 1 //entity is invisible (lowest possible alpha) 205 #define ENTALPHA_ONE 255 //entity is fully opaque (highest possible alpha) 206 #define ENTALPHA_ENCODE(a) (((a)==0)?ENTALPHA_DEFAULT:Q_rint(CLAMP(1,(a)*254.0f+1,255))) //server convert to byte to send to client 207 #define ENTALPHA_DECODE(a) (((a)==ENTALPHA_DEFAULT)?1.0f:((float)(a)-1)/(254)) //client convert to float for rendering 208 #define ENTALPHA_TOSAVE(a) (((a)==ENTALPHA_DEFAULT)?0.0f:(((a)==ENTALPHA_ZERO)?-1.0f:((float)(a)-1)/(254))) //server convert to float for savegame 209 //johnfitz 210 211 // defaults for clientinfo messages 212 #define DEFAULT_VIEWHEIGHT 22 213 214 // game types sent by serverinfo 215 // these determine which intermission screen plays 216 #define GAME_COOP 0 217 #define GAME_DEATHMATCH 1 218 219 //================== 220 // note that there are some defs.qc that mirror to these numbers 221 // also related to svc_strings[] in cl_parse 222 //================== 223 224 //used by the 2021 rerelease 225 //Note: same value as svcdp_effect! 226 #define svc_achievement 52 // [string] id 227 228 // 229 // server to client 230 // 231 #define svc_bad 0 232 #define svc_nop 1 233 #define svc_disconnect 2 234 #define svc_updatestat 3 // [byte] [long] 235 #define svc_version 4 // [long] server version 236 #define svc_setview 5 // [short] entity number 237 #define svc_sound 6 // <see code> 238 #define svc_time 7 // [float] server time 239 #define svc_print 8 // [string] null terminated string 240 #define svc_stufftext 9 // [string] stuffed into client's console buffer 241 // the string should be \n terminated 242 #define svc_setangle 10 // [angle3] set the view angle to this absolute value 243 #define svc_serverinfo 11 // [long] version 244 // [string] signon string 245 // [string]..[0]model cache 246 // [string]...[0]sounds cache 247 #define svc_lightstyle 12 // [byte] [string] 248 #define svc_updatename 13 // [byte] [string] 249 #define svc_updatefrags 14 // [byte] [short] 250 #define svc_clientdata 15 // <shortbits + data> 251 #define svc_stopsound 16 // <see code> 252 #define svc_updatecolors 17 // [byte] [byte] 253 #define svc_particle 18 // [vec3] <variable> 254 #define svc_damage 19 255 #define svc_spawnstatic 20 256 //#define svc_spawnbinary 21 257 #define svcfte_spawnstatic2 21 258 #define svc_spawnbaseline 22 259 #define svc_temp_entity 23 260 #define svc_setpause 24 // [byte] on / off 261 #define svc_signonnum 25 // [byte] used for the signon sequence 262 #define svc_centerprint 26 // [string] to put in center of the screen 263 #define svc_killedmonster 27 264 #define svc_foundsecret 28 265 #define svc_spawnstaticsound 29 // [coord3] [byte] samp [byte] vol [byte] aten 266 #define svc_intermission 30 // [string] music 267 #define svc_finale 31 // [string] music [string] text 268 #define svc_cdtrack 32 // [byte] track [byte] looptrack 269 #define svc_sellscreen 33 270 #define svc_cutscene 34 271 272 //johnfitz -- PROTOCOL_FITZQUAKE -- new server messages 273 #define svc_skybox 37 // [string] name 274 #define svc_bf 40 275 #define svc_fog 41 // [byte] density [byte] red [byte] green [byte] blue [float] time 276 #define svc_spawnbaseline2 42 // support for large modelindex, large framenum, alpha, using flags 277 #define svc_spawnstatic2 43 // support for large modelindex, large framenum, alpha, using flags 278 #define svc_spawnstaticsound2 44 // [coord3] [short] samp [byte] vol [byte] aten 279 //johnfitz 280 281 //spike -- some extensions for particles. 282 //some extra stuff for fte's pext2_replacementdeltas, including stats 283 //fte reuses the dp svcs for nq (instead of qw-specific ones), at least where the protocol is identical. this should make dpp7 support a little easier if you ever want to implement that. 284 //dp has a tendancy to use the svcs even when told to use protocol 15, so supporting them helps there too. 285 #define svcdp_downloaddata 50 286 #define svcdp_updatestatbyte 51 287 #define svcdp_effect 52 // [vector] org [byte] modelindex [byte] startframe [byte] framecount [byte] framerate 288 #define svcdp_effect2 53 // [vector] org [short] modelindex [short] startframe [byte] framecount [byte] framerate 289 #define svcdp_precache 54 // [short] precacheindex [string] filename. index&0x8000 = sound, 0x4000 = particle, 0xc000 = reserved (probably to reclaim these bits eventually), otherwise model. 290 #define svcdp_spawnbaseline2 55 291 #define svcdp_spawnstatic2 56 292 #define svcdp_entities 57 293 #define svcdp_csqcentities 58 294 #define svcdp_spawnstaticsound2 59 // [coord3] [short] samp [byte] vol [byte] aten 295 #define svcdp_trailparticles 60 // [short] entnum [short] effectnum [vector] start [vector] end 296 #define svcdp_pointparticles 61 // [short] effectnum [vector] start [vector] velocity [short] count 297 #define svcdp_pointparticles1 62 // [short] effectnum [vector] start, same as svc_pointparticles except velocity is zero and count is 1 298 #define svcfte_spawnbaseline2 66 299 #define svcfte_updatestatstring 78 300 #define svcfte_updatestatfloat 79 301 #define svcfte_cgamepacket 83 302 #define svcfte_voicechat 84 303 #define svcfte_setangledelta 85 304 #define svcfte_updateentities 86 305 //spike -- end 306 307 // 308 // client to server 309 // 310 #define clc_bad 0 311 #define clc_nop 1 312 #define clc_disconnect 2 313 #define clc_move 3 // [usercmd_t] 314 #define clc_stringcmd 4 // [string] message 315 #define clcdp_ackframe 50 // [long] frame sequence. reused by fte replacement deltas 316 // 317 // temp entity events 318 // 319 #define TE_SPIKE 0 320 #define TE_SUPERSPIKE 1 321 #define TE_GUNSHOT 2 322 #define TE_EXPLOSION 3 323 #define TE_TAREXPLOSION 4 324 #define TE_LIGHTNING1 5 325 #define TE_LIGHTNING2 6 326 #define TE_WIZSPIKE 7 327 #define TE_KNIGHTSPIKE 8 328 #define TE_LIGHTNING3 9 329 #define TE_LAVASPLASH 10 330 #define TE_TELEPORT 11 331 #define TE_EXPLOSION2 12 332 333 // PGM 01/21/97 334 #define TE_BEAM 13 335 // PGM 01/21/97 336 337 #define TEDP_PARTICLERAIN 55 // [vector] min [vector] max [vector] dir [short] count [byte] color 338 #define TEDP_PARTICLESNOW 56 // [vector] min [vector] max [vector] dir [short] count [byte] color 339 340 typedef struct entity_state_s 341 { 342 vec3_t origin; 343 vec3_t angles; 344 unsigned short modelindex; //johnfitz -- was int 345 unsigned short frame; //johnfitz -- was int 346 unsigned int effects; 347 unsigned char colormap; //johnfitz -- was int 348 unsigned char skin; //johnfitz -- was int 349 unsigned char scale; //spike -- *16 350 unsigned char pmovetype; //spike 351 unsigned short traileffectnum; //spike -- for qc-defined particle trails. typically evilly used for things that are not trails. 352 unsigned short emiteffectnum; //spike -- for qc-defined particle trails. typically evilly used for things that are not trails. 353 short velocity[3]; //spike -- the player's velocity. 354 unsigned char eflags; 355 unsigned char tagindex; 356 unsigned short tagentity; 357 unsigned short pad; 358 unsigned char colormod[3]; //spike -- entity tints, *32 359 unsigned char alpha; //johnfitz -- added 360 unsigned int solidsize; //for csqc prediction logic. 361 #define ES_SOLID_NOT 0 362 #define ES_SOLID_BSP 31 363 #define ES_SOLID_HULL1 0x80201810 364 #define ES_SOLID_HULL2 0x80401820 365 } entity_state_t; 366 #define EFLAGS_STEP 1 367 //#define EFLAGS_GLOWTRAIL 2 368 #define EFLAGS_VIEWMODEL 4 //does not appear in reflections/third person. attached to the view. 369 #define EFLAGS_EXTERIORMODEL 8 //only appears in reflections/third person 370 //#define EFLAGS_ 16 371 #define EFLAGS_COLOURMAPPED 32 //.colormap=1024|(top<<4)|bottom), instead of a player number 372 //#define EFLAGS_ 64 373 #define EFLAGS_ONGROUND 128 //for bobbing more than anything else. *sigh*. 374 375 extern entity_state_t nullentitystate; //note: not all null. 376 377 typedef struct 378 { 379 float servertime; 380 float seconds; //servertime-previous->servertime 381 vec3_t viewangles; 382 383 // intended velocities 384 float forwardmove; 385 float sidemove; 386 float upmove; 387 388 unsigned int buttons; 389 unsigned int impulse; 390 391 unsigned int sequence; 392 393 int weapon; 394 } usercmd_t; 395 396 #endif /* _QUAKE_PROTOCOL_H */ 397 398