1 /*
2  * protocol.h -- communications protocols
3  * $Id: protocol.h,v 1.15 2008-01-26 20:02:07 sezero Exp $
4  *
5  * Copyright (C) 1996-1997  Id Software, Inc.
6  * Copyright (C) 1997-1998  Raven Software Corp.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or (at
11  * your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22  */
23 
24 #ifndef __HX2_PROTOCOL_H
25 #define __HX2_PROTOCOL_H
26 
27 #define	PROTOCOL_RAVEN_107		15	/* cd version, aka 1.03 (not supported) */
28 #define	PROTOCOL_RAVEN_109		17	/* official 1.09 update (not supported) */
29 #define	PROTOCOL_RAVEN_111		18	/* official 1.11 update */
30 #define	PROTOCOL_RAVEN_112		19	/* 1.12, mission pack */
31 #define	PROTOCOL_UQE_113		20	/* Korax UQE patch 1.13 */
32 /* the default protocol: */
33 #define	PROTOCOL_VERSION		(PROTOCOL_RAVEN_112)
34 
35 //=========================================
36 
37 //==================
38 // note that constant.hc may mirror to some of these numbers
39 // also related to svc_strings[] in cl_parse
40 //==================
41 
42 //
43 // server to client
44 //
45 #define	svc_bad			0
46 #define	svc_nop			1
47 #define	svc_disconnect		2
48 #define	svc_updatestat		3	// [byte] [long]
49 #define	svc_version		4	// [long] server version
50 #define	svc_setview		5	// [short] entity number
51 #define	svc_sound		6	// <see code>
52 #define	svc_time		7	// [float] server time
53 #define	svc_print		8	// [string] null terminated string
54 #define	svc_stufftext		9	// [string] stuffed into client's console buffer
55 					// the string should be \n terminated
56 
57 #define	svc_setangle		10	// [angle3] set the view angle to this absolute value
58 
59 #define	svc_serverinfo		11	// [long] version
60 					// [string] signon string
61 					// [string]..[0]model cache
62 					// [string]...[0]sounds cache
63 
64 #define	svc_lightstyle		12	// [byte] [string]
65 #define	svc_updatename		13	// [byte] [string]
66 #define	svc_updatefrags		14	// [byte] [short]
67 #define	svc_clientdata		15	// <shortbits + data>
68 #define	svc_stopsound		16	// <see code>
69 #define	svc_updatecolors	17	// [byte] [byte]
70 #define	svc_particle		18	// [vec3] <variable>
71 #define	svc_damage		19
72 #define	svc_spawnstatic		20
73 #define	svc_raineffect		21
74 #define	svc_spawnbaseline	22
75 #define	svc_temp_entity		23
76 #define	svc_setpause		24	// [byte] on / off
77 #define	svc_signonnum		25	// [byte]  used for the signon sequence
78 #define	svc_centerprint		26	// [string] to put in center of the screen
79 #define	svc_killedmonster	27
80 #define	svc_foundsecret		28
81 #define	svc_spawnstaticsound	29	// [coord3] [byte] samp [byte] vol [byte] aten
82 #define	svc_intermission	30	// [string] music
83 #define	svc_finale		31	// [string] music [string] text
84 #define	svc_cdtrack		32	// [byte] track [byte] looptrack
85 #define	svc_sellscreen		33
86 #define	svc_particle2		34	// [vec3] <variable>
87 #define	svc_cutscene		35
88 #define	svc_midi_name		36	// [string] name
89 #define	svc_updateclass		37	// [byte] [byte]
90 #define	svc_particle3		38
91 #define	svc_particle4		39
92 #define	svc_set_view_flags	40
93 #define	svc_clear_view_flags	41
94 #define	svc_start_effect	42
95 #define	svc_end_effect		43
96 #define	svc_plaque		44
97 #define	svc_particle_explosion	45
98 #define	svc_set_view_tint	46
99 #define	svc_reference		47
100 #define	svc_clear_edicts	48
101 #define	svc_update_inv		49
102 
103 #define	svc_setangle_interpolate	50
104 #define	svc_update_kingofhill	51
105 #define	svc_toggle_statbar	52
106 #define	svc_sound_update_pos	53	// [short] ent+channel [coord3] pos
107 #define	svc_mod_name		54	// [string] name (UQE v1.13 by Korax, music file name)
108 #define	svc_skybox		55	// [string] name (UQE v1.13 by Korax, skybox name)
109 
110 //==============================================
111 
112 //
113 // client to server
114 //
115 #define	clc_bad			0
116 #define	clc_nop 		1
117 #define	clc_disconnect		2
118 #define	clc_move		3	// [usercmd_t]
119 #define	clc_stringcmd		4	// [string] message
120 #define	clc_inv_select		5
121 #define	clc_frame		6
122 
123 //==============================================
124 
125 // if the high bit of the servercmd is set, the low bits are fast update flags:
126 #define	U_MOREBITS	(1<<0)
127 #define	U_ORIGIN1	(1<<1)
128 #define	U_ORIGIN2	(1<<2)
129 #define	U_ORIGIN3	(1<<3)
130 #define	U_ANGLE2	(1<<4)
131 #define	U_NOLERP	(1<<5)		// don't interpolate movement
132 #define	U_FRAME		(1<<6)
133 #define	U_SIGNAL	(1<<7)		// just differentiates from other updates
134 
135 // svc_update can pass all of the fast update bits, plus more
136 #define	U_ANGLE1	(1<<8)
137 #define	U_ANGLE3	(1<<9)
138 #define	U_MODEL		(1<<10)
139 #define	U_CLEAR_ENT	(1<<11)
140 #define	U_ENT_OFF	(1<<13)
141 #define	U_LONGENTITY	(1<<14)
142 #define	U_MOREBITS2	(1<<15)
143 
144 #define	U_SKIN		(1<<16)
145 #define	U_EFFECTS	(1<<17)
146 #define	U_SCALE		(1<<18)
147 #define	U_COLORMAP	(1<<19)
148 
149 #define	BE_ON		(1<<0)
150 
151 #define	SU_VIEWHEIGHT	(1<<0)
152 #define	SU_IDEALPITCH	(1<<1)
153 #define	SU_PUNCH1	(1<<2)
154 #define	SU_PUNCH2	(1<<3)
155 #define	SU_PUNCH3	(1<<4)
156 #define	SU_VELOCITY1	(1<<5)
157 #define	SU_VELOCITY2	(1<<6)
158 #define	SU_VELOCITY3	(1<<7)
159 //define	SU_AIMENT	(1<<8)  AVAILABLE BIT
160 #define	SU_IDEALROLL	(1<<8)	// I'll take that available bit
161 #define	SU_SC1		(1<<9)
162 #define	SU_ONGROUND	(1<<10)	// no data follows, the bit is it
163 #define	SU_INWATER	(1<<11)	// no data follows, the bit is it
164 #define	SU_WEAPONFRAME	(1<<12)
165 #define	SU_ARMOR	(1<<13)
166 #define	SU_WEAPON	(1<<14)
167 #define	SU_SC2		(1<<15)
168 
169 // Bits to help send server info about the client's edict variables
170 #define SC1_HEALTH		(1<<0)		// changes stat bar
171 #define SC1_LEVEL		(1<<1)		// changes stat bar
172 #define SC1_INTELLIGENCE	(1<<2)		// changes stat bar
173 #define SC1_WISDOM		(1<<3)		// changes stat bar
174 #define SC1_STRENGTH		(1<<4)		// changes stat bar
175 #define SC1_DEXTERITY		(1<<5)		// changes stat bar
176 #define SC1_WEAPON		(1<<6)		// changes stat bar
177 #define SC1_BLUEMANA		(1<<7)		// changes stat bar
178 #define SC1_GREENMANA		(1<<8)		// changes stat bar
179 #define SC1_EXPERIENCE		(1<<9)		// changes stat bar
180 #define SC1_CNT_TORCH		(1<<10)		// changes stat bar
181 #define SC1_CNT_H_BOOST		(1<<11)		// changes stat bar
182 #define SC1_CNT_SH_BOOST	(1<<12)		// changes stat bar
183 #define SC1_CNT_MANA_BOOST	(1<<13)		// changes stat bar
184 #define SC1_CNT_TELEPORT	(1<<14)		// changes stat bar
185 #define SC1_CNT_TOME		(1<<15)		// changes stat bar
186 #define SC1_CNT_SUMMON		(1<<16)		// changes stat bar
187 #define SC1_CNT_INVISIBILITY	(1<<17)		// changes stat bar
188 #define SC1_CNT_GLYPH		(1<<18)		// changes stat bar
189 #define SC1_CNT_HASTE		(1<<19)		// changes stat bar
190 #define SC1_CNT_BLAST		(1<<20)		// changes stat bar
191 #define SC1_CNT_POLYMORPH	(1<<21)		// changes stat bar
192 #define SC1_CNT_FLIGHT		(1<<22)		// changes stat bar
193 #define SC1_CNT_CUBEOFFORCE	(1<<23)		// changes stat bar
194 #define SC1_CNT_INVINCIBILITY	(1<<24)		// changes stat bar
195 #define SC1_ARTIFACT_ACTIVE	(1<<25)
196 #define SC1_ARTIFACT_LOW	(1<<26)
197 #define SC1_MOVETYPE		(1<<27)
198 #define SC1_CAMERAMODE		(1<<28)
199 #define SC1_HASTED		(1<<29)
200 #define SC1_INVENTORY		(1<<30)
201 #define SC1_RINGS_ACTIVE	(1<<31)
202 
203 #define SC2_RINGS_LOW		(1<<0)
204 #define SC2_AMULET		(1<<1)
205 #define SC2_BRACER		(1<<2)
206 #define SC2_BREASTPLATE		(1<<3)
207 #define SC2_HELMET		(1<<4)
208 #define SC2_FLIGHT_T		(1<<5)
209 #define SC2_WATER_T		(1<<6)
210 #define SC2_TURNING_T		(1<<7)
211 #define SC2_REGEN_T		(1<<8)
212 #define SC2_HASTE_T		(1<<9)
213 #define SC2_TOME_T		(1<<10)
214 #define SC2_PUZZLE1		(1<<11)
215 #define SC2_PUZZLE2		(1<<12)
216 #define SC2_PUZZLE3		(1<<13)
217 #define SC2_PUZZLE4		(1<<14)
218 #define SC2_PUZZLE5		(1<<15)
219 #define SC2_PUZZLE6		(1<<16)
220 #define SC2_PUZZLE7		(1<<17)
221 #define SC2_PUZZLE8		(1<<18)
222 #define SC2_MAXHEALTH		(1<<19)
223 #define SC2_MAXMANA		(1<<20)
224 #define SC2_FLAGS		(1<<21)
225 #define SC2_OBJ			(1<<22)
226 #define SC2_OBJ2		(1<<23)
227 
228 
229 // This is to mask out those items that need to generate a stat bar change
230 #define SC1_STAT_BAR	0x01ffffff
231 #define SC2_STAT_BAR	0x0000001e
232 
233 // This is to mask out those items in the inventory (for inventory changes)
234 #define SC1_INV		0x01fffc00
235 #define SC2_INV		0x00000000
236 
237 //==============================================
238 
239 // a sound with no channel is a local only sound
240 #define	SND_VOLUME	(1<<0)	/* a byte	*/
241 #define	SND_ATTENUATION	(1<<1)	/* a byte	*/
242 #define	SND_OVERFLOW	(1<<2)	/* add 256 to snd num			*/
243 #define	SND_OVERFLOW2	(1<<3)	/* add 512 to snd num: a UQE/1.13 thing	*/
244 
245 // gonna use the rest of the bits to pack the ent+channel
246 #define DEFAULT_SOUND_PACKET_VOLUME		255
247 #define DEFAULT_SOUND_PACKET_ATTENUATION	1.0
248 
249 // defaults for clientinfo messages
250 #define	DEFAULT_VIEWHEIGHT	22
251 #define	DEFAULT_ITEMS		16385
252 
253 
254 // game types sent by serverinfo
255 // these determine which intermission screen plays
256 #define	GAME_COOP		0
257 #define	GAME_DEATHMATCH		1
258 
259 /*
260 ==========================================================
261 
262   ELEMENTS COMMUNICATED ACROSS THE NET
263 
264 ==========================================================
265 */
266 
267 //
268 // entity states and client frames
269 //
270 typedef struct
271 {
272 	vec3_t	origin;
273 	vec3_t	angles;
274 	short	modelindex;
275 	byte	frame;
276 	byte	colormap;
277 	byte	skin;
278 	byte	effects;
279 	byte	scale;
280 	byte	drawflags;
281 	byte	abslight;
282 	byte	ClearCount[32];
283 } entity_state_t;
284 
285 typedef struct
286 {
287 	byte	flags;
288 	short	index;
289 
290 	vec3_t	origin;
291 	vec3_t	angles;
292 	short	modelindex;
293 	byte	frame;
294 	byte	colormap;
295 	byte	skin;
296 	byte	effects;
297 	byte	scale;
298 	byte	drawflags;
299 	byte	abslight;
300 } entity_state2_t;
301 
302 typedef struct
303 {
304 	byte	flags;
305 
306 	vec3_t	origin;
307 	vec3_t	angles;
308 	short	modelindex;
309 	byte	frame;
310 	byte	colormap;
311 	byte	skin;
312 	byte	effects;
313 	byte	scale;
314 	byte	drawflags;
315 	byte	abslight;
316 } entity_state3_t;
317 
318 #define MAX_CLIENT_STATES	150
319 #define MAX_FRAMES		5
320 #define CLEAR_LIMIT		2
321 
322 #define ENT_STATE_ON		1
323 #define ENT_CLEARED		2
324 
325 typedef struct
326 {
327 	entity_state2_t	states[MAX_CLIENT_STATES];
328 //	unsigned long	frame;
329 //	unsigned long	flags;
330 	int		count;
331 } client_frames_t;
332 
333 typedef struct
334 {
335 	entity_state2_t	states[MAX_CLIENT_STATES*2];
336 	int		count;
337 } client_frames2_t;
338 
339 typedef struct
340 {
341 	client_frames_t	frames[MAX_FRAMES+2];	// 0 = base, 1-max = proposed, max+1 = too late
342 } client_state2_t;
343 
344 typedef struct usercmd_s
345 {
346 	vec3_t		viewangles;
347 
348 // intended velocities
349 	float		forwardmove;
350 	float		sidemove;
351 	float		upmove;
352 	byte		lightlevel;
353 } usercmd_t;
354 
355 #endif	/* __HX2_PROTOCOL_H */
356 
357