1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 */
20
21 #ifndef PROTOCOL_H
22 #define PROTOCOL_H
23
24 // protocol.h -- communications protocols
25
26 #include "qtypes.h"
27
28 #define PROTOCOL_VERSION_NQ 15
29 #define PROTOCOL_VERSION_FITZ 666
30 #define PROTOCOL_VERSION_BJP 10000
31 #define PROTOCOL_VERSION_BJP2 10001
32 #define PROTOCOL_VERSION_BJP3 10002
33
34 static INLINE qboolean
Protocol_Known(int version)35 Protocol_Known(int version)
36 {
37 switch (version) {
38 case PROTOCOL_VERSION_NQ:
39 case PROTOCOL_VERSION_FITZ:
40 case PROTOCOL_VERSION_BJP:
41 case PROTOCOL_VERSION_BJP2:
42 case PROTOCOL_VERSION_BJP3:
43 return true;
44 default:
45 return false;
46 }
47 }
48
49 static INLINE int
max_models(int protocol)50 max_models(int protocol)
51 {
52 switch (protocol) {
53 case PROTOCOL_VERSION_NQ:
54 return qmin(256, MAX_MODELS);
55 case PROTOCOL_VERSION_BJP:
56 case PROTOCOL_VERSION_BJP2:
57 case PROTOCOL_VERSION_BJP3:
58 case PROTOCOL_VERSION_FITZ:
59 return qmin(65536, MAX_MODELS);
60 default:
61 return 0;
62 }
63 }
64
65 static INLINE int
max_sounds_static(int protocol)66 max_sounds_static(int protocol)
67 {
68 switch (protocol) {
69 case PROTOCOL_VERSION_NQ:
70 case PROTOCOL_VERSION_BJP:
71 case PROTOCOL_VERSION_BJP3:
72 return qmin(256, MAX_SOUNDS);
73 case PROTOCOL_VERSION_BJP2:
74 case PROTOCOL_VERSION_FITZ:
75 return qmin(65536, MAX_SOUNDS);
76 default:
77 return 0;
78 }
79 }
80
81 static INLINE int
max_sounds_dynamic(int protocol)82 max_sounds_dynamic(int protocol)
83 {
84 switch (protocol) {
85 case PROTOCOL_VERSION_NQ:
86 case PROTOCOL_VERSION_BJP:
87 return qmin(256, MAX_SOUNDS);
88 case PROTOCOL_VERSION_BJP2:
89 case PROTOCOL_VERSION_BJP3:
90 case PROTOCOL_VERSION_FITZ:
91 return qmin(65536, MAX_SOUNDS);
92 default:
93 return 0;
94 }
95 }
96
97 static INLINE int
max_sounds(int p)98 max_sounds(int p)
99 {
100 return qmax(max_sounds_dynamic(p), max_sounds_static(p));
101 }
102
103 // if the high bit of the servercmd is set, the low bits are fast update flags:
104 #define U_MOREBITS (1<<0)
105 #define U_ORIGIN1 (1<<1)
106 #define U_ORIGIN2 (1<<2)
107 #define U_ORIGIN3 (1<<3)
108 #define U_ANGLE2 (1<<4)
109 #define U_NOLERP (1<<5) // don't interpolate movement
110 #define U_FRAME (1<<6)
111 #define U_SIGNAL (1<<7) // just differentiates from other updates
112
113 // svc_update can pass all of the fast update bits, plus more
114 #define U_ANGLE1 (1<<8)
115 #define U_ANGLE3 (1<<9)
116 #define U_MODEL (1<<10)
117 #define U_COLORMAP (1<<11)
118 #define U_SKIN (1<<12)
119 #define U_EFFECTS (1<<13)
120 #define U_LONGENTITY (1<<14)
121
122 // Extra FITZ bits
123 #define U_FITZ_EXTEND1 (1<<15)
124 #define U_FITZ_ALPHA (1<<16) // alpha byte follows
125 #define U_FITZ_FRAME2 (1<<17) // byte for frame high bits follows
126 #define U_FITZ_MODEL2 (1<<18) // byte for model high bits follows
127 #define U_FITZ_LERPFINISH (1<<19)
128 #define U_FITZ_EXTEND2 (1<<23)
129
130 #define SU_VIEWHEIGHT (1<<0)
131 #define SU_IDEALPITCH (1<<1)
132 #define SU_PUNCH1 (1<<2)
133 #define SU_PUNCH2 (1<<3)
134 #define SU_PUNCH3 (1<<4)
135 #define SU_VELOCITY1 (1<<5)
136 #define SU_VELOCITY2 (1<<6)
137 #define SU_VELOCITY3 (1<<7)
138 //define SU_AIMENT (1<<8) AVAILABLE BIT
139 #define SU_ITEMS (1<<9)
140 #define SU_ONGROUND (1<<10) // no data follows, the bit is it
141 #define SU_INWATER (1<<11) // no data follows, the bit is it
142 #define SU_WEAPONFRAME (1<<12)
143 #define SU_ARMOR (1<<13)
144 #define SU_WEAPON (1<<14)
145
146 // Extra FITZ bits
147 #define SU_FITZ_EXTEND1 (1<<15)
148 #define SU_FITZ_WEAPON2 (1<<16)
149 #define SU_FITZ_ARMOR2 (1<<17)
150 #define SU_FITZ_AMMO2 (1<<18)
151 #define SU_FITZ_SHELLS2 (1<<19)
152 #define SU_FITZ_NAILS2 (1<<20)
153 #define SU_FITZ_ROCKETS2 (1<<21)
154 #define SU_FITZ_CELLS2 (1<<22)
155 #define SU_FITZ_EXTEND2 (1<<23)
156 #define SU_FITZ_WEAPONFRAME2 (1<<24)
157 #define SU_FITZ_WEAPONALPHA (1<<25)
158 #define SU_FITZ_EXTEND3 (1<<31)
159
160 // a sound with no channel is a local only sound
161 #define SND_VOLUME (1<<0) // a byte
162 #define SND_ATTENUATION (1<<1) // a byte
163 #define SND_LOOPING (1<<2) // a long
164 // Extra bits for FITZ protocol
165 #define SND_FITZ_LARGEENTITY (1<<3) // a short + byte (instead of just a short)
166 #define SND_FITZ_LARGESOUND (1<<4) // a short soundindex (instead of a byte)
167
168 // extra FITZ model flags
169 #define B_FITZ_LARGEMODEL (1<<0)
170 #define B_FITZ_LARGEFRAME (1<<1)
171 #define B_FITZ_ALPHA (1<<2)
172
173 // defaults for clientinfo messages
174 #define DEFAULT_VIEWHEIGHT 22
175
176
177 // game types sent by serverinfo
178 // these determine which intermission screen plays
179 #define GAME_COOP 0
180 #define GAME_DEATHMATCH 1
181
182 //==================
183 // note that there are some defs.qc that mirror to these numbers
184 // also related to svc_strings[] in cl_parse
185 //==================
186
187 //
188 // server to client
189 //
190 #define svc_bad 0
191 #define svc_nop 1
192 #define svc_disconnect 2
193 #define svc_updatestat 3 // [byte] [long]
194 #define svc_version 4 // [long] server version
195 #define svc_setview 5 // [short] entity number
196 #define svc_sound 6 // <see code>
197 #define svc_time 7 // [float] server time
198 #define svc_print 8 // [string] null terminated string
199 #define svc_stufftext 9 // [string] stuffed into client's console buffer
200 // the string should be \n terminated
201 #define svc_setangle 10 // [angle3] set the view angle to this absolute value
202
203 #define svc_serverinfo 11 // [long] version
204 // [string] signon string
205 // [string]..[0]model cache
206 // [string]...[0]sounds cache
207 #define svc_lightstyle 12 // [byte] [string]
208 #define svc_updatename 13 // [byte] [string]
209 #define svc_updatefrags 14 // [byte] [short]
210 #define svc_clientdata 15 // <shortbits + data>
211 #define svc_stopsound 16 // <see code>
212 #define svc_updatecolors 17 // [byte] [byte]
213 #define svc_particle 18 // [vec3] <variable>
214 #define svc_damage 19
215
216 #define svc_spawnstatic 20
217 // svc_spawnbinary 21
218 #define svc_spawnbaseline 22
219
220 #define svc_temp_entity 23
221
222 #define svc_setpause 24 // [byte] on / off
223 #define svc_signonnum 25 // [byte] used for the signon sequence
224
225 #define svc_centerprint 26 // [string] to put in center of the screen
226
227 #define svc_killedmonster 27
228 #define svc_foundsecret 28
229
230 #define svc_spawnstaticsound 29 // [coord3] [byte] samp [byte] vol [byte] aten
231
232 #define svc_intermission 30 // [string] music
233 #define svc_finale 31 // [string] music [string] text
234
235 #define svc_cdtrack 32 // [byte] track [byte] looptrack
236 #define svc_sellscreen 33
237
238 #define svc_cutscene 34
239
240 // FITZ protocol messages
241 #define svc_fitz_skybox 37
242 #define svc_fitz_bf 40
243 #define svc_fitz_fog 41
244 #define svc_fitz_spawnbaseline2 42
245 #define svc_fitz_spawnstatic2 43
246 #define svc_fitz_spawnstaticsound2 44
247
248 //
249 // client to server
250 //
251 #define clc_bad 0
252 #define clc_nop 1
253 #define clc_disconnect 2
254 #define clc_move 3 // [usercmd_t]
255 #define clc_stringcmd 4 // [string] message
256
257
258 //
259 // temp entity events
260 //
261 #define TE_SPIKE 0
262 #define TE_SUPERSPIKE 1
263 #define TE_GUNSHOT 2
264 #define TE_EXPLOSION 3
265 #define TE_TAREXPLOSION 4
266 #define TE_LIGHTNING1 5
267 #define TE_LIGHTNING2 6
268 #define TE_WIZSPIKE 7
269 #define TE_KNIGHTSPIKE 8
270 #define TE_LIGHTNING3 9
271 #define TE_LAVASPLASH 10
272 #define TE_TELEPORT 11
273 #define TE_EXPLOSION2 12
274
275 // PGM 01/21/97
276 #define TE_BEAM 13
277 // PGM 01/21/97
278
279 // FIXME - use this properly...
280 #define MAX_CLIENTS 16
281
282 #endif /* PROTOCOL_H */
283