Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

g_local.h

Go to the documentation of this file.
00001 /*
00002 ===========================================================================
00003 Copyright (C) 1999-2005 Id Software, Inc.
00004 
00005 This file is part of Quake III Arena source code.
00006 
00007 Quake III Arena source code is free software; you can redistribute it
00008 and/or modify it under the terms of the GNU General Public License as
00009 published by the Free Software Foundation; either version 2 of the License,
00010 or (at your option) any later version.
00011 
00012 Quake III Arena source code is distributed in the hope that it will be
00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Foobar; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 ===========================================================================
00021 */
00022 //
00023 // g_local.h -- local definitions for game module
00024 
00025 #include "q_shared.h"
00026 #include "bg_public.h"
00027 #include "g_public.h"
00028 
00029 //==================================================================
00030 
00031 // the "gameversion" client command will print this plus compile date
00032 #define GAMEVERSION "baseq3"
00033 
00034 #define BODY_QUEUE_SIZE     8
00035 
00036 #define INFINITE            1000000
00037 
00038 #define FRAMETIME           100                 // msec
00039 #define CARNAGE_REWARD_TIME 3000
00040 #define REWARD_SPRITE_TIME  2000
00041 
00042 #define INTERMISSION_DELAY_TIME 1000
00043 #define SP_INTERMISSION_DELAY_TIME  5000
00044 
00045 // gentity->flags
00046 #define FL_GODMODE              0x00000010
00047 #define FL_NOTARGET             0x00000020
00048 #define FL_TEAMSLAVE            0x00000400  // not the first on the team
00049 #define FL_NO_KNOCKBACK         0x00000800
00050 #define FL_DROPPED_ITEM         0x00001000
00051 #define FL_NO_BOTS              0x00002000  // spawn point not for bot use
00052 #define FL_NO_HUMANS            0x00004000  // spawn point just for bots
00053 #define FL_FORCE_GESTURE        0x00008000  // force gesture on client
00054 
00055 // movers are things like doors, plats, buttons, etc
00056 typedef enum {
00057     MOVER_POS1,
00058     MOVER_POS2,
00059     MOVER_1TO2,
00060     MOVER_2TO1
00061 } moverState_t;
00062 
00063 #define SP_PODIUM_MODEL     "models/mapobjects/podium/podium4.md3"
00064 
00065 //============================================================================
00066 
00067 typedef struct gentity_s gentity_t;
00068 typedef struct gclient_s gclient_t;
00069 
00070 struct gentity_s {
00071     entityState_t   s;              // communicated by server to clients
00072     entityShared_t  r;              // shared by both the server system and game
00073 
00074     // DO NOT MODIFY ANYTHING ABOVE THIS, THE SERVER
00075     // EXPECTS THE FIELDS IN THAT ORDER!
00076     //================================
00077 
00078     struct gclient_s    *client;            // NULL if not a client
00079 
00080     qboolean    inuse;
00081 
00082     char        *classname;         // set in QuakeEd
00083     int         spawnflags;         // set in QuakeEd
00084 
00085     qboolean    neverFree;          // if true, FreeEntity will only unlink
00086                                     // bodyque uses this
00087 
00088     int         flags;              // FL_* variables
00089 
00090     char        *model;
00091     char        *model2;
00092     int         freetime;           // level.time when the object was freed
00093     
00094     int         eventTime;          // events will be cleared EVENT_VALID_MSEC after set
00095     qboolean    freeAfterEvent;
00096     qboolean    unlinkAfterEvent;
00097 
00098     qboolean    physicsObject;      // if true, it can be pushed by movers and fall off edges
00099                                     // all game items are physicsObjects, 
00100     float       physicsBounce;      // 1.0 = continuous bounce, 0.0 = no bounce
00101     int         clipmask;           // brushes with this content value will be collided against
00102                                     // when moving.  items and corpses do not collide against
00103                                     // players, for instance
00104 
00105     // movers
00106     moverState_t moverState;
00107     int         soundPos1;
00108     int         sound1to2;
00109     int         sound2to1;
00110     int         soundPos2;
00111     int         soundLoop;
00112     gentity_t   *parent;
00113     gentity_t   *nextTrain;
00114     gentity_t   *prevTrain;
00115     vec3_t      pos1, pos2;
00116 
00117     char        *message;
00118 
00119     int         timestamp;      // body queue sinking, etc
00120 
00121     float       angle;          // set in editor, -1 = up, -2 = down
00122     char        *target;
00123     char        *targetname;
00124     char        *team;
00125     char        *targetShaderName;
00126     char        *targetShaderNewName;
00127     gentity_t   *target_ent;
00128 
00129     float       speed;
00130     vec3_t      movedir;
00131 
00132     int         nextthink;
00133     void        (*think)(gentity_t *self);
00134     void        (*reached)(gentity_t *self);    // movers call this when hitting endpoint
00135     void        (*blocked)(gentity_t *self, gentity_t *other);
00136     void        (*touch)(gentity_t *self, gentity_t *other, trace_t *trace);
00137     void        (*use)(gentity_t *self, gentity_t *other, gentity_t *activator);
00138     void        (*pain)(gentity_t *self, gentity_t *attacker, int damage);
00139     void        (*die)(gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod);
00140 
00141     int         pain_debounce_time;
00142     int         fly_sound_debounce_time;    // wind tunnel
00143     int         last_move_time;
00144 
00145     int         health;
00146 
00147     qboolean    takedamage;
00148 
00149     int         damage;
00150     int         splashDamage;   // quad will increase this without increasing radius
00151     int         splashRadius;
00152     int         methodOfDeath;
00153     int         splashMethodOfDeath;
00154 
00155     int         count;
00156 
00157     gentity_t   *chain;
00158     gentity_t   *enemy;
00159     gentity_t   *activator;
00160     gentity_t   *teamchain;     // next entity in team
00161     gentity_t   *teammaster;    // master of the team
00162 
00163 #ifdef MISSIONPACK
00164     int         kamikazeTime;
00165     int         kamikazeShockTime;
00166 #endif
00167 
00168     int         watertype;
00169     int         waterlevel;
00170 
00171     int         noise_index;
00172 
00173     // timing variables
00174     float       wait;
00175     float       random;
00176 
00177     gitem_t     *item;          // for bonus items
00178 };
00179 
00180 
00181 typedef enum {
00182     CON_DISCONNECTED,
00183     CON_CONNECTING,
00184     CON_CONNECTED
00185 } clientConnected_t;
00186 
00187 typedef enum {
00188     SPECTATOR_NOT,
00189     SPECTATOR_FREE,
00190     SPECTATOR_FOLLOW,
00191     SPECTATOR_SCOREBOARD
00192 } spectatorState_t;
00193 
00194 typedef enum {
00195     TEAM_BEGIN,     // Beginning a team game, spawn at base
00196     TEAM_ACTIVE     // Now actively playing
00197 } playerTeamStateState_t;
00198 
00199 typedef struct {
00200     playerTeamStateState_t  state;
00201 
00202     int         location;
00203 
00204     int         captures;
00205     int         basedefense;
00206     int         carrierdefense;
00207     int         flagrecovery;
00208     int         fragcarrier;
00209     int         assists;
00210 
00211     float       lasthurtcarrier;
00212     float       lastreturnedflag;
00213     float       flagsince;
00214     float       lastfraggedcarrier;
00215 } playerTeamState_t;
00216 
00217 // the auto following clients don't follow a specific client
00218 // number, but instead follow the first two active players
00219 #define FOLLOW_ACTIVE1  -1
00220 #define FOLLOW_ACTIVE2  -2
00221 
00222 // client data that stays across multiple levels or tournament restarts
00223 // this is achieved by writing all the data to cvar strings at game shutdown
00224 // time and reading them back at connection time.  Anything added here
00225 // MUST be dealt with in G_InitSessionData() / G_ReadSessionData() / G_WriteSessionData()
00226 typedef struct {
00227     team_t      sessionTeam;
00228     int         spectatorTime;      // for determining next-in-line to play
00229     spectatorState_t    spectatorState;
00230     int         spectatorClient;    // for chasecam and follow mode
00231     int         wins, losses;       // tournament stats
00232     qboolean    teamLeader;         // true when this client is a team leader
00233 } clientSession_t;
00234 
00235 //
00236 #define MAX_NETNAME         36
00237 #define MAX_VOTE_COUNT      3
00238 
00239 // client data that stays across multiple respawns, but is cleared
00240 // on each level change or team change at ClientBegin()
00241 typedef struct {
00242     clientConnected_t   connected;  
00243     usercmd_t   cmd;                // we would lose angles if not persistant
00244     qboolean    localClient;        // true if "ip" info key is "localhost"
00245     qboolean    initialSpawn;       // the first spawn should be at a cool location
00246     qboolean    predictItemPickup;  // based on cg_predictItems userinfo
00247     qboolean    pmoveFixed;         //
00248     char        netname[MAX_NETNAME];
00249     int         maxHealth;          // for handicapping
00250     int         enterTime;          // level.time the client entered the game
00251     playerTeamState_t teamState;    // status in teamplay games
00252     int         voteCount;          // to prevent people from constantly calling votes
00253     int         teamVoteCount;      // to prevent people from constantly calling votes
00254     qboolean    teamInfo;           // send team overlay updates?
00255 } clientPersistant_t;
00256 
00257 
00258 // this structure is cleared on each ClientSpawn(),
00259 // except for 'client->pers' and 'client->sess'
00260 struct gclient_s {
00261     // ps MUST be the first element, because the server expects it
00262     playerState_t   ps;             // communicated by server to clients
00263 
00264     // the rest of the structure is private to game
00265     clientPersistant_t  pers;
00266     clientSession_t     sess;
00267 
00268     qboolean    readyToExit;        // wishes to leave the intermission
00269 
00270     qboolean    noclip;
00271 
00272     int         lastCmdTime;        // level.time of last usercmd_t, for EF_CONNECTION
00273                                     // we can't just use pers.lastCommand.time, because
00274                                     // of the g_sycronousclients case
00275     int         buttons;
00276     int         oldbuttons;
00277     int         latched_buttons;
00278 
00279     vec3_t      oldOrigin;
00280 
00281     // sum up damage over an entire frame, so
00282     // shotgun blasts give a single big kick
00283     int         damage_armor;       // damage absorbed by armor
00284     int         damage_blood;       // damage taken out of health
00285     int         damage_knockback;   // impact damage
00286     vec3_t      damage_from;        // origin for vector calculation
00287     qboolean    damage_fromWorld;   // if true, don't use the damage_from vector
00288 
00289     int         accurateCount;      // for "impressive" reward sound
00290 
00291     int         accuracy_shots;     // total number of shots
00292     int         accuracy_hits;      // total number of hits
00293 
00294     //
00295     int         lastkilled_client;  // last client that this client killed
00296     int         lasthurt_client;    // last client that damaged this client
00297     int         lasthurt_mod;       // type of damage the client did
00298 
00299     // timers
00300     int         respawnTime;        // can respawn when time > this, force after g_forcerespwan
00301     int         inactivityTime;     // kick players when time > this
00302     qboolean    inactivityWarning;  // qtrue if the five seoond warning has been given
00303     int         rewardTime;         // clear the EF_AWARD_IMPRESSIVE, etc when time > this
00304 
00305     int         airOutTime;
00306 
00307     int         lastKillTime;       // for multiple kill rewards
00308 
00309     qboolean    fireHeld;           // used for hook
00310     gentity_t   *hook;              // grapple hook if out
00311 
00312     int         switchTeamTime;     // time the player switched teams
00313 
00314     // timeResidual is used to handle events that happen every second
00315     // like health / armor countdowns and regeneration
00316     int         timeResidual;
00317 
00318 #ifdef MISSIONPACK
00319     gentity_t   *persistantPowerup;
00320     int         portalID;
00321     int         ammoTimes[WP_NUM_WEAPONS];
00322     int         invulnerabilityTime;
00323 #endif
00324 
00325     char        *areabits;
00326 };
00327 
00328 
00329 //
00330 // this structure is cleared as each map is entered
00331 //
00332 #define MAX_SPAWN_VARS          64
00333 #define MAX_SPAWN_VARS_CHARS    4096
00334 
00335 typedef struct {
00336     struct gclient_s    *clients;       // [maxclients]
00337 
00338     struct gentity_s    *gentities;
00339     int         gentitySize;
00340     int         num_entities;       // current number, <= MAX_GENTITIES
00341 
00342     int         warmupTime;         // restart match at this time
00343 
00344     fileHandle_t    logFile;
00345 
00346     // store latched cvars here that we want to get at often
00347     int         maxclients;
00348 
00349     int         framenum;
00350     int         time;                   // in msec
00351     int         previousTime;           // so movers can back up when blocked
00352 
00353     int         startTime;              // level.time the map was started
00354 
00355     int         teamScores[TEAM_NUM_TEAMS];
00356     int         lastTeamLocationTime;       // last time of client team location update
00357 
00358     qboolean    newSession;             // don't use any old session data, because
00359                                         // we changed gametype
00360 
00361     qboolean    restarted;              // waiting for a map_restart to fire
00362 
00363     int         numConnectedClients;
00364     int         numNonSpectatorClients; // includes connecting clients
00365     int         numPlayingClients;      // connected, non-spectators
00366     int         sortedClients[MAX_CLIENTS];     // sorted by score
00367     int         follow1, follow2;       // clientNums for auto-follow spectators
00368 
00369     int         snd_fry;                // sound index for standing in lava
00370 
00371     int         warmupModificationCount;    // for detecting if g_warmup is changed
00372 
00373     // voting state
00374     char        voteString[MAX_STRING_CHARS];
00375     char        voteDisplayString[MAX_STRING_CHARS];
00376     int         voteTime;               // level.time vote was called
00377     int         voteExecuteTime;        // time the vote is executed
00378     int         voteYes;
00379     int         voteNo;
00380     int         numVotingClients;       // set by CalculateRanks
00381 
00382     // team voting state
00383     char        teamVoteString[2][MAX_STRING_CHARS];
00384     int         teamVoteTime[2];        // level.time vote was called
00385     int         teamVoteYes[2];
00386     int         teamVoteNo[2];
00387     int         numteamVotingClients[2];// set by CalculateRanks
00388 
00389     // spawn variables
00390     qboolean    spawning;               // the G_Spawn*() functions are valid
00391     int         numSpawnVars;
00392     char        *spawnVars[MAX_SPAWN_VARS][2];  // key / value pairs
00393     int         numSpawnVarChars;
00394     char        spawnVarChars[MAX_SPAWN_VARS_CHARS];
00395 
00396     // intermission state
00397     int         intermissionQueued;     // intermission was qualified, but
00398                                         // wait INTERMISSION_DELAY_TIME before
00399                                         // actually going there so the last
00400                                         // frag can be watched.  Disable future
00401                                         // kills during this delay
00402     int         intermissiontime;       // time the intermission was started
00403     char        *changemap;
00404     qboolean    readyToExit;            // at least one client wants to exit
00405     int         exitTime;
00406     vec3_t      intermission_origin;    // also used for spectator spawns
00407     vec3_t      intermission_angle;
00408 
00409     qboolean    locationLinked;         // target_locations get linked
00410     gentity_t   *locationHead;          // head of the location list
00411     int         bodyQueIndex;           // dead bodies
00412     gentity_t   *bodyQue[BODY_QUEUE_SIZE];
00413 #ifdef MISSIONPACK
00414     int         portalSequence;
00415 #endif
00416 } level_locals_t;
00417 
00418 
00419 //
00420 // g_spawn.c
00421 //
00422 qboolean    G_SpawnString( const char *key, const char *defaultString, char **out );
00423 // spawn string returns a temporary reference, you must CopyString() if you want to keep it
00424 qboolean    G_SpawnFloat( const char *key, const char *defaultString, float *out );
00425 qboolean    G_SpawnInt( const char *key, const char *defaultString, int *out );
00426 qboolean    G_SpawnVector( const char *key, const char *defaultString, float *out );
00427 void        G_SpawnEntitiesFromString( void );
00428 char *G_NewString( const char *string );
00429 
00430 //
00431 // g_cmds.c
00432 //
00433 void Cmd_Score_f (gentity_t *ent);
00434 void StopFollowing( gentity_t *ent );
00435 void BroadcastTeamChange( gclient_t *client, int oldTeam );
00436 void SetTeam( gentity_t *ent, char *s );
00437 void Cmd_FollowCycle_f( gentity_t *ent, int dir );
00438 
00439 //
00440 // g_items.c
00441 //
00442 void G_CheckTeamItems( void );
00443 void G_RunItem( gentity_t *ent );
00444 void RespawnItem( gentity_t *ent );
00445 
00446 void UseHoldableItem( gentity_t *ent );
00447 void PrecacheItem (gitem_t *it);
00448 gentity_t *Drop_Item( gentity_t *ent, gitem_t *item, float angle );
00449 gentity_t *LaunchItem( gitem_t *item, vec3_t origin, vec3_t velocity );
00450 void SetRespawn (gentity_t *ent, float delay);
00451 void G_SpawnItem (gentity_t *ent, gitem_t *item);
00452 void FinishSpawningItem( gentity_t *ent );
00453 void Think_Weapon (gentity_t *ent);
00454 int ArmorIndex (gentity_t *ent);
00455 void    Add_Ammo (gentity_t *ent, int weapon, int count);
00456 void Touch_Item (gentity_t *ent, gentity_t *other, trace_t *trace);
00457 
00458 void ClearRegisteredItems( void );
00459 void RegisterItem( gitem_t *item );
00460 void SaveRegisteredItems( void );
00461 
00462 //
00463 // g_utils.c
00464 //
00465 int G_ModelIndex( char *name );
00466 int     G_SoundIndex( char *name );
00467 void    G_TeamCommand( team_t team, char *cmd );
00468 void    G_KillBox (gentity_t *ent);
00469 gentity_t *G_Find (gentity_t *from, int fieldofs, const char *match);
00470 gentity_t *G_PickTarget (char *targetname);
00471 void    G_UseTargets (gentity_t *ent, gentity_t *activator);
00472 void    G_SetMovedir ( vec3_t angles, vec3_t movedir);
00473 
00474 void    G_InitGentity( gentity_t *e );
00475 gentity_t   *G_Spawn (void);
00476 gentity_t *G_TempEntity( vec3_t origin, int event );
00477 void    G_Sound( gentity_t *ent, int channel, int soundIndex );
00478 void    G_FreeEntity( gentity_t *e );
00479 qboolean    G_EntitiesFree( void );
00480 
00481 void    G_TouchTriggers (gentity_t *ent);
00482 void    G_TouchSolids (gentity_t *ent);
00483 
00484 float   *tv (float x, float y, float z);
00485 char    *vtos( const vec3_t v );
00486 
00487 float vectoyaw( const vec3_t vec );
00488 
00489 void G_AddPredictableEvent( gentity_t *ent, int event, int eventParm );
00490 void G_AddEvent( gentity_t *ent, int event, int eventParm );
00491 void G_SetOrigin( gentity_t *ent, vec3_t origin );
00492 void AddRemap(const char *oldShader, const char *newShader, float timeOffset);
00493 const char *BuildShaderStateConfig();
00494 
00495 //
00496 // g_combat.c
00497 //
00498 qboolean CanDamage (gentity_t *targ, vec3_t origin);
00499 void G_Damage (gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, vec3_t dir, vec3_t point, int damage, int dflags, int mod);
00500 qboolean G_RadiusDamage (vec3_t origin, gentity_t *attacker, float damage, float radius, gentity_t *ignore, int mod);
00501 int G_InvulnerabilityEffect( gentity_t *targ, vec3_t dir, vec3_t point, vec3_t impactpoint, vec3_t bouncedir );
00502 void body_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath );
00503 void TossClientItems( gentity_t *self );
00504 #ifdef MISSIONPACK
00505 void TossClientPersistantPowerups( gentity_t *self );
00506 #endif
00507 void TossClientCubes( gentity_t *self );
00508 
00509 // damage flags
00510 #define DAMAGE_RADIUS               0x00000001  // damage was indirect
00511 #define DAMAGE_NO_ARMOR             0x00000002  // armour does not protect from this damage
00512 #define DAMAGE_NO_KNOCKBACK         0x00000004  // do not affect velocity, just view angles
00513 #define DAMAGE_NO_PROTECTION        0x00000008  // armor, shields, invulnerability, and godmode have no effect
00514 #ifdef MISSIONPACK
00515 #define DAMAGE_NO_TEAM_PROTECTION   0x00000010  // armor, shields, invulnerability, and godmode have no effect
00516 #endif
00517 
00518 //
00519 // g_missile.c
00520 //
00521 void G_RunMissile( gentity_t *ent );
00522 
00523 gentity_t *fire_blaster (gentity_t *self, vec3_t start, vec3_t aimdir);
00524 gentity_t *fire_plasma (gentity_t *self, vec3_t start, vec3_t aimdir);
00525 gentity_t *fire_grenade (gentity_t *self, vec3_t start, vec3_t aimdir);
00526 gentity_t *fire_rocket (gentity_t *self, vec3_t start, vec3_t dir);
00527 gentity_t *fire_bfg (gentity_t *self, vec3_t start, vec3_t dir);
00528 gentity_t *fire_grapple (gentity_t *self, vec3_t start, vec3_t dir);
00529 #ifdef MISSIONPACK
00530 gentity_t *fire_nail( gentity_t *self, vec3_t start, vec3_t forward, vec3_t right, vec3_t up );
00531 gentity_t *fire_prox( gentity_t *self, vec3_t start, vec3_t aimdir );
00532 #endif
00533 
00534 
00535 //
00536 // g_mover.c
00537 //
00538 void G_RunMover( gentity_t *ent );
00539 void Touch_DoorTrigger( gentity_t *ent, gentity_t *other, trace_t *trace );
00540 
00541 //
00542 // g_trigger.c
00543 //
00544 void trigger_teleporter_touch (gentity_t *self, gentity_t *other, trace_t *trace );
00545 
00546 
00547 //
00548 // g_misc.c
00549 //
00550 void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles );
00551 #ifdef MISSIONPACK
00552 void DropPortalSource( gentity_t *ent );
00553 void DropPortalDestination( gentity_t *ent );
00554 #endif
00555 
00556 
00557 //
00558 // g_weapon.c
00559 //
00560 qboolean LogAccuracyHit( gentity_t *target, gentity_t *attacker );
00561 void CalcMuzzlePoint ( gentity_t *ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint );
00562 void SnapVectorTowards( vec3_t v, vec3_t to );
00563 qboolean CheckGauntletAttack( gentity_t *ent );
00564 void Weapon_HookFree (gentity_t *ent);
00565 void Weapon_HookThink (gentity_t *ent);
00566 
00567 
00568 //
00569 // g_client.c
00570 //
00571 team_t TeamCount( int ignoreClientNum, int team );
00572 int TeamLeader( int team );
00573 team_t PickTeam( int ignoreClientNum );
00574 void SetClientViewAngle( gentity_t *ent, vec3_t angle );
00575 gentity_t *SelectSpawnPoint ( vec3_t avoidPoint, vec3_t origin, vec3_t angles );
00576 void CopyToBodyQue( gentity_t *ent );
00577 void respawn (gentity_t *ent);
00578 void BeginIntermission (void);
00579 void InitClientPersistant (gclient_t *client);
00580 void InitClientResp (gclient_t *client);
00581 void InitBodyQue (void);
00582 void ClientSpawn( gentity_t *ent );
00583 void player_die (gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod);
00584 void AddScore( gentity_t *ent, vec3_t origin, int score );
00585 void CalculateRanks( void );
00586 qboolean SpotWouldTelefrag( gentity_t *spot );
00587 
00588 //
00589 // g_svcmds.c
00590 //
00591 qboolean    ConsoleCommand( void );
00592 void G_ProcessIPBans(void);
00593 qboolean G_FilterPacket (char *from);
00594 
00595 //
00596 // g_weapon.c
00597 //
00598 void FireWeapon( gentity_t *ent );
00599 #ifdef MISSIONPACK
00600 void G_StartKamikaze( gentity_t *ent );
00601 #endif
00602 
00603 //
00604 // p_hud.c
00605 //
00606 void MoveClientToIntermission (gentity_t *client);
00607 void G_SetStats (gentity_t *ent);
00608 void DeathmatchScoreboardMessage (gentity_t *client);
00609 
00610 //
00611 // g_cmds.c
00612 //
00613 
00614 //
00615 // g_pweapon.c
00616 //
00617 
00618 
00619 //
00620 // g_main.c
00621 //
00622 void FindIntermissionPoint( void );
00623 void SetLeader(int team, int client);
00624 void CheckTeamLeader( int team );
00625 void G_RunThink (gentity_t *ent);
00626 void QDECL G_LogPrintf( const char *fmt, ... );
00627 void SendScoreboardMessageToAllClients( void );
00628 void QDECL G_Printf( const char *fmt, ... );
00629 void QDECL G_Error( const char *fmt, ... );
00630 
00631 //
00632 // g_client.c
00633 //
00634 char *ClientConnect( int clientNum, qboolean firstTime, qboolean isBot );
00635 void ClientUserinfoChanged( int clientNum );
00636 void ClientDisconnect( int clientNum );
00637 void ClientBegin( int clientNum );
00638 void ClientCommand( int clientNum );
00639 
00640 //
00641 // g_active.c
00642 //
00643 void ClientThink( int clientNum );
00644 void ClientEndFrame( gentity_t *ent );
00645 void G_RunClient( gentity_t *ent );
00646 
00647 //
00648 // g_team.c
00649 //
00650 qboolean OnSameTeam( gentity_t *ent1, gentity_t *ent2 );
00651 void Team_CheckDroppedItem( gentity_t *dropped );
00652 qboolean CheckObeliskAttack( gentity_t *obelisk, gentity_t *attacker );
00653 
00654 //
00655 // g_mem.c
00656 //
00657 void *G_Alloc( int size );
00658 void G_InitMemory( void );
00659 void Svcmd_GameMem_f( void );
00660 
00661 //
00662 // g_session.c
00663 //
00664 void G_ReadSessionData( gclient_t *client );
00665 void G_InitSessionData( gclient_t *client, char *userinfo );
00666 
00667 void G_InitWorldSession( void );
00668 void G_WriteSessionData( void );
00669 
00670 //
00671 // g_arenas.c
00672 //
00673 void UpdateTournamentInfo( void );
00674 void SpawnModelsOnVictoryPads( void );
00675 void Svcmd_AbortPodium_f( void );
00676 
00677 //
00678 // g_bot.c
00679 //
00680 void G_InitBots( qboolean restart );
00681 char *G_GetBotInfoByNumber( int num );
00682 char *G_GetBotInfoByName( const char *name );
00683 void G_CheckBotSpawn( void );
00684 void G_RemoveQueuedBotBegin( int clientNum );
00685 qboolean G_BotConnect( int clientNum, qboolean restart );
00686 void Svcmd_AddBot_f( void );
00687 void Svcmd_BotList_f( void );
00688 void BotInterbreedEndMatch( void );
00689 
00690 // ai_main.c
00691 #define MAX_FILEPATH            144
00692 
00693 //bot settings
00694 typedef struct bot_settings_s
00695 {
00696     char characterfile[MAX_FILEPATH];
00697     float skill;
00698     char team[MAX_FILEPATH];
00699 } bot_settings_t;
00700 
00701 int BotAISetup( int restart );
00702 int BotAIShutdown( int restart );
00703 int BotAILoadMap( int restart );
00704 int BotAISetupClient(int client, struct bot_settings_s *settings, qboolean restart);
00705 int BotAIShutdownClient( int client, qboolean restart );
00706 int BotAIStartFrame( int time );
00707 void BotTestAAS(vec3_t origin);
00708 
00709 #include "g_team.h" // teamplay specific stuff
00710 
00711 
00712 extern  level_locals_t  level;
00713 extern  gentity_t       g_entities[MAX_GENTITIES];
00714 
00715 #define FOFS(x) ((int)&(((gentity_t *)0)->x))
00716 
00717 extern  vmCvar_t    g_gametype;
00718 extern  vmCvar_t    g_dedicated;
00719 extern  vmCvar_t    g_cheats;
00720 extern  vmCvar_t    g_maxclients;           // allow this many total, including spectators
00721 extern  vmCvar_t    g_maxGameClients;       // allow this many active
00722 extern  vmCvar_t    g_restarted;
00723 
00724 extern  vmCvar_t    g_dmflags;
00725 extern  vmCvar_t    g_fraglimit;
00726 extern  vmCvar_t    g_timelimit;
00727 extern  vmCvar_t    g_capturelimit;
00728 extern  vmCvar_t    g_friendlyFire;
00729 extern  vmCvar_t    g_password;
00730 extern  vmCvar_t    g_needpass;
00731 extern  vmCvar_t    g_gravity;
00732 extern  vmCvar_t    g_speed;
00733 extern  vmCvar_t    g_knockback;
00734 extern  vmCvar_t    g_quadfactor;
00735 extern  vmCvar_t    g_forcerespawn;
00736 extern  vmCvar_t    g_inactivity;
00737 extern  vmCvar_t    g_debugMove;
00738 extern  vmCvar_t    g_debugAlloc;
00739 extern  vmCvar_t    g_debugDamage;
00740 extern  vmCvar_t    g_weaponRespawn;
00741 extern  vmCvar_t    g_weaponTeamRespawn;
00742 extern  vmCvar_t    g_synchronousClients;
00743 extern  vmCvar_t    g_motd;
00744 extern  vmCvar_t    g_warmup;
00745 extern  vmCvar_t    g_doWarmup;
00746 extern  vmCvar_t    g_blood;
00747 extern  vmCvar_t    g_allowVote;
00748 extern  vmCvar_t    g_teamAutoJoin;
00749 extern  vmCvar_t    g_teamForceBalance;
00750 extern  vmCvar_t    g_banIPs;
00751 extern  vmCvar_t    g_filterBan;
00752 extern  vmCvar_t    g_obeliskHealth;
00753 extern  vmCvar_t    g_obeliskRegenPeriod;
00754 extern  vmCvar_t    g_obeliskRegenAmount;
00755 extern  vmCvar_t    g_obeliskRespawnDelay;
00756 extern  vmCvar_t    g_cubeTimeout;
00757 extern  vmCvar_t    g_redteam;
00758 extern  vmCvar_t    g_blueteam;
00759 extern  vmCvar_t    g_smoothClients;
00760 extern  vmCvar_t    pmove_fixed;
00761 extern  vmCvar_t    pmove_msec;
00762 extern  vmCvar_t    g_rankings;
00763 extern  vmCvar_t    g_enableDust;
00764 extern  vmCvar_t    g_enableBreath;
00765 extern  vmCvar_t    g_singlePlayer;
00766 extern  vmCvar_t    g_proxMineTimeout;
00767 
00768 void    trap_Printf( const char *fmt );
00769 void    trap_Error( const char *fmt );
00770 int     trap_Milliseconds( void );
00771 int     trap_Argc( void );
00772 void    trap_Argv( int n, char *buffer, int bufferLength );
00773 void    trap_Args( char *buffer, int bufferLength );
00774 int     trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode );
00775 void    trap_FS_Read( void *buffer, int len, fileHandle_t f );
00776 void    trap_FS_Write( const void *buffer, int len, fileHandle_t f );
00777 void    trap_FS_FCloseFile( fileHandle_t f );
00778 int     trap_FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize );
00779 int     trap_FS_Seek( fileHandle_t f, long offset, int origin ); // fsOrigin_t
00780 void    trap_SendConsoleCommand( int exec_when, const char *text );
00781 void    trap_Cvar_Register( vmCvar_t *cvar, const char *var_name, const char *value, int flags );
00782 void    trap_Cvar_Update( vmCvar_t *cvar );
00783 void    trap_Cvar_Set( const char *var_name, const char *value );
00784 int     trap_Cvar_VariableIntegerValue( const char *var_name );
00785 float   trap_Cvar_VariableValue( const char *var_name );
00786 void    trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );
00787 void    trap_LocateGameData( gentity_t *gEnts, int numGEntities, int sizeofGEntity_t, playerState_t *gameClients, int sizeofGameClient );
00788 void    trap_DropClient( int clientNum, const char *reason );
00789 void    trap_SendServerCommand( int clientNum, const char *text );
00790 void    trap_SetConfigstring( int num, const char *string );
00791 void    trap_GetConfigstring( int num, char *buffer, int bufferSize );
00792 void    trap_GetUserinfo( int num, char *buffer, int bufferSize );
00793 void    trap_SetUserinfo( int num, const char *buffer );
00794 void    trap_GetServerinfo( char *buffer, int bufferSize );
00795 void    trap_SetBrushModel( gentity_t *ent, const char *name );
00796 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 );
00797 int     trap_PointContents( const vec3_t point, int passEntityNum );
00798 qboolean trap_InPVS( const vec3_t p1, const vec3_t p2 );
00799 qboolean trap_InPVSIgnorePortals( const vec3_t p1, const vec3_t p2 );
00800 void    trap_AdjustAreaPortalState( gentity_t *ent, qboolean open );
00801 qboolean trap_AreasConnected( int area1, int area2 );
00802 void    trap_LinkEntity( gentity_t *ent );
00803 void    trap_UnlinkEntity( gentity_t *ent );
00804 int     trap_EntitiesInBox( const vec3_t mins, const vec3_t maxs, int *entityList, int maxcount );
00805 qboolean trap_EntityContact( const vec3_t mins, const vec3_t maxs, const gentity_t *ent );
00806 int     trap_BotAllocateClient( void );
00807 void    trap_BotFreeClient( int clientNum );
00808 void    trap_GetUsercmd( int clientNum, usercmd_t *cmd );
00809 qboolean    trap_GetEntityToken( char *buffer, int bufferSize );
00810 
00811 int     trap_DebugPolygonCreate(int color, int numPoints, vec3_t *points);
00812 void    trap_DebugPolygonDelete(int id);
00813 
00814 int     trap_BotLibSetup( void );
00815 int     trap_BotLibShutdown( void );
00816 int     trap_BotLibVarSet(char *var_name, char *value);
00817 int     trap_BotLibVarGet(char *var_name, char *value, int size);
00818 int     trap_BotLibDefine(char *string);
00819 int     trap_BotLibStartFrame(float time);
00820 int     trap_BotLibLoadMap(const char *mapname);
00821 int     trap_BotLibUpdateEntity(int ent, void /* struct bot_updateentity_s */ *bue);
00822 int     trap_BotLibTest(int parm0, char *parm1, vec3_t parm2, vec3_t parm3);
00823 
00824 int     trap_BotGetSnapshotEntity( int clientNum, int sequence );
00825 int     trap_BotGetServerCommand(int clientNum, char *message, int size);
00826 void    trap_BotUserCommand(int client, usercmd_t *ucmd);
00827 
00828 int     trap_AAS_BBoxAreas(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas);
00829 int     trap_AAS_AreaInfo( int areanum, void /* struct aas_areainfo_s */ *info );
00830 void    trap_AAS_EntityInfo(int entnum, void /* struct aas_entityinfo_s */ *info);
00831 
00832 int     trap_AAS_Initialized(void);
00833 void    trap_AAS_PresenceTypeBoundingBox(int presencetype, vec3_t mins, vec3_t maxs);
00834 float   trap_AAS_Time(void);
00835 
00836 int     trap_AAS_PointAreaNum(vec3_t point);
00837 int     trap_AAS_PointReachabilityAreaIndex(vec3_t point);
00838 int     trap_AAS_TraceAreas(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas);
00839 
00840 int     trap_AAS_PointContents(vec3_t point);
00841 int     trap_AAS_NextBSPEntity(int ent);
00842 int     trap_AAS_ValueForBSPEpairKey(int ent, char *key, char *value, int size);
00843 int     trap_AAS_VectorForBSPEpairKey(int ent, char *key, vec3_t v);
00844 int     trap_AAS_FloatForBSPEpairKey(int ent, char *key, float *value);
00845 int     trap_AAS_IntForBSPEpairKey(int ent, char *key, int *value);
00846 
00847 int     trap_AAS_AreaReachability(int areanum);
00848 
00849 int     trap_AAS_AreaTravelTimeToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags);
00850 int     trap_AAS_EnableRoutingArea( int areanum, int enable );
00851 int     trap_AAS_PredictRoute(void /*struct aas_predictroute_s*/ *route, int areanum, vec3_t origin,
00852                             int goalareanum, int travelflags, int maxareas, int maxtime,
00853                             int stopevent, int stopcontents, int stoptfl, int stopareanum);
00854 
00855 int     trap_AAS_AlternativeRouteGoals(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags,
00856                                         void /*struct aas_altroutegoal_s*/ *altroutegoals, int maxaltroutegoals,
00857                                         int type);
00858 int     trap_AAS_Swimming(vec3_t origin);
00859 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);
00860 
00861 
00862 void    trap_EA_Say(int client, char *str);
00863 void    trap_EA_SayTeam(int client, char *str);
00864 void    trap_EA_Command(int client, char *command);
00865 
00866 void    trap_EA_Action(int client, int action);
00867 void    trap_EA_Gesture(int client);
00868 void    trap_EA_Talk(int client);
00869 void    trap_EA_Attack(int client);
00870 void    trap_EA_Use(int client);
00871 void    trap_EA_Respawn(int client);
00872 void    trap_EA_Crouch(int client);
00873 void    trap_EA_MoveUp(int client);
00874 void    trap_EA_MoveDown(int client);
00875 void    trap_EA_MoveForward(int client);
00876 void    trap_EA_MoveBack(int client);
00877 void    trap_EA_MoveLeft(int client);
00878 void    trap_EA_MoveRight(int client);
00879 void    trap_EA_SelectWeapon(int client, int weapon);
00880 void    trap_EA_Jump(int client);
00881 void    trap_EA_DelayedJump(int client);
00882 void    trap_EA_Move(int client, vec3_t dir, float speed);
00883 void    trap_EA_View(int client, vec3_t viewangles);
00884 
00885 void    trap_EA_EndRegular(int client, float thinktime);
00886 void    trap_EA_GetInput(int client, float thinktime, void /* struct bot_input_s */ *input);
00887 void    trap_EA_ResetInput(int client);
00888 
00889 
00890 int     trap_BotLoadCharacter(char *charfile, float skill);
00891 void    trap_BotFreeCharacter(int character);
00892 float   trap_Characteristic_Float(int character, int index);
00893 float   trap_Characteristic_BFloat(int character, int index, float min, float max);
00894 int     trap_Characteristic_Integer(int character, int index);
00895 int     trap_Characteristic_BInteger(int character, int index, int min, int max);
00896 void    trap_Characteristic_String(int character, int index, char *buf, int size);
00897 
00898 int     trap_BotAllocChatState(void);
00899 void    trap_BotFreeChatState(int handle);
00900 void    trap_BotQueueConsoleMessage(int chatstate, int type, char *message);
00901 void    trap_BotRemoveConsoleMessage(int chatstate, int handle);
00902 int     trap_BotNextConsoleMessage(int chatstate, void /* struct bot_consolemessage_s */ *cm);
00903 int     trap_BotNumConsoleMessages(int chatstate);
00904 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 );
00905 int     trap_BotNumInitialChats(int chatstate, char *type);
00906 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 );
00907 int     trap_BotChatLength(int chatstate);
00908 void    trap_BotEnterChat(int chatstate, int client, int sendto);
00909 void    trap_BotGetChatMessage(int chatstate, char *buf, int size);
00910 int     trap_StringContains(char *str1, char *str2, int casesensitive);
00911 int     trap_BotFindMatch(char *str, void /* struct bot_match_s */ *match, unsigned long int context);
00912 void    trap_BotMatchVariable(void /* struct bot_match_s */ *match, int variable, char *buf, int size);
00913 void    trap_UnifyWhiteSpaces(char *string);
00914 void    trap_BotReplaceSynonyms(char *string, unsigned long int context);
00915 int     trap_BotLoadChatFile(int chatstate, char *chatfile, char *chatname);
00916 void    trap_BotSetChatGender(int chatstate, int gender);
00917 void    trap_BotSetChatName(int chatstate, char *name, int client);
00918 void    trap_BotResetGoalState(int goalstate);
00919 void    trap_BotRemoveFromAvoidGoals(int goalstate, int number);
00920 void    trap_BotResetAvoidGoals(int goalstate);
00921 void    trap_BotPushGoal(int goalstate, void /* struct bot_goal_s */ *goal);
00922 void    trap_BotPopGoal(int goalstate);
00923 void    trap_BotEmptyGoalStack(int goalstate);
00924 void    trap_BotDumpAvoidGoals(int goalstate);
00925 void    trap_BotDumpGoalStack(int goalstate);
00926 void    trap_BotGoalName(int number, char *name, int size);
00927 int     trap_BotGetTopGoal(int goalstate, void /* struct bot_goal_s */ *goal);
00928 int     trap_BotGetSecondGoal(int goalstate, void /* struct bot_goal_s */ *goal);
00929 int     trap_BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags);
00930 int     trap_BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags, void /* struct bot_goal_s */ *ltg, float maxtime);
00931 int     trap_BotTouchingGoal(vec3_t origin, void /* struct bot_goal_s */ *goal);
00932 int     trap_BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, void /* struct bot_goal_s */ *goal);
00933 int     trap_BotGetNextCampSpotGoal(int num, void /* struct bot_goal_s */ *goal);
00934 int     trap_BotGetMapLocationGoal(char *name, void /* struct bot_goal_s */ *goal);
00935 int     trap_BotGetLevelItemGoal(int index, char *classname, void /* struct bot_goal_s */ *goal);
00936 float   trap_BotAvoidGoalTime(int goalstate, int number);
00937 void    trap_BotSetAvoidGoalTime(int goalstate, int number, float avoidtime);
00938 void    trap_BotInitLevelItems(void);
00939 void    trap_BotUpdateEntityItems(void);
00940 int     trap_BotLoadItemWeights(int goalstate, char *filename);
00941 void    trap_BotFreeItemWeights(int goalstate);
00942 void    trap_BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child);
00943 void    trap_BotSaveGoalFuzzyLogic(int goalstate, char *filename);
00944 void    trap_BotMutateGoalFuzzyLogic(int goalstate, float range);
00945 int     trap_BotAllocGoalState(int state);
00946 void    trap_BotFreeGoalState(