1 /*
2 ===========================================================================
3 
4 Return to Castle Wolfenstein multiplayer GPL Source Code
5 Copyright (C) 1999-2010 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Return to Castle Wolfenstein multiplayer GPL Source Code (“RTCW MP Source Code”).
8 
9 RTCW MP Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 RTCW MP Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with RTCW MP Source Code.  If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the RTCW MP Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the RTCW MP Source Code.  If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 
29 
30 
31 // g_local.h -- local definitions for game module
32 
33 #include "../qcommon/q_shared.h"
34 #include "bg_public.h"
35 #include "g_public.h"
36 
37 //==================================================================
38 
39 // the "gameversion" client command will print this plus compile date
40 //----(SA) Wolfenstein
41 #define GAMEVERSION BASEGAME
42 // done.
43 
44 #define BODY_QUEUE_SIZE     8
45 
46 #define INFINITE            1000000
47 
48 #define FRAMETIME           100                 // msec
49 #define EVENT_VALID_MSEC    300
50 #define CARNAGE_REWARD_TIME 3000
51 #define REWARD_SPRITE_TIME  2000
52 
53 #define INTERMISSION_DELAY_TIME 1000
54 
55 #define MG42_MULTIPLAYER_HEALTH 350             // JPW NERVE
56 
57 // gentity->flags
58 #define FL_GODMODE              0x00000010
59 #define FL_NOTARGET             0x00000020
60 #define FL_TEAMSLAVE            0x00000400  // not the first on the team
61 #define FL_NO_KNOCKBACK         0x00000800
62 #define FL_DROPPED_ITEM         0x00001000
63 #define FL_NO_BOTS              0x00002000  // spawn point not for bot use
64 #define FL_NO_HUMANS            0x00004000  // spawn point just for bots
65 #define FL_AI_GRENADE_KICK      0x00008000  // an AI has already decided to kick this grenade
66 // Rafael
67 #define FL_NOFATIGUE            0x00010000  // cheat flag no fatigue
68 
69 #define FL_TOGGLE               0x00020000  //----(SA)	ent is toggling (doors use this for ex.)
70 #define FL_KICKACTIVATE         0x00040000  //----(SA)	ent has been activated by a kick (doors use this too for ex.)
71 #define FL_SOFTACTIVATE         0x00000040  //----(SA)	ent has been activated while 'walking' (doors use this too for ex.)
72 #define FL_DEFENSE_GUARD        0x00080000  // warzombie defense pose
73 
74 #define FL_PARACHUTE            0x00100000
75 #define FL_WARZOMBIECHARGE      0x00200000
76 #define FL_NO_MONSTERSLICK      0x00400000
77 #define FL_NO_HEADCHECK         0x00800000
78 
79 #define FL_NODRAW               0x01000000
80 
81 // movers are things like doors, plats, buttons, etc
82 typedef enum {
83 	MOVER_POS1,
84 	MOVER_POS2,
85 	MOVER_POS3,
86 	MOVER_1TO2,
87 	MOVER_2TO1,
88 	// JOSEPH 1-26-00
89 	MOVER_2TO3,
90 	MOVER_3TO2,
91 	// END JOSEPH
92 
93 	// Rafael
94 	MOVER_POS1ROTATE,
95 	MOVER_POS2ROTATE,
96 	MOVER_1TO2ROTATE,
97 	MOVER_2TO1ROTATE
98 } moverState_t;
99 
100 
101 // door AI sound ranges
102 #define HEAR_RANGE_DOOR_LOCKED      128 // really close since this is a cruel check
103 #define HEAR_RANGE_DOOR_KICKLOCKED  512
104 #define HEAR_RANGE_DOOR_OPEN        256
105 #define HEAR_RANGE_DOOR_KICKOPEN    768
106 
107 // DHM - Nerve :: Worldspawn spawnflags to indicate if a gametype is not supported
108 #define NO_GT_WOLF      1
109 #define NO_STOPWATCH    2
110 #define NO_CHECKPOINT   4
111 
112 //============================================================================
113 
114 typedef struct gentity_s gentity_t;
115 typedef struct gclient_s gclient_t;
116 
117 //====================================================================
118 //
119 // Scripting, these structure are not saved into savegames (parsed each start)
120 typedef struct
121 {
122 	char    *actionString;
123 	qboolean ( *actionFunc )( gentity_t *ent, char *params );
124 } g_script_stack_action_t;
125 //
126 typedef struct
127 {
128 	//
129 	// set during script parsing
130 	g_script_stack_action_t     *action;            // points to an action to perform
131 	char                        *params;
132 } g_script_stack_item_t;
133 //
134 #define G_MAX_SCRIPT_STACK_ITEMS    64
135 //
136 typedef struct
137 {
138 	g_script_stack_item_t items[G_MAX_SCRIPT_STACK_ITEMS];
139 	int numItems;
140 } g_script_stack_t;
141 //
142 typedef struct
143 {
144 	int eventNum;                           // index in scriptEvents[]
145 	char                *params;            // trigger targetname, etc
146 	g_script_stack_t stack;
147 } g_script_event_t;
148 //
149 typedef struct
150 {
151 	char        *eventStr;
152 	qboolean ( *eventMatch )( g_script_event_t *event, char *eventParm );
153 } g_script_event_define_t;
154 //
155 // Script Flags
156 #define SCFL_GOING_TO_MARKER    0x1
157 #define SCFL_ANIMATING          0x2
158 //
159 // Scripting Status (NOTE: this MUST NOT contain any pointer vars)
160 typedef struct
161 {
162 	int scriptStackHead, scriptStackChangeTime;
163 	int scriptEventIndex;       // current event containing stack of actions to perform
164 	// scripting system variables
165 	int scriptId;                   // incremented each time the script changes
166 	int scriptFlags;
167 	char    *animatingParams;
168 } g_script_status_t;
169 //
170 #define G_MAX_SCRIPT_ACCUM_BUFFERS  8
171 //
172 void G_Script_ScriptEvent( gentity_t *ent, char *eventStr, char *params );
173 //====================================================================
174 
175 
176 #define CFOFS( x ) ( (int)&( ( (gclient_t *)0 )->x ) )
177 
178 struct gentity_s {
179 	entityState_t s;                // communicated by server to clients
180 	entityShared_t r;               // shared by both the server system and game
181 
182 	// DO NOT MODIFY ANYTHING ABOVE THIS, THE SERVER
183 	// EXPECTS THE FIELDS IN THAT ORDER!
184 	//================================
185 
186 	struct gclient_s    *client;            // NULL if not a client
187 
188 	qboolean inuse;
189 
190 	char        *classname;         // set in QuakeEd
191 	int spawnflags;                 // set in QuakeEd
192 
193 	qboolean neverFree;             // if true, FreeEntity will only unlink
194 									// bodyque uses this
195 
196 	int flags;                      // FL_* variables
197 
198 	char        *model;
199 	char        *model2;
200 	int freetime;                   // level.time when the object was freed
201 
202 	int eventTime;                  // events will be cleared EVENT_VALID_MSEC after set
203 	qboolean freeAfterEvent;
204 	qboolean unlinkAfterEvent;
205 
206 	qboolean physicsObject;         // if true, it can be pushed by movers and fall off edges
207 									// all game items are physicsObjects,
208 	float physicsBounce;            // 1.0 = continuous bounce, 0.0 = no bounce
209 	int clipmask;                   // brushes with this content value will be collided against
210 									// when moving.  items and corpses do not collide against
211 									// players, for instance
212 
213 	// movers
214 	moverState_t moverState;
215 	int soundPos1;
216 	int sound1to2;
217 	int sound2to1;
218 	int soundPos2;
219 	int soundLoop;
220 	// JOSEPH 1-26-00
221 	int sound2to3;
222 	int sound3to2;
223 	int soundPos3;
224 	// END JOSEPH
225 
226 	int soundKicked;
227 	int soundKickedEnd;
228 
229 	int soundSoftopen;
230 	int soundSoftendo;
231 	int soundSoftclose;
232 	int soundSoftendc;
233 
234 	gentity_t   *parent;
235 	gentity_t   *nextTrain;
236 	gentity_t   *prevTrain;
237 	// JOSEPH 1-26-00
238 	vec3_t pos1, pos2, pos3;
239 	// END JOSEPH
240 
241 	char        *message;
242 
243 	int timestamp;              // body queue sinking, etc
244 
245 	float		angle;			// set in editor, -1 = up, -2 = down
246 	char        *target;
247 	char        *targetname;
248 	char        *team;
249 	char        *targetShaderName;
250 	char        *targetShaderNewName;
251 	gentity_t   *target_ent;
252 
253 	float speed;
254 	float closespeed;           // for movers that close at a different speed than they open
255 	vec3_t movedir;
256 
257 	int gDuration;
258 	int gDurationBack;
259 	vec3_t gDelta;
260 	vec3_t gDeltaBack;
261 
262 	int nextthink;
263 	void ( *think )( gentity_t *self );
264 	void ( *reached )( gentity_t *self );       // movers call this when hitting endpoint
265 	void ( *blocked )( gentity_t *self, gentity_t *other );
266 	void ( *touch )( gentity_t *self, gentity_t *other, trace_t *trace );
267 	void ( *use )( gentity_t *self, gentity_t *other, gentity_t *activator );
268 	void ( *pain )( gentity_t *self, gentity_t *attacker, int damage, vec3_t point );
269 	void ( *die )( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod );
270 
271 	int pain_debounce_time;
272 	int fly_sound_debounce_time;            // wind tunnel
273 	int last_move_time;
274 
275 	int health;
276 
277 	qboolean takedamage;
278 
279 	int damage;
280 	int splashDamage;           // quad will increase this without increasing radius
281 	int splashRadius;
282 	int methodOfDeath;
283 	int splashMethodOfDeath;
284 
285 	int count;
286 
287 	gentity_t   *chain;
288 	gentity_t   *enemy;
289 	gentity_t   *activator;
290 	gentity_t   *teamchain;     // next entity in team
291 	gentity_t   *teammaster;    // master of the team
292 
293 	int watertype;
294 	int waterlevel;
295 
296 	int noise_index;
297 
298 	// timing variables
299 	float wait;
300 	float random;
301 
302 	// Rafael - sniper variable
303 	// sniper uses delay, random, radius
304 	int radius;
305 	float delay;
306 
307 	// JOSEPH 10-11-99
308 	int TargetFlag;
309 	float duration;
310 	vec3_t rotate;
311 	vec3_t TargetAngles;
312 	// END JOSEPH
313 
314 	gitem_t     *item;          // for bonus items
315 
316 	// Ridah, AI fields
317 	char        *aiAttributes;
318 	char        *aiName;
319 	int aiTeam;
320 	void ( *AIScript_AlertEntity )( gentity_t *ent );
321 	qboolean aiInactive;
322 	int aiCharacter;            // the index of the type of character we are (from aicast_soldier.c)
323 	// done.
324 
325 	char        *aiSkin;
326 	char        *aihSkin;
327 
328 	vec3_t dl_color;
329 	char        *dl_stylestring;
330 	char        *dl_shader;
331 	int dl_atten;
332 
333 
334 	int key;                    // used by:  target_speaker->nopvs,
335 
336 	qboolean active;
337 	qboolean botDelayBegin;
338 
339 	// Rafael - mg42
340 	float harc;
341 	float varc;
342 
343 	int props_frame_state;
344 
345 	// Ridah
346 	int missionLevel;               // mission we are currently trying to complete
347 									// gets reset each new level
348 	// done.
349 
350 	// Rafael
351 	qboolean is_dead;
352 	// done
353 
354 	int start_size;
355 	int end_size;
356 
357 	// Rafael props
358 
359 	qboolean isProp;
360 
361 	int mg42BaseEnt;
362 
363 	gentity_t   *melee;
364 
365 	char        *spawnitem;
366 
367 	qboolean nopickup;
368 
369 	int flameQuota, flameQuotaTime, flameBurnEnt;
370 
371 	int count2;
372 
373 	int grenadeExplodeTime;         // we've caught a grenade, which was due to explode at this time
374 	int grenadeFired;               // the grenade entity we last fired
375 
376 	int mg42ClampTime;              // time to wait before an AI decides to ditch the mg42
377 
378 	char        *track;
379 
380 	// entity scripting system
381 	char                *scriptName;
382 
383 	int numScriptEvents;
384 	g_script_event_t    *scriptEvents;  // contains a list of actions to perform for each event type
385 	g_script_status_t scriptStatus;     // current status of scripting
386 	// the accumulation buffer
387 	int scriptAccumBuffer[G_MAX_SCRIPT_ACCUM_BUFFERS];
388 
389 	qboolean AASblocking;
390 	float accuracy;
391 
392 	char        *tagName;       // name of the tag we are attached to
393 	gentity_t   *tagParent;
394 
395 	float headshotDamageScale;
396 
397 	int lastHintCheckTime;                  // DHM - Nerve
398 	// -------------------------------------------------------------------------------------------
399 	// if working on a post release patch, new variables should ONLY be inserted after this point
400 	// DHM - Nerve :: the above warning does not really apply to MP, but I'll follow it for good measure
401 
402 	int voiceChatSquelch;                   // DHM - Nerve
403 	int voiceChatPreviousTime;              // DHM - Nerve
404 	int lastBurnedFrameNumber;              // JPW - Nerve   : to fix FT instant-kill exploit
405 };
406 
407 // Ridah
408 #include "ai_cast_global.h"
409 // done.
410 
411 typedef enum {
412 	CON_DISCONNECTED,
413 	CON_CONNECTING,
414 	CON_CONNECTED
415 } clientConnected_t;
416 
417 typedef enum {
418 	SPECTATOR_NOT,
419 	SPECTATOR_FREE,
420 	SPECTATOR_FOLLOW,
421 	SPECTATOR_SCOREBOARD
422 } spectatorState_t;
423 
424 typedef enum {
425 	TEAM_BEGIN,     // Beginning a team game, spawn at base
426 	TEAM_ACTIVE     // Now actively playing
427 } playerTeamStateState_t;
428 
429 typedef struct {
430 	playerTeamStateState_t state;
431 
432 	int location;
433 
434 	int captures;
435 	int basedefense;
436 	int carrierdefense;
437 	int flagrecovery;
438 	int fragcarrier;
439 	int assists;
440 
441 	float lasthurtcarrier;
442 	float lastreturnedflag;
443 	float flagsince;
444 	float lastfraggedcarrier;
445 } playerTeamState_t;
446 
447 // client data that stays across multiple levels or tournament restarts
448 // this is achieved by writing all the data to cvar strings at game shutdown
449 // time and reading them back at connection time.  Anything added here
450 // MUST be dealt with in G_InitSessionData() / G_ReadSessionData() / G_WriteSessionData()
451 typedef struct {
452 	team_t sessionTeam;
453 	int spectatorNum;		// for determining next-in-line to play
454 	spectatorState_t spectatorState;
455 	int spectatorClient;            // for chasecam and follow mode
456 	int wins, losses;               // tournament stats
457 	int playerType;                 // DHM - Nerve :: for GT_WOLF
458 	int playerWeapon;               // DHM - Nerve :: for GT_WOLF
459 	int playerItem;                 // DHM - Nerve :: for GT_WOLF
460 	int playerSkin;                 // DHM - Nerve :: for GT_WOLF
461 	int spawnObjectiveIndex;         // JPW NERVE index of objective to spawn nearest to (returned from UI)
462 	int latchPlayerType;            // DHM - Nerve :: for GT_WOLF not archived
463 	int latchPlayerWeapon;          // DHM - Nerve :: for GT_WOLF not archived
464 	int latchPlayerItem;            // DHM - Nerve :: for GT_WOLF not archived
465 	int latchPlayerSkin;            // DHM - Nerve :: for GT_WOLF not archived
466 } clientSession_t;
467 
468 //
469 #define MAX_NETNAME         36
470 #define MAX_VOTE_COUNT      3
471 
472 #define PICKUP_ACTIVATE 0   // pickup items only when using "+activate"
473 #define PICKUP_TOUCH    1   // pickup items when touched
474 #define PICKUP_FORCE    2   // pickup the next item when touched (and reset to PICKUP_ACTIVATE when done)
475 
476 // client data that stays across multiple respawns, but is cleared
477 // on each level change or team change at ClientBegin()
478 typedef struct {
479 	clientConnected_t connected;
480 	usercmd_t cmd;                  // we would lose angles if not persistant
481 	usercmd_t oldcmd;               // previous command processed by pmove()
482 	qboolean localClient;           // true if "ip" info key is "localhost"
483 	qboolean initialSpawn;          // the first spawn should be at a cool location
484 	qboolean predictItemPickup;     // based on cg_predictItems userinfo
485 	qboolean pmoveFixed;            //
486 	char netname[MAX_NETNAME];
487 
488 	int autoActivate;               // based on cg_autoactivate userinfo		(uses the PICKUP_ values above)
489 	int emptySwitch;                // based on cg_emptyswitch userinfo (means "switch my weapon for me when ammo reaches '0' rather than -1)
490 
491 	int maxHealth;                  // for handicapping
492 	int enterTime;                  // level.time the client entered the game
493 	int connectTime;                // DHM - Nerve :: level.time the client first connected to the server
494 	playerTeamState_t teamState;    // status in teamplay games
495 	int voteCount;                  // to prevent people from constantly calling votes
496 	int teamVoteCount;              // to prevent people from constantly calling votes
497 
498 	int complaints;                     // DHM - Nerve :: number of complaints lodged against this client
499 	int complaintClient;                // DHM - Nerve :: able to lodge complaint against this client
500 	int complaintEndTime;               // DHM - Nerve :: until this time has expired
501 
502 	int lastReinforceTime;              // DHM - Nerve :: last reinforcement
503 
504 	qboolean teamInfo;              // send team overlay updates?
505 
506 	qboolean bAutoReloadAux; // TTimo - auxiliary storage for pmoveExt_t::bAutoReload, to achieve persistance
507 } clientPersistant_t;
508 
509 typedef struct {
510 	vec3_t mins;
511 	vec3_t maxs;
512 
513 	vec3_t origin;
514 
515 	int time;
516 	int servertime;
517 } clientMarker_t;
518 
519 #define MAX_CLIENT_MARKERS 10
520 
521 #define LT_SPECIAL_PICKUP_MOD   3       // JPW NERVE # of times (minus one for modulo) LT must drop ammo before scoring a point
522 #define MEDIC_SPECIAL_PICKUP_MOD    4   // JPW NERVE same thing for medic
523 
524 // this structure is cleared on each ClientSpawn(),
525 // except for 'client->pers' and 'client->sess'
526 struct gclient_s {
527 	// ps MUST be the first element, because the server expects it
528 	playerState_t ps;               // communicated by server to clients
529 
530 	// the rest of the structure is private to game
531 	clientPersistant_t pers;
532 	clientSession_t sess;
533 
534 	qboolean readyToExit;           // wishes to leave the intermission
535 
536 	qboolean noclip;
537 
538 	int lastCmdTime;                // level.time of last usercmd_t, for EF_CONNECTION
539 									// we can't just use pers.lastCommand.time, because
540 									// of the g_sycronousclients case
541 	int buttons;
542 	int oldbuttons;
543 	int latched_buttons;
544 
545 	int wbuttons;
546 	int oldwbuttons;
547 	int latched_wbuttons;
548 	vec3_t oldOrigin;
549 
550 	// sum up damage over an entire frame, so
551 	// shotgun blasts give a single big kick
552 	int damage_armor;               // damage absorbed by armor
553 	int damage_blood;               // damage taken out of health
554 	int damage_knockback;           // impact damage
555 	vec3_t damage_from;             // origin for vector calculation
556 	qboolean damage_fromWorld;      // if true, don't use the damage_from vector
557 
558 	int accurateCount;              // for "impressive" reward sound
559 
560 	int accuracy_shots;             // total number of shots
561 	int accuracy_hits;              // total number of hits
562 
563 	//
564 	int lastkilled_client;          // last client that this client killed
565 	int lasthurt_client;            // last client that damaged this client
566 	int lasthurt_mod;               // type of damage the client did
567 
568 	// timers
569 	int respawnTime;                // can respawn when time > this, force after g_forcerespwan
570 	int inactivityTime;             // kick players when time > this
571 	qboolean inactivityWarning;     // qtrue if the five seoond warning has been given
572 	int rewardTime;                 // clear the EF_AWARD_IMPRESSIVE, etc when time > this
573 
574 	int airOutTime;
575 
576 	int lastKillTime;               // for multiple kill rewards
577 
578 	qboolean fireHeld;              // used for hook
579 	gentity_t   *hook;              // grapple hook if out
580 
581 	int switchTeamTime;             // time the player switched teams
582 
583 	// timeResidual is used to handle events that happen every second
584 	// like health / armor countdowns and regeneration
585 	int timeResidual;
586 
587 	float currentAimSpreadScale;
588 
589 	int medicHealAmt;
590 
591 	// RF, may be shared by multiple clients/characters
592 	animModelInfo_t *modelInfo;
593 
594 	// -------------------------------------------------------------------------------------------
595 	// if working on a post release patch, new variables should ONLY be inserted after this point
596 
597 	gentity_t   *persistantPowerup;
598 	int portalID;
599 	int ammoTimes[WP_NUM_WEAPONS];
600 	int invulnerabilityTime;
601 
602 	gentity_t   *cameraPortal;              // grapple hook if out
603 	vec3_t cameraOrigin;
604 
605 	int dropWeaponTime;         // JPW NERVE last time a weapon was dropped
606 	int limboDropWeapon;         // JPW NERVE weapon to drop in limbo
607 	int deployQueueNumber;         // JPW NERVE player order in reinforcement FIFO queue
608 	int sniperRifleFiredTime;         // JPW NERVE last time a sniper rifle was fired (for muzzle flip effects)
609 	float sniperRifleMuzzleYaw;       // JPW NERVE for time-dependent muzzle flip in multiplayer
610 	int lastBurnTime;         // JPW NERVE last time index for flamethrower burn
611 	int PCSpecialPickedUpCount;         // JPW NERVE used to count # of times somebody's picked up this LTs ammo (or medic health) (for scoring)
612 	int saved_persistant[MAX_PERSISTANT];           // DHM - Nerve :: Save ps->persistant here during Limbo
613 
614 	// g_antilag.c
615 	int topMarker;
616 	clientMarker_t clientMarkers[MAX_CLIENT_MARKERS];
617 	clientMarker_t backupMarker;
618 
619 	gentity_t       *tempHead;  // Gordon: storing a temporary head for bullet head shot detection
620 
621 	pmoveExt_t pmext;
622 };
623 
624 
625 //
626 // this structure is cleared as each map is entered
627 //
628 #define MAX_SPAWN_VARS          64
629 #define MAX_SPAWN_VARS_CHARS    2048
630 
631 typedef struct {
632 	struct gclient_s    *clients;       // [maxclients]
633 
634 	struct gentity_s    *gentities;
635 	int gentitySize;
636 	int num_entities;               // MAX_CLIENTS <= num_entities <= ENTITYNUM_MAX_NORMAL
637 
638 	int warmupTime;                 // restart match at this time
639 
640 	fileHandle_t logFile;
641 
642 	// store latched cvars here that we want to get at often
643 	int maxclients;
644 
645 	int framenum;
646 	int time;                           // in msec
647 	int previousTime;                   // so movers can back up when blocked
648 	int frameTime;                      // Gordon: time the frame started, for antilag stuff
649 
650 	int startTime;                      // level.time the map was started
651 
652 	int teamScores[TEAM_NUM_TEAMS];
653 	int lastTeamLocationTime;               // last time of client team location update
654 
655 	qboolean newSession;                // don't use any old session data, because
656 										// we changed gametype
657 
658 	qboolean restarted;                 // waiting for a map_restart to fire
659 
660 	int numConnectedClients;
661 	int numNonSpectatorClients;         // includes connecting clients
662 	int numPlayingClients;              // connected, non-spectators
663 	int sortedClients[MAX_CLIENTS];             // sorted by score
664 	int follow1, follow2;               // clientNums for auto-follow spectators
665 
666 	int snd_fry;                        // sound index for standing in lava
667 
668 	int warmupModificationCount;            // for detecting if g_warmup is changed
669 
670 	// voting state
671 	char voteString[MAX_STRING_CHARS];
672 	char voteDisplayString[MAX_STRING_CHARS];
673 	int voteTime;                       // level.time vote was called
674 	int voteExecuteTime;                // time the vote is executed
675 	int prevVoteExecuteTime;            // JPW NERVE last vote execute time
676 	int voteYes;
677 	int voteNo;
678 	int numVotingClients;               // set by CalculateRanks
679 
680 	// team voting state
681 	char teamVoteString[2][MAX_STRING_CHARS];
682 	int teamVoteTime[2];                // level.time vote was called
683 	int teamVoteYes[2];
684 	int teamVoteNo[2];
685 	int numteamVotingClients[2];        // set by CalculateRanks
686 
687 	// spawn variables
688 	qboolean spawning;                  // the G_Spawn*() functions are valid
689 	int numSpawnVars;
690 	char        *spawnVars[MAX_SPAWN_VARS][2];  // key / value pairs
691 	int numSpawnVarChars;
692 	char spawnVarChars[MAX_SPAWN_VARS_CHARS];
693 
694 	// intermission state
695 	int intermissionQueued;             // intermission was qualified, but
696 										// wait INTERMISSION_DELAY_TIME before
697 										// actually going there so the last
698 										// frag can be watched.  Disable future
699 										// kills during this delay
700 	int intermissiontime;               // time the intermission was started
701 	char        *changemap;
702 	qboolean readyToExit;               // at least one client wants to exit
703 	int exitTime;
704 	vec3_t intermission_origin;         // also used for spectator spawns
705 	vec3_t intermission_angle;
706 
707 	qboolean locationLinked;            // target_locations get linked
708 	gentity_t   *locationHead;          // head of the location list
709 	int bodyQueIndex;                   // dead bodies
710 	gentity_t   *bodyQue[BODY_QUEUE_SIZE];
711 
712 	int portalSequence;
713 	// Ridah
714 	char        *scriptAI;
715 	int reloadPauseTime;                // don't think AI/client's until this time has elapsed
716 	int reloadDelayTime;                // don't start loading the savegame until this has expired
717 
718 	int lastGrenadeKick;
719 
720 	int loperZapSound;
721 	int stimSoldierFlySound;
722 	int bulletRicochetSound;
723 	// done.
724 
725 	int snipersound;
726 
727 	//----(SA)	added
728 	int knifeSound[4];
729 	//----(SA)	end
730 
731 // JPW NERVE
732 	int capturetimes[4];         // red, blue, none, spectator for WOLF_MP_CPH
733 	int redReinforceTime, blueReinforceTime;         // last time reinforcements arrived in ms
734 	int redNumWaiting, blueNumWaiting;         // number of reinforcements in queue
735 	vec3_t spawntargets[MAX_MULTI_SPAWNTARGETS];      // coordinates of spawn targets
736 	int numspawntargets;         // # spawntargets in this map
737 // jpw
738 
739 	// RF, entity scripting
740 	char        *scriptEntity;
741 
742 	// player/AI model scripting (server repository)
743 	animScriptData_t animScriptData;
744 
745 	// NERVE - SMF - debugging/profiling info
746 	int totalHeadshots;
747 	int missedHeadshots;
748 	qboolean lastRestartTime;
749 	// -NERVE - SMF
750 
751 	int numFinalDead[2];                // DHM - Nerve :: unable to respawn and in limbo (per team)
752 	int numOidTriggers;                 // DHM - Nerve
753 
754 	qboolean latchGametype;             // DHM - Nerve
755 } level_locals_t;
756 
757 extern qboolean reloading;                  // loading up a savegame
758 // JPW NERVE
759 extern char testid1[];
760 extern char testid2[];
761 extern char testid3[];
762 // jpw
763 
764 //
765 // g_spawn.c
766 //
767 qboolean    G_SpawnString( const char *key, const char *defaultString, char **out );
768 // spawn string returns a temporary reference, you must CopyString() if you want to keep it
769 qboolean    G_SpawnFloat( const char *key, const char *defaultString, float *out );
770 qboolean    G_SpawnInt( const char *key, const char *defaultString, int *out );
771 qboolean    G_SpawnVector( const char *key, const char *defaultString, float *out );
772 void        G_SpawnEntitiesFromString( void );
773 char *G_NewString( const char *string );
774 // Ridah
775 qboolean G_CallSpawn( gentity_t *ent );
776 // done.
777 
778 //
779 // g_cmds.c
780 //
781 void Cmd_Score_f( gentity_t *ent );
782 void StopFollowing( gentity_t *ent );
783 //void BroadcastTeamChange( gclient_t *client, int oldTeam );
784 void SetTeam( gentity_t *ent, const char *s );
785 void SetWolfData( gentity_t *ent, char *ptype, char *weap, char *grenade, char *skinnum );  // DHM - Nerve
786 void Cmd_FollowCycle_f( gentity_t *ent, int dir );
787 
788 //
789 // g_items.c
790 //
791 void G_CheckTeamItems( void );
792 void G_RunItem( gentity_t *ent );
793 void RespawnItem( gentity_t *ent );
794 
795 void UseHoldableItem( gentity_t *ent, int item );
796 void PrecacheItem( gitem_t *it );
797 gentity_t *Drop_Item( gentity_t *ent, gitem_t *item, float angle, qboolean novelocity );
798 gentity_t *LaunchItem( gitem_t *item, vec3_t origin, vec3_t velocity, int ownerNum );
799 void SetRespawn( gentity_t *ent, float delay );
800 void G_SpawnItem( gentity_t *ent, gitem_t *item );
801 void FinishSpawningItem( gentity_t *ent );
802 void Think_Weapon( gentity_t *ent );
803 int ArmorIndex( gentity_t *ent );
804 void Fill_Clip( playerState_t *ps, int weapon );
805 void    Add_Ammo( gentity_t *ent, int weapon, int count, qboolean fillClip );
806 void Touch_Item( gentity_t *ent, gentity_t *other, trace_t *trace );
807 
808 // Touch_Item_Auto is bound by the rules of autoactivation (if cg_autoactivate is 0, only touch on "activate")
809 void Touch_Item_Auto( gentity_t *ent, gentity_t *other, trace_t *trace );
810 
811 void ClearRegisteredItems( void );
812 void RegisterItem( gitem_t *item );
813 void SaveRegisteredItems( void );
814 void Prop_Break_Sound( gentity_t *ent );
815 void Spawn_Shard( gentity_t *ent, gentity_t *inflictor, int quantity, int type );
816 
817 //
818 // g_utils.c
819 //
820 // Ridah
821 int G_FindConfigstringIndex( const char *name, int start, int max, qboolean create );
822 // done.
823 int G_ModelIndex( char *name );
824 int     G_SoundIndex( const char *name );
825 void    G_TeamCommand( team_t team, char *cmd );
826 void    G_KillBox( gentity_t *ent );
827 gentity_t *G_Find( gentity_t *from, int fieldofs, const char *match );
828 gentity_t *G_PickTarget( char *targetname );
829 void    G_UseTargets( gentity_t *ent, gentity_t *activator );
830 void    G_SetMovedir( vec3_t angles, vec3_t movedir );
831 
832 void    G_InitGentity( gentity_t *e );
833 gentity_t   *G_Spawn( void );
834 gentity_t *G_TempEntity( vec3_t origin, int event );
835 void    G_Sound( gentity_t *ent, int soundIndex );
836 void    G_AnimScriptSound( int soundIndex, vec3_t org, int client );
837 void    G_FreeEntity( gentity_t *e );
838 //qboolean	G_EntitiesFree( void );
839 
840 void    G_TouchTriggers( gentity_t *ent );
841 
842 float   *tv( float x, float y, float z );
843 char    *vtos( const vec3_t v );
844 
845 void G_AddPredictableEvent( gentity_t *ent, int event, int eventParm );
846 void G_AddEvent( gentity_t *ent, int event, int eventParm );
847 void G_SetOrigin( gentity_t *ent, vec3_t origin );
848 void AddRemap( const char *oldShader, const char *newShader, float timeOffset );
849 const char *BuildShaderStateConfig( void );
850 void G_SetAngle( gentity_t *ent, vec3_t angle );
851 
852 qboolean infront( gentity_t *self, gentity_t *other );
853 
854 void G_ProcessTagConnect( gentity_t *ent );
855 
856 //
857 // g_combat.c
858 //
859 qboolean CanDamage( gentity_t *targ, vec3_t origin );
860 void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, vec3_t dir, vec3_t point, int damage, int dflags, int mod );
861 qboolean G_RadiusDamage( vec3_t origin, gentity_t *attacker, float damage, float radius, gentity_t *ignore, int mod );
862 void body_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath );
863 void TossClientItems( gentity_t *self );
864 gentity_t* G_BuildHead( gentity_t *ent );
865 
866 // damage flags
867 #define DAMAGE_RADIUS           0x00000001  // damage was indirect
868 #define DAMAGE_NO_ARMOR         0x00000002  // armour does not protect from this damage
869 #define DAMAGE_NO_KNOCKBACK     0x00000008  // do not affect velocity, just view angles
870 #define DAMAGE_NO_PROTECTION    0x00000020  // armor, shields, invulnerability, and godmode have no effect
871 #define DAMAGE_NO_TEAM_PROTECTION   0x00000010  // armor, shields, invulnerability, and godmode have no effect
872 
873 //
874 // g_missile.c
875 //
876 void G_RunMissile( gentity_t *ent );
877 int G_PredictMissile( gentity_t *ent, int duration, vec3_t endPos, qboolean allowBounce );
878 
879 // Rafael zombiespit
880 void G_RunDebris( gentity_t *ent );
881 
882 //DHM - Nerve :: server side flamethrower collision
883 void G_RunFlamechunk( gentity_t *ent );
884 
885 //----(SA) removed unused q3a weapon firing
886 gentity_t *fire_flamechunk( gentity_t *self, vec3_t start, vec3_t dir );
887 
888 gentity_t *fire_grenade( gentity_t *self, vec3_t start, vec3_t aimdir, int grenadeWPID );
889 gentity_t *fire_rocket( gentity_t *self, vec3_t start, vec3_t dir );
890 gentity_t *fire_speargun( gentity_t *self, vec3_t start, vec3_t dir );
891 
892 //----(SA)	added from MP
893 gentity_t *fire_nail( gentity_t *self, vec3_t start, vec3_t forward, vec3_t right, vec3_t up );
894 gentity_t *fire_prox( gentity_t *self, vec3_t start, vec3_t aimdir );
895 //----(SA)	end
896 
897 // Rafael sniper
898 void fire_lead( gentity_t *self,  vec3_t start, vec3_t dir, int damage );
899 qboolean visible( gentity_t *self, gentity_t *other );
900 
901 gentity_t *fire_mortar( gentity_t *self, vec3_t start, vec3_t dir );
902 gentity_t *fire_flamebarrel( gentity_t *self, vec3_t start, vec3_t dir );
903 // done
904 
905 //
906 // g_mover.c
907 //
908 gentity_t *G_TestEntityPosition( gentity_t *ent );
909 void G_RunMover( gentity_t *ent );
910 void Use_BinaryMover( gentity_t *ent, gentity_t *other, gentity_t *activator );
911 void G_Activate( gentity_t *ent, gentity_t *activator );
912 
913 void G_TryDoor( gentity_t *ent, gentity_t *other, gentity_t *activator ); //----(SA)	added
914 
915 void InitMoverRotate( gentity_t *ent );
916 
917 void InitMover( gentity_t *ent );
918 void SetMoverState( gentity_t *ent, moverState_t moverState, int time );
919 
920 //
921 // g_tramcar.c
922 //
923 void Reached_Tramcar( gentity_t *ent );
924 
925 
926 //
927 // g_misc.c
928 //
929 void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles );
930 void mg42_fire( gentity_t *other );
931 
932 
933 //
934 // g_weapon.c
935 //
936 qboolean LogAccuracyHit( gentity_t *target, gentity_t *attacker );
937 void CalcMuzzlePoint( gentity_t *ent, int weapon, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint );
938 void SnapVectorTowards( vec3_t v, vec3_t to );
939 trace_t *CheckMeleeAttack( gentity_t *ent, float dist, qboolean isTest );
940 gentity_t *weapon_grenadelauncher_fire( gentity_t *ent, int grenadeWPID );
941 // Rafael
942 
943 void CalcMuzzlePoints( gentity_t *ent, int weapon );
944 
945 // Rafael - for activate
946 void CalcMuzzlePointForActivate( gentity_t *ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint );
947 // done.
948 
949 //
950 // g_client.c
951 //
952 int TeamCount( int ignoreClientNum, team_t team );
953 team_t PickTeam( int ignoreClientNum );
954 void SetClientViewAngle( gentity_t *ent, vec3_t angle );
955 gentity_t *SelectSpawnPoint( vec3_t avoidPoint, vec3_t origin, vec3_t angles );
956 void ClientRespawn(gentity_t *ent);
957 void BeginIntermission( void );
958 void InitBodyQue( void );
959 void ClientSpawn( gentity_t *ent, qboolean revived );
960 void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod );
961 void AddScore( gentity_t *ent, int score );
962 void CalculateRanks( void );
963 qboolean SpotWouldTelefrag( gentity_t *spot );
964 
965 //
966 // g_svcmds.c
967 //
968 qboolean    ConsoleCommand( void );
969 void G_ProcessIPBans( void );
970 qboolean G_FilterPacket( char *from );
971 qboolean G_FilterMaxLivesPacket( char *from );
972 void AddMaxLivesGUID( char *str );
973 void ClearMaxLivesGUID( void );
974 
975 //
976 // g_weapon.c
977 //
978 void G_BurnMeGood( gentity_t *self, gentity_t *body );
979 void FireWeapon( gentity_t *ent );
980 
981 //
982 // g_cmds.c
983 //
984 void G_SayTo( gentity_t *ent, gentity_t *other, int mode, int color, const char *name, const char *message, qboolean localize ); // JPW NERVE removed static declaration so it would link
985 void DeathmatchScoreboardMessage( gentity_t *ent );
986 
987 //
988 // g_main.c
989 //
990 void MoveClientToIntermission( gentity_t *ent );
991 void FindIntermissionPoint( void );
992 void G_RunThink( gentity_t *ent );
993 void AddTournamentQueue(gclient_t *client);
994 void QDECL G_LogPrintf( const char *fmt, ... ) __attribute__ ((format (printf, 1, 2)));
995 void SendScoreboardMessageToAllClients( void );
996 void QDECL G_Printf( const char *fmt, ... ) __attribute__ ((format (printf, 1, 2)));
997 void QDECL G_DPrintf( const char *fmt, ... ) __attribute__ ((format (printf, 1, 2)));
998 void QDECL G_Error( const char *fmt, ... ) __attribute__ ((noreturn, format (printf, 1, 2)));
999 
1000 //
1001 // g_client.c
1002 //
1003 char *ClientConnect( int clientNum, qboolean firstTime, qboolean isBot );
1004 void ClientUserinfoChanged( int clientNum );
1005 void ClientDisconnect( int clientNum );
1006 void ClientBegin( int clientNum );
1007 void ClientCommand( int clientNum );
1008 
1009 //
1010 // g_active.c
1011 //
1012 void ClientThink( int clientNum );
1013 void ClientEndFrame( gentity_t *ent );
1014 void G_RunClient( gentity_t *ent );
1015 
1016 //
1017 // g_team.c
1018 //
1019 qboolean OnSameTeam( gentity_t *ent1, gentity_t *ent2 );
1020 
1021 
1022 //
1023 // g_mem.c
1024 //
1025 void *G_Alloc( int size );
1026 void G_InitMemory( void );
1027 void Svcmd_GameMem_f( void );
1028 
1029 //
1030 // g_session.c
1031 //
1032 void G_ReadSessionData( gclient_t *client );
1033 void G_InitSessionData( gclient_t *client, char *userinfo );
1034 
1035 void G_InitWorldSession( void );
1036 void G_WriteSessionData( void );
1037 
1038 //
1039 // g_bot.c
1040 //
1041 void G_InitBots( qboolean restart );
1042 char *G_GetBotInfoByNumber( int num );
1043 char *G_GetBotInfoByName( const char *name );
1044 void G_CheckBotSpawn( void );
1045 void G_QueueBotBegin( int clientNum );
1046 qboolean G_BotConnect( int clientNum, qboolean restart );
1047 void Svcmd_AddBot_f( void );
1048 
1049 // ai_main.c
1050 #define MAX_FILEPATH            144
1051 
1052 //bot settings
1053 typedef struct bot_settings_s
1054 {
1055 	char characterfile[MAX_FILEPATH];
1056 	float skill;
1057 } bot_settings_t;
1058 
1059 int BotAISetup( int restart );
1060 int BotAIShutdown( int restart );
1061 int BotAILoadMap( int restart );
1062 int BotAISetupClient( int client, struct bot_settings_s *settings );
1063 int BotAIShutdownClient( int client );
1064 int BotAIStartFrame( int time );
1065 void BotTestAAS( vec3_t origin );
1066 
1067 
1068 // g_cmd.c
1069 void Cmd_Activate_f( gentity_t *ent );
1070 int Cmd_WolfKick_f( gentity_t *ent );
1071 // Ridah
1072 
1073 // g_save.c
1074 /*qboolean G_SaveGame(char *username);
1075 void G_LoadGame(char *username);
1076 qboolean G_SavePersistant(char *nextmap);
1077 void G_LoadPersistant(void);
1078 void G_UpdatePlayTime ( void );*/
1079 
1080 // g_script.c
1081 void G_Script_ScriptParse( gentity_t *ent );
1082 qboolean G_Script_ScriptRun( gentity_t *ent );
1083 void G_Script_ScriptEvent( gentity_t *ent, char *eventStr, char *params );
1084 void G_Script_ScriptLoad( void );
1085 
1086 float AngleDifference( float ang1, float ang2 );
1087 
1088 // g_props.c
1089 void Props_Chair_Skyboxtouch( gentity_t *ent );
1090 
1091 #include "g_team.h" // teamplay specific stuff
1092 
1093 
1094 extern level_locals_t level;
1095 extern gentity_t g_entities[];          //DAJ was explicit set to MAX_ENTITIES
1096 extern gentity_t       *g_camEnt;
1097 
1098 #define	FOFS(x) ((size_t)&(((gentity_t *)0)->x))
1099 
1100 extern vmCvar_t g_gametype;
1101 
1102 // Rafael gameskill
1103 extern vmCvar_t g_gameskill;
1104 // done
1105 
1106 extern vmCvar_t g_dedicated;
1107 extern vmCvar_t g_cheats;
1108 extern vmCvar_t g_maxclients;               // allow this many total, including spectators
1109 extern vmCvar_t g_maxGameClients;           // allow this many active
1110 extern vmCvar_t g_minGameClients;           // NERVE - SMF - we need at least this many before match actually starts
1111 extern vmCvar_t g_restarted;
1112 
1113 extern vmCvar_t g_dmflags;
1114 extern vmCvar_t g_fraglimit;
1115 extern vmCvar_t g_timelimit;
1116 extern vmCvar_t g_capturelimit;
1117 extern vmCvar_t g_friendlyFire;
1118 extern vmCvar_t g_password;
1119 extern vmCvar_t g_needpass;
1120 extern vmCvar_t g_gravity;
1121 extern vmCvar_t g_speed;
1122 extern vmCvar_t g_knockback;
1123 extern vmCvar_t g_quadfactor;
1124 extern vmCvar_t g_forcerespawn;
1125 extern vmCvar_t g_inactivity;
1126 extern vmCvar_t g_debugMove;
1127 extern vmCvar_t g_debugAlloc;
1128 extern vmCvar_t g_debugDamage;
1129 extern vmCvar_t g_debugBullets;     //----(SA)	added
1130 extern vmCvar_t g_weaponRespawn;
1131 extern vmCvar_t g_synchronousClients;
1132 extern vmCvar_t g_motd;
1133 extern vmCvar_t g_warmup;
1134 extern vmCvar_t g_voteFlags;
1135 
1136 // DHM - Nerve :: The number of complaints allowed before kick/ban
1137 extern vmCvar_t g_complaintlimit;
1138 extern vmCvar_t g_maxlives;                 // DHM - Nerve :: number of respawns allowed (0==infinite)
1139 extern vmCvar_t g_voiceChatsAllowed;        // DHM - Nerve :: number before spam control
1140 extern vmCvar_t g_alliedmaxlives;           // Xian
1141 extern vmCvar_t g_axismaxlives;             // Xian
1142 extern vmCvar_t g_fastres;                  // Xian - Fast medic res'ing
1143 extern vmCvar_t g_fastResMsec;
1144 extern vmCvar_t g_knifeonly;                // Xian - Wacky Knife-Only rounds
1145 extern vmCvar_t g_enforcemaxlives;          // Xian - Temp ban with maxlives between rounds
1146 
1147 extern vmCvar_t g_weaponTeamRespawn;
1148 extern vmCvar_t g_doWarmup;
1149 extern vmCvar_t g_teamAutoJoin;
1150 extern vmCvar_t g_teamForceBalance;
1151 extern vmCvar_t g_banIPs;
1152 extern vmCvar_t g_filterBan;
1153 extern vmCvar_t g_rankings;
1154 extern vmCvar_t g_enableBreath;
1155 extern vmCvar_t g_smoothClients;
1156 extern vmCvar_t pmove_fixed;
1157 extern vmCvar_t pmove_msec;
1158 
1159 //Rafael
1160 extern vmCvar_t g_autoactivate;
1161 
1162 extern vmCvar_t g_testPain;
1163 
1164 extern vmCvar_t g_missionStats;
1165 extern vmCvar_t ai_scriptName;          // name of AI script file to run (instead of default for that map)
1166 extern vmCvar_t g_scriptName;           // name of script file to run (instead of default for that map)
1167 
1168 extern vmCvar_t g_scriptDebug;
1169 
1170 extern vmCvar_t g_userAim;
1171 
1172 extern vmCvar_t g_forceModel;
1173 
1174 extern vmCvar_t g_mg42arc;
1175 
1176 extern vmCvar_t g_footstepAudibleRange;
1177 // JPW NERVE multiplayer
1178 extern vmCvar_t g_redlimbotime;
1179 extern vmCvar_t g_bluelimbotime;
1180 extern vmCvar_t g_medicChargeTime;
1181 extern vmCvar_t g_engineerChargeTime;
1182 extern vmCvar_t g_LTChargeTime;
1183 extern vmCvar_t g_soldierChargeTime;
1184 extern vmCvar_t sv_screenshake;
1185 // jpw
1186 
1187 // NERVE - SMF
1188 extern vmCvar_t g_warmupLatch;
1189 extern vmCvar_t g_nextTimeLimit;
1190 extern vmCvar_t g_showHeadshotRatio;
1191 extern vmCvar_t g_userTimeLimit;
1192 extern vmCvar_t g_userAlliedRespawnTime;
1193 extern vmCvar_t g_userAxisRespawnTime;
1194 extern vmCvar_t g_currentRound;
1195 extern vmCvar_t g_noTeamSwitching;
1196 extern vmCvar_t g_altStopwatchMode;
1197 extern vmCvar_t g_gamestate;
1198 extern vmCvar_t g_swapteams;
1199 // -NERVE - SMF
1200 
1201 //Gordon
1202 extern vmCvar_t g_antilag;
1203 
1204 extern vmCvar_t g_dbgRevive;
1205 
1206 extern vmCvar_t g_localTeamPref;
1207 
1208 void	trap_Print( const char *text );
1209 void	trap_Error( const char *text ) __attribute__((noreturn));
1210 int     trap_Milliseconds( void );
1211 int	trap_RealTime( qtime_t *qtime );
1212 int     trap_Argc( void );
1213 void    trap_Argv( int n, char *buffer, int bufferLength );
1214 void    trap_Args( char *buffer, int bufferLength );
1215 int     trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode );
1216 void    trap_FS_Read( void *buffer, int len, fileHandle_t f );
1217 int     trap_FS_Write( const void *buffer, int len, fileHandle_t f );
1218 int     trap_FS_Rename( const char *from, const char *to );
1219 void    trap_FS_FCloseFile( fileHandle_t f );
1220 int     trap_FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize );
1221 void    trap_SendConsoleCommand( int exec_when, const char *text );
1222 void    trap_Cvar_Register( vmCvar_t *cvar, const char *var_name, const char *value, int flags );
1223 void    trap_Cvar_Update( vmCvar_t *cvar );
1224 void    trap_Cvar_Set( const char *var_name, const char *value );
1225 int     trap_Cvar_VariableIntegerValue( const char *var_name );
1226 float   trap_Cvar_VariableValue( const char *var_name );
1227 void    trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );
1228 void    trap_LocateGameData( gentity_t *gEnts, int numGEntities, int sizeofGEntity_t, playerState_t *gameClients, int sizeofGameClient );
1229 void    trap_DropClient( int clientNum, const char *reason );
1230 void    trap_SendServerCommand( int clientNum, const char *text );
1231 void    trap_SetConfigstring( int num, const char *string );
1232 void    trap_GetConfigstring( int num, char *buffer, int bufferSize );
1233 void    trap_GetUserinfo( int num, char *buffer, int bufferSize );
1234 void    trap_SetUserinfo( int num, const char *buffer );
1235 void    trap_GetServerinfo( char *buffer, int bufferSize );
1236 void    trap_SetBrushModel( gentity_t *ent, const char *name );
1237 void    trap_Trace( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask );
1238 void    trap_TraceCapsule( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask );
1239 int     trap_PointContents( const vec3_t point, int passEntityNum );
1240 qboolean trap_InPVS( const vec3_t p1, const vec3_t p2 );
1241 qboolean trap_InPVSIgnorePortals( const vec3_t p1, const vec3_t p2 );
1242 void    trap_AdjustAreaPortalState( gentity_t *ent, qboolean open );
1243 qboolean trap_AreasConnected( int area1, int area2 );
1244 void    trap_LinkEntity( gentity_t *ent );
1245 void    trap_UnlinkEntity( gentity_t *ent );
1246 int     trap_EntitiesInBox( const vec3_t mins, const vec3_t maxs, int *entityList, int maxcount );
1247 qboolean trap_EntityContact( const vec3_t mins, const vec3_t maxs, const gentity_t *ent );
1248 qboolean trap_EntityContactCapsule( const vec3_t mins, const vec3_t maxs, const gentity_t *ent );
1249 int     trap_BotAllocateClient( void );
1250 void    trap_BotFreeClient( int clientNum );
1251 void    trap_GetUsercmd( int clientNum, usercmd_t *cmd );
1252 qboolean    trap_GetEntityToken( char *buffer, int bufferSize );
1253 qboolean trap_GetTag( int clientNum, char *tagName, orientation_t * or );
1254 
1255 int     trap_DebugPolygonCreate( int color, int numPoints, vec3_t *points );
1256 void    trap_DebugPolygonDelete( int id );
1257 
1258 int     trap_BotLibSetup( void );
1259 int     trap_BotLibShutdown( void );
1260 int     trap_BotLibVarSet( char *var_name, char *value );
1261 int     trap_BotLibVarGet( char *var_name, char *value, int size );
1262 int     trap_BotLibDefine( char *string );
1263 int     trap_BotLibStartFrame( float time );
1264 int     trap_BotLibLoadMap( const char *mapname );
1265 int     trap_BotLibUpdateEntity( int ent, void /* struct bot_updateentity_s */ *bue );
1266 int     trap_BotLibTest( int parm0, char *parm1, vec3_t parm2, vec3_t parm3 );
1267 
1268 int     trap_BotGetSnapshotEntity( int clientNum, int sequence );
1269 int     trap_BotGetServerCommand( int clientNum, char *message, int size );
1270 //int		trap_BotGetConsoleMessage(int clientNum, char *message, int size);
1271 void    trap_BotUserCommand( int client, usercmd_t *ucmd );
1272 
1273 void        trap_AAS_EntityInfo( int entnum, void /* struct aas_entityinfo_s */ *info );
1274 
1275 int         trap_AAS_Initialized( void );
1276 void        trap_AAS_PresenceTypeBoundingBox( int presencetype, vec3_t mins, vec3_t maxs );
1277 float       trap_AAS_Time( void );
1278 
1279 // Ridah
1280 void        trap_AAS_SetCurrentWorld( int index );
1281 // done.
1282 
1283 int         trap_AAS_PointAreaNum( vec3_t point );
1284 int         trap_AAS_TraceAreas( vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas );
1285 
1286 int         trap_AAS_PointContents( vec3_t point );
1287 int         trap_AAS_NextBSPEntity( int ent );
1288 int         trap_AAS_ValueForBSPEpairKey( int ent, char *key, char *value, int size );
1289 int         trap_AAS_VectorForBSPEpairKey( int ent, char *key, vec3_t v );
1290 int         trap_AAS_FloatForBSPEpairKey( int ent, char *key, float *value );
1291 int         trap_AAS_IntForBSPEpairKey( int ent, char *key, int *value );
1292 
1293 int         trap_AAS_AreaReachability( int areanum );
1294 
1295 int         trap_AAS_AreaTravelTimeToGoalArea( int areanum, vec3_t origin, int goalareanum, int travelflags );
1296 
1297 int         trap_AAS_Swimming( vec3_t origin );
1298 int         trap_AAS_PredictClientMovement( void /* aas_clientmove_s */ *move, int entnum, vec3_t origin, int presencetype, int onground, vec3_t velocity, vec3_t cmdmove, int cmdframes, int maxframes, float frametime, int stopevent, int stopareanum, int visualize );
1299 
1300 // Ridah, route-tables
1301 void        trap_AAS_RT_ShowRoute( vec3_t srcpos, int srcnum, int destnum );
1302 qboolean    trap_AAS_RT_GetHidePos( vec3_t srcpos, int srcnum, int srcarea, vec3_t destpos, int destnum, int destarea, vec3_t returnPos );
1303 int         trap_AAS_FindAttackSpotWithinRange( int srcnum, int rangenum, int enemynum, float rangedist, int travelflags, float *outpos );
1304 void        trap_AAS_SetAASBlockingEntity( vec3_t absmin, vec3_t absmax, qboolean blocking );
1305 // done.
1306 
1307 void    trap_EA_Say( int client, char *str );
1308 void    trap_EA_SayTeam( int client, char *str );
1309 void    trap_EA_UseItem( int client, char *it );
1310 void    trap_EA_DropItem( int client, char *it );
1311 void    trap_EA_UseInv( int client, char *inv );
1312 void    trap_EA_DropInv( int client, char *inv );
1313 void    trap_EA_Gesture( int client );
1314 void    trap_EA_Command( int client, char *command );
1315 
1316 void    trap_EA_SelectWeapon( int client, int weapon );
1317 void    trap_EA_Talk( int client );
1318 void    trap_EA_Attack( int client );
1319 void    trap_EA_Reload( int client );
1320 void    trap_EA_Use( int client );
1321 void    trap_EA_Respawn( int client );
1322 void    trap_EA_Jump( int client );
1323 void    trap_EA_DelayedJump( int client );
1324 void    trap_EA_Crouch( int client );
1325 void    trap_EA_MoveUp( int client );
1326 void    trap_EA_MoveDown( int client );
1327 void    trap_EA_MoveForward( int client );
1328 void    trap_EA_MoveBack( int client );
1329 void    trap_EA_MoveLeft( int client );
1330 void    trap_EA_MoveRight( int client );
1331 void    trap_EA_Move( int client, vec3_t dir, float speed );
1332 void    trap_EA_View( int client, vec3_t viewangles );
1333 
1334 void    trap_EA_EndRegular( int client, float thinktime );
1335 void    trap_EA_GetInput( int client, float thinktime, void /* struct bot_input_s */ *input );
1336 void    trap_EA_ResetInput( int client, void *init );
1337 
1338 
1339 int     trap_BotLoadCharacter( char *charfile, int skill );
1340 void    trap_BotFreeCharacter( int character );
1341 float   trap_Characteristic_Float( int character, int index );
1342 float   trap_Characteristic_BFloat( int character, int index, float min, float max );
1343 int     trap_Characteristic_Integer( int character, int index );
1344 int     trap_Characteristic_BInteger( int character, int index, int min, int max );
1345 void    trap_Characteristic_String( int character, int index, char *buf, int size );
1346 
1347 int     trap_BotAllocChatState( void );
1348 void    trap_BotFreeChatState( int handle );
1349 void    trap_BotQueueConsoleMessage( int chatstate, int type, char *message );
1350 void    trap_BotRemoveConsoleMessage( int chatstate, int handle );
1351 int     trap_BotNextConsoleMessage( int chatstate, void /* struct bot_consolemessage_s */ *cm );
1352 int     trap_BotNumConsoleMessages( int chatstate );
1353 void    trap_BotInitialChat( int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7 );
1354 int     trap_BotNumInitialChats( int chatstate, char *type );
1355 int     trap_BotReplyChat( int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7 );
1356 int     trap_BotChatLength( int chatstate );
1357 void    trap_BotEnterChat( int chatstate, int client, int sendto );
1358 void    trap_BotGetChatMessage( int chatstate, char *buf, int size );
1359 int     trap_StringContains( char *str1, char *str2, int casesensitive );
1360 int     trap_BotFindMatch( char *str, void /* struct bot_match_s */ *match, unsigned long int context );
1361 void    trap_BotMatchVariable( void /* struct bot_match_s */ *match, int variable, char *buf, int size );
1362 void    trap_UnifyWhiteSpaces( char *string );
1363 void    trap_BotReplaceSynonyms( char *string, unsigned long int context );
1364 int     trap_BotLoadChatFile( int chatstate, char *chatfile, char *chatname );
1365 void    trap_BotSetChatGender( int chatstate, int gender );
1366 void    trap_BotSetChatName( int chatstate, char *name );
1367 void    trap_BotResetGoalState( int goalstate );
1368 void    trap_BotRemoveFromAvoidGoals( int goalstate, int number );
1369 void    trap_BotResetAvoidGoals( int goalstate );
1370 void    trap_BotPushGoal( int goalstate, void /* struct bot_goal_s */ *goal );
1371 void    trap_BotPopGoal( int goalstate );
1372 void    trap_BotEmptyGoalStack( int goalstate );
1373 void    trap_BotDumpAvoidGoals( int goalstate );
1374 void    trap_BotDumpGoalStack( int goalstate );
1375 void    trap_BotGoalName( int number, char *name, int size );
1376 int     trap_BotGetTopGoal( int goalstate, void /* struct bot_goal_s */ *goal );
1377 int     trap_BotGetSecondGoal( int goalstate, void /* struct bot_goal_s */ *goal );
1378 int     trap_BotChooseLTGItem( int goalstate, vec3_t origin, int *inventory, int travelflags );
1379 int     trap_BotChooseNBGItem( int goalstate, vec3_t origin, int *inventory, int travelflags, void /* struct bot_goal_s */ *ltg, float maxtime );
1380 int     trap_BotTouchingGoal( vec3_t origin, void /* struct bot_goal_s */ *goal );
1381 int     trap_BotItemGoalInVisButNotVisible( int viewer, vec3_t eye, vec3_t viewangles, void /* struct bot_goal_s */ *goal );
1382 int     trap_BotGetNextCampSpotGoal( int num, void /* struct bot_goal_s */ *goal );
1383 int     trap_BotGetMapLocationGoal( char *name, void /* struct bot_goal_s */ *goal );
1384 int     trap_BotGetLevelItemGoal( int index, char *classname, void /* struct bot_goal_s */ *goal );
1385 float   trap_BotAvoidGoalTime( int goalstate, int number );
1386 void    trap_BotInitLevelItems( void );
1387 void    trap_BotUpdateEntityItems( void );
1388 int     trap_BotLoadItemWeights( int goalstate, char *filename );
1389 void    trap_BotFreeItemWeights( int goalstate );
1390 void    trap_BotInterbreedGoalFuzzyLogic( int parent1, int parent2, int child );
1391 void    trap_BotSaveGoalFuzzyLogic( int goalstate, char *filename );
1392 void    trap_BotMutateGoalFuzzyLogic( int goalstate, float range );
1393 int     trap_BotAllocGoalState( int state );
1394 void    trap_BotFreeGoalState( int handle );
1395 
1396 void    trap_BotResetMoveState( int movestate );
1397 void    trap_BotMoveToGoal( void /* struct bot_moveresult_s */ *result, int movestate, void /* struct bot_goal_s */ *goal, int travelflags );
1398 int     trap_BotMoveInDirection( int movestate, vec3_t dir, float speed, int type );
1399 void    trap_BotResetAvoidReach( int movestate );
1400 void    trap_BotResetLastAvoidReach( int movestate );
1401 int     trap_BotReachabilityArea( vec3_t origin, int testground );
1402 int     trap_BotMovementViewTarget( int movestate, void /* struct bot_goal_s */ *goal, int travelflags, float lookahead, vec3_t target );
1403 int     trap_BotPredictVisiblePosition( vec3_t origin, int areanum, void /* struct bot_goal_s */ *goal, int travelflags, vec3_t target );
1404 int     trap_BotAllocMoveState( void );
1405 void    trap_BotFreeMoveState( int handle );
1406 void    trap_BotInitMoveState( int handle, void /* struct bot_initmove_s */ *initmove );
1407 // Ridah
1408 void    trap_BotInitAvoidReach( int handle );
1409 // done.
1410 
1411 int     trap_BotChooseBestFightWeapon( int weaponstate, int *inventory );
1412 void    trap_BotGetWeaponInfo( int weaponstate, int weapon, void /* struct weaponinfo_s */ *weaponinfo );
1413 int     trap_BotLoadWeaponWeights( int weaponstate, char *filename );
1414 int     trap_BotAllocWeaponState( void );
1415 void    trap_BotFreeWeaponState( int weaponstate );
1416 void    trap_BotResetWeaponState( int weaponstate );
1417 
1418 int     trap_GeneticParentsAndChildSelection( int numranks, float *ranks, int *parent1, int *parent2, int *child );
1419 
1420 void    trap_SnapVector( float *v );
1421 
1422 typedef enum
1423 {
1424 	shard_glass = 0,
1425 	shard_wood,
1426 	shard_metal,
1427 	shard_ceramic,
1428 	shard_rubble
1429 } shards_t;
1430 
1431 // g_antilag.c
1432 void G_StoreClientPosition( gentity_t* ent );
1433 void G_HistoricalTrace( gentity_t* ent, trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask );
1434 void G_ResetMarkers( gentity_t* ent );
1435