1 /*
2 ===========================================================================
3 Copyright (C) 1999 - 2005, Id Software, Inc.
4 Copyright (C) 2000 - 2013, Raven Software, Inc.
5 Copyright (C) 2001 - 2013, Activision, Inc.
6 Copyright (C) 2005 - 2015, ioquake3 contributors
7 Copyright (C) 2013 - 2015, OpenJK contributors
8 
9 This file is part of the OpenJK source code.
10 
11 OpenJK is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License version 2 as
13 published by the Free Software Foundation.
14 
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, see <http://www.gnu.org/licenses/>.
22 ===========================================================================
23 */
24 
25 #ifndef __Q_SHARED_H
26 #define __Q_SHARED_H
27 
28 // q_shared.h -- included first by ALL program modules.
29 // A user mod should never modify this file
30 
31 #include "qcommon/q_math.h"
32 #include "qcommon/q_color.h"
33 #include "qcommon/q_string.h"
34 
35 #ifdef _MSC_VER
36 
37 #pragma warning(disable : 4018)     // signed/unsigned mismatch
38 //#pragma warning(disable : 4032)		//formal parameter 'number' has different type when promoted
39 //#pragma warning(disable : 4051)		//type conversion; possible loss of data
40 //#pragma warning(disable : 4057)		// slightly different base types
41 #pragma warning(disable : 4100)		// unreferenced formal parameter
42 //#pragma warning(disable : 4115)		//'type' : named type definition in parentheses
43 #pragma warning(disable : 4125)		// decimal digit terminates octal escape sequence
44 #pragma warning(disable : 4127)		// conditional expression is constant
45 //#pragma warning(disable : 4136)		//conversion between different floating-point types
46 //#pragma warning(disable : 4201)		//nonstandard extension used : nameless struct/union
47 //#pragma warning(disable : 4214)		//nonstandard extension used : bit field types other than int
48 //#pragma warning(disable : 4220)		// varargs matches remaining parameters
49 #pragma warning(disable : 4244)		//'conversion' conversion from 'type1' to 'type2', possible loss of data
50 #pragma warning(disable : 4284)		// return type not UDT
51 //#pragma warning(disable : 4305)		// truncation from const double to float
52 #pragma warning(disable : 4310)		// cast truncates constant value
53 #pragma warning(disable : 4514)		//unreferenced inline/local function has been removed
54 #pragma warning(disable : 4710)		// not inlined
55 #pragma warning(disable : 4711)		// selected for automatic inline expansion
56 #pragma warning(disable : 4786)		// identifier was truncated
57 #pragma warning(disable : 5208)		// unnamed class used in typedef name cannot declare members other than non-static data members, member enumerations, or member classes
58 
59 #pragma warning(disable : 4996)		// This function or variable may be unsafe.
60 
61 #endif
62 
63 //rww - conveniently toggle "gore" code, for model decals and stuff.
64 #ifndef JK2_MODE
65 #define _G2_GORE
66 #endif // !JK2_MODE
67 
68 #if JK2_MODE
69 #define PRODUCT_NAME			"openjo_sp"
70 
71 #define CLIENT_WINDOW_TITLE "OpenJO (SP)"
72 #define CLIENT_CONSOLE_TITLE "OpenJO Console (SP)"
73 #define HOMEPATH_NAME_UNIX "openjo"
74 #define HOMEPATH_NAME_WIN "OpenJO"
75 #define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN
76 #else
77 #define PRODUCT_NAME			"openjk_sp"
78 
79 #define CLIENT_WINDOW_TITLE "OpenJK (SP)"
80 #define CLIENT_CONSOLE_TITLE "OpenJK Console (SP)"
81 #define HOMEPATH_NAME_UNIX "openjk"
82 #define HOMEPATH_NAME_WIN "OpenJK"
83 #define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN
84 #endif
85 
86 #define	BASEGAME "base"
87 #define OPENJKGAME "OpenJK"
88 
89 #define Q3CONFIG_NAME PRODUCT_NAME ".cfg"
90 
91 #define BASE_SAVE_COMPAT // this is defined to disable/fix some changes that break save compatibility
92 
93 #define VALIDSTRING( a )	( ( a != NULL ) && ( a[0] != '\0' ) )
94 
95 //JAC: Added
96 #define ARRAY_LEN( x ) ( sizeof( x ) / sizeof( *(x) ) )
97 #define STRING( a ) #a
98 #define XSTRING( a ) STRING( a )
99 
100 #ifndef FINAL_BUILD
101 #ifdef _WIN32
102 #define G2_PERFORMANCE_ANALYSIS
103 #endif
104 #endif
105 
106 #include <assert.h>
107 #include <math.h>
108 #include <float.h>
109 #include <stdio.h>
110 #include <stdarg.h>
111 #include <string.h>
112 #include <stdlib.h>
113 #include <time.h>
114 #include <ctype.h>
115 #include <limits.h>
116 #include <errno.h>
117 #include <stddef.h>
118 
119 #ifdef __cplusplus
120 #include <cmath>
121 #endif
122 
123 
124 //Ignore __attribute__ on non-gcc platforms
125 #if !defined(__GNUC__) && !defined(__attribute__)
126 	#define __attribute__(x)
127 #endif
128 
129 #if defined(__GNUC__)
130 	#define UNUSED_VAR __attribute__((unused))
131 #else
132 	#define UNUSED_VAR
133 #endif
134 
135 #if (defined _MSC_VER)
136 	#define Q_EXPORT __declspec(dllexport)
137 #elif (defined __SUNPRO_C)
138 	#define Q_EXPORT __global
139 #elif ((__GNUC__ >= 3) && (!__EMX__) && (!sun))
140 	#define Q_EXPORT __attribute__((visibility("default")))
141 #else
142 	#define Q_EXPORT
143 #endif
144 
145 // this is the define for determining if we have an asm version of a C function
146 #if (defined(_M_IX86) || defined(__i386__)) && !defined(__sun__)
147 	#define id386	1
148 #else
149 	#define id386	0
150 #endif
151 
152 #if (defined(powerc) || defined(powerpc) || defined(ppc) || defined(__ppc) || defined(__ppc__)) && !defined(C_ONLY)
153 	#define idppc	1
154 #else
155 	#define idppc	0
156 #endif
157 
158 #include "qcommon/q_platform.h"
159 #include "ojk_saved_game_helper_fwd.h"
160 
161 
162 // ================================================================
163 // TYPE DEFINITIONS
164 // ================================================================
165 
166 typedef int32_t qhandle_t, thandle_t, fxHandle_t, sfxHandle_t, fileHandle_t, clipHandle_t;
167 
168 #define NULL_HANDLE ((qhandle_t)0)
169 #define NULL_SOUND ((sfxHandle_t)0)
170 #define NULL_FX ((fxHandle_t)0)
171 #define NULL_SFX ((sfxHandle_t)0)
172 #define NULL_FILE ((fileHandle_t)0)
173 #define NULL_CLIP ((clipHandle_t)0)
174 
175 #define PAD(base, alignment)	(((base)+(alignment)-1) & ~((alignment)-1))
176 #define PADLEN(base, alignment)	(PAD((base), (alignment)) - (base))
177 
178 #define PADP(base, alignment)	((void *) PAD((intptr_t) (base), (alignment)))
179 
180 #ifdef __GNUC__
181 #define QALIGN(x) __attribute__((aligned(x)))
182 #else
183 #define QALIGN(x)
184 #endif
185 
186 #ifndef NULL
187 // NOTE: This is all c++ so casting to void * is wrong
188 #define NULL ((void *)0)
189 #endif
190 
191 #define INT_ID( a, b, c, d ) (uint32_t)((((a) & 0xff) << 24) | (((b) & 0xff) << 16) | (((c) & 0xff) << 8) | ((d) & 0xff))
192 
193 // the game guarantees that no string from the network will ever
194 // exceed MAX_STRING_CHARS
195 #define	MAX_STRING_CHARS	1024	// max length of a string passed to Cmd_TokenizeString
196 #define	MAX_STRING_TOKENS	1024	// max tokens resulting from Cmd_TokenizeString
197 #define	MAX_TOKEN_CHARS		1024	// max length of an individual token
198 
199 #define	MAX_INFO_STRING		1024
200 #define	MAX_INFO_KEY		1024
201 #define	MAX_INFO_VALUE		1024
202 
203 #define	BIG_INFO_STRING		8192  // used for system info key only
204 #define	BIG_INFO_KEY		  8192
205 #define	BIG_INFO_VALUE		8192
206 
207 #define	MAX_QPATH			64		// max length of a quake game pathname
208 #ifdef PATH_MAX
209 #define MAX_OSPATH			PATH_MAX
210 #else
211 #define	MAX_OSPATH			256		// max length of a filesystem pathname
212 #endif
213 
214 #define	MAX_NAME_LENGTH		32		// max length of a client name
215 
216 // paramters for command buffer stuffing
217 typedef enum {
218 	EXEC_NOW,			// don't return until completed, a VM should NEVER use this,
219 						// because some commands might cause the VM to be unloaded...
220 	EXEC_INSERT,		// insert at current position, but don't run yet
221 	EXEC_APPEND			// add to end of the command buffer (normal case)
222 } cbufExec_t;
223 
224 
225 //
226 // these aren't needed by any of the VMs.  put in another header?
227 //
228 #define	MAX_MAP_AREA_BYTES		32		// bit vector of area visibility
229 
230 // Light Style Constants
231 
232 #define LS_STYLES_START			0
233 #define LS_NUM_STYLES			32
234 #define	LS_SWITCH_START			(LS_STYLES_START+LS_NUM_STYLES)
235 #define LS_NUM_SWITCH			32
236 #define MAX_LIGHT_STYLES		64
237 
238 // print levels from renderer (FIXME: set up for game / cgame?)
239 typedef enum {
240 	PRINT_ALL,
241 	PRINT_DEVELOPER,		// only print when "developer 1"
242 	PRINT_WARNING,
243 	PRINT_ERROR
244 } printParm_t;
245 
246 // parameters to the main Error routine
247 typedef enum {
248 	ERR_FATAL,					// exit the entire game with a popup window
249 	ERR_DROP,					// print to console and disconnect from game
250 	ERR_DISCONNECT,				// don't kill server
251 } errorParm_t;
252 
253 // font rendering values used by ui and cgame
254 #define PROP_GAP_WIDTH			2 // 3
255 #define PROP_SPACE_WIDTH		4
256 #define PROP_HEIGHT				16
257 
258 #define PROP_TINY_SIZE_SCALE	1
259 #define PROP_SMALL_SIZE_SCALE	1
260 #define PROP_BIG_SIZE_SCALE		1
261 #define PROP_GIANT_SIZE_SCALE	2
262 
263 #define PROP_TINY_HEIGHT		10
264 #define PROP_GAP_TINY_WIDTH		1
265 #define PROP_SPACE_TINY_WIDTH	3
266 
267 #define PROP_BIG_HEIGHT			24
268 #define PROP_GAP_BIG_WIDTH		3
269 #define PROP_SPACE_BIG_WIDTH	6
270 
271 
272 #define BLINK_DIVISOR			600
273 #define PULSE_DIVISOR			75
274 
275 #define UI_LEFT			0x00000000	// default
276 #define UI_CENTER		0x00000001
277 #define UI_RIGHT		0x00000002
278 #define UI_FORMATMASK	0x00000007
279 #define UI_SMALLFONT	0x00000010
280 #define UI_BIGFONT		0x00000020	// default
281 
282 #define UI_DROPSHADOW	0x00000800
283 #define UI_BLINK		0x00001000
284 #define UI_INVERSE		0x00002000
285 #define UI_PULSE		0x00004000
286 
287 
288 #define Com_Memset memset
289 #define Com_Memcpy memcpy
290 
291 // stuff for TA's ROQ cinematic code...
292 //
293 #define CIN_system	1
294 #define CIN_loop	2
295 #define	CIN_hold	4
296 #define CIN_silent	8
297 #define CIN_shader	16
298 
299 
300 // all drawing is done to a 640*480 virtual screen size
301 // and will be automatically scaled to the real resolution
302 #define	SCREEN_WIDTH		640
303 #define	SCREEN_HEIGHT		480
304 
305 #define TINYCHAR_WIDTH		(SMALLCHAR_WIDTH)
306 #define TINYCHAR_HEIGHT		(SMALLCHAR_HEIGHT/2)
307 
308 #define SMALLCHAR_WIDTH		8
309 #define SMALLCHAR_HEIGHT	16
310 
311 #define BIGCHAR_WIDTH		16
312 #define BIGCHAR_HEIGHT		16
313 
314 #define	GIANTCHAR_WIDTH		32
315 #define	GIANTCHAR_HEIGHT	48
316 
317 
318 // Player weapons effects
319 typedef enum
320 {
321 	SABER_RED,
322 	SABER_ORANGE,
323 	SABER_YELLOW,
324 	SABER_GREEN,
325 	SABER_BLUE,
326 	SABER_PURPLE
327 
328 } saber_colors_t;
329 
330 #define MAX_BATTERIES	2500
331 
332 #define ENUM2STRING(arg)   { #arg,arg }
333 
334 //=============================================
335 
336 char	*COM_SkipPath( char *pathname );
337 const char	*COM_GetExtension( const char *name );
338 void	COM_StripExtension( const char *in, char *out, int destsize );
339 qboolean COM_CompareExtension(const char *in, const char *ext);
340 void	COM_DefaultExtension( char *path, int maxSize, const char *extension );
341 
342 //JLFCALLOUT include MPNOTUSED
343 void	 COM_BeginParseSession( void );
344 void	 COM_EndParseSession( void );
345 
346 // For compatibility with shared code
COM_BeginParseSession(const char * sessionName)347 QINLINE void COM_BeginParseSession( const char *sessionName )
348 {
349 	COM_BeginParseSession();
350 }
351 
352 class COM_ParseSession {
353 public:
COM_ParseSession()354 	COM_ParseSession() { COM_BeginParseSession(); };
~COM_ParseSession()355 	~COM_ParseSession() { COM_EndParseSession(); };
356 };
357 
358 int		 COM_GetCurrentParseLine( void );
359 char	*COM_Parse( const char **data_p );
360 char	*COM_ParseExt( const char **data_p, qboolean allowLineBreak );
361 int		 COM_Compress( char *data_p );
362 qboolean COM_ParseString( const char **data, const char **s );
363 qboolean COM_ParseInt( const char **data, int *i );
364 qboolean COM_ParseFloat( const char **data, float *f );
365 qboolean COM_ParseVec4( const char **buffer, vec4_t *c);
366 
367 // data is an in/out parm, returns a parsed out token
368 
369 void	COM_MatchToken( char**buf_p, char *match );
370 
371 void SkipBracedSection (const char **program);
372 void SkipRestOfLine ( const char **data );
373 
374 void Parse1DMatrix (const char **buf_p, int x, float *m);
375 void Parse2DMatrix (const char **buf_p, int y, int x, float *m);
376 void Parse3DMatrix (const char **buf_p, int z, int y, int x, float *m);
377 int Com_HexStrToInt( const char *str );
378 
379 int	QDECL Com_sprintf (char *dest, int size, const char *fmt, ...);
380 
381 char *Com_SkipTokens( char *s, int numTokens, char *sep );
382 char *Com_SkipCharset( char *s, char *sep );
383 
384 
385 // mode parm for FS_FOpenFile
386 typedef enum {
387 	FS_READ,
388 	FS_WRITE,
389 	FS_APPEND,
390 	FS_APPEND_SYNC
391 } fsMode_t;
392 
393 typedef enum {
394 	FS_SEEK_CUR,
395 	FS_SEEK_END,
396 	FS_SEEK_SET
397 } fsOrigin_t;
398 
399 //=============================================
400 char	* QDECL va(const char *format, ...);
401 
402 #define TRUNCATE_LENGTH	64
403 void Com_TruncateLongString( char *buffer, const char *s );
404 
405 //=============================================
406 
407 //
408 // key / value info strings
409 //
410 const char *Info_ValueForKey( const char *s, const char *key );
411 void Info_RemoveKey( char *s, const char *key );
412 void Info_SetValueForKey( char *s, const char *key, const char *value );
413 qboolean Info_Validate( const char *s );
414 void Info_NextPair( const char **s, char key[MAX_INFO_KEY], char value[MAX_INFO_VALUE] );
415 
416 // this is only here so the functions in q_shared.c and bg_*.c can link
417 void	NORETURN QDECL Com_Error( int level, const char *error, ... );
418 void	QDECL Com_Printf( const char *msg, ... );
419 
420 
421 /*
422 ==========================================================
423 
424 CVARS (console variables)
425 
426 Many variables can be used for cheating purposes, so when
427 cheats is zero, force all unspecified variables to their
428 default values.
429 ==========================================================
430 */
431 
432 #define	CVAR_TEMP			0	// can be set even when cheats are disabled, but is not archived
433 #define	CVAR_ARCHIVE		1	// set to cause it to be saved to vars.rc
434 								// used for system variables, not for player
435 								// specific configurations
436 #define	CVAR_USERINFO		2	// sent to server on connect or change
437 #define	CVAR_SERVERINFO		4	// sent in response to front end requests
438 #define	CVAR_SYSTEMINFO		8	// these cvars will be duplicated on all clients
439 #define	CVAR_INIT			16	// don't allow change from console at all,
440 								// but can be set from the command line
441 #define	CVAR_LATCH			32	// will only change when C code next does
442 								// a Cvar_Get(), so it can't be changed
443 								// without proper initialization.  modified
444 								// will be set, even though the value hasn't
445 								// changed yet
446 #define	CVAR_ROM			64	// display only, cannot be set by user at all
447 #define	CVAR_USER_CREATED	128	// created by a set command
448 #define	CVAR_SAVEGAME		256	// store this in the savegame
449 #define CVAR_CHEAT			512	// can not be changed if cheats are disabled
450 #define CVAR_NORESTART		1024	// do not clear when a cvar_restart is issued
451 
452 #define CVAR_SERVER_CREATED	2048	// cvar was created by a server the client connected to.
453 #define CVAR_VM_CREATED		4096	// cvar was created exclusively in one of the VMs.
454 #define CVAR_PROTECTED		8192	// prevent modifying this var from VMs or the server
455 #define CVAR_NODEFAULT		16384	// do not write to config if matching with default value
456 
457 #define CVAR_ARCHIVE_ND		(CVAR_ARCHIVE | CVAR_NODEFAULT)
458 // These flags are only returned by the Cvar_Flags() function
459 #define CVAR_MODIFIED		0x40000000		// Cvar was modified
460 #define CVAR_NONEXISTENT	0x80000000		// Cvar doesn't exist.
461 
462 // nothing outside the Cvar_*() functions should modify these fields!
463 typedef struct cvar_s {
464 	char		*name;
465 	char		*string;
466 	char		*resetString;		// cvar_restart will reset to this value
467 	char		*latchedString;		// for CVAR_LATCH vars
468 	int			flags;
469 	qboolean	modified;			// set each time the cvar is changed
470 	int			modificationCount;	// incremented each time the cvar is changed
471 	float		value;				// atof( string )
472 	int			integer;			// atoi( string )
473 	qboolean	validate;
474 	qboolean	integral;
475 	float		min;
476 	float		max;
477 	struct cvar_s *next;
478 	struct cvar_s *prev;
479 	struct cvar_s *hashNext;
480 	struct cvar_s *hashPrev;
481 	int			hashIndex;
482 } cvar_t;
483 
484 #define	MAX_CVAR_VALUE_STRING	256
485 
486 typedef int	cvarHandle_t;
487 
488 // the modules that run in the virtual machine can't access the cvar_t directly,
489 // so they must ask for structured updates
490 typedef struct {
491 	cvarHandle_t	handle;
492 	int			modificationCount;
493 	float		value;
494 	int			integer;
495 	char		string[MAX_CVAR_VALUE_STRING];
496 } vmCvar_t;
497 
498 /*
499 ==============================================================
500 
501 COLLISION DETECTION
502 
503 ==============================================================
504 */
505 
506 #include "../game/surfaceflags.h"			// shared with the q3map utility
507 
508 /*
509 Ghoul2 Insert Start
510 */
511 
512 #if !defined(GHOUL2_SHARED_H_INC)
513 	#include "../game/ghoul2_shared.h"	//for CGhoul2Info_v
514 #endif
515 
516 /*
517 Ghoul2 Insert End
518 */
519 
520 #define MAX_G2_COLLISIONS 16
521 // a trace is returned when a box is swept through the world
522 typedef struct {
523 	qboolean	allsolid;	// if true, plane is not valid
524 	qboolean	startsolid;	// if true, the initial point was in a solid area
525 	float		fraction;	// time completed, 1.0 = didn't hit anything
526 	vec3_t		endpos;		// final position
527 	cplane_t	plane;		// surface normal at impact, transformed to world space
528 	int			surfaceFlags;	// surface hit
529 	int			contents;	// contents on other side of surface hit
530 	int			entityNum;	// entity the contacted sirface is a part of
531 /*
532 Ghoul2 Insert Start
533 */
534 	CCollisionRecord G2CollisionMap[MAX_G2_COLLISIONS];	// map that describes all of the parts of ghoul2 models that got hit
535 /*
536 Ghoul2 Insert End
537 */
538 
539 
sg_export__anon52142eef0808540 	void sg_export(
541 		ojk::SavedGameHelper& saved_game) const
542 	{
543 		saved_game.write<int8_t>(allsolid);
544 		saved_game.write<int8_t>(startsolid);
545 		saved_game.write<float>(fraction);
546 		saved_game.write<float>(endpos);
547 		saved_game.write<>(plane);
548 		saved_game.write<int8_t>(surfaceFlags);
549 		saved_game.write<int8_t>(contents);
550 		saved_game.write<int8_t>(entityNum);
551 		saved_game.write<>(G2CollisionMap);
552 	}
553 
sg_import__anon52142eef0808554 	void sg_import(
555 		ojk::SavedGameHelper& saved_game)
556 	{
557 		saved_game.read<int8_t>(allsolid);
558 		saved_game.read<int8_t>(startsolid);
559 		saved_game.read<float>(fraction);
560 		saved_game.read<float>(endpos);
561 		saved_game.read<>(plane);
562 		saved_game.read<int8_t>(surfaceFlags);
563 		saved_game.read<int8_t>(contents);
564 		saved_game.read<int8_t>(entityNum);
565 		saved_game.read<>(G2CollisionMap);
566 	}
567 } trace_t;
568 
569 // trace->entityNum can also be 0 to (MAX_GENTITIES-1)
570 // or ENTITYNUM_NONE, ENTITYNUM_WORLD
571 
572 
573 // markfragments are returned by CM_MarkFragments()
574 typedef struct {
575 	int		firstPoint;
576 	int		numPoints;
577 } markFragment_t;
578 
579 
580 
581 typedef struct {
582 	vec3_t		origin;
583 	vec3_t		axis[3];
584 } orientation_t;
585 
586 //=====================================================================
587 
588 
589 // in order from highest priority to lowest
590 // if none of the catchers are active, bound key strings will be executed
591 #define KEYCATCH_CONSOLE	1
592 #define	KEYCATCH_UI			2
593 
594 
595 // sound channels
596 // channel 0 never willingly overrides
597 // other channels will allways override a playing sound on that channel
598 #include "../game/channels.h"
599 
600 /*
601 ========================================================================
602 
603   ELEMENTS COMMUNICATED ACROSS THE NET
604 
605 ========================================================================
606 */
607 
608 #define	ANGLE2SHORT(x)	((int)((x)*65536/360) & 65535)
609 #define	SHORT2ANGLE(x)	((x)*(360.0/65536))
610 
611 #define	SNAPFLAG_RATE_DELAYED	1
612 #define	SNAPFLAG_NOT_ACTIVE		2	// snapshot used during connection and for zombies
613 #define SNAPFLAG_SERVERCOUNT	4	// toggled every map_restart so transitions can be detected
614 
615 //
616 // per-level limits
617 //
618 #define	MAX_CLIENTS			1 // 128		// absolute limit
619 #define MAX_TERRAINS		1 //32
620 
621 #define	GENTITYNUM_BITS		10		// don't need to send any more
622 #define	MAX_GENTITIES		(1<<GENTITYNUM_BITS)
623 
624 // entitynums are communicated with GENTITY_BITS, so any reserved
625 // values thatare going to be communcated over the net need to
626 // also be in this range
627 #define	ENTITYNUM_NONE		(MAX_GENTITIES-1)
628 #define	ENTITYNUM_WORLD		(MAX_GENTITIES-2)
629 #define	ENTITYNUM_MAX_NORMAL	(MAX_GENTITIES-2)
630 
631 
632 #define	MAX_MODELS			256
633 
634 #ifdef JK2_MODE
635 #define MAX_SOUNDS (256)
636 #else
637 #define	MAX_SOUNDS			380
638 #endif // JK2_MODE
639 
640 #define MAX_SUB_BSP			32
641 
642 #define	MAX_SUBMODELS		512		// nine bits
643 
644 #define MAX_FX				128
645 
646 #ifdef JK2_MODE
647 #define MAX_WORLD_FX (4)
648 #else
649 #define MAX_WORLD_FX		66		// was 16 // was 4
650 #endif // JK2_MODE
651 
652 /*
653 Ghoul2 Insert Start
654 */
655 #define	MAX_CHARSKINS		64		// character skins
656 /*
657 Ghoul2 Insert End
658 */
659 
660 #ifdef JK2_MODE
661 #define MAX_CONFIGSTRINGS (1024)
662 #else
663 #define	MAX_CONFIGSTRINGS	1300//1024 //rww - I had to up this for terrains
664 #endif // JK2_MODE
665 
666 // these are the only configstrings that the system reserves, all the
667 // other ones are strictly for servergame to clientgame communication
668 #define	CS_SERVERINFO		0		// an info string with all the serverinfo cvars
669 #define	CS_SYSTEMINFO		1		// an info string for server system to client system configuration (timescale, etc)
670 
671 #define	RESERVED_CONFIGSTRINGS	2	// game can't modify below this, only the system can
672 //
673 // config strings are a general means of communicating variable length strings
674 // from the server to all connected clients.
675 //
676 
677 // CS_SERVERINFO and CS_SYSTEMINFO are defined in q_shared.h
678 #define	CS_MUSIC			2
679 #define	CS_MESSAGE			3		// from the map worldspawn's message field
680 #define	CS_ITEMS			4		// string of 0's and 1's that tell which items are present
681 #define CS_AMBIENT_SET		5		// ambient set information for the player
682 
683 #define	CS_MODELS			10
684 
685 #ifndef JK2_MODE
686 #define	CS_SKYBOXORG		(CS_MODELS+MAX_MODELS)		//rww - skybox info
687 #endif // !JK2_MODE
688 
689 #ifdef JK2_MODE
690 #define CS_SOUNDS (CS_MODELS + MAX_MODELS)
691 #else
692 #define	CS_SOUNDS			(CS_SKYBOXORG+1)
693 #endif // JK2_MODE
694 
695 #ifdef BASE_SAVE_COMPAT
696 #define CS_RESERVED1		(CS_SOUNDS+MAX_SOUNDS) // reserved field for base compat from immersion removal
697 #define	CS_PLAYERS			(CS_RESERVED1 + 96)
698 #else
699 #define	CS_PLAYERS			(CS_SOUNDS+MAX_SOUNDS)
700 #endif
701 
702 #define	CS_LIGHT_STYLES		(CS_PLAYERS+MAX_CLIENTS)
703 
704 #ifndef JK2_MODE
705 #define CS_TERRAINS			(CS_LIGHT_STYLES + (MAX_LIGHT_STYLES*3))
706 #define CS_BSP_MODELS		(CS_TERRAINS + MAX_TERRAINS)
707 #endif // !JK2_MODE
708 
709 #ifdef JK2_MODE
710 #define CS_EFFECTS (CS_LIGHT_STYLES + (MAX_LIGHT_STYLES * 3))
711 #else
712 #define CS_EFFECTS			(CS_BSP_MODELS + MAX_SUB_BSP)//(CS_LIGHT_STYLES + (MAX_LIGHT_STYLES*3))
713 #endif // JK2_MODE
714 
715 /*
716 Ghoul2 Insert Start
717 */
718 #define CS_CHARSKINS 		(CS_EFFECTS + MAX_FX)
719 /*
720 Ghoul2 Insert End
721 */
722 #define CS_DYNAMIC_MUSIC_STATE	(CS_CHARSKINS + MAX_CHARSKINS)
723 #define CS_WORLD_FX				(CS_DYNAMIC_MUSIC_STATE + 1)
724 #define CS_MAX					(CS_WORLD_FX + MAX_WORLD_FX)
725 
726 #if (CS_MAX) > MAX_CONFIGSTRINGS
727 #error overflow: (CS_MAX) > MAX_CONFIGSTRINGS
728 #endif
729 
730 #define	MAX_GAMESTATE_CHARS	16000
731 typedef struct {
732 	int			stringOffsets[MAX_CONFIGSTRINGS];
733 	char		stringData[MAX_GAMESTATE_CHARS];
734 	int			dataCount;
735 } gameState_t;
736 
737 typedef enum
738 {
739 	FP_FIRST = 0,//marker
740 	FP_HEAL = 0,//instant
741 	FP_LEVITATION,//hold/duration
742 	FP_SPEED,//duration
743 	FP_PUSH,//hold/duration
744 	FP_PULL,//hold/duration
745 	FP_TELEPATHY,//instant
746 	FP_GRIP,//hold/duration
747 	FP_LIGHTNING,//hold/duration
748 	FP_SABERTHROW,
749 	FP_SABER_DEFENSE,
750 	FP_SABER_OFFENSE,
751 
752 #ifndef JK2_MODE
753 	//new Jedi Academy powers
754 	FP_RAGE,//duration - speed, invincibility and extra damage for short period, drains your health and leaves you weak and slow afterwards.
755 	FP_PROTECT,//duration - protect against physical/energy (level 1 stops blaster/energy bolts, level 2 stops projectiles, level 3 protects against explosions)
756 	FP_ABSORB,//duration - protect against dark force powers (grip, lightning, drain - maybe push/pull, too?)
757 	FP_DRAIN,//hold/duration - drain force power for health
758 	FP_SEE,//duration - detect/see hidden enemies
759 #endif // !JK2_MODE
760 
761 	NUM_FORCE_POWERS
762 } forcePowers_t;
763 
764 typedef enum
765 {
766 	SABER_NONE = 0,
767 	SABER_SINGLE,
768 	SABER_STAFF,
769 	SABER_DAGGER,
770 	SABER_BROAD,
771 	SABER_PRONG,
772 	SABER_ARC,
773 	SABER_SAI,
774 	SABER_CLAW,
775 	SABER_LANCE,
776 	SABER_STAR,
777 	SABER_TRIDENT,
778 	SABER_SITH_SWORD,
779 	NUM_SABERS
780 } saberType_t;
781 
782 //=========================================================
783 
784 // bit field limits
785 #define	MAX_STATS				16
786 
787 // NOTE!!! be careful about altering this because although it's used to define an array size, the entry indexes come from
788 //	the typedef'd enum "persEnum_t" in bg_public.h, and there's no compile-tie between the 2 -slc
789 //
790 #define	MAX_PERSISTANT			16
791 
792 #define	MAX_POWERUPS			16
793 #define	MAX_WEAPONS				32
794 #define MAX_AMMO				10
795 #define MAX_INVENTORY			15		// See INV_MAX
796 #define MAX_SECURITY_KEYS		5
797 #define MAX_SECURITY_KEY_MESSSAGE		24
798 
799 #define	MAX_PS_EVENTS			2		// this must be a power of 2 unless you change some &'s to %'s -ste
800 
801 
802 #define MAX_WORLD_COORD		( 64*1024 )
803 #define MIN_WORLD_COORD		( -64*1024 )
804 #define WORLD_SIZE			( MAX_WORLD_COORD - MIN_WORLD_COORD )
805 
806 typedef enum
807 {
808 	WHL_NONE,
809 	WHL_ANKLES,
810 	WHL_KNEES,
811 	WHL_WAIST,
812 	WHL_TORSO,
813 	WHL_SHOULDERS,
814 	WHL_HEAD,
815 	WHL_UNDER
816 } waterHeightLevel_t;
817 
818 // !!!!!!! loadsave affecting struct !!!!!!!
819 typedef struct
820 {
821 	// Actual trail stuff
822 	int		inAction;	// controls whether should we even consider starting one
823 	int		duration;	// how long each trail seg stays in existence
824 	int		lastTime;	// time a saber segement was last stored
825 	vec3_t	base;
826 	vec3_t	tip;
827 
828 	// Marks stuff
829 	qboolean	haveOldPos[2];
830 	vec3_t		oldPos[2];
831 	vec3_t		oldNormal[2];	// store this in case we don't have a connect-the-dots situation
832 							//	..then we'll need the normal to project a mark blob onto the impact point
833 
834 
sg_export__anon52142eef0f08835 	void sg_export(
836 		ojk::SavedGameHelper& saved_game) const
837 	{
838 		saved_game.write<int32_t>(inAction);
839 		saved_game.write<int32_t>(duration);
840 		saved_game.write<int32_t>(lastTime);
841 		saved_game.write<float>(base);
842 		saved_game.write<float>(tip);
843 		saved_game.write<int32_t>(haveOldPos);
844 		saved_game.write<float>(oldPos);
845 		saved_game.write<float>(oldNormal);
846 	}
847 
sg_import__anon52142eef0f08848 	void sg_import(
849 		ojk::SavedGameHelper& saved_game)
850 	{
851 		saved_game.read<int32_t>(inAction);
852 		saved_game.read<int32_t>(duration);
853 		saved_game.read<int32_t>(lastTime);
854 		saved_game.read<float>(base);
855 		saved_game.read<float>(tip);
856 		saved_game.read<int32_t>(haveOldPos);
857 		saved_game.read<float>(oldPos);
858 		saved_game.read<float>(oldNormal);
859 	}
860 } saberTrail_t;
861 
862 #define MAX_SABER_TRAIL_SEGS 8
863 
864 // !!!!!!!!!!!!! loadsave affecting struct !!!!!!!!!!!!!!!
865 typedef struct
866 {
867 	qboolean	active;
868 	saber_colors_t	color;
869 	float		radius;
870 	float		length;
871 	float		lengthMax;
872 	float		lengthOld;
873 	vec3_t		muzzlePoint;
874 	vec3_t		muzzlePointOld;
875 	vec3_t		muzzleDir;
876 	vec3_t		muzzleDirOld;
877 	saberTrail_t	trail;
ActivateTrail__anon52142eef1008878 	void		ActivateTrail ( float duration )
879 				{
880 					trail.inAction = qtrue;
881 					trail.duration = duration;
882 				};
DeactivateTrail__anon52142eef1008883 	void		DeactivateTrail ( float duration )
884 				{
885 					trail.inAction = qfalse;
886 					trail.duration = duration;
887 				};
888 
889 
sg_export__anon52142eef1008890 	void sg_export(
891 		ojk::SavedGameHelper& saved_game) const
892 	{
893 		saved_game.write<int32_t>(active);
894 		saved_game.write<int32_t>(color);
895 		saved_game.write<float>(radius);
896 		saved_game.write<float>(length);
897 		saved_game.write<float>(lengthMax);
898 		saved_game.write<float>(lengthOld);
899 		saved_game.write<float>(muzzlePoint);
900 		saved_game.write<float>(muzzlePointOld);
901 		saved_game.write<float>(muzzleDir);
902 		saved_game.write<float>(muzzleDirOld);
903 		saved_game.write<>(trail);
904 	}
905 
sg_import__anon52142eef1008906 	void sg_import(
907 		ojk::SavedGameHelper& saved_game)
908 	{
909 		saved_game.read<int32_t>(active);
910 		saved_game.read<int32_t>(color);
911 		saved_game.read<float>(radius);
912 		saved_game.read<float>(length);
913 		saved_game.read<float>(lengthMax);
914 		saved_game.read<float>(lengthOld);
915 		saved_game.read<float>(muzzlePoint);
916 		saved_game.read<float>(muzzlePointOld);
917 		saved_game.read<float>(muzzleDir);
918 		saved_game.read<float>(muzzleDirOld);
919 		saved_game.read<>(trail);
920 	}
921 } bladeInfo_t;
922 
923 #define MAX_BLADES 8
924 
925 typedef enum
926 {
927 	SS_NONE = 0,
928 	SS_FAST,
929 	SS_MEDIUM,
930 	SS_STRONG,
931 	SS_DESANN,
932 	SS_TAVION,
933 	SS_DUAL,
934 	SS_STAFF,
935 	SS_NUM_SABER_STYLES
936 } saber_styles_t;
937 
938 //SABER FLAGS
939 //Old bools converted to a flag now
940 #define SFL_NOT_LOCKABLE			(1<<0)//can't get into a saberlock
941 #define SFL_NOT_THROWABLE			(1<<1)//can't be thrown - FIXME: maybe make this a max level of force saber throw that can be used with this saber?
942 #define SFL_NOT_DISARMABLE			(1<<2)//can't be dropped
943 #define SFL_NOT_ACTIVE_BLOCKING		(1<<3)//don't to try to block incoming shots with this saber
944 #define SFL_TWO_HANDED				(1<<4)//uses both hands
945 #define SFL_SINGLE_BLADE_THROWABLE	(1<<5)//can throw this saber if only the first blade is on
946 #define SFL_RETURN_DAMAGE			(1<<6)//when returning from a saber throw, it keeps spinning and doing damage
947 //NEW FLAGS
948 #define SFL_ON_IN_WATER				(1<<7)//if set, weapon stays active even in water
949 #define SFL_BOUNCE_ON_WALLS			(1<<8)//if set, the saber will bounce back when it hits solid architecture (good for real-sword type mods)
950 #define SFL_BOLT_TO_WRIST			(1<<9)//if set, saber model is bolted to wrist, not in hand... useful for things like claws & shields, etc.
951 //#define SFL_STICK_ON_IMPACT		(1<<?)//if set, the saber will stick in the wall when thrown and hits solid architecture (good for sabers that are meant to be thrown).
952 //#define SFL_NO_ATTACK				(1<<?)//if set, you cannot attack with the saber (for sabers/weapons that are meant to be thrown only, not used as melee weapons).
953 //Move Restrictions
954 #define SFL_NO_PULL_ATTACK			(1<<10)//if set, cannot do pull+attack move (move not available in MP anyway)
955 #define SFL_NO_BACK_ATTACK			(1<<11)//if set, cannot do back-stab moves
956 #define SFL_NO_STABDOWN				(1<<12)//if set, cannot do stabdown move (when enemy is on ground)
957 #define SFL_NO_WALL_RUNS			(1<<13)//if set, cannot side-run or forward-run on walls
958 #define SFL_NO_WALL_FLIPS			(1<<14)//if set, cannot do backflip off wall or side-flips off walls
959 #define SFL_NO_WALL_GRAB			(1<<15)//if set, cannot grab wall & jump off
960 #define SFL_NO_ROLLS				(1<<16)//if set, cannot roll
961 #define SFL_NO_FLIPS				(1<<17)//if set, cannot do flips
962 #define SFL_NO_CARTWHEELS			(1<<18)//if set, cannot do cartwheels
963 #define SFL_NO_KICKS				(1<<19)//if set, cannot do kicks (can't do kicks anyway if using a throwable saber/sword)
964 #define SFL_NO_MIRROR_ATTACKS		(1<<20)//if set, cannot do the simultaneous attack left/right moves (only available in Dual Lightsaber Combat Style)
965 #define SFL_NO_ROLL_STAB			(1<<21)//if set, cannot do roll-stab move at end of roll
966 //SABER FLAGS2
967 //Primary Blade Style
968 #define SFL2_NO_WALL_MARKS			(1<<0)//if set, stops the saber from drawing marks on the world (good for real-sword type mods)
969 #define SFL2_NO_DLIGHT				(1<<1)//if set, stops the saber from drawing a dynamic light (good for real-sword type mods)
970 #define SFL2_NO_BLADE				(1<<2)//if set, stops the saber from drawing a blade (good for real-sword type mods)
971 #define SFL2_NO_CLASH_FLARE			(1<<3)//if set, the saber will not do the big, white clash flare with other sabers
972 #define SFL2_NO_DISMEMBERMENT		(1<<4)//if set, the saber never does dismemberment (good for pointed/blunt melee weapons)
973 #define SFL2_NO_IDLE_EFFECT			(1<<5)//if set, the saber will not do damage or any effects when it is idle (not in an attack anim).  (good for real-sword type mods)
974 #define SFL2_ALWAYS_BLOCK			(1<<6)//if set, the blades will always be blocking (good for things like shields that should always block)
975 #define SFL2_NO_MANUAL_DEACTIVATE	(1<<7)//if set, the blades cannot manually be toggled on and off
976 #define SFL2_TRANSITION_DAMAGE		(1<<8)//if set, the blade does damage in start, transition and return anims (like strong style does)
977 //Secondary Blade Style
978 #define SFL2_NO_WALL_MARKS2			(1<<9)//if set, stops the saber from drawing marks on the world (good for real-sword type mods)
979 #define SFL2_NO_DLIGHT2				(1<<10)//if set, stops the saber from drawing a dynamic light (good for real-sword type mods)
980 #define SFL2_NO_BLADE2				(1<<11)//if set, stops the saber from drawing a blade (good for real-sword type mods)
981 #define SFL2_NO_CLASH_FLARE2		(1<<12)//if set, the saber will not do the big, white clash flare with other sabers
982 #define SFL2_NO_DISMEMBERMENT2		(1<<13)//if set, the saber never does dismemberment (good for pointed/blunt melee weapons)
983 #define SFL2_NO_IDLE_EFFECT2		(1<<14)//if set, the saber will not do damage or any effects when it is idle (not in an attack anim).  (good for real-sword type mods)
984 #define SFL2_ALWAYS_BLOCK2			(1<<15)//if set, the blades will always be blocking (good for things like shields that should always block)
985 #define SFL2_NO_MANUAL_DEACTIVATE2	(1<<16)//if set, the blades cannot manually be toggled on and off
986 #define SFL2_TRANSITION_DAMAGE2		(1<<17)//if set, the blade does damage in start, transition and return anims (like strong style does)
987 
988 // !!!!!!!!!!!! loadsave affecting struct !!!!!!!!!!!!!!!!!!!!!!!!!!
989 typedef struct
990 {
991 	char		*name;						//entry in sabers.cfg, if any
992 	char		*fullName;					//the "Proper Name" of the saber, shown in the UI
993 	saberType_t	type;						//none, single or staff
994 	char		*model;						//hilt model
995 	char		*skin;						//hilt custom skin
996 	int			soundOn;					//game soundindex for turning on sound
997 	int			soundLoop;					//game soundindex for hum/loop sound
998 	int			soundOff;					//game soundindex for turning off sound
999 	int			numBlades;
1000 	bladeInfo_t	blade[MAX_BLADES];			//blade info - like length, trail, origin, dir, etc.
1001 	int			stylesLearned;				//styles you get when you get this saber, if any
1002 	int			stylesForbidden;			//styles you cannot use with this saber, if any
1003 	int			maxChain;					//how many moves can be chained in a row with this weapon (-1 is infinite, 0 is use default behavior)
1004 	int			forceRestrictions;			//force powers that cannot be used while this saber is on (bitfield) - FIXME: maybe make this a limit on the max level, per force power, that can be used with this type?
1005 	int			lockBonus;					//in saberlocks, this type of saber pushes harder or weaker
1006 	int			parryBonus;					//added to strength of parry with this saber
1007 	int			breakParryBonus;			//added to strength when hit a parry
1008 	int			breakParryBonus2;			//for bladeStyle2 (see bladeStyle2Start below)
1009 	int			disarmBonus;				//added to disarm chance when win saberlock or have a good parry (knockaway)
1010 	int			disarmBonus2;				//for bladeStyle2 (see bladeStyle2Start below)
1011 	saber_styles_t	singleBladeStyle;		//makes it so that you use a different style if you only have the first blade active
1012 	char		*brokenSaber1;				//if saber is actually hit by another saber, it can be cut in half/broken and will be replaced with this saber in your right hand
1013 	char		*brokenSaber2;				//if saber is actually hit by another saber, it can be cut in half/broken and will be replaced with this saber in your left hand
1014 //===NEW========================================================================================
1015 	//these values are global to the saber, like all of the ones above
1016 	int			saberFlags;					//from SFL_ list above
1017 	int			saberFlags2;				//from SFL2_ list above
1018 
1019 	//done in cgame (client-side code)
1020 	qhandle_t	spinSound;					//none - if set, plays this sound as it spins when thrown
1021 	qhandle_t	swingSound[3];				//none - if set, plays one of these 3 sounds when swung during an attack - NOTE: must provide all 3!!!
1022 	qhandle_t	fallSound[3];				//none - if set, plays one of these 3 sounds when weapon drops to the ground - NOTE: must provide all 3!!!
1023 
1024 	//done in game (server-side code)
1025 	float		moveSpeedScale;				//1.0 - you move faster/slower when using this saber
1026 	float		animSpeedScale;				//1.0 - plays normal attack animations faster/slower
1027 
1028 	//done in both cgame and game (BG code)
1029 	int	kataMove;				//LS_INVALID - if set, player will execute this move when they press both attack buttons at the same time
1030 	int	lungeAtkMove;			//LS_INVALID - if set, player will execute this move when they crouch+fwd+attack
1031 	int	jumpAtkUpMove;			//LS_INVALID - if set, player will execute this move when they jump+attack
1032 	int	jumpAtkFwdMove;			//LS_INVALID - if set, player will execute this move when they jump+fwd+attack
1033 	int	jumpAtkBackMove;		//LS_INVALID - if set, player will execute this move when they jump+back+attack
1034 	int	jumpAtkRightMove;		//LS_INVALID - if set, player will execute this move when they jump+rightattack
1035 	int	jumpAtkLeftMove;		//LS_INVALID - if set, player will execute this move when they jump+left+attack
1036 	int	readyAnim;				//-1 - anim to use when standing idle
1037 	int	drawAnim;				//-1 - anim to use when drawing weapon
1038 	int	putawayAnim;			//-1 - anim to use when putting weapon away
1039 	int	tauntAnim;				//-1 - anim to use when hit "taunt"
1040 	int	bowAnim;				//-1 - anim to use when hit "bow"
1041 	int	meditateAnim;			//-1 - anim to use when hit "meditate"
1042 	int	flourishAnim;			//-1 - anim to use when hit "flourish"
1043 	int	gloatAnim;				//-1 - anim to use when hit "gloat"
1044 
1045 	//***NOTE: you can only have a maximum of 2 "styles" of blades, so this next value, "bladeStyle2Start" is the number of the first blade to use these value on... all blades before this use the normal values above, all blades at and after this number use the secondary values below***
1046 	int			bladeStyle2Start;			//0 - if set, blades from this number and higher use the following values (otherwise, they use the normal values already set)
1047 
1048 	//***The following can be different for the extra blades - not setting them individually defaults them to the value for the whole saber (and first blade)***
1049 
1050 	//===PRIMARY BLADES=====================
1051 	//done in cgame (client-side code)
1052 	int			trailStyle;					//0 - default (0) is normal, 1 is a motion blur and 2 is no trail at all (good for real-sword type mods)
1053 	char		g2MarksShader[MAX_QPATH];	//none - if set, the game will use this shader for marks on enemies instead of the default "gfx/damage/saberglowmark"
1054 	char		g2WeaponMarkShader[MAX_QPATH];	//none - if set, the game will ry to project this shader onto the weapon when it damages a person (good for a blood splatter on the weapon)
1055 	//int		bladeShader;				//none - if set, overrides the shader used for the saber blade?
1056 	//int		trailShader;				//none - if set, overrides the shader used for the saber trail?
1057 	qhandle_t	hitSound[3];				//none - if set, plays one of these 3 sounds when saber hits a person - NOTE: must provide all 3!!!
1058 	qhandle_t	blockSound[3];				//none - if set, plays one of these 3 sounds when saber/sword hits another saber/sword - NOTE: must provide all 3!!!
1059 	qhandle_t	bounceSound[3];				//none - if set, plays one of these 3 sounds when saber/sword hits a wall and bounces off (must set bounceOnWall to 1 to use these sounds) - NOTE: must provide all 3!!!
1060 	int			blockEffect;				//none - if set, plays this effect when the saber/sword hits another saber/sword (instead of "saber/saber_block.efx")
1061 	int			hitPersonEffect;			//none - if set, plays this effect when the saber/sword hits a person (instead of "saber/blood_sparks_mp.efx")
1062 	int			hitOtherEffect;				//none - if set, plays this effect when the saber/sword hits something else damagable (instead of "saber/saber_cut.efx")
1063 	int			bladeEffect;				//none - if set, plays this effect at the blade tag
1064 
1065 	//done in game (server-side code)
1066 	float		knockbackScale;				//0 - if non-zero, uses damage done to calculate an appropriate amount of knockback
1067 	float		damageScale;				//1 - scale up or down the damage done by the saber
1068 	float		splashRadius;				//0 - radius of splashDamage
1069 	int			splashDamage;				//0 - amount of splashDamage, 100% at a distance of 0, 0% at a distance = splashRadius
1070 	float		splashKnockback;			//0 - amount of splashKnockback, 100% at a distance of 0, 0% at a distance = splashRadius
1071 
1072 	//===SECONDARY BLADES===================
1073 	//done in cgame (client-side code)
1074 	int			trailStyle2;				//0 - default (0) is normal, 1 is a motion blur and 2 is no trail at all (good for real-sword type mods)
1075 	char		g2MarksShader2[MAX_QPATH];	//none - if set, the game will use this shader for marks on enemies instead of the default "gfx/damage/saberglowmark"
1076 	char		g2WeaponMarkShader2[MAX_QPATH];	//none - if set, the game will ry to project this shader onto the weapon when it damages a person (good for a blood splatter on the weapon)
1077 	//int		bladeShader2;				//none - if set, overrides the shader used for the saber blade?
1078 	//int		trailShader2;				//none - if set, overrides the shader used for the saber trail?
1079 	qhandle_t	hit2Sound[3];				//none - if set, plays one of these 3 sounds when saber hits a person - NOTE: must provide all 3!!!
1080 	qhandle_t	block2Sound[3];				//none - if set, plays one of these 3 sounds when saber/sword hits another saber/sword - NOTE: must provide all 3!!!
1081 	qhandle_t	bounce2Sound[3];			//none - if set, plays one of these 3 sounds when saber/sword hits a wall and bounces off (must set bounceOnWall to 1 to use these sounds) - NOTE: must provide all 3!!!
1082 	int			blockEffect2;				//none - if set, plays this effect when the saber/sword hits another saber/sword (instead of "saber/saber_block.efx")
1083 	int			hitPersonEffect2;			//none - if set, plays this effect when the saber/sword hits a person (instead of "saber/blood_sparks_mp.efx")
1084 	int			hitOtherEffect2;			//none - if set, plays this effect when the saber/sword hits something else damagable (instead of "saber/saber_cut.efx")
1085 	int			bladeEffect2;				//none - if set, plays this effect at the blade tag
1086 
1087 	//done in game (server-side code)
1088 	float		knockbackScale2;			//0 - if non-zero, uses damage done to calculate an appropriate amount of knockback
1089 	float		damageScale2;				//1 - scale up or down the damage done by the saber
1090 	float		splashRadius2;				//0 - radius of splashDamage
1091 	int			splashDamage2;				//0 - amount of splashDamage, 100% at a distance of 0, 0% at a distance = splashRadius
1092 	float		splashKnockback2;			//0 - amount of splashKnockback, 100% at a distance of 0, 0% at a distance = splashRadius
1093 //=========================================================================================================================================
Activate__anon52142eef12081094 	void		Activate( void )
1095 				{
1096 					for ( int i = 0; i < numBlades; i++ )
1097 					{
1098 						blade[i].active = qtrue;
1099 					}
1100 				};
1101 
Deactivate__anon52142eef12081102 	void		Deactivate( void )
1103 				{
1104 					for ( int i = 0; i < numBlades; i++ )
1105 					{
1106 						blade[i].active = qfalse;
1107 					}
1108 				};
1109 
1110 	// Description: Activate a specific Blade of this Saber.
1111 	// Created: 10/03/02 by Aurelio Reis, Modified: 10/03/02 by Aurelio Reis.
1112 	//	[in]		int iBlade		Which Blade to activate.
1113 	//	[in]		bool bActive	Whether to activate it (default true), or deactivate it (false).
1114 	//	[return]	void
1115 	void		BladeActivate( int iBlade, qboolean bActive = qtrue )
1116 				{
1117 					// Validate blade ID/Index.
1118 					if ( iBlade < 0 || iBlade >= numBlades )
1119 						return;
1120 
1121 					blade[iBlade].active = bActive;
1122 				}
1123 
Active__anon52142eef12081124 	qboolean	Active()
1125 				{
1126 					for ( int i = 0; i < numBlades; i++ )
1127 					{
1128 						if ( blade[i].active )
1129 						{
1130 							return qtrue;
1131 						}
1132 					}
1133 					return qfalse;
1134 				}
ActiveManualOnly__anon52142eef12081135 	qboolean	ActiveManualOnly()
1136 				{
1137 					for ( int i = 0; i < numBlades; i++ )
1138 					{
1139 						if ( bladeStyle2Start > 0 )
1140 						{
1141 							if ( i >= bladeStyle2Start )
1142 							{
1143 								if ( (saberFlags2&SFL2_NO_MANUAL_DEACTIVATE2) )
1144 								{//don't count this blade
1145 									continue;
1146 								}
1147 							}
1148 							else if ( (saberFlags2&SFL2_NO_MANUAL_DEACTIVATE) )
1149 							{//don't count this blade
1150 								continue;
1151 							}
1152 						}
1153 						else if ( (saberFlags2&SFL2_NO_MANUAL_DEACTIVATE) )
1154 						{//don't count any of these blades!
1155 							continue;
1156 						}
1157 						else if ( blade[i].active )
1158 						{
1159 							return qtrue;
1160 						}
1161 					}
1162 					return qfalse;
1163 				}
SetLength__anon52142eef12081164 	void		SetLength( float length )
1165 				{
1166 					for ( int i = 0; i < numBlades; i++ )
1167 					{
1168 						blade[i].length = length;
1169 					}
1170 				}
Length__anon52142eef12081171 	float		Length()
1172 				{//return largest length
1173 					float len1 = 0;
1174 					for ( int i = 0; i < numBlades; i++ )
1175 					{
1176 						if ( blade[i].length > len1 )
1177 						{
1178 							len1 = blade[i].length;
1179 						}
1180 					}
1181 					return len1;
1182 				};
LengthMax__anon52142eef12081183 	float		LengthMax()
1184 				{
1185 					float len1 = 0;
1186 					for ( int i = 0; i < numBlades; i++ )
1187 					{
1188 						if ( blade[i].lengthMax > len1 )
1189 						{
1190 							len1 = blade[i].lengthMax;
1191 						}
1192 					}
1193 					return len1;
1194 				};
ActivateTrail__anon52142eef12081195 	void		ActivateTrail ( float duration )
1196 				{
1197 					for ( int i = 0; i < numBlades; i++ )
1198 					{
1199 						blade[i].ActivateTrail( duration );
1200 					}
1201 				};
DeactivateTrail__anon52142eef12081202 	void		DeactivateTrail ( float duration )
1203 				{
1204 					for ( int i = 0; i < numBlades; i++ )
1205 					{
1206 						blade[i].DeactivateTrail( duration );
1207 					}
1208 				};
1209 
1210 
sg_export__anon52142eef12081211 	void sg_export(
1212 		ojk::SavedGameHelper& saved_game) const
1213 	{
1214 		saved_game.write<int32_t>(name);
1215 		saved_game.write<int32_t>(fullName);
1216 		saved_game.write<int32_t>(type);
1217 		saved_game.write<int32_t>(model);
1218 		saved_game.write<int32_t>(skin);
1219 		saved_game.write<int32_t>(soundOn);
1220 		saved_game.write<int32_t>(soundLoop);
1221 		saved_game.write<int32_t>(soundOff);
1222 		saved_game.write<int32_t>(numBlades);
1223 		saved_game.write<>(blade);
1224 		saved_game.write<int32_t>(stylesLearned);
1225 		saved_game.write<int32_t>(stylesForbidden);
1226 		saved_game.write<int32_t>(maxChain);
1227 		saved_game.write<int32_t>(forceRestrictions);
1228 		saved_game.write<int32_t>(lockBonus);
1229 		saved_game.write<int32_t>(parryBonus);
1230 		saved_game.write<int32_t>(breakParryBonus);
1231 		saved_game.write<int32_t>(breakParryBonus2);
1232 		saved_game.write<int32_t>(disarmBonus);
1233 		saved_game.write<int32_t>(disarmBonus2);
1234 		saved_game.write<int32_t>(singleBladeStyle);
1235 		saved_game.write<int32_t>(brokenSaber1);
1236 		saved_game.write<int32_t>(brokenSaber2);
1237 		saved_game.write<int32_t>(saberFlags);
1238 		saved_game.write<int32_t>(saberFlags2);
1239 		saved_game.write<int32_t>(spinSound);
1240 		saved_game.write<int32_t>(swingSound);
1241 		saved_game.write<int32_t>(fallSound);
1242 		saved_game.write<float>(moveSpeedScale);
1243 		saved_game.write<float>(animSpeedScale);
1244 		saved_game.write<int32_t>(kataMove);
1245 		saved_game.write<int32_t>(lungeAtkMove);
1246 		saved_game.write<int32_t>(jumpAtkUpMove);
1247 		saved_game.write<int32_t>(jumpAtkFwdMove);
1248 		saved_game.write<int32_t>(jumpAtkBackMove);
1249 		saved_game.write<int32_t>(jumpAtkRightMove);
1250 		saved_game.write<int32_t>(jumpAtkLeftMove);
1251 		saved_game.write<int32_t>(readyAnim);
1252 		saved_game.write<int32_t>(drawAnim);
1253 		saved_game.write<int32_t>(putawayAnim);
1254 		saved_game.write<int32_t>(tauntAnim);
1255 		saved_game.write<int32_t>(bowAnim);
1256 		saved_game.write<int32_t>(meditateAnim);
1257 		saved_game.write<int32_t>(flourishAnim);
1258 		saved_game.write<int32_t>(gloatAnim);
1259 		saved_game.write<int32_t>(bladeStyle2Start);
1260 		saved_game.write<int32_t>(trailStyle);
1261 		saved_game.write<int8_t>(g2MarksShader);
1262 		saved_game.write<int8_t>(g2WeaponMarkShader);
1263 		saved_game.write<int32_t>(hitSound);
1264 		saved_game.write<int32_t>(blockSound);
1265 		saved_game.write<int32_t>(bounceSound);
1266 		saved_game.write<int32_t>(blockEffect);
1267 		saved_game.write<int32_t>(hitPersonEffect);
1268 		saved_game.write<int32_t>(hitOtherEffect);
1269 		saved_game.write<int32_t>(bladeEffect);
1270 		saved_game.write<float>(knockbackScale);
1271 		saved_game.write<float>(damageScale);
1272 		saved_game.write<float>(splashRadius);
1273 		saved_game.write<int32_t>(splashDamage);
1274 		saved_game.write<float>(splashKnockback);
1275 		saved_game.write<int32_t>(trailStyle2);
1276 		saved_game.write<int8_t>(g2MarksShader2);
1277 		saved_game.write<int8_t>(g2WeaponMarkShader2);
1278 		saved_game.write<int32_t>(hit2Sound);
1279 		saved_game.write<int32_t>(block2Sound);
1280 		saved_game.write<int32_t>(bounce2Sound);
1281 		saved_game.write<int32_t>(blockEffect2);
1282 		saved_game.write<int32_t>(hitPersonEffect2);
1283 		saved_game.write<int32_t>(hitOtherEffect2);
1284 		saved_game.write<int32_t>(bladeEffect2);
1285 		saved_game.write<float>(knockbackScale2);
1286 		saved_game.write<float>(damageScale2);
1287 		saved_game.write<float>(splashRadius2);
1288 		saved_game.write<int32_t>(splashDamage2);
1289 		saved_game.write<float>(splashKnockback2);
1290 	}
1291 
sg_import__anon52142eef12081292 	void sg_import(
1293 		ojk::SavedGameHelper& saved_game)
1294 	{
1295 		saved_game.read<int32_t>(name);
1296 		saved_game.read<int32_t>(fullName);
1297 		saved_game.read<int32_t>(type);
1298 		saved_game.read<int32_t>(model);
1299 		saved_game.read<int32_t>(skin);
1300 		saved_game.read<int32_t>(soundOn);
1301 		saved_game.read<int32_t>(soundLoop);
1302 		saved_game.read<int32_t>(soundOff);
1303 		saved_game.read<int32_t>(numBlades);
1304 		saved_game.read<>(blade);
1305 		saved_game.read<int32_t>(stylesLearned);
1306 		saved_game.read<int32_t>(stylesForbidden);
1307 		saved_game.read<int32_t>(maxChain);
1308 		saved_game.read<int32_t>(forceRestrictions);
1309 		saved_game.read<int32_t>(lockBonus);
1310 		saved_game.read<int32_t>(parryBonus);
1311 		saved_game.read<int32_t>(breakParryBonus);
1312 		saved_game.read<int32_t>(breakParryBonus2);
1313 		saved_game.read<int32_t>(disarmBonus);
1314 		saved_game.read<int32_t>(disarmBonus2);
1315 		saved_game.read<int32_t>(singleBladeStyle);
1316 		saved_game.read<int32_t>(brokenSaber1);
1317 		saved_game.read<int32_t>(brokenSaber2);
1318 		saved_game.read<int32_t>(saberFlags);
1319 		saved_game.read<int32_t>(saberFlags2);
1320 		saved_game.read<int32_t>(spinSound);
1321 		saved_game.read<int32_t>(swingSound);
1322 		saved_game.read<int32_t>(fallSound);
1323 		saved_game.read<float>(moveSpeedScale);
1324 		saved_game.read<float>(animSpeedScale);
1325 		saved_game.read<int32_t>(kataMove);
1326 		saved_game.read<int32_t>(lungeAtkMove);
1327 		saved_game.read<int32_t>(jumpAtkUpMove);
1328 		saved_game.read<int32_t>(jumpAtkFwdMove);
1329 		saved_game.read<int32_t>(jumpAtkBackMove);
1330 		saved_game.read<int32_t>(jumpAtkRightMove);
1331 		saved_game.read<int32_t>(jumpAtkLeftMove);
1332 		saved_game.read<int32_t>(readyAnim);
1333 		saved_game.read<int32_t>(drawAnim);
1334 		saved_game.read<int32_t>(putawayAnim);
1335 		saved_game.read<int32_t>(tauntAnim);
1336 		saved_game.read<int32_t>(bowAnim);
1337 		saved_game.read<int32_t>(meditateAnim);
1338 		saved_game.read<int32_t>(flourishAnim);
1339 		saved_game.read<int32_t>(gloatAnim);
1340 		saved_game.read<int32_t>(bladeStyle2Start);
1341 		saved_game.read<int32_t>(trailStyle);
1342 		saved_game.read<int8_t>(g2MarksShader);
1343 		saved_game.read<int8_t>(g2WeaponMarkShader);
1344 		saved_game.read<int32_t>(hitSound);
1345 		saved_game.read<int32_t>(blockSound);
1346 		saved_game.read<int32_t>(bounceSound);
1347 		saved_game.read<int32_t>(blockEffect);
1348 		saved_game.read<int32_t>(hitPersonEffect);
1349 		saved_game.read<int32_t>(hitOtherEffect);
1350 		saved_game.read<int32_t>(bladeEffect);
1351 		saved_game.read<float>(knockbackScale);
1352 		saved_game.read<float>(damageScale);
1353 		saved_game.read<float>(splashRadius);
1354 		saved_game.read<int32_t>(splashDamage);
1355 		saved_game.read<float>(splashKnockback);
1356 		saved_game.read<int32_t>(trailStyle2);
1357 		saved_game.read<int8_t>(g2MarksShader2);
1358 		saved_game.read<int8_t>(g2WeaponMarkShader2);
1359 		saved_game.read<int32_t>(hit2Sound);
1360 		saved_game.read<int32_t>(block2Sound);
1361 		saved_game.read<int32_t>(bounce2Sound);
1362 		saved_game.read<int32_t>(blockEffect2);
1363 		saved_game.read<int32_t>(hitPersonEffect2);
1364 		saved_game.read<int32_t>(hitOtherEffect2);
1365 		saved_game.read<int32_t>(bladeEffect2);
1366 		saved_game.read<float>(knockbackScale2);
1367 		saved_game.read<float>(damageScale2);
1368 		saved_game.read<float>(splashRadius2);
1369 		saved_game.read<int32_t>(splashDamage2);
1370 		saved_game.read<float>(splashKnockback2);
1371 	}
1372 } saberInfo_t;
1373 
1374 //NOTE: Below is the *retail* version of the saberInfo_t structure - it is ONLY used for loading retail-version savegames (we load the savegame into this smaller structure, then copy each field into the appropriate field in the new structure - see SG_ConvertRetailSaberinfoToNewSaberinfo()
1375 class saberInfoRetail_t
1376 {
1377 public:
1378 	char		*name;						//entry in sabers.cfg, if any
1379 	char		*fullName;					//the "Proper Name" of the saber, shown in the UI
1380 	saberType_t	type;						//none, single or staff
1381 	char		*model;						//hilt model
1382 	char		*skin;						//hilt custom skin
1383 	int			soundOn;					//game soundindex for turning on sound
1384 	int			soundLoop;					//game soundindex for hum/loop sound
1385 	int			soundOff;					//game soundindex for turning off sound
1386 	int			numBlades;
1387 	bladeInfo_t	blade[MAX_BLADES];			//blade info - like length, trail, origin, dir, etc.
1388 	saber_styles_t	style;					//locked style to use, if any
1389 	int			maxChain;					//how many moves can be chained in a row with this weapon (-1 is infinite, 0 is use default behavior)
1390 	qboolean	lockable;					//can get into a saberlock
1391 	qboolean	throwable;					//whether or not this saber can be thrown - FIXME: maybe make this a max level of force saber throw that can be used with this saber?
1392 	qboolean	disarmable;					//whether or not this saber can be dropped
1393 	qboolean	activeBlocking;				//whether or not to try to block incoming shots with this saber
1394 	qboolean	twoHanded;					//uses both hands
1395 	int			forceRestrictions;			//force powers that cannot be used while this saber is on (bitfield) - FIXME: maybe make this a limit on the max level, per force power, that can be used with this type?
1396 	int			lockBonus;					//in saberlocks, this type of saber pushes harder or weaker
1397 	int			parryBonus;					//added to strength of parry with this saber
1398 	int			breakParryBonus;			//added to strength when hit a parry
1399 	int			disarmBonus;				//added to disarm chance when win saberlock or have a good parry (knockaway)
1400 	saber_styles_t	singleBladeStyle;		//makes it so that you use a different style if you only have the first blade active
1401 	qboolean	singleBladeThrowable;		//makes it so that you can throw this saber if only the first blade is on
1402 	char		*brokenSaber1;				//if saber is actually hit by another saber, it can be cut in half/broken and will be replaced with this saber in your right hand
1403 	char		*brokenSaber2;				//if saber is actually hit by another saber, it can be cut in half/broken and will be replaced with this saber in your left hand
1404 	qboolean	returnDamage;				//when returning from a saber throw, it keeps spinning and doing damage
Activate(void)1405 	void		Activate( void )
1406 				{
1407 					for ( int i = 0; i < numBlades; i++ )
1408 					{
1409 						blade[i].active = qtrue;
1410 					}
1411 				};
1412 
Deactivate(void)1413 	void		Deactivate( void )
1414 				{
1415 					for ( int i = 0; i < numBlades; i++ )
1416 					{
1417 						blade[i].active = qfalse;
1418 					}
1419 				};
1420 
1421 	// Description: Activate a specific Blade of this Saber.
1422 	// Created: 10/03/02 by Aurelio Reis, Modified: 10/03/02 by Aurelio Reis.
1423 	//	[in]		int iBlade		Which Blade to activate.
1424 	//	[in]		bool bActive	Whether to activate it (default true), or deactivate it (false).
1425 	//	[return]	void
1426 	void		BladeActivate( int iBlade, qboolean bActive = qtrue )
1427 				{
1428 					// Validate blade ID/Index.
1429 					if ( iBlade < 0 || iBlade >= numBlades )
1430 						return;
1431 
1432 					blade[iBlade].active = bActive;
1433 				}
1434 
Active()1435 	qboolean	Active()
1436 				{
1437 					for ( int i = 0; i < numBlades; i++ )
1438 					{
1439 						if ( blade[i].active )
1440 						{
1441 							return qtrue;
1442 						}
1443 					}
1444 					return qfalse;
1445 				}
SetLength(float length)1446 	void		SetLength( float length )
1447 				{
1448 					for ( int i = 0; i < numBlades; i++ )
1449 					{
1450 						blade[i].length = length;
1451 					}
1452 				}
Length()1453 	float		Length()
1454 				{//return largest length
1455 					float len1 = 0;
1456 					for ( int i = 0; i < numBlades; i++ )
1457 					{
1458 						if ( blade[i].length > len1 )
1459 						{
1460 							len1 = blade[i].length;
1461 						}
1462 					}
1463 					return len1;
1464 				};
LengthMax()1465 	float		LengthMax()
1466 				{
1467 					float len1 = 0;
1468 					for ( int i = 0; i < numBlades; i++ )
1469 					{
1470 						if ( blade[i].lengthMax > len1 )
1471 						{
1472 							len1 = blade[i].lengthMax;
1473 						}
1474 					}
1475 					return len1;
1476 				};
ActivateTrail(float duration)1477 	void		ActivateTrail ( float duration )
1478 				{
1479 					for ( int i = 0; i < numBlades; i++ )
1480 					{
1481 						blade[i].ActivateTrail( duration );
1482 					}
1483 				};
DeactivateTrail(float duration)1484 	void		DeactivateTrail ( float duration )
1485 				{
1486 					for ( int i = 0; i < numBlades; i++ )
1487 					{
1488 						blade[i].DeactivateTrail( duration );
1489 					}
1490 				};
1491 
1492 
sg_export(ojk::SavedGameHelper & saved_game)1493 	void sg_export(
1494 		ojk::SavedGameHelper& saved_game) const
1495 	{
1496 		saved_game.write<int32_t>(name);
1497 		saved_game.write<int32_t>(fullName);
1498 		saved_game.write<int32_t>(type);
1499 		saved_game.write<int32_t>(model);
1500 		saved_game.write<int32_t>(skin);
1501 		saved_game.write<int32_t>(soundOn);
1502 		saved_game.write<int32_t>(soundLoop);
1503 		saved_game.write<int32_t>(soundOff);
1504 		saved_game.write<int32_t>(numBlades);
1505 		saved_game.write<>(blade);
1506 		saved_game.write<int32_t>(style);
1507 		saved_game.write<int32_t>(maxChain);
1508 		saved_game.write<int32_t>(lockable);
1509 		saved_game.write<int32_t>(throwable);
1510 		saved_game.write<int32_t>(disarmable);
1511 		saved_game.write<int32_t>(activeBlocking);
1512 		saved_game.write<int32_t>(twoHanded);
1513 		saved_game.write<int32_t>(forceRestrictions);
1514 		saved_game.write<int32_t>(lockBonus);
1515 		saved_game.write<int32_t>(parryBonus);
1516 		saved_game.write<int32_t>(breakParryBonus);
1517 		saved_game.write<int32_t>(disarmBonus);
1518 		saved_game.write<int32_t>(singleBladeStyle);
1519 		saved_game.write<int32_t>(singleBladeThrowable);
1520 		saved_game.write<int32_t>(brokenSaber1);
1521 		saved_game.write<int32_t>(brokenSaber2);
1522 		saved_game.write<int32_t>(returnDamage);
1523 	}
1524 
sg_import(ojk::SavedGameHelper & saved_game)1525 	void sg_import(
1526 		ojk::SavedGameHelper& saved_game)
1527 	{
1528 		saved_game.read<int32_t>(name);
1529 		saved_game.read<int32_t>(fullName);
1530 		saved_game.read<int32_t>(type);
1531 		saved_game.read<int32_t>(model);
1532 		saved_game.read<int32_t>(skin);
1533 		saved_game.read<int32_t>(soundOn);
1534 		saved_game.read<int32_t>(soundLoop);
1535 		saved_game.read<int32_t>(soundOff);
1536 		saved_game.read<int32_t>(numBlades);
1537 		saved_game.read<>(blade);
1538 		saved_game.read<int32_t>(style);
1539 		saved_game.read<int32_t>(maxChain);
1540 		saved_game.read<int32_t>(lockable);
1541 		saved_game.read<int32_t>(throwable);
1542 		saved_game.read<int32_t>(disarmable);
1543 		saved_game.read<int32_t>(activeBlocking);
1544 		saved_game.read<int32_t>(twoHanded);
1545 		saved_game.read<int32_t>(forceRestrictions);
1546 		saved_game.read<int32_t>(lockBonus);
1547 		saved_game.read<int32_t>(parryBonus);
1548 		saved_game.read<int32_t>(breakParryBonus);
1549 		saved_game.read<int32_t>(disarmBonus);
1550 		saved_game.read<int32_t>(singleBladeStyle);
1551 		saved_game.read<int32_t>(singleBladeThrowable);
1552 		saved_game.read<int32_t>(brokenSaber1);
1553 		saved_game.read<int32_t>(brokenSaber2);
1554 		saved_game.read<int32_t>(returnDamage);
1555 	}
1556 
1557 	void sg_export(
1558 		saberInfo_t& dst) const;
1559 }; // saberInfoRetail_t
1560 
1561 #define MAX_SABERS 2	// if this ever changes then update the table "static const save_field_t savefields_gClient[]"!!!!!!!!!!!!
1562 
1563 // playerState_t is the information needed by both the client and server
1564 // to predict player motion and actions
1565 // nothing outside of pmove should modify these, or some degree of prediction error
1566 // will occur
1567 
1568 // you can't add anything to this without modifying the code in msg.c
1569 
1570 // playerState_t is a full superset of entityState_t as it is used by players,
1571 // so if a playerState_t is transmitted, the entityState_t can be fully derived
1572 // from it.
1573 // !!!!!!!!!! LOADSAVE-affecting structure !!!!!!!!!!
1574 template<typename TSaberInfo>
1575 class PlayerStateBase
1576 {
1577 public:
1578 	int			commandTime;		// cmd->serverTime of last executed command
1579 	int			pm_type;
1580 	int			bobCycle;			// for view bobbing and footstep generation
1581 	int			pm_flags;			// ducked, jump_held, etc
1582 	int			pm_time;
1583 
1584 	vec3_t		origin;
1585 	vec3_t		velocity;
1586 	int			weaponTime;
1587 	int			weaponChargeTime;
1588 	int			rechargeTime;		// for the phaser
1589 	int			gravity;
1590 	int			leanofs;
1591 	int			friction;
1592 	int			speed;
1593 	int			delta_angles[3];	// add to command angles to get view direction
1594 									// changed by spawns, rotating objects, and teleporters
1595 
1596 	int			groundEntityNum;// ENTITYNUM_NONE = in air
1597 	int			legsAnim;		//
1598 	int			legsAnimTimer;	// don't change low priority animations on legs until this runs out
1599 	int			torsoAnim;		//
1600 	int			torsoAnimTimer;	// don't change low priority animations on torso until this runs out
1601 	int			movementDir;	// a number 0 to 7 that represents the relative angle
1602 								// of movement to the view angle (axial and diagonals)
1603 								// when at rest, the value will remain unchanged
1604 								// used to twist the legs during strafing
1605 
1606 	int			eFlags;			// copied to entityState_t->eFlags
1607 
1608 	int			eventSequence;	// pmove generated events
1609 	int			events[MAX_PS_EVENTS];
1610 	int			eventParms[MAX_PS_EVENTS];
1611 
1612 	int			externalEvent;	// events set on player from another source
1613 	int			externalEventParm;
1614 	int			externalEventTime;
1615 
1616 	int			clientNum;		// ranges from 0 to MAX_CLIENTS-1
1617 	int			weapon;			// copied to entityState_t->weapon
1618 	int			weaponstate;
1619 
1620 	int			batteryCharge;
1621 
1622 	vec3_t		viewangles;		// for fixed views
1623 	float		legsYaw;		// actual legs forward facing
1624 	int			viewheight;
1625 
1626 	// damage feedback
1627 	int			damageEvent;							// when it changes, latch the other parms
1628 	int			damageYaw;
1629 	int			damagePitch;
1630 	int			damageCount;
1631 
1632 	int			stats[MAX_STATS];
1633 	int			persistant[MAX_PERSISTANT];				// stats that aren't cleared on death
1634 	int			powerups[MAX_POWERUPS];					// level.time that the powerup runs out
1635 	int			ammo[MAX_AMMO];
1636 	int			inventory[MAX_INVENTORY];							// Count of each inventory item.
1637 	char  		security_key_message[MAX_SECURITY_KEYS][MAX_SECURITY_KEY_MESSSAGE];	// Security key types
1638 
1639 	vec3_t		serverViewOrg;
1640 
1641 	qboolean	saberInFlight;
1642 #ifdef JK2_MODE
1643 	qboolean	saberActive;	// -- JK2 --
1644 
1645 	int			vehicleModel;	// -- JK2 --
1646 	int			viewEntity;		// For overriding player movement controls and vieworg
1647 	saber_colors_t	saberColor; // -- JK2 --
1648 	float		saberLength;	// -- JK2 --
1649 	float		saberLengthMax;	// -- JK2 --
1650 	int			forcePowersActive;	//prediction needs to know this
1651 #else
1652 	int			viewEntity;		// For overriding player movement controls and vieworg
1653 	int			forcePowersActive;	//prediction needs to know this
1654 
1655 #endif
1656 
1657 	//NEW vehicle stuff
1658 	// This has been localized to the vehicle stuff (NOTE: We can still use it later, I'm just commenting it to
1659 	// root out all the calls. We can store the data in vehicles and update by copying it here).
1660 	//int			vehicleIndex;	// Index into vehicleData table
1661 	//vec3_t		vehicleAngles;	// current angles of your vehicle
1662 	//int			vehicleArmor;	// current armor of your vehicle (explodes if drops to 0)
1663 
1664 	// !!
1665 	// not communicated over the net at all
1666 	// !!
1667 	//int			vehicleLastFXTime;				//timer for all cgame-FX...?
1668 	//int			vehicleExplodeTime;				//when it will go BOOM!
1669 
1670 	int			useTime;	//not sent
1671 	int			lastShotTime;//last time you shot your weapon
1672 	int			ping;			// server to game info for scoreboard
1673 	int			lastOnGround;	//last time you were on the ground
1674 	int			lastStationary;	//last time you were on the ground
1675 	int			weaponShotCount;
1676 
1677 #ifndef JK2_MODE
1678 	//FIXME: maybe allocate all these structures (saber, force powers, vehicles)
1679 	//			or descend them as classes - so not every client has all this info
1680 	TSaberInfo	saber[MAX_SABERS];
1681 	qboolean	dualSabers;
SaberStaff(void)1682 	qboolean	SaberStaff( void ) { return (qboolean)( saber[0].type == SABER_STAFF || (dualSabers && saber[1].type == SABER_STAFF) ); };
SaberActive()1683 	qboolean	SaberActive() { return (qboolean)( saber[0].Active() || (dualSabers&&saber[1].Active()) ); };
SetSaberLength(float length)1684 	void		SetSaberLength( float length )
1685 				{
1686 					saber[0].SetLength( length );
1687 					if ( dualSabers )
1688 					{
1689 						saber[1].SetLength( length );
1690 					}
1691 				}
SaberLength()1692 	float		SaberLength()
1693 				{//return largest length
1694 					float len1 = saber[0].Length();
1695 					if ( dualSabers && saber[1].Length() > len1 )
1696 					{
1697 						return saber[1].Length();
1698 					}
1699 					return len1;
1700 				};
SaberLengthMax()1701 	float		SaberLengthMax()
1702 				{
1703 					if ( saber[0].LengthMax() > saber[1].LengthMax() )
1704 					{
1705 						return saber[0].LengthMax();
1706 					}
1707 					else if ( dualSabers )
1708 					{
1709 						return saber[1].LengthMax();
1710 					}
1711 					return 0.0f;
1712 				};
1713 
1714 	// Activate or deactivate a specific Blade of a Saber.
1715 	// Created: 10/03/02 by Aurelio Reis, Modified: 10/03/02 by Aurelio Reis.
1716 	//	[in]	int iSaber		Which Saber to modify.
1717 	//	[in]	int iBlade		Which blade to modify (0 - (NUM_BLADES - 1)).
1718 	//	[in]	bool bActive	Whether to make it active (default true) or inactive (false).
1719 	//	[return]	void
1720 	void		SaberBladeActivate( int iSaber, int iBlade, qboolean bActive = qtrue )
1721 	{
1722 		// Validate saber (if it's greater than or equal to zero, OR it above the first saber but we
1723 		// are not doing duel Sabers, leave, something is not right.
1724 		if ( iSaber < 0 || ( iSaber > 0  && !dualSabers ) )
1725 			return;
1726 
1727 		saber[iSaber].BladeActivate( iBlade, bActive );
1728 	}
1729 
SaberActivate(void)1730 	void		SaberActivate( void )
1731 				{
1732 					saber[0].Activate();
1733 					if ( dualSabers )
1734 					{
1735 						saber[1].Activate();
1736 					}
1737 				}
SaberDeactivate(void)1738 	void		SaberDeactivate( void )
1739 				{
1740 					saber[0].Deactivate();
1741 					saber[1].Deactivate();
1742 				};
SaberActivateTrail(float duration)1743 	void		SaberActivateTrail ( float duration )
1744 				{
1745 					saber[0].ActivateTrail( duration );
1746 					if ( dualSabers )
1747 					{
1748 						saber[1].ActivateTrail( duration );
1749 					}
1750 				};
SaberDeactivateTrail(float duration)1751 	void		SaberDeactivateTrail ( float duration )
1752 				{
1753 					saber[0].DeactivateTrail( duration );
1754 					if ( dualSabers )
1755 					{
1756 						saber[1].DeactivateTrail( duration );
1757 					}
1758 				};
SaberDisarmBonus(int bladeNum)1759 	int			SaberDisarmBonus( int bladeNum )
1760 				{
1761 					int disarmBonus = 0;
1762 					if ( saber[0].Active() )
1763 					{
1764 						if ( saber[0].bladeStyle2Start > 0
1765 							&& bladeNum >= saber[0].bladeStyle2Start )
1766 						{
1767 							disarmBonus += saber[0].disarmBonus2;
1768 						}
1769 						else
1770 						{
1771 							disarmBonus += saber[0].disarmBonus;
1772 						}
1773 					}
1774 					if ( dualSabers && saber[1].Active() )
1775 					{//bonus for having 2 sabers
1776 						if ( saber[1].bladeStyle2Start > 0
1777 							&& bladeNum >= saber[1].bladeStyle2Start )
1778 						{
1779                             disarmBonus += 1 + saber[1].disarmBonus2;
1780 						}
1781 						else
1782 						{
1783                             disarmBonus += 1 + saber[1].disarmBonus;
1784 						}
1785 					}
1786 					return disarmBonus;
1787 				};
SaberParryBonus(void)1788 	int			SaberParryBonus( void )
1789 				{
1790 					int parryBonus = 0;
1791 					if ( saber[0].Active() )
1792 					{
1793 						parryBonus += saber[0].parryBonus;
1794 					}
1795 					if ( dualSabers && saber[1].Active() )
1796 					{//bonus for having 2 sabers
1797 						parryBonus += 1 + saber[1].parryBonus;
1798 					}
1799 					return parryBonus;
1800 				};
1801 #endif // !JK2_MODE
1802 
1803 	short		saberMove;
1804 
1805 #ifndef JK2_MODE
1806 	short		saberMoveNext;
1807 #endif // !JK2_MODE
1808 
1809 	short		saberBounceMove;
1810 	short		saberBlocking;
1811 	short		saberBlocked;
1812 	short		leanStopDebounceTime;
1813 
1814 #ifdef JK2_MODE
1815 	float		saberLengthOld;
1816 #endif
1817 	int			saberEntityNum;
1818 	float		saberEntityDist;
1819 	int			saberThrowTime;
1820 	int			saberEntityState;
1821 	int			saberDamageDebounceTime;
1822 	int			saberHitWallSoundDebounceTime;
1823 	int			saberEventFlags;
1824 	int			saberBlockingTime;
1825 	int			saberAnimLevel;
1826 	int			saberAttackChainCount;
1827 	int			saberLockTime;
1828 	int			saberLockEnemy;
1829 
1830 #ifndef JK2_MODE
1831 	int			saberStylesKnown;
1832 #endif // !JK2_MODE
1833 
1834 #ifdef JK2_MODE
1835 	char		*saberModel;
1836 #endif
1837 
1838 	int			forcePowersKnown;
1839 	int			forcePowerDuration[NUM_FORCE_POWERS];	//for effects that have a duration
1840 	int			forcePowerDebounce[NUM_FORCE_POWERS];	//for effects that must have an interval
1841 	int			forcePower;
1842 	int			forcePowerMax;
1843 	int			forcePowerRegenDebounceTime;
1844 
1845 #ifndef JK2_MODE
1846 	int			forcePowerRegenRate;				//default is 100ms
1847 	int			forcePowerRegenAmount;				//default is 1
1848 #endif // !JK2_MODE
1849 
1850 	int			forcePowerLevel[NUM_FORCE_POWERS];		//so we know the max forceJump power you have
1851 	float		forceJumpZStart;					//So when you land, you don't get hurt as much
1852 	float		forceJumpCharge;					//you're current forceJump charge-up level, increases the longer you hold the force jump button down
1853 	int			forceGripEntityNum;					//what entity I'm gripping
1854 	vec3_t		forceGripOrg;						//where the gripped ent should be lifted to
1855 
1856 #ifndef JK2_MODE
1857 	int			forceDrainEntityNum;				//what entity I'm draining
1858 	vec3_t		forceDrainOrg;						//where the drained ent should be lifted to
1859 #endif // !JK2_MODE
1860 
1861 	int			forceHealCount;						//how many points of force heal have been applied so far
1862 
1863 #ifndef JK2_MODE
1864 	//new Jedi Academy force powers
1865 	int			forceAllowDeactivateTime;
1866 	int			forceRageDrainTime;
1867 	int			forceRageRecoveryTime;
1868 	int			forceDrainEntNum;
1869 	float		forceDrainTime;
1870 	int			forcePowersForced;					//client is being forced to use these powers (FIXME: and only these?)
1871 	int			pullAttackEntNum;
1872 	int			pullAttackTime;
1873 	int			lastKickedEntNum;
1874 #endif // !JK2_MODE
1875 
1876 	int			taunting;							//replaced BUTTON_GESTURE
1877 
1878 	float		jumpZStart;							//So when you land, you don't get hurt as much
1879 	vec3_t		moveDir;
1880 
1881 	float		waterheight;						//exactly what the z org of the water is (will be +4 above if under water, -4 below if not in water)
1882 	waterHeightLevel_t	waterHeightLevel;					//how high it really is
1883 
1884 #ifndef JK2_MODE
1885 	//testing IK grabbing
1886 	qboolean	ikStatus;		//for IK
1887 	int			heldClient;		//for IK, who I'm grabbing, if anyone
1888 	int			heldByClient;	//for IK, someone is grabbing me
1889 	int			heldByBolt;		//for IK, what bolt I'm attached to on the holdersomeone is grabbing me by
1890 	int			heldByBone;		//for IK, what bone I'm being held by
1891 
1892 	//vehicle turn-around stuff... FIXME: only vehicles need this in SP...
1893 	int			vehTurnaroundIndex;
1894 	int			vehTurnaroundTime;
1895 
1896 	//NOTE: not really used in SP, just for Fighter Vehicle damage stuff
1897 	int			brokenLimbs;
1898 	int			electrifyTime;
1899 #endif // !JK2_MODE
1900 
1901 
sg_export(ojk::SavedGameHelper & saved_game)1902 	void sg_export(
1903 		ojk::SavedGameHelper& saved_game) const
1904 	{
1905 		saved_game.write<int32_t>(commandTime);
1906 		saved_game.write<int32_t>(pm_type);
1907 		saved_game.write<int32_t>(bobCycle);
1908 		saved_game.write<int32_t>(pm_flags);
1909 		saved_game.write<int32_t>(pm_time);
1910 		saved_game.write<float>(origin);
1911 		saved_game.write<float>(velocity);
1912 		saved_game.write<int32_t>(weaponTime);
1913 		saved_game.write<int32_t>(weaponChargeTime);
1914 		saved_game.write<int32_t>(rechargeTime);
1915 		saved_game.write<int32_t>(gravity);
1916 		saved_game.write<int32_t>(leanofs);
1917 		saved_game.write<int32_t>(friction);
1918 		saved_game.write<int32_t>(speed);
1919 		saved_game.write<int32_t>(delta_angles);
1920 		saved_game.write<int32_t>(groundEntityNum);
1921 		saved_game.write<int32_t>(legsAnim);
1922 		saved_game.write<int32_t>(legsAnimTimer);
1923 		saved_game.write<int32_t>(torsoAnim);
1924 		saved_game.write<int32_t>(torsoAnimTimer);
1925 		saved_game.write<int32_t>(movementDir);
1926 		saved_game.write<int32_t>(eFlags);
1927 		saved_game.write<int32_t>(eventSequence);
1928 		saved_game.write<int32_t>(events);
1929 		saved_game.write<int32_t>(eventParms);
1930 		saved_game.write<int32_t>(externalEvent);
1931 		saved_game.write<int32_t>(externalEventParm);
1932 		saved_game.write<int32_t>(externalEventTime);
1933 		saved_game.write<int32_t>(clientNum);
1934 		saved_game.write<int32_t>(weapon);
1935 		saved_game.write<int32_t>(weaponstate);
1936 		saved_game.write<int32_t>(batteryCharge);
1937 		saved_game.write<float>(viewangles);
1938 		saved_game.write<float>(legsYaw);
1939 		saved_game.write<int32_t>(viewheight);
1940 		saved_game.write<int32_t>(damageEvent);
1941 		saved_game.write<int32_t>(damageYaw);
1942 		saved_game.write<int32_t>(damagePitch);
1943 		saved_game.write<int32_t>(damageCount);
1944 		saved_game.write<int32_t>(stats);
1945 		saved_game.write<int32_t>(persistant);
1946 		saved_game.write<int32_t>(powerups);
1947 		saved_game.write<int32_t>(ammo);
1948 		saved_game.write<int32_t>(inventory);
1949 		saved_game.write<int8_t>(security_key_message);
1950 		saved_game.write<float>(serverViewOrg);
1951 		saved_game.write<int32_t>(saberInFlight);
1952 
1953 #ifdef JK2_MODE
1954 		saved_game.write<int32_t>(saberActive);
1955 		saved_game.write<int32_t>(vehicleModel);
1956 		saved_game.write<int32_t>(viewEntity);
1957 		saved_game.write<int32_t>(saberColor);
1958 		saved_game.write<float>(saberLength);
1959 		saved_game.write<float>(saberLengthMax);
1960 		saved_game.write<int32_t>(forcePowersActive);
1961 #else
1962 		saved_game.write<int32_t>(viewEntity);
1963 		saved_game.write<int32_t>(forcePowersActive);
1964 #endif // JK2_MODE
1965 
1966 		saved_game.write<int32_t>(useTime);
1967 		saved_game.write<int32_t>(lastShotTime);
1968 		saved_game.write<int32_t>(ping);
1969 		saved_game.write<int32_t>(lastOnGround);
1970 		saved_game.write<int32_t>(lastStationary);
1971 		saved_game.write<int32_t>(weaponShotCount);
1972 
1973 #ifndef JK2_MODE
1974 		saved_game.write<>(saber);
1975 		saved_game.write<int32_t>(dualSabers);
1976 #endif // !JK2_MODE
1977 
1978 		saved_game.write<int16_t>(saberMove);
1979 
1980 #ifndef JK2_MODE
1981 		saved_game.write<int16_t>(saberMoveNext);
1982 #endif // !JK2_MODE
1983 
1984 		saved_game.write<int16_t>(saberBounceMove);
1985 		saved_game.write<int16_t>(saberBlocking);
1986 		saved_game.write<int16_t>(saberBlocked);
1987 		saved_game.write<int16_t>(leanStopDebounceTime);
1988 
1989 #ifdef JK2_MODE
1990 		saved_game.skip(2);
1991 		saved_game.write<float>(saberLengthOld);
1992 #endif // JK2_MODE
1993 
1994 		saved_game.write<int32_t>(saberEntityNum);
1995 		saved_game.write<float>(saberEntityDist);
1996 		saved_game.write<int32_t>(saberThrowTime);
1997 		saved_game.write<int32_t>(saberEntityState);
1998 		saved_game.write<int32_t>(saberDamageDebounceTime);
1999 		saved_game.write<int32_t>(saberHitWallSoundDebounceTime);
2000 		saved_game.write<int32_t>(saberEventFlags);
2001 		saved_game.write<int32_t>(saberBlockingTime);
2002 		saved_game.write<int32_t>(saberAnimLevel);
2003 		saved_game.write<int32_t>(saberAttackChainCount);
2004 		saved_game.write<int32_t>(saberLockTime);
2005 		saved_game.write<int32_t>(saberLockEnemy);
2006 
2007 #ifndef JK2_MODE
2008 		saved_game.write<int32_t>(saberStylesKnown);
2009 #endif // !JK2_MODE
2010 
2011 #ifdef JK2_MODE
2012 		saved_game.write<int32_t>(saberModel);
2013 #endif // JK2_MODE
2014 
2015 		saved_game.write<int32_t>(forcePowersKnown);
2016 		saved_game.write<int32_t>(forcePowerDuration);
2017 		saved_game.write<int32_t>(forcePowerDebounce);
2018 		saved_game.write<int32_t>(forcePower);
2019 		saved_game.write<int32_t>(forcePowerMax);
2020 		saved_game.write<int32_t>(forcePowerRegenDebounceTime);
2021 
2022 #ifndef JK2_MODE
2023 		saved_game.write<int32_t>(forcePowerRegenRate);
2024 		saved_game.write<int32_t>(forcePowerRegenAmount);
2025 #endif // !JK2_MODE
2026 
2027 		saved_game.write<int32_t>(forcePowerLevel);
2028 		saved_game.write<float>(forceJumpZStart);
2029 		saved_game.write<float>(forceJumpCharge);
2030 		saved_game.write<int32_t>(forceGripEntityNum);
2031 		saved_game.write<float>(forceGripOrg);
2032 
2033 #ifndef JK2_MODE
2034 		saved_game.write<int32_t>(forceDrainEntityNum);
2035 		saved_game.write<float>(forceDrainOrg);
2036 #endif // !JK2_MODE
2037 
2038 		saved_game.write<int32_t>(forceHealCount);
2039 
2040 #ifndef JK2_MODE
2041 		saved_game.write<int32_t>(forceAllowDeactivateTime);
2042 		saved_game.write<int32_t>(forceRageDrainTime);
2043 		saved_game.write<int32_t>(forceRageRecoveryTime);
2044 		saved_game.write<int32_t>(forceDrainEntNum);
2045 		saved_game.write<float>(forceDrainTime);
2046 		saved_game.write<int32_t>(forcePowersForced);
2047 		saved_game.write<int32_t>(pullAttackEntNum);
2048 		saved_game.write<int32_t>(pullAttackTime);
2049 		saved_game.write<int32_t>(lastKickedEntNum);
2050 #endif // !JK2_MODE
2051 
2052 		saved_game.write<int32_t>(taunting);
2053 		saved_game.write<float>(jumpZStart);
2054 		saved_game.write<float>(moveDir);
2055 		saved_game.write<float>(waterheight);
2056 		saved_game.write<int32_t>(waterHeightLevel);
2057 
2058 #ifndef JK2_MODE
2059 		saved_game.write<int32_t>(ikStatus);
2060 		saved_game.write<int32_t>(heldClient);
2061 		saved_game.write<int32_t>(heldByClient);
2062 		saved_game.write<int32_t>(heldByBolt);
2063 		saved_game.write<int32_t>(heldByBone);
2064 		saved_game.write<int32_t>(vehTurnaroundIndex);
2065 		saved_game.write<int32_t>(vehTurnaroundTime);
2066 		saved_game.write<int32_t>(brokenLimbs);
2067 		saved_game.write<int32_t>(electrifyTime);
2068 #endif // !JK2_MODE
2069 	}
2070 
sg_import(ojk::SavedGameHelper & saved_game)2071 	void sg_import(
2072 		ojk::SavedGameHelper& saved_game)
2073 	{
2074 		saved_game.read<int32_t>(commandTime);
2075 		saved_game.read<int32_t>(pm_type);
2076 		saved_game.read<int32_t>(bobCycle);
2077 		saved_game.read<int32_t>(pm_flags);
2078 		saved_game.read<int32_t>(pm_time);
2079 		saved_game.read<float>(origin);
2080 		saved_game.read<float>(velocity);
2081 		saved_game.read<int32_t>(weaponTime);
2082 		saved_game.read<int32_t>(weaponChargeTime);
2083 		saved_game.read<int32_t>(rechargeTime);
2084 		saved_game.read<int32_t>(gravity);
2085 		saved_game.read<int32_t>(leanofs);
2086 		saved_game.read<int32_t>(friction);
2087 		saved_game.read<int32_t>(speed);
2088 		saved_game.read<int32_t>(delta_angles);
2089 		saved_game.read<int32_t>(groundEntityNum);
2090 		saved_game.read<int32_t>(legsAnim);
2091 		saved_game.read<int32_t>(legsAnimTimer);
2092 		saved_game.read<int32_t>(torsoAnim);
2093 		saved_game.read<int32_t>(torsoAnimTimer);
2094 		saved_game.read<int32_t>(movementDir);
2095 		saved_game.read<int32_t>(eFlags);
2096 		saved_game.read<int32_t>(eventSequence);
2097 		saved_game.read<int32_t>(events);
2098 		saved_game.read<int32_t>(eventParms);
2099 		saved_game.read<int32_t>(externalEvent);
2100 		saved_game.read<int32_t>(externalEventParm);
2101 		saved_game.read<int32_t>(externalEventTime);
2102 		saved_game.read<int32_t>(clientNum);
2103 		saved_game.read<int32_t>(weapon);
2104 		saved_game.read<int32_t>(weaponstate);
2105 		saved_game.read<int32_t>(batteryCharge);
2106 		saved_game.read<float>(viewangles);
2107 		saved_game.read<float>(legsYaw);
2108 		saved_game.read<int32_t>(viewheight);
2109 		saved_game.read<int32_t>(damageEvent);
2110 		saved_game.read<int32_t>(damageYaw);
2111 		saved_game.read<int32_t>(damagePitch);
2112 		saved_game.read<int32_t>(damageCount);
2113 		saved_game.read<int32_t>(stats);
2114 		saved_game.read<int32_t>(persistant);
2115 		saved_game.read<int32_t>(powerups);
2116 		saved_game.read<int32_t>(ammo);
2117 		saved_game.read<int32_t>(inventory);
2118 		saved_game.read<int8_t>(security_key_message);
2119 		saved_game.read<float>(serverViewOrg);
2120 		saved_game.read<int32_t>(saberInFlight);
2121 
2122 #ifdef JK2_MODE
2123 		saved_game.read<int32_t>(saberActive);
2124 		saved_game.read<int32_t>(vehicleModel);
2125 		saved_game.read<int32_t>(viewEntity);
2126 		saved_game.read<int32_t>(saberColor);
2127 		saved_game.read<float>(saberLength);
2128 		saved_game.read<float>(saberLengthMax);
2129 		saved_game.read<int32_t>(forcePowersActive);
2130 #else
2131 		saved_game.read<int32_t>(viewEntity);
2132 		saved_game.read<int32_t>(forcePowersActive);
2133 #endif // JK2_MODE
2134 
2135 		saved_game.read<int32_t>(useTime);
2136 		saved_game.read<int32_t>(lastShotTime);
2137 		saved_game.read<int32_t>(ping);
2138 		saved_game.read<int32_t>(lastOnGround);
2139 		saved_game.read<int32_t>(lastStationary);
2140 		saved_game.read<int32_t>(weaponShotCount);
2141 
2142 #ifndef JK2_MODE
2143 		saved_game.read<>(saber);
2144 		saved_game.read<int32_t>(dualSabers);
2145 #endif // !JK2_MODE
2146 
2147 		saved_game.read<int16_t>(saberMove);
2148 
2149 #ifndef JK2_MODE
2150 		saved_game.read<int16_t>(saberMoveNext);
2151 #endif // !JK2_MODE
2152 
2153 		saved_game.read<int16_t>(saberBounceMove);
2154 		saved_game.read<int16_t>(saberBlocking);
2155 		saved_game.read<int16_t>(saberBlocked);
2156 		saved_game.read<int16_t>(leanStopDebounceTime);
2157 
2158 #ifdef JK2_MODE
2159 		saved_game.skip(2);
2160 		saved_game.read<float>(saberLengthOld);
2161 #endif // JK2_MODE
2162 
2163 		saved_game.read<int32_t>(saberEntityNum);
2164 		saved_game.read<float>(saberEntityDist);
2165 		saved_game.read<int32_t>(saberThrowTime);
2166 		saved_game.read<int32_t>(saberEntityState);
2167 		saved_game.read<int32_t>(saberDamageDebounceTime);
2168 		saved_game.read<int32_t>(saberHitWallSoundDebounceTime);
2169 		saved_game.read<int32_t>(saberEventFlags);
2170 		saved_game.read<int32_t>(saberBlockingTime);
2171 		saved_game.read<int32_t>(saberAnimLevel);
2172 		saved_game.read<int32_t>(saberAttackChainCount);
2173 		saved_game.read<int32_t>(saberLockTime);
2174 		saved_game.read<int32_t>(saberLockEnemy);
2175 
2176 #ifndef JK2_MODE
2177 		saved_game.read<int32_t>(saberStylesKnown);
2178 #endif // !JK2_MODE
2179 
2180 #ifdef JK2_MODE
2181 		saved_game.read<int32_t>(saberModel);
2182 #endif // JK2_MODE
2183 
2184 		saved_game.read<int32_t>(forcePowersKnown);
2185 		saved_game.read<int32_t>(forcePowerDuration);
2186 		saved_game.read<int32_t>(forcePowerDebounce);
2187 		saved_game.read<int32_t>(forcePower);
2188 		saved_game.read<int32_t>(forcePowerMax);
2189 		saved_game.read<int32_t>(forcePowerRegenDebounceTime);
2190 
2191 #ifndef JK2_MODE
2192 		saved_game.read<int32_t>(forcePowerRegenRate);
2193 		saved_game.read<int32_t>(forcePowerRegenAmount);
2194 #endif // !JK2_MODE
2195 
2196 		saved_game.read<int32_t>(forcePowerLevel);
2197 		saved_game.read<float>(forceJumpZStart);
2198 		saved_game.read<float>(forceJumpCharge);
2199 		saved_game.read<int32_t>(forceGripEntityNum);
2200 		saved_game.read<float>(forceGripOrg);
2201 
2202 #ifndef JK2_MODE
2203 		saved_game.read<int32_t>(forceDrainEntityNum);
2204 		saved_game.read<float>(forceDrainOrg);
2205 #endif // !JK2_MODE
2206 
2207 		saved_game.read<int32_t>(forceHealCount);
2208 
2209 #ifndef JK2_MODE
2210 		saved_game.read<int32_t>(forceAllowDeactivateTime);
2211 		saved_game.read<int32_t>(forceRageDrainTime);
2212 		saved_game.read<int32_t>(forceRageRecoveryTime);
2213 		saved_game.read<int32_t>(forceDrainEntNum);
2214 		saved_game.read<float>(forceDrainTime);
2215 		saved_game.read<int32_t>(forcePowersForced);
2216 		saved_game.read<int32_t>(pullAttackEntNum);
2217 		saved_game.read<int32_t>(pullAttackTime);
2218 		saved_game.read<int32_t>(lastKickedEntNum);
2219 #endif // !JK2_MODE
2220 
2221 		saved_game.read<int32_t>(taunting);
2222 		saved_game.read<float>(jumpZStart);
2223 		saved_game.read<float>(moveDir);
2224 		saved_game.read<float>(waterheight);
2225 		saved_game.read<int32_t>(waterHeightLevel);
2226 
2227 #ifndef JK2_MODE
2228 		saved_game.read<int32_t>(ikStatus);
2229 		saved_game.read<int32_t>(heldClient);
2230 		saved_game.read<int32_t>(heldByClient);
2231 		saved_game.read<int32_t>(heldByBolt);
2232 		saved_game.read<int32_t>(heldByBone);
2233 		saved_game.read<int32_t>(vehTurnaroundIndex);
2234 		saved_game.read<int32_t>(vehTurnaroundTime);
2235 		saved_game.read<int32_t>(brokenLimbs);
2236 		saved_game.read<int32_t>(electrifyTime);
2237 #endif // !JK2_MODE
2238 	}
2239 }; // PlayerStateBase
2240 
2241 
2242 using playerState_t = PlayerStateBase<saberInfo_t>;
2243 //====================================================================
2244 
2245 
2246 //
2247 // usercmd_t->button bits, many of which are generated by the client system,
2248 // so they aren't game/cgame only definitions
2249 //
2250 #define	BUTTON_ATTACK		1
2251 #define	BUTTON_FORCE_LIGHTNING	2			// displays talk balloon and disables actions
2252 #define	BUTTON_USE_FORCE	4
2253 #define	BUTTON_FORCE_DRAIN	8			// draining
2254 #define	BUTTON_BLOCKING		8
2255 #define	BUTTON_VEH_SPEED	8			// used for some horrible vehicle hack... :)
2256 #define	BUTTON_WALKING		16			// walking can't just be infered from MOVE_RUN because a key pressed late in the frame will
2257 										// only generate a small move value for that frame walking will use different animations and
2258 										// won't generate footsteps
2259 #define	BUTTON_USE			32			// the ol' use key returns!
2260 #define BUTTON_FORCEGRIP	64			//
2261 #define BUTTON_ALT_ATTACK	128
2262 
2263 #define	BUTTON_FORCE_FOCUS	256			// any key whatsoever
2264 
2265 #define	MOVE_RUN			120			// if forwardmove or rightmove are >= MOVE_RUN,
2266 										// then BUTTON_WALKING should be set
2267 
2268 
2269 typedef enum
2270 {
2271 	GENCMD_FORCE_HEAL = 1,
2272 	GENCMD_FORCE_SPEED,
2273 	GENCMD_FORCE_THROW,
2274 	GENCMD_FORCE_PULL,
2275 	GENCMD_FORCE_DISTRACT,
2276 	GENCMD_FORCE_GRIP,
2277 	GENCMD_FORCE_LIGHTNING,
2278 	GENCMD_FORCE_RAGE,
2279 	GENCMD_FORCE_PROTECT,
2280 	GENCMD_FORCE_ABSORB,
2281 	GENCMD_FORCE_DRAIN,
2282 	GENCMD_FORCE_SEEING,
2283 } genCmds_t;
2284 
2285 
2286 // usercmd_t is sent to the server each client frame
2287 // !!!!!!!!!! LOADSAVE-affecting structure !!!!!!!!!!
2288 typedef struct usercmd_s {
2289 	int		serverTime;
2290 	int		buttons;
2291 	byte	weapon;
2292 	int		angles[3];
2293 	byte	generic_cmd;
2294 	signed char	forwardmove, rightmove, upmove;
2295 
2296 
sg_exportusercmd_s2297 	void sg_export(
2298 		ojk::SavedGameHelper& saved_game) const
2299 	{
2300 		saved_game.write<int32_t>(serverTime);
2301 		saved_game.write<int32_t>(buttons);
2302 		saved_game.write<uint8_t>(weapon);
2303 		saved_game.skip(3);
2304 		saved_game.write<int32_t>(angles);
2305 		saved_game.write<uint8_t>(generic_cmd);
2306 		saved_game.write<int8_t>(forwardmove);
2307 		saved_game.write<int8_t>(rightmove);
2308 		saved_game.write<int8_t>(upmove);
2309 	}
2310 
sg_importusercmd_s2311 	void sg_import(
2312 		ojk::SavedGameHelper& saved_game)
2313 	{
2314 		saved_game.read<int32_t>(serverTime);
2315 		saved_game.read<int32_t>(buttons);
2316 		saved_game.read<uint8_t>(weapon);
2317 		saved_game.skip(3);
2318 		saved_game.read<int32_t>(angles);
2319 		saved_game.read<uint8_t>(generic_cmd);
2320 		saved_game.read<int8_t>(forwardmove);
2321 		saved_game.read<int8_t>(rightmove);
2322 		saved_game.read<int8_t>(upmove);
2323 	}
2324 } usercmd_t;
2325 
2326 //===================================================================
2327 
2328 // if entityState->solid == SOLID_BMODEL, modelindex is an inline model number
2329 #define	SOLID_BMODEL	0xffffff
2330 
2331 typedef enum {// !!!!!!!!!!! LOADSAVE-affecting struct !!!!!!!!!!
2332 	TR_STATIONARY,
2333 	TR_INTERPOLATE,				// non-parametric, but interpolate between snapshots
2334 	TR_LINEAR,
2335 	TR_LINEAR_STOP,
2336 	TR_NONLINEAR_STOP,
2337 	TR_SINE,					// value = base + sin( time / duration ) * delta
2338 	TR_GRAVITY
2339 } trType_t;
2340 
2341 typedef struct {// !!!!!!!!!!! LOADSAVE-affecting struct !!!!!!!!!!
2342 	trType_t	trType;
2343 	int		trTime;
2344 	int		trDuration;			// if non 0, trTime + trDuration = stop time
2345 	vec3_t	trBase;
2346 	vec3_t	trDelta;			// velocity, etc
2347 
2348 
sg_export__anon52142eef15082349 	void sg_export(
2350 		ojk::SavedGameHelper& saved_game) const
2351 	{
2352 		saved_game.write<int32_t>(trType);
2353 		saved_game.write<int32_t>(trTime);
2354 		saved_game.write<int32_t>(trDuration);
2355 		saved_game.write<float>(trBase);
2356 		saved_game.write<float>(trDelta);
2357 	}
2358 
sg_import__anon52142eef15082359 	void sg_import(
2360 		ojk::SavedGameHelper& saved_game)
2361 	{
2362 		saved_game.read<int32_t>(trType);
2363 		saved_game.read<int32_t>(trTime);
2364 		saved_game.read<int32_t>(trDuration);
2365 		saved_game.read<float>(trBase);
2366 		saved_game.read<float>(trDelta);
2367 	}
2368 } trajectory_t;
2369 
2370 
2371 // entityState_t is the information conveyed from the server
2372 // in an update message about entities that the client will
2373 // need to render in some way
2374 // Different eTypes may use the information in different ways
2375 // The messages are delta compressed, so it doesn't really matter if
2376 // the structure size is fairly large
2377 
2378 typedef struct entityState_s {// !!!!!!!!!!! LOADSAVE-affecting struct !!!!!!!!!!!!!
2379 	int		number;			// entity index
2380 	int		eType;			// entityType_t
2381 	int		eFlags;
2382 
2383 	trajectory_t	pos;	// for calculating position
2384 	trajectory_t	apos;	// for calculating angles
2385 
2386 	int		time;
2387 	int		time2;
2388 
2389 	vec3_t	origin;
2390 	vec3_t	origin2;
2391 
2392 	vec3_t	angles;
2393 	vec3_t	angles2;
2394 
2395 	int		otherEntityNum;	// shotgun sources, etc
2396 	int		otherEntityNum2;
2397 
2398 	int		groundEntityNum;	// -1 = in air
2399 
2400 	int		constantLight;	// r + (g<<8) + (b<<16) + (intensity<<24)
2401 	int		loopSound;		// constantly loop this sound
2402 
2403 	int		modelindex;
2404 	int		modelindex2;
2405 	int		modelindex3;
2406 	int		clientNum;		// 0 to (MAX_CLIENTS - 1), for players and corpses
2407 	int		frame;
2408 
2409 	int		solid;			// for client side prediction, gi.linkentity sets this properly
2410 
2411 	int		event;			// impulse events -- muzzle flashes, footsteps, etc
2412 	int		eventParm;
2413 
2414 	// for players
2415 	int		powerups;		// bit flags
2416 	int		weapon;			// determines weapon and flash model, etc
2417 	int		legsAnim;		//
2418 	int		legsAnimTimer;	// don't change low priority animations on legs until this runs out
2419 	int		torsoAnim;		//
2420 	int		torsoAnimTimer;	// don't change low priority animations on torso until this runs out
2421 
2422 	int		scale;			//Scale players
2423 
2424 	//FIXME: why did IMMERSION dupe these 2 fields here?  There's no reason for this!!!
2425 	qboolean	saberInFlight;
2426 	qboolean	saberActive;
2427 
2428 #ifdef JK2_MODE
2429 	int		vehicleModel;	// For overriding your playermodel with a drivable vehicle
2430 #endif
2431 
2432 #ifndef JK2_MODE
2433 	//int		vehicleIndex;		// What kind of vehicle you're driving
2434 	vec3_t	vehicleAngles;		//
2435 	int		vehicleArmor;		// current armor of your vehicle (explodes if drops to 0)
2436 	// 0 if not in a vehicle, otherwise the client number.
2437 	int m_iVehicleNum;
2438 #endif // !JK2_MODE
2439 
2440 /*
2441 Ghoul2 Insert Start
2442 */
2443 	vec3_t	modelScale;		// used to scale models in any axis
2444 	int		radius;			// used for culling all the ghoul models attached to this ent NOTE - this is automatically scaled by Ghoul2 if/when you scale the model. This is a 100% size value
2445 	int		boltInfo;		// info used for bolting entities to Ghoul2 models - NOT used for bolting ghoul2 models to themselves, more for stuff like bolting effects to ghoul2 models
2446 /*
2447 Ghoul2 Insert End
2448 */
2449 
2450 #ifndef JK2_MODE
2451 	qboolean	isPortalEnt;
2452 #endif // !JK2_MODE
2453 
2454 
sg_exportentityState_s2455 	void sg_export(
2456 		ojk::SavedGameHelper& saved_game) const
2457 	{
2458 		saved_game.write<int32_t>(number);
2459 		saved_game.write<int32_t>(eType);
2460 		saved_game.write<int32_t>(eFlags);
2461 		saved_game.write<>(pos);
2462 		saved_game.write<>(apos);
2463 		saved_game.write<int32_t>(time);
2464 		saved_game.write<int32_t>(time2);
2465 		saved_game.write<float>(origin);
2466 		saved_game.write<float>(origin2);
2467 		saved_game.write<float>(angles);
2468 		saved_game.write<float>(angles2);
2469 		saved_game.write<int32_t>(otherEntityNum);
2470 		saved_game.write<int32_t>(otherEntityNum2);
2471 		saved_game.write<int32_t>(groundEntityNum);
2472 		saved_game.write<int32_t>(constantLight);
2473 		saved_game.write<int32_t>(loopSound);
2474 		saved_game.write<int32_t>(modelindex);
2475 		saved_game.write<int32_t>(modelindex2);
2476 		saved_game.write<int32_t>(modelindex3);
2477 		saved_game.write<int32_t>(clientNum);
2478 		saved_game.write<int32_t>(frame);
2479 		saved_game.write<int32_t>(solid);
2480 		saved_game.write<int32_t>(event);
2481 		saved_game.write<int32_t>(eventParm);
2482 		saved_game.write<int32_t>(powerups);
2483 		saved_game.write<int32_t>(weapon);
2484 		saved_game.write<int32_t>(legsAnim);
2485 		saved_game.write<int32_t>(legsAnimTimer);
2486 		saved_game.write<int32_t>(torsoAnim);
2487 		saved_game.write<int32_t>(torsoAnimTimer);
2488 		saved_game.write<int32_t>(scale);
2489 		saved_game.write<int32_t>(saberInFlight);
2490 		saved_game.write<int32_t>(saberActive);
2491 
2492 #ifdef JK2_MODE
2493 		saved_game.write<int32_t>(vehicleModel);
2494 #endif // JK2_MODE
2495 
2496 #ifndef JK2_MODE
2497 		saved_game.write<float>(vehicleAngles);
2498 		saved_game.write<int32_t>(vehicleArmor);
2499 		saved_game.write<int32_t>(m_iVehicleNum);
2500 #endif // !JK2_MODE
2501 
2502 		saved_game.write<float>(modelScale);
2503 		saved_game.write<int32_t>(radius);
2504 		saved_game.write<int32_t>(boltInfo);
2505 
2506 #ifndef JK2_MODE
2507 		saved_game.write<int32_t>(isPortalEnt);
2508 #endif // !JK2_MODE
2509 	}
2510 
sg_importentityState_s2511 	void sg_import(
2512 		ojk::SavedGameHelper& saved_game)
2513 	{
2514 		saved_game.read<int32_t>(number);
2515 		saved_game.read<int32_t>(eType);
2516 		saved_game.read<int32_t>(eFlags);
2517 		saved_game.read<>(pos);
2518 		saved_game.read<>(apos);
2519 		saved_game.read<int32_t>(time);
2520 		saved_game.read<int32_t>(time2);
2521 		saved_game.read<float>(origin);
2522 		saved_game.read<float>(origin2);
2523 		saved_game.read<float>(angles);
2524 		saved_game.read<float>(angles2);
2525 		saved_game.read<int32_t>(otherEntityNum);
2526 		saved_game.read<int32_t>(otherEntityNum2);
2527 		saved_game.read<int32_t>(groundEntityNum);
2528 		saved_game.read<int32_t>(constantLight);
2529 		saved_game.read<int32_t>(loopSound);
2530 		saved_game.read<int32_t>(modelindex);
2531 		saved_game.read<int32_t>(modelindex2);
2532 		saved_game.read<int32_t>(modelindex3);
2533 		saved_game.read<int32_t>(clientNum);
2534 		saved_game.read<int32_t>(frame);
2535 		saved_game.read<int32_t>(solid);
2536 		saved_game.read<int32_t>(event);
2537 		saved_game.read<int32_t>(eventParm);
2538 		saved_game.read<int32_t>(powerups);
2539 		saved_game.read<int32_t>(weapon);
2540 		saved_game.read<int32_t>(legsAnim);
2541 		saved_game.read<int32_t>(legsAnimTimer);
2542 		saved_game.read<int32_t>(torsoAnim);
2543 		saved_game.read<int32_t>(torsoAnimTimer);
2544 		saved_game.read<int32_t>(scale);
2545 		saved_game.read<int32_t>(saberInFlight);
2546 		saved_game.read<int32_t>(saberActive);
2547 
2548 #ifdef JK2_MODE
2549 		saved_game.read<int32_t>(vehicleModel);
2550 #endif // JK2_MODE
2551 
2552 #ifndef JK2_MODE
2553 		saved_game.read<float>(vehicleAngles);
2554 		saved_game.read<int32_t>(vehicleArmor);
2555 		saved_game.read<int32_t>(m_iVehicleNum);
2556 #endif // !JK2_MODE
2557 
2558 		saved_game.read<float>(modelScale);
2559 		saved_game.read<int32_t>(radius);
2560 		saved_game.read<int32_t>(boltInfo);
2561 
2562 #ifndef JK2_MODE
2563 		saved_game.read<int32_t>(isPortalEnt);
2564 #endif // !JK2_MODE
2565 	}
2566 } entityState_t;
2567 
2568 
2569 typedef enum {
2570 	CA_UNINITIALIZED,
2571 	CA_DISCONNECTED, 	// not talking to a server
2572 	CA_CONNECTING,		// sending request packets to the server
2573 	CA_CHALLENGING,		// sending challenge packets to the server
2574 	CA_CONNECTED,		// netchan_t established, getting gamestate
2575 	CA_LOADING,			// only during cgame initialization, never during main loop
2576 	CA_PRIMED,			// got gamestate, waiting for first frame
2577 	CA_ACTIVE,			// game views should be displayed
2578 	CA_CINEMATIC		// playing a cinematic or a static pic, not connected to a server
2579 } connstate_t;
2580 
2581 typedef struct SSkinGoreData_s
2582 {
2583 	vec3_t			angles;
2584 	vec3_t			position;
2585 	int				currentTime;
2586 	int				entNum;
2587 	vec3_t			rayDirection;	// in world space
2588 	vec3_t			hitLocation;	// in world space
2589 	vec3_t			scale;
2590 	float			SSize;			// size of splotch in the S texture direction in world units
2591 	float			TSize;			// size of splotch in the T texture direction in world units
2592 	float			theta;			// angle to rotate the splotch
2593 	vec3_t			uaxis;			//mark direction
2594 	float			depthStart;		// limit marks begin depth
2595 	float			depthEnd;		// depth to stop making marks
2596 
2597 	bool			useTheta;
2598 	bool			frontFaces;
2599 	bool			backFaces;
2600 	bool			fadeRGB; //specify fade method to modify RGB (by default, the alpha is set instead)
2601 
2602 	// growing stuff
2603 	int				growDuration;			// time over which we want this to scale up, set to -1 for no scaling
2604 	float			goreScaleStartFraction; // fraction of the final size at which we want the gore to initially appear
2605 
2606 	//qboolean		baseModelOnly;
2607 	int				lifeTime;				// effect expires after this amount of time
2608 	int				firstModel;				// which model to start the gore on (can skip the first)
2609 	int				fadeOutTime;			//specify the duration of fading, from the lifeTime (e.g. 3000 will start fading 3 seconds before removal and be faded entirely by removal)
2610 	//int				shrinkOutTime;			// unimplemented
2611 	//float			alphaModulate;			// unimplemented
2612 	//vec3_t			tint;					// unimplemented
2613 	//float			impactStrength;			// unimplemented
2614 
2615 	int				shader; // shader handle
2616 
2617 	int				myIndex; // used internally
2618 
2619 } SSkinGoreData;
2620 
2621 //rww - used for my ik stuff (ported directly from mp)
2622 typedef struct
2623 {
2624 	vec3_t angles;
2625 	vec3_t position;
2626 	vec3_t scale;
2627 	vec3_t velocity;
2628 	int	me;
2629 } sharedRagDollUpdateParams_t;
2630 
2631 //rww - update parms for ik bone stuff
2632 typedef struct
2633 {
2634 	char boneName[512]; //name of bone
2635 	vec3_t desiredOrigin; //world coordinate that this bone should be attempting to reach
2636 	vec3_t origin; //world coordinate of the entity who owns the g2 instance that owns the bone
2637 	float movementSpeed; //how fast the bone should move toward the destination
2638 } sharedIKMoveParams_t;
2639 
2640 
2641 typedef struct
2642 {
2643 	vec3_t pcjMins; //ik joint limit
2644 	vec3_t pcjMaxs; //ik joint limit
2645 	vec3_t origin; //origin of caller
2646 	vec3_t angles; //angles of caller
2647 	vec3_t scale; //scale of caller
2648 	float radius; //bone rad
2649 	int blendTime; //bone blend time
2650 	int pcjOverrides; //override ik bone flags
2651 	int startFrame; //base pose start
2652 	int endFrame; //base pose end
2653 } sharedSetBoneIKStateParams_t;
2654 
2655 enum sharedEIKMoveState
2656 {
2657 	IKS_NONE = 0,
2658 	IKS_DYNAMIC
2659 };
2660 
2661 /*
2662 ========================================================================
2663 
2664 String ID Tables
2665 
2666 ========================================================================
2667 */
2668 typedef struct stringID_table_s
2669 {
2670 	const char	*name;
2671 	int		id;
2672 } stringID_table_t;
2673 
2674 int GetIDForString ( const stringID_table_t *table, const char *string );
2675 const char *GetStringForID( const stringID_table_t *table, int id );
2676 
2677 // savegame screenshot size stuff...
2678 //
2679 #define SG_SCR_WIDTH			512	//256
2680 #define SG_SCR_HEIGHT			512	//256
2681 #define iSG_COMMENT_SIZE		64
2682 
2683 #define sCVARNAME_PLAYERSAVE	"playersave"	// used for level-transition, accessed by game and server modules
2684 
2685 
2686 /*
2687 Ghoul2 Insert Start
2688 */
2689 
2690 // For ghoul2 axis use
2691 
2692 enum Eorientations
2693 {
2694 	ORIGIN = 0,
2695 	POSITIVE_X,
2696 	POSITIVE_Z,
2697 	POSITIVE_Y,
2698 	NEGATIVE_X,
2699 	NEGATIVE_Z,
2700 	NEGATIVE_Y
2701 };
2702 /*
2703 Ghoul2 Insert End
2704 */
2705 
2706 #define MAX_PARSEFILES	16
2707 typedef struct parseData_s
2708 {
2709 	char	fileName[MAX_QPATH];			// Name of current file being read in
2710 	int		com_lines;						// Number of lines read in
2711 	int		com_tokenline;
2712 	const char	*bufferStart;					// Start address of buffer holding data that was read in
2713 	const char	*bufferCurrent;					// Where data is currently being parsed from buffer
2714 } parseData_t;
2715 
2716 //JFLCALLOUT include
2717 //changed to array
2718 extern parseData_t  parseData[];
2719 extern int parseDataCount;
2720 
2721 
2722 // cinematic states
2723 typedef enum {
2724 	FMV_IDLE,
2725 	FMV_PLAY,		// play
2726 	FMV_EOF,		// all other conditions, i.e. stop/EOF/abort
2727 	FMV_ID_BLT,
2728 	FMV_ID_IDLE,
2729 	FMV_LOOPED,
2730 	FMV_ID_WAIT
2731 } e_status;
2732 
2733 
2734 // define the new memory tags for the zone, used by all modules now
2735 //
2736 #define TAGDEF(blah) TAG_ ## blah
2737 enum {
2738 	#include "../qcommon/tags.h"
2739 };
2740 typedef unsigned memtag_t;
2741 
2742 // stuff to help out during development process, force reloading/uncacheing of certain filetypes...
2743 //
2744 typedef enum
2745 {
2746 	eForceReload_NOTHING,
2747 	eForceReload_BSP,
2748 	eForceReload_MODELS,
2749 	eForceReload_ALL
2750 
2751 } ForceReload_e;
2752 
2753 qboolean Q_InBitflags( const uint32_t *bits, int index, uint32_t bitsPerByte );
2754 void Q_AddToBitflags( uint32_t *bits, int index, uint32_t bitsPerByte );
2755 void Q_RemoveFromBitflags( uint32_t *bits, int index, uint32_t bitsPerByte );
2756 
2757 typedef int( *cmpFunc_t )(const void *a, const void *b);
2758 
2759 void *Q_LinearSearch( const void *key, const void *ptr, size_t count,
2760 	size_t size, cmpFunc_t cmp );
2761 
2762 #endif	// __Q_SHARED_H
2763