1 /* 2 =========================================================================== 3 Copyright (C) 1999-2005 Id Software, Inc. 4 Copyright (C) 2000-2006 Tim Angus 5 6 This file is part of Tremulous. 7 8 Tremulous is free software; you can redistribute it 9 and/or modify it under the terms of the GNU General Public License as 10 published by the Free Software Foundation; either version 2 of the License, 11 or (at your option) any later version. 12 13 Tremulous is distributed in the hope that it will be 14 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with Tremulous; if not, write to the Free Software 20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 =========================================================================== 22 */ 23 24 // g_local.h -- local definitions for game module 25 26 #include "../qcommon/q_shared.h" 27 #include "bg_public.h" 28 #include "g_public.h" 29 30 //================================================================== 31 32 #define INFINITE 1000000 33 34 #define FRAMETIME 100 // msec 35 #define CARNAGE_REWARD_TIME 3000 36 #define REWARD_SPRITE_TIME 2000 37 38 #define INTERMISSION_DELAY_TIME 1000 39 #define SP_INTERMISSION_DELAY_TIME 5000 40 41 // gentity->flags 42 #define FL_GODMODE 0x00000010 43 #define FL_NOTARGET 0x00000020 44 #define FL_TEAMSLAVE 0x00000400 // not the first on the team 45 #define FL_NO_KNOCKBACK 0x00000800 46 #define FL_DROPPED_ITEM 0x00001000 47 #define FL_NO_BOTS 0x00002000 // spawn point not for bot use 48 #define FL_NO_HUMANS 0x00004000 // spawn point just for bots 49 #define FL_FORCE_GESTURE 0x00008000 // spawn point just for bots 50 51 // movers are things like doors, plats, buttons, etc 52 typedef enum 53 { 54 MOVER_POS1, 55 MOVER_POS2, 56 MOVER_1TO2, 57 MOVER_2TO1, 58 59 ROTATOR_POS1, 60 ROTATOR_POS2, 61 ROTATOR_1TO2, 62 ROTATOR_2TO1, 63 64 MODEL_POS1, 65 MODEL_POS2, 66 MODEL_1TO2, 67 MODEL_2TO1 68 } moverState_t; 69 70 #define SP_PODIUM_MODEL "models/mapobjects/podium/podium4.md3" 71 72 //============================================================================ 73 74 typedef struct gentity_s gentity_t; 75 typedef struct gclient_s gclient_t; 76 77 struct gentity_s 78 { 79 entityState_t s; // communicated by server to clients 80 entityShared_t r; // shared by both the server system and game 81 82 // DO NOT MODIFY ANYTHING ABOVE THIS, THE SERVER 83 // EXPECTS THE FIELDS IN THAT ORDER! 84 //================================ 85 86 struct gclient_s *client; // NULL if not a client 87 88 qboolean inuse; 89 90 char *classname; // set in QuakeEd 91 int spawnflags; // set in QuakeEd 92 93 qboolean neverFree; // if true, FreeEntity will only unlink 94 // bodyque uses this 95 96 int flags; // FL_* variables 97 98 char *model; 99 char *model2; 100 int freetime; // level.time when the object was freed 101 102 int eventTime; // events will be cleared EVENT_VALID_MSEC after set 103 qboolean freeAfterEvent; 104 qboolean unlinkAfterEvent; 105 106 qboolean physicsObject; // if true, it can be pushed by movers and fall off edges 107 // all game items are physicsObjects, 108 float physicsBounce; // 1.0 = continuous bounce, 0.0 = no bounce 109 int clipmask; // brushes with this content value will be collided against 110 // when moving. items and corpses do not collide against 111 // players, for instance 112 113 // movers 114 moverState_t moverState; 115 int soundPos1; 116 int sound1to2; 117 int sound2to1; 118 int soundPos2; 119 int soundLoop; 120 gentity_t *parent; 121 gentity_t *nextTrain; 122 gentity_t *prevTrain; 123 vec3_t pos1, pos2; 124 float rotatorAngle; 125 gentity_t *clipBrush; //TA: clipping brush for model doors 126 127 char *message; 128 129 int timestamp; // body queue sinking, etc 130 131 float angle; // set in editor, -1 = up, -2 = down 132 char *target; 133 char *targetname; 134 char *team; 135 char *targetShaderName; 136 char *targetShaderNewName; 137 gentity_t *target_ent; 138 139 float speed; 140 float lastSpeed; //TA: used by trains that have been restarted 141 vec3_t movedir; 142 143 //TA: acceleration evaluation 144 qboolean evaluateAcceleration; 145 vec3_t oldVelocity; 146 vec3_t acceleration; 147 vec3_t oldAccel; 148 vec3_t jerk; 149 150 int nextthink; 151 void (*think)( gentity_t *self ); 152 void (*reached)( gentity_t *self ); // movers call this when hitting endpoint 153 void (*blocked)( gentity_t *self, gentity_t *other ); 154 void (*touch)( gentity_t *self, gentity_t *other, trace_t *trace ); 155 void (*use)( gentity_t *self, gentity_t *other, gentity_t *activator ); 156 void (*pain)( gentity_t *self, gentity_t *attacker, int damage ); 157 void (*die)( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod ); 158 159 int pain_debounce_time; 160 int fly_sound_debounce_time; // wind tunnel 161 int last_move_time; 162 163 int health; 164 int lastHealth; //TA: currently only used for overmind 165 166 qboolean takedamage; 167 168 int damage; 169 int splashDamage; // quad will increase this without increasing radius 170 int splashRadius; 171 int methodOfDeath; 172 int splashMethodOfDeath; 173 int chargeRepeat; 174 175 int count; 176 177 gentity_t *chain; 178 gentity_t *enemy; 179 gentity_t *activator; 180 gentity_t *teamchain; // next entity in team 181 gentity_t *teammaster; // master of the team 182 183 int watertype; 184 int waterlevel; 185 186 int noise_index; 187 188 // timing variables 189 float wait; 190 float random; 191 192 pTeam_t stageTeam; 193 stage_t stageStage; 194 195 int biteam; //TA: buildable item team 196 gentity_t *parentNode; //TA: for creep and defence/spawn dependencies 197 qboolean active; //TA: for power repeater, but could be useful elsewhere 198 qboolean powered; //TA: for human buildables 199 int builtBy; //TA: clientNum of person that built this 200 gentity_t *dccNode; //TA: controlling dcc 201 gentity_t *overmindNode;//TA: controlling overmind 202 qboolean dcced; //TA: controlled by a dcc or not? 203 qboolean spawned; //TA: whether or not this buildable has finished spawning 204 int buildTime; //TA: when this buildable was built 205 int time1000; //TA: timer evaluated every second 206 int overmindAttackTimer; 207 int overmindDyingTimer; 208 int overmindSpawnsTimer; 209 int nextPhysicsTime; //TA: buildables don't need to check what they're sitting on 210 // every single frame.. so only do it periodically 211 int clientSpawnTime; //TA: the time until this spawn can spawn a client 212 qboolean lev1Grabbed; //TA: for turrets interacting with lev1s 213 int lev1GrabTime; //TA: for turrets interacting with lev1s 214 215 int credits[ MAX_CLIENTS ]; //TA: human credits for each client 216 qboolean creditsHash[ MAX_CLIENTS ]; //TA: track who has claimed credit 217 int killedBy; //TA: clientNum of killer 218 219 gentity_t *targeted; //TA: true if the player is currently a valid target of a turret 220 vec3_t turretAim; //TA: aim vector for turrets 221 222 vec4_t animation; //TA: animated map objects 223 224 gentity_t *builder; //TA: occupant of this hovel 225 226 qboolean nonSegModel; //TA: this entity uses a nonsegmented player model 227 228 buildable_t bTriggers[ BA_NUM_BUILDABLES ]; //TA: which buildables are triggers 229 pClass_t cTriggers[ PCL_NUM_CLASSES ]; //TA: which classes are triggers 230 weapon_t wTriggers[ WP_NUM_WEAPONS ]; //TA: which weapons are triggers 231 upgrade_t uTriggers[ UP_NUM_UPGRADES ]; //TA: which upgrades are triggers 232 233 int triggerGravity; //TA: gravity for this trigger 234 235 int suicideTime; //TA: when the client will suicide 236 237 int lastDamageTime; 238 }; 239 240 typedef enum 241 { 242 CON_DISCONNECTED, 243 CON_CONNECTING, 244 CON_CONNECTED 245 } clientConnected_t; 246 247 typedef enum 248 { 249 SPECTATOR_NOT, 250 SPECTATOR_FREE, 251 SPECTATOR_LOCKED, 252 SPECTATOR_FOLLOW, 253 SPECTATOR_SCOREBOARD 254 } spectatorState_t; 255 256 typedef enum 257 { 258 TEAM_BEGIN, // Beginning a team game, spawn at base 259 TEAM_ACTIVE // Now actively playing 260 } playerTeamStateState_t; 261 262 typedef struct 263 { 264 playerTeamStateState_t state; 265 266 int location; 267 268 int captures; 269 int basedefense; 270 int carrierdefense; 271 int flagrecovery; 272 int fragcarrier; 273 int assists; 274 275 float lasthurtcarrier; 276 float lastreturnedflag; 277 float flagsince; 278 float lastfraggedcarrier; 279 } playerTeamState_t; 280 281 // the auto following clients don't follow a specific client 282 // number, but instead follow the first two active players 283 #define FOLLOW_ACTIVE1 -1 284 #define FOLLOW_ACTIVE2 -2 285 286 // client data that stays across multiple levels or tournament restarts 287 // this is achieved by writing all the data to cvar strings at game shutdown 288 // time and reading them back at connection time. Anything added here 289 // MUST be dealt with in G_InitSessionData() / G_ReadSessionData() / G_WriteSessionData() 290 typedef struct 291 { 292 team_t sessionTeam; 293 int spectatorTime; // for determining next-in-line to play 294 spectatorState_t spectatorState; 295 int spectatorClient; // for chasecam and follow mode 296 int wins, losses; // tournament stats 297 qboolean teamLeader; // true when this client is a team leader 298 } clientSession_t; 299 300 #define MAX_NETNAME 36 301 #define MAX_VOTE_COUNT 3 302 303 // data to store details of clients that have abnormally disconnected 304 typedef struct connectionRecord_s 305 { 306 int clientNum; 307 pTeam_t clientTeam; 308 int clientCredit; 309 310 int ptrCode; 311 } connectionRecord_t; 312 313 // client data that stays across multiple respawns, but is cleared 314 // on each level change or team change at ClientBegin() 315 typedef struct 316 { 317 clientConnected_t connected; 318 usercmd_t cmd; // we would lose angles if not persistant 319 qboolean localClient; // true if "ip" info key is "localhost" 320 qboolean initialSpawn; // the first spawn should be at a cool location 321 qboolean predictItemPickup; // based on cg_predictItems userinfo 322 qboolean pmoveFixed; // 323 char netname[ MAX_NETNAME ]; 324 int maxHealth; // for handicapping 325 int enterTime; // level.time the client entered the game 326 playerTeamState_t teamState; // status in teamplay games 327 int voteCount; // to prevent people from constantly calling votes 328 int teamVoteCount; // to prevent people from constantly calling votes 329 qboolean teamInfo; // send team overlay updates? 330 331 pClass_t classSelection; //TA: player class (copied to ent->client->ps.stats[ STAT_PCLASS ] once spawned) 332 float evolveHealthFraction; 333 weapon_t humanItemSelection; //TA: humans have a starting item 334 pTeam_t teamSelection; //TA: player team (copied to ps.stats[ STAT_PTEAM ]) 335 336 qboolean joinedATeam; //TA: used to tell when a PTR code is valid 337 connectionRecord_t *connection; 338 339 vec3_t lastDeathLocation; 340 } clientPersistant_t; 341 342 // this structure is cleared on each ClientSpawn(), 343 // except for 'client->pers' and 'client->sess' 344 struct gclient_s 345 { 346 // ps MUST be the first element, because the server expects it 347 playerState_t ps; // communicated by server to clients 348 349 // the rest of the structure is private to game 350 clientPersistant_t pers; 351 clientSession_t sess; 352 353 qboolean readyToExit; // wishes to leave the intermission 354 355 qboolean noclip; 356 357 int lastCmdTime; // level.time of last usercmd_t, for EF_CONNECTION 358 // we can't just use pers.lastCommand.time, because 359 // of the g_sycronousclients case 360 int buttons; 361 int oldbuttons; 362 int latched_buttons; 363 364 vec3_t oldOrigin; 365 366 // sum up damage over an entire frame, so 367 // shotgun blasts give a single big kick 368 int damage_armor; // damage absorbed by armor 369 int damage_blood; // damage taken out of health 370 int damage_knockback; // impact damage 371 vec3_t damage_from; // origin for vector calculation 372 qboolean damage_fromWorld; // if true, don't use the damage_from vector 373 374 // 375 int lastkilled_client;// last client that this client killed 376 int lasthurt_client; // last client that damaged this client 377 int lasthurt_mod; // type of damage the client did 378 379 // timers 380 int respawnTime; // can respawn when time > this, force after g_forcerespwan 381 int inactivityTime; // kick players when time > this 382 qboolean inactivityWarning;// qtrue if the five seoond warning has been given 383 int rewardTime; // clear the EF_AWARD_IMPRESSIVE, etc when time > this 384 385 int airOutTime; 386 387 int lastKillTime; // for multiple kill rewards 388 389 qboolean fireHeld; // used for hook 390 qboolean fire2Held; // used for alt fire 391 gentity_t *hook; // grapple hook if out 392 393 int switchTeamTime; // time the player switched teams 394 395 // timeResidual is used to handle events that happen every second 396 // like health / armor countdowns and regeneration 397 //TA: two timers, one every 100 msecs, another every sec 398 int time100; 399 int time1000; 400 int time10000; 401 402 char *areabits; 403 404 gentity_t *hovel; //TA: body that is being infested. must be persistant 405 406 int lastPoisonTime; 407 int poisonImmunityTime; 408 gentity_t *lastPoisonClient; 409 int lastPoisonCloudedTime; 410 gentity_t *lastPoisonCloudedClient; 411 int grabExpiryTime; 412 int lastLockTime; 413 int lastSlowTime; 414 int lastBoostedTime; 415 int lastMedKitTime; 416 int medKitHealthToRestore; 417 int medKitIncrementTime; 418 int lastCreepSlowTime; //TA: time until creep can be removed 419 420 int pouncePayload; //TA: amount of damage pounce attack will do 421 qboolean allowedToPounce; 422 423 qboolean charging; 424 425 vec3_t hovelOrigin; //TA: player origin before entering hovel 426 427 int lastFlameBall; //TA: s.number of the last flame ball fired 428 429 #define RAM_FRAMES 1 //TA: number of frames to wait before retriggering 430 int retriggerArmouryMenu; //TA: frame number to retrigger the armoury menu 431 }; 432 433 434 typedef struct spawnQueue_s 435 { 436 int clients[ MAX_CLIENTS ]; 437 438 int front, back; 439 } spawnQueue_t; 440 441 #define QUEUE_PLUS1(x) (((x)+1)%MAX_CLIENTS) 442 #define QUEUE_MINUS1(x) (((x)+MAX_CLIENTS-1)%MAX_CLIENTS) 443 444 void G_InitSpawnQueue( spawnQueue_t *sq ); 445 int G_GetSpawnQueueLength( spawnQueue_t *sq ); 446 int G_PopSpawnQueue( spawnQueue_t *sq ); 447 int G_PeekSpawnQueue( spawnQueue_t *sq ); 448 void G_PushSpawnQueue( spawnQueue_t *sq, int clientNum ); 449 qboolean G_RemoveFromSpawnQueue( spawnQueue_t *sq, int clientNum ); 450 int G_GetPosInSpawnQueue( spawnQueue_t *sq, int clientNum ); 451 452 453 #define MAX_LOCDAMAGE_TEXT 8192 454 #define MAX_LOCDAMAGE_REGIONS 16 455 456 //TA: store locational damage regions 457 typedef struct damageRegion_s 458 { 459 float minHeight, maxHeight; 460 int minAngle, maxAngle; 461 462 float modifier; 463 464 qboolean crouch; 465 } damageRegion_t; 466 467 #define MAX_ARMOUR_TEXT 8192 468 #define MAX_ARMOUR_REGIONS 16 469 470 //TA: store locational armour regions 471 typedef struct armourRegion_s 472 { 473 float minHeight, maxHeight; 474 int minAngle, maxAngle; 475 476 float modifier; 477 478 qboolean crouch; 479 } armourRegion_t; 480 481 // 482 // this structure is cleared as each map is entered 483 // 484 #define MAX_SPAWN_VARS 64 485 #define MAX_SPAWN_VARS_CHARS 4096 486 487 typedef struct 488 { 489 struct gclient_s *clients; // [maxclients] 490 491 struct gentity_s *gentities; 492 int gentitySize; 493 int num_entities; // current number, <= MAX_GENTITIES 494 495 int warmupTime; // restart match at this time 496 497 fileHandle_t logFile; 498 499 // store latched cvars here that we want to get at often 500 int maxclients; 501 502 int framenum; 503 int time; // in msec 504 int previousTime; // so movers can back up when blocked 505 506 int startTime; // level.time the map was started 507 508 int teamScores[ TEAM_NUM_TEAMS ]; 509 int lastTeamLocationTime; // last time of client team location update 510 511 qboolean newSession; // don't use any old session data, because 512 // we changed gametype 513 514 qboolean restarted; // waiting for a map_restart to fire 515 516 int numConnectedClients; 517 int numNonSpectatorClients; // includes connecting clients 518 int numPlayingClients; // connected, non-spectators 519 int sortedClients[MAX_CLIENTS]; // sorted by score 520 int follow1, follow2; // clientNums for auto-follow spectators 521 522 int snd_fry; // sound index for standing in lava 523 524 int warmupModificationCount; // for detecting if g_warmup is changed 525 526 // voting state 527 char voteString[MAX_STRING_CHARS]; 528 char voteDisplayString[MAX_STRING_CHARS]; 529 int voteTime; // level.time vote was called 530 int voteExecuteTime; // time the vote is executed 531 int voteYes; 532 int voteNo; 533 int numVotingClients; // set by CalculateRanks 534 535 // team voting state 536 char teamVoteString[ 2 ][ MAX_STRING_CHARS ]; 537 int teamVoteTime[ 2 ]; // level.time vote was called 538 int teamVoteYes[ 2 ]; 539 int teamVoteNo[ 2 ]; 540 int numteamVotingClients[ 2 ]; // set by CalculateRanks 541 542 // spawn variables 543 qboolean spawning; // the G_Spawn*() functions are valid 544 int numSpawnVars; 545 char *spawnVars[ MAX_SPAWN_VARS ][ 2 ]; // key / value pairs 546 int numSpawnVarChars; 547 char spawnVarChars[ MAX_SPAWN_VARS_CHARS ]; 548 549 // intermission state 550 int intermissionQueued; // intermission was qualified, but 551 // wait INTERMISSION_DELAY_TIME before 552 // actually going there so the last 553 // frag can be watched. Disable future 554 // kills during this delay 555 int intermissiontime; // time the intermission was started 556 char *changemap; 557 qboolean readyToExit; // at least one client wants to exit 558 int exitTime; 559 vec3_t intermission_origin; // also used for spectator spawns 560 vec3_t intermission_angle; 561 562 qboolean locationLinked; // target_locations get linked 563 gentity_t *locationHead; // head of the location list 564 565 //TA: extra stuff: 566 int numAlienSpawns; 567 int numHumanSpawns; 568 569 int numAlienClients; 570 int numHumanClients; 571 572 float averageNumAlienClients; 573 int numAlienSamples; 574 float averageNumHumanClients; 575 int numHumanSamples; 576 577 int numLiveAlienClients; 578 int numLiveHumanClients; 579 580 int alienBuildPoints; 581 int humanBuildPoints; 582 int humanBuildPointsPowered; 583 584 int bankCredits[ MAX_CLIENTS ]; //global credits storage 585 586 int alienKills; 587 int humanKills; 588 589 qboolean reactorPresent; 590 qboolean overmindPresent; 591 592 int humanBaseAttackTimer; 593 594 pTeam_t lastWin; 595 596 spawnQueue_t alienSpawnQueue; 597 spawnQueue_t humanSpawnQueue; 598 599 int alienStage2Time; 600 int alienStage3Time; 601 int humanStage2Time; 602 int humanStage3Time; 603 604 qboolean uncondAlienWin; 605 qboolean uncondHumanWin; 606 } level_locals_t; 607 608 // 609 // g_spawn.c 610 // 611 qboolean G_SpawnString( const char *key, const char *defaultString, char **out ); 612 // spawn string returns a temporary reference, you must CopyString() if you want to keep it 613 qboolean G_SpawnFloat( const char *key, const char *defaultString, float *out ); 614 qboolean G_SpawnInt( const char *key, const char *defaultString, int *out ); 615 qboolean G_SpawnVector( const char *key, const char *defaultString, float *out ); 616 void G_SpawnEntitiesFromString( void ); 617 char *G_NewString( const char *string ); 618 619 // 620 // g_cmds.c 621 // 622 void Cmd_Score_f( gentity_t *ent ); 623 void G_StopFollowing( gentity_t *ent ); 624 qboolean G_FollowNewClient( gentity_t *ent, int dir ); 625 void Cmd_Follow_f( gentity_t *ent, qboolean toggle ); 626 627 // 628 // g_physics.c 629 // 630 void G_Physics( gentity_t *ent, int msec ); 631 632 // 633 // g_buildable.c 634 // 635 636 #define MAX_ALIEN_BBOX 25 637 638 typedef enum 639 { 640 IBE_NONE, 641 642 IBE_NOOVERMIND, 643 IBE_OVERMIND, 644 IBE_NOASSERT, 645 IBE_SPWNWARN, 646 IBE_NOCREEP, 647 IBE_HOVEL, 648 IBE_HOVELEXIT, 649 650 IBE_REACTOR, 651 IBE_REPEATER, 652 IBE_TNODEWARN, 653 IBE_RPTWARN, 654 IBE_RPTWARN2, 655 IBE_NOPOWER, 656 IBE_NODCC, 657 658 IBE_NORMAL, 659 IBE_NOROOM, 660 IBE_PERMISSION, 661 662 IBE_MAXERRORS 663 } itemBuildError_t; 664 665 qboolean AHovel_Blocked( gentity_t *hovel, gentity_t *player, qboolean provideExit ); 666 gentity_t *G_CheckSpawnPoint( int spawnNum, vec3_t origin, vec3_t normal, 667 buildable_t spawn, vec3_t spawnOrigin ); 668 669 qboolean G_isPower( vec3_t origin ); 670 qboolean G_isDCC( void ); 671 qboolean G_isOvermind( void ); 672 673 void G_BuildableThink( gentity_t *ent, int msec ); 674 qboolean G_BuildableRange( vec3_t origin, float r, buildable_t buildable ); 675 itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance, vec3_t origin ); 676 gentity_t *G_buildItem( gentity_t *builder, buildable_t buildable, vec3_t origin, vec3_t angles ); 677 qboolean G_ValidateBuild( gentity_t *ent, buildable_t buildable ); 678 void G_setBuildableAnim( gentity_t *ent, buildableAnimNumber_t anim, qboolean force ); 679 void G_setIdleBuildableAnim( gentity_t *ent, buildableAnimNumber_t anim ); 680 void G_SpawnBuildable(gentity_t *ent, buildable_t buildable); 681 void FinishSpawningBuildable( gentity_t *ent ); 682 683 // 684 // g_utils.c 685 // 686 int G_ParticleSystemIndex( char *name ); 687 int G_ShaderIndex( char *name ); 688 int G_ModelIndex( char *name ); 689 int G_SoundIndex( char *name ); 690 void G_TeamCommand( pTeam_t team, char *cmd ); 691 void G_KillBox (gentity_t *ent); 692 gentity_t *G_Find (gentity_t *from, int fieldofs, const char *match); 693 gentity_t *G_PickTarget (char *targetname); 694 void G_UseTargets (gentity_t *ent, gentity_t *activator); 695 void G_SetMovedir ( vec3_t angles, vec3_t movedir); 696 697 void G_InitGentity( gentity_t *e ); 698 gentity_t *G_Spawn( void ); 699 gentity_t *G_TempEntity( vec3_t origin, int event ); 700 void G_Sound( gentity_t *ent, int channel, int soundIndex ); 701 void G_FreeEntity( gentity_t *e ); 702 qboolean G_EntitiesFree( void ); 703 704 void G_TouchTriggers( gentity_t *ent ); 705 void G_TouchSolids( gentity_t *ent ); 706 707 float *tv( float x, float y, float z ); 708 char *vtos( const vec3_t v ); 709 710 float vectoyaw( const vec3_t vec ); 711 712 void G_AddPredictableEvent( gentity_t *ent, int event, int eventParm ); 713 void G_AddEvent( gentity_t *ent, int event, int eventParm ); 714 void G_BroadcastEvent( int event, int eventParm ); 715 void G_SetOrigin( gentity_t *ent, vec3_t origin ); 716 void AddRemap(const char *oldShader, const char *newShader, float timeOffset); 717 const char *BuildShaderStateConfig( void ); 718 719 720 #define MAX_QUEUE_COMMANDS 64 //should be MAX_RELIABLE_COMMANDS/server.h 721 722 typedef struct commandQueueElement_s 723 { 724 qboolean used; 725 struct commandQueueElement_s *next; 726 char command[ MAX_TOKEN_CHARS ]; 727 } commandQueueElement_t; 728 729 typedef struct commandQueue_s 730 { 731 int nextCommandTime; //next time that the queue can be popped 732 733 int numElements; 734 commandQueueElement_t *front; 735 commandQueueElement_t *back; 736 737 commandQueueElement_t pool[ MAX_QUEUE_COMMANDS ]; 738 } commandQueue_t; 739 740 qboolean G_ClientIsLagging( gclient_t *client ); 741 void G_ProcessCommandQueues( void ); 742 void G_SendCommandFromServer( int clientNum, const char *cmd ); 743 void G_InitCommandQueue( int clientNum ); 744 745 void G_TriggerMenu( int clientNum, dynMenu_t menu ); 746 void G_CloseMenus( int clientNum ); 747 748 qboolean G_Visible( gentity_t *ent1, gentity_t *ent2 ); 749 gentity_t *G_ClosestEnt( vec3_t origin, gentity_t **entities, int numEntities ); 750 751 // 752 // g_combat.c 753 // 754 qboolean CanDamage( gentity_t *targ, vec3_t origin ); 755 void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, 756 vec3_t dir, vec3_t point, int damage, int dflags, int mod ); 757 void G_SelectiveDamage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, vec3_t dir, 758 vec3_t point, int damage, int dflags, int mod, int team ); 759 qboolean G_RadiusDamage( vec3_t origin, gentity_t *attacker, float damage, float radius, 760 gentity_t *ignore, int mod ); 761 qboolean G_SelectiveRadiusDamage( vec3_t origin, gentity_t *attacker, float damage, float radius, 762 gentity_t *ignore, int mod, int team ); 763 void body_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath ); 764 void AddScore( gentity_t *ent, int score ); 765 766 //TA: 767 void G_InitDamageLocations( void ); 768 769 // damage flags 770 #define DAMAGE_RADIUS 0x00000001 // damage was indirect 771 #define DAMAGE_NO_ARMOR 0x00000002 // armour does not protect from this damage 772 #define DAMAGE_NO_KNOCKBACK 0x00000004 // do not affect velocity, just view angles 773 #define DAMAGE_NO_PROTECTION 0x00000008 // armor, shields, invulnerability, and godmode have no effect 774 #define DAMAGE_NO_LOCDAMAGE 0x00000010 // do not apply locational damage 775 776 // 777 // g_missile.c 778 // 779 void G_RunMissile( gentity_t *ent ); 780 781 gentity_t *fire_flamer( gentity_t *self, vec3_t start, vec3_t aimdir ); 782 gentity_t *fire_blaster( gentity_t *self, vec3_t start, vec3_t dir ); 783 gentity_t *fire_pulseRifle( gentity_t *self, vec3_t start, vec3_t dir ); 784 gentity_t *fire_luciferCannon( gentity_t *self, vec3_t start, vec3_t dir, int damage, int radius ); 785 gentity_t *fire_lockblob( gentity_t *self, vec3_t start, vec3_t dir ); 786 gentity_t *fire_paraLockBlob( gentity_t *self, vec3_t start, vec3_t dir ); 787 gentity_t *fire_slowBlob( gentity_t *self, vec3_t start, vec3_t dir ); 788 gentity_t *fire_bounceBall( gentity_t *self, vec3_t start, vec3_t dir ); 789 gentity_t *fire_hive( gentity_t *self, vec3_t start, vec3_t dir ); 790 gentity_t *launch_grenade( gentity_t *self, vec3_t start, vec3_t dir ); 791 792 793 // 794 // g_mover.c 795 // 796 void G_RunMover( gentity_t *ent ); 797 void Touch_DoorTrigger( gentity_t *ent, gentity_t *other, trace_t *trace ); 798 void manualTriggerSpectator( gentity_t *trigger, gentity_t *player ); 799 800 // 801 // g_trigger.c 802 // 803 void trigger_teleporter_touch( gentity_t *self, gentity_t *other, trace_t *trace ); 804 void G_Checktrigger_stages( pTeam_t team, stage_t stage ); 805 806 807 // 808 // g_misc.c 809 // 810 void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles ); 811 void ShineTorch( gentity_t *self ); 812 813 // 814 // g_weapon.c 815 // 816 817 #define MAX_ZAP_TARGETS LEVEL2_AREAZAP_MAX_TARGETS 818 819 typedef struct zap_s 820 { 821 qboolean used; 822 823 gentity_t *creator; 824 gentity_t *targets[ MAX_ZAP_TARGETS ]; 825 int numTargets; 826 827 int timeToLive; 828 829 gentity_t *effectChannel; 830 } zap_t; 831 832 void G_ForceWeaponChange( gentity_t *ent, weapon_t weapon ); 833 void G_GiveClientMaxAmmo( gentity_t *ent, qboolean buyingEnergyAmmo ); 834 void CalcMuzzlePoint( gentity_t *ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint ); 835 void SnapVectorTowards( vec3_t v, vec3_t to ); 836 qboolean CheckVenomAttack( gentity_t *ent ); 837 void CheckGrabAttack( gentity_t *ent ); 838 qboolean CheckPounceAttack( gentity_t *ent ); 839 void ChargeAttack( gentity_t *ent, gentity_t *victim ); 840 void G_UpdateZaps( int msec ); 841 842 843 // 844 // g_client.c 845 // 846 void G_AddCreditToClient( gclient_t *client, short credit, qboolean cap ); 847 team_t TeamCount( int ignoreClientNum, int team ); 848 void SetClientViewAngle( gentity_t *ent, vec3_t angle ); 849 gentity_t *SelectTremulousSpawnPoint( pTeam_t team, vec3_t preference, vec3_t origin, vec3_t angles ); 850 gentity_t *SelectSpawnPoint( vec3_t avoidPoint, vec3_t origin, vec3_t angles ); 851 void SpawnCorpse( gentity_t *ent ); 852 void respawn( gentity_t *ent ); 853 void BeginIntermission( void ); 854 void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles ); 855 void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod ); 856 qboolean SpotWouldTelefrag( gentity_t *spot ); 857 858 // 859 // g_svcmds.c 860 // 861 qboolean ConsoleCommand( void ); 862 void G_ProcessIPBans( void ); 863 qboolean G_FilterPacket( char *from ); 864 865 // 866 // g_weapon.c 867 // 868 void FireWeapon( gentity_t *ent ); 869 void FireWeapon2( gentity_t *ent ); 870 void FireWeapon3( gentity_t *ent ); 871 872 // 873 // g_cmds.c 874 // 875 876 // 877 // g_main.c 878 // 879 void ScoreboardMessage( gentity_t *client ); 880 void MoveClientToIntermission( gentity_t *client ); 881 void CalculateRanks( void ); 882 void FindIntermissionPoint( void ); 883 void G_RunThink( gentity_t *ent ); 884 void QDECL G_LogPrintf( const char *fmt, ... ); 885 void SendScoreboardMessageToAllClients( void ); 886 void QDECL G_Printf( const char *fmt, ... ); 887 void QDECL G_Error( const char *fmt, ... ); 888 889 // 890 // g_client.c 891 // 892 char *ClientConnect( int clientNum, qboolean firstTime, qboolean isBot ); 893 void ClientUserinfoChanged( int clientNum ); 894 void ClientDisconnect( int clientNum ); 895 void ClientBegin( int clientNum ); 896 void ClientCommand( int clientNum ); 897 898 // 899 // g_active.c 900 // 901 void ClientThink( int clientNum ); 902 void ClientEndFrame( gentity_t *ent ); 903 void G_RunClient( gentity_t *ent ); 904 905 // 906 // g_team.c 907 // 908 qboolean OnSameTeam( gentity_t *ent1, gentity_t *ent2 ); 909 gentity_t *Team_GetLocation( gentity_t *ent ); 910 qboolean Team_GetLocationMsg( gentity_t *ent, char *loc, int loclen ); 911 void TeamplayInfoMessage( gentity_t *ent ); 912 void CheckTeamStatus( void ); 913 914 // 915 // g_mem.c 916 // 917 void *G_Alloc( int size ); 918 void G_InitMemory( void ); 919 void G_Free( void *ptr ); 920 void G_DefragmentMemory( void ); 921 void Svcmd_GameMem_f( void ); 922 923 // 924 // g_session.c 925 // 926 void G_ReadSessionData( gclient_t *client ); 927 void G_InitSessionData( gclient_t *client, char *userinfo ); 928 void G_WriteSessionData( void ); 929 930 // 931 // g_maprotation.c 932 // 933 #define MAX_MAP_ROTATIONS 16 934 #define MAX_MAP_ROTATION_MAPS 64 935 #define MAX_MAP_COMMANDS 16 936 #define MAX_MAP_ROTATION_CONDS 4 937 938 #define NOT_ROTATING -1 939 940 typedef enum 941 { 942 MCV_ERR, 943 MCV_RANDOM, 944 MCV_NUMCLIENTS, 945 MCV_LASTWIN 946 } mapConditionVariable_t; 947 948 typedef enum 949 { 950 MCO_LT, 951 MCO_EQ, 952 MCO_GT 953 } mapConditionOperator_t; 954 955 typedef enum 956 { 957 MCT_ERR, 958 MCT_MAP, 959 MCT_ROTATION 960 } mapConditionType_t; 961 962 typedef struct mapRotationCondition_s 963 { 964 char dest[ MAX_QPATH ]; 965 966 qboolean unconditional; 967 968 mapConditionVariable_t lhs; 969 mapConditionOperator_t op; 970 971 int numClients; 972 pTeam_t lastWin; 973 } mapRotationCondition_t; 974 975 typedef struct mapRotationEntry_s 976 { 977 char name[ MAX_QPATH ]; 978 979 char postCmds[ MAX_QPATH ][ MAX_MAP_COMMANDS ]; 980 int numCmds; 981 982 mapRotationCondition_t conditions[ MAX_MAP_ROTATION_CONDS ]; 983 int numConditions; 984 } mapRotationEntry_t; 985 986 typedef struct mapRotation_s 987 { 988 char name[ MAX_QPATH ]; 989 990 mapRotationEntry_t maps[ MAX_MAP_ROTATION_MAPS ]; 991 int numMaps; 992 int currentMap; 993 } mapRotation_t; 994 995 typedef struct mapRotations_s 996 { 997 mapRotation_t rotations[ MAX_MAP_ROTATIONS ]; 998 int numRotations; 999 } mapRotations_t; 1000 1001 void G_PrintRotations( void ); 1002 qboolean G_AdvanceMapRotation( void ); 1003 qboolean G_StartMapRotation( char *name, qboolean changeMap ); 1004 void G_StopMapRotation( void ); 1005 qboolean G_MapRotationActive( void ); 1006 void G_InitMapRotations( void ); 1007 1008 // 1009 // g_ptr.c 1010 // 1011 void G_UpdatePTRConnection( gclient_t *client ); 1012 connectionRecord_t *G_GenerateNewConnection( gclient_t *client ); 1013 qboolean G_VerifyPTRC( int code ); 1014 void G_ResetPTRConnections( void ); 1015 connectionRecord_t *G_FindConnectionForCode( int code ); 1016 void G_DeletePTRConnection( connectionRecord_t *connection ); 1017 1018 1019 //some maxs 1020 #define MAX_FILEPATH 144 1021 1022 extern level_locals_t level; 1023 extern gentity_t g_entities[ MAX_GENTITIES ]; 1024 1025 #define FOFS(x) ((int)&(((gentity_t *)0)->x)) 1026 1027 extern vmCvar_t g_dedicated; 1028 extern vmCvar_t g_cheats; 1029 extern vmCvar_t g_maxclients; // allow this many total, including spectators 1030 extern vmCvar_t g_maxGameClients; // allow this many active 1031 extern vmCvar_t g_restarted; 1032 extern vmCvar_t g_minCommandPeriod; 1033 1034 extern vmCvar_t g_timelimit; 1035 extern vmCvar_t g_suddenDeathTime; 1036 extern vmCvar_t g_friendlyFire; 1037 extern vmCvar_t g_password; 1038 extern vmCvar_t g_needpass; 1039 extern vmCvar_t g_gravity; 1040 extern vmCvar_t g_speed; 1041 extern vmCvar_t g_knockback; 1042 extern vmCvar_t g_quadfactor; 1043 extern vmCvar_t g_forcerespawn; 1044 extern vmCvar_t g_inactivity; 1045 extern vmCvar_t g_debugMove; 1046 extern vmCvar_t g_debugAlloc; 1047 extern vmCvar_t g_debugDamage; 1048 extern vmCvar_t g_weaponRespawn; 1049 extern vmCvar_t g_weaponTeamRespawn; 1050 extern vmCvar_t g_synchronousClients; 1051 extern vmCvar_t g_motd; 1052 extern vmCvar_t g_warmup; 1053 extern vmCvar_t g_doWarmup; 1054 extern vmCvar_t g_blood; 1055 extern vmCvar_t g_allowVote; 1056 extern vmCvar_t g_teamAutoJoin; 1057 extern vmCvar_t g_teamForceBalance; 1058 extern vmCvar_t g_banIPs; 1059 extern vmCvar_t g_filterBan; 1060 extern vmCvar_t g_smoothClients; 1061 extern vmCvar_t pmove_fixed; 1062 extern vmCvar_t pmove_msec; 1063 extern vmCvar_t g_rankings; 1064 extern vmCvar_t g_enableDust; 1065 extern vmCvar_t g_enableBreath; 1066 extern vmCvar_t g_singlePlayer; 1067 1068 extern vmCvar_t g_humanBuildPoints; 1069 extern vmCvar_t g_alienBuildPoints; 1070 extern vmCvar_t g_humanStage; 1071 extern vmCvar_t g_humanKills; 1072 extern vmCvar_t g_humanMaxStage; 1073 extern vmCvar_t g_humanStage2Threshold; 1074 extern vmCvar_t g_humanStage3Threshold; 1075 extern vmCvar_t g_alienStage; 1076 extern vmCvar_t g_alienKills; 1077 extern vmCvar_t g_alienMaxStage; 1078 extern vmCvar_t g_alienStage2Threshold; 1079 extern vmCvar_t g_alienStage3Threshold; 1080 1081 extern vmCvar_t g_disabledEquipment; 1082 extern vmCvar_t g_disabledClasses; 1083 extern vmCvar_t g_disabledBuildables; 1084 1085 extern vmCvar_t g_debugMapRotation; 1086 extern vmCvar_t g_currentMapRotation; 1087 extern vmCvar_t g_currentMap; 1088 extern vmCvar_t g_initialMapRotation; 1089 1090 void trap_Printf( const char *fmt ); 1091 void trap_Error( const char *fmt ); 1092 int trap_Milliseconds( void ); 1093 int trap_Argc( void ); 1094 void trap_Argv( int n, char *buffer, int bufferLength ); 1095 void trap_Args( char *buffer, int bufferLength ); 1096 int trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode ); 1097 void trap_FS_Read( void *buffer, int len, fileHandle_t f ); 1098 void trap_FS_Write( const void *buffer, int len, fileHandle_t f ); 1099 void trap_FS_FCloseFile( fileHandle_t f ); 1100 int trap_FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize ); 1101 int trap_FS_Seek( fileHandle_t f, long offset, int origin ); // fsOrigin_t 1102 void trap_SendConsoleCommand( int exec_when, const char *text ); 1103 void trap_Cvar_Register( vmCvar_t *cvar, const char *var_name, const char *value, int flags ); 1104 void trap_Cvar_Update( vmCvar_t *cvar ); 1105 void trap_Cvar_Set( const char *var_name, const char *value ); 1106 int trap_Cvar_VariableIntegerValue( const char *var_name ); 1107 float trap_Cvar_VariableValue( const char *var_name ); 1108 void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize ); 1109 void trap_LocateGameData( gentity_t *gEnts, int numGEntities, int sizeofGEntity_t, 1110 playerState_t *gameClients, int sizeofGameClient ); 1111 void trap_DropClient( int clientNum, const char *reason ); 1112 void trap_SendServerCommand( int clientNum, const char *text ); 1113 void trap_SetConfigstring( int num, const char *string ); 1114 void trap_GetConfigstring( int num, char *buffer, int bufferSize ); 1115 void trap_GetUserinfo( int num, char *buffer, int bufferSize ); 1116 void trap_SetUserinfo( int num, const char *buffer ); 1117 void trap_GetServerinfo( char *buffer, int bufferSize ); 1118 void trap_SetBrushModel( gentity_t *ent, const char *name ); 1119 void trap_Trace( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, 1120 const vec3_t end, int passEntityNum, int contentmask ); 1121 int trap_PointContents( const vec3_t point, int passEntityNum ); 1122 qboolean trap_InPVS( const vec3_t p1, const vec3_t p2 ); 1123 qboolean trap_InPVSIgnorePortals( const vec3_t p1, const vec3_t p2 ); 1124 void trap_AdjustAreaPortalState( gentity_t *ent, qboolean open ); 1125 qboolean trap_AreasConnected( int area1, int area2 ); 1126 void trap_LinkEntity( gentity_t *ent ); 1127 void trap_UnlinkEntity( gentity_t *ent ); 1128 int trap_EntitiesInBox( const vec3_t mins, const vec3_t maxs, int *entityList, int maxcount ); 1129 qboolean trap_EntityContact( const vec3_t mins, const vec3_t maxs, const gentity_t *ent ); 1130 int trap_BotAllocateClient( void ); 1131 void trap_BotFreeClient( int clientNum ); 1132 void trap_GetUsercmd( int clientNum, usercmd_t *cmd ); 1133 qboolean trap_GetEntityToken( char *buffer, int bufferSize ); 1134 1135 int trap_DebugPolygonCreate(int color, int numPoints, vec3_t *points); 1136 void trap_DebugPolygonDelete(int id); 1137 1138 void trap_SnapVector( float *v ); 1139 void trap_SendGameStat( const char *data ); 1140