summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2002-09-03 01:57:18 +0000
committerTim Angus <tim@ngus.net>2002-09-03 01:57:18 +0000
commit01aee82bd49575f16b5701cf842f04e6b1ba7b3d (patch)
treec306eed20c91cce6221a115a173f9b6cf68da393 /src/game
parentbb5d52f699a403e22584aa18946a091f345662e8 (diff)
* Large purge of legacy Q3A code
* Removed Q3A team system * Removed "gametype" stuff * Removed items * Refactored buildable physics * Other general cleanups
Diffstat (limited to 'src/game')
-rw-r--r--src/game/bg_pmove.c2
-rw-r--r--src/game/bg_public.h18
-rw-r--r--src/game/g_active.c39
-rw-r--r--src/game/g_buildable.c66
-rw-r--r--src/game/g_client.c99
-rw-r--r--src/game/g_cmds.c1055
-rw-r--r--src/game/g_combat.c102
-rw-r--r--src/game/g_local.h36
-rw-r--r--src/game/g_main.c591
-rw-r--r--src/game/g_mover.c4
-rw-r--r--src/game/g_physics.c187
-rw-r--r--src/game/g_session.c82
-rw-r--r--src/game/g_spawn.c49
-rw-r--r--src/game/g_svcmds.c18
-rw-r--r--src/game/g_target.c78
-rw-r--r--src/game/g_team.c858
-rw-r--r--src/game/g_trigger.c31
-rw-r--r--src/game/g_utils.c14
18 files changed, 838 insertions, 2491 deletions
diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c
index f3158199..e79a3a8c 100644
--- a/src/game/bg_pmove.c
+++ b/src/game/bg_pmove.c
@@ -1834,7 +1834,7 @@ static void PM_CheckDuck (void)
BG_FindViewheightForClass( pm->ps->stats[ STAT_PCLASS ], &PCvh, &PCcvh );
//TA: iD bug? you can still crouch when you're a spectator
- if( pm->ps->persistant[PERS_TEAM] == TEAM_SPECTATOR )
+ if( pm->ps->persistant[ PERS_TEAM ] == TEAM_SPECTATOR )
PCcvh = PCvh;
pm->mins[0] = PCmins[0];
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index 2fd58deb..97def1db 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -103,22 +103,6 @@
#error overflow: (CS_MAX) > MAX_CONFIGSTRINGS
#endif
-typedef enum {
- GT_FFA, // free for all
- GT_TOURNAMENT, // one on one tournament
- GT_SINGLE_PLAYER, // single player ffa
-
- //-- team games go after this --
-
- GT_TEAM, // team deathmatch
- GT_CTF, // capture the flag
- GT_1FCTF,
- GT_OBELISK,
- GT_HARVESTER,
-
- GT_MAX_GAME_TYPE
-} gametype_t;
-
typedef enum { GENDER_MALE, GENDER_FEMALE, GENDER_NEUTER } gender_t;
/*
@@ -735,8 +719,6 @@ typedef struct animation_s {
typedef enum {
TEAM_FREE,
- TEAM_HUMANS,
- TEAM_ALIENS,
TEAM_SPECTATOR,
TEAM_NUM_TEAMS
diff --git a/src/game/g_active.c b/src/game/g_active.c
index 6e6b7f1b..cef172a5 100644
--- a/src/game/g_active.c
+++ b/src/game/g_active.c
@@ -663,38 +663,6 @@ void ClientEvents( gentity_t *ent, int oldEventSequence ) {
FireWeapon3( ent );
break;
- case EV_USE_ITEM1: // teleporter
- // drop flags in CTF
- item = NULL;
- j = 0;
-
- /*if ( ent->client->ps.powerups[ PW_REDFLAG ] ) {
- item = BG_FindItemForPowerup( PW_REDFLAG );
- i = PW_REDFLAG;
- } else if ( ent->client->ps.powerups[ PW_BLUEFLAG ] ) {
- item = BG_FindItemForPowerup( PW_BLUEFLAG );
- i = PW_BLUEFLAG;
- }*/
-
- if ( item ) {
- drop = Drop_Item( ent, item, 0 );
- // decide how many seconds it has left
- /*drop->count = ( ent->client->ps.powerups[ j ] - level.time ) / 1000;*/
- if ( drop->count < 1 ) {
- drop->count = 1;
- }
-
- /*ent->client->ps.powerups[ j ] = 0;*/
- }
-
- SelectSpawnPoint( ent->client->ps.origin, origin, angles );
- TeleportPlayer( ent, origin, angles );
- break;
-
- case EV_USE_ITEM2: // medkit
- ent->health = ent->client->ps.stats[STAT_MAX_HEALTH];
- break;
-
default:
break;
}
@@ -743,9 +711,6 @@ static int StuckInOtherClient(gentity_t *ent) {
return qfalse;
}
-//TA: rip bots
-//void BotTestSolid(vec3_t origin);
-
/*
==============
SendPendingPredictableEvents
@@ -1089,10 +1054,6 @@ void ClientThink_real( gentity_t *ent ) {
// NOTE: now copy the exact origin over otherwise clients can be snapped into solid
VectorCopy( ent->client->ps.origin, ent->r.currentOrigin );
- //test for solid areas in the AAS file
- //TA: rip bots
- //BotTestSolid(ent->r.currentOrigin);
-
// touch other objects
ClientImpacts( ent, &pm );
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 657aed73..93d5619d 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -2282,3 +2282,69 @@ void G_ValidateBuild( gentity_t *ent, buildable_t buildable )
break;
}
}
+
+/*
+================
+FinishSpawningBuildable
+
+Traces down to find where an item should rest, instead of letting them
+free fall from their spawn points
+================
+*/
+void FinishSpawningBuildable( gentity_t *ent )
+{
+ trace_t tr;
+ vec3_t dest;
+ gentity_t *built;
+ buildable_t buildable = ent->s.modelindex;
+
+ built = G_buildItem( ent, buildable, ent->s.pos.trBase, ent->s.angles );
+ G_FreeEntity( ent );
+
+ // drop to floor
+ if( buildable != BA_NONE && BG_FindTrajectoryForBuildable( buildable ) == TR_BUOYANCY )
+ VectorSet( dest, built->s.origin[0], built->s.origin[1], built->s.origin[2] + 4096 );
+ else
+ VectorSet( dest, built->s.origin[0], built->s.origin[1], built->s.origin[2] - 4096 );
+
+ trap_Trace( &tr, built->s.origin, built->r.mins, built->r.maxs, dest, built->s.number, built->clipmask );
+ if( tr.startsolid )
+ {
+ G_Printf ("FinishSpawningBuildable: %s startsolid at %s\n", built->classname, vtos(built->s.origin));
+ G_FreeEntity( built );
+ return;
+ }
+
+ //point items in the correct direction
+ VectorCopy( tr.plane.normal, built->s.origin2 );
+
+ // allow to ride movers
+ built->s.groundEntityNum = tr.entityNum;
+
+ G_SetOrigin( built, tr.endpos );
+
+ trap_LinkEntity( built );
+}
+
+
+qboolean itemRegistered[MAX_ITEMS];
+
+/*
+============
+G_SpawnBuildable
+
+Sets the clipping size and plants the object on the floor.
+
+Items can't be immediately dropped to floor, because they might
+be on an entity that hasn't spawned yet.
+============
+*/
+void G_SpawnBuildable( gentity_t *ent, buildable_t buildable )
+{
+ ent->s.modelindex = buildable;
+
+ // some movers spawn on the second frame, so delay item
+ // spawns until the third frame so they can ride trains
+ ent->nextthink = level.time + FRAMETIME * 2;
+ ent->think = FinishSpawningBuildable;
+}
diff --git a/src/game/g_client.c b/src/game/g_client.c
index ac5329fa..fc469041 100644
--- a/src/game/g_client.c
+++ b/src/game/g_client.c
@@ -858,52 +858,6 @@ int TeamLeader( int team ) {
return -1;
}
-
-/*
-================
-PickTeam
-
-================
-*/
-team_t PickTeam( int ignoreClientNum ) {
- int counts[TEAM_NUM_TEAMS];
-
- counts[TEAM_ALIENS] = TeamCount( ignoreClientNum, TEAM_ALIENS );
- counts[TEAM_HUMANS] = TeamCount( ignoreClientNum, TEAM_HUMANS );
-
- if ( counts[TEAM_ALIENS] > counts[TEAM_HUMANS] ) {
- return TEAM_HUMANS;
- }
- if ( counts[TEAM_HUMANS] > counts[TEAM_ALIENS] ) {
- return TEAM_ALIENS;
- }
- // equal team count, so join the team with the lowest score
- if ( level.teamScores[TEAM_ALIENS] > level.teamScores[TEAM_HUMANS] ) {
- return TEAM_HUMANS;
- }
- return TEAM_ALIENS;
-}
-
-/*
-===========
-ForceClientSkin
-
-Forces a client's skin (for teamplay)
-===========
-*/
-/*
-static void ForceClientSkin( gclient_t *client, char *model, const char *skin ) {
- char *p;
-
- if ((p = Q_strrchr(model, '/')) != 0) {
- *p = 0;
- }
-
- Q_strcat(model, MAX_QPATH, "/");
- Q_strcat(model, MAX_QPATH, skin);
-}
-*/
-
/*
===========
ClientCheckName
@@ -1172,15 +1126,6 @@ char *ClientConnect( int clientNum, qboolean firstTime, qboolean isBot ) {
}
G_ReadSessionData( client );
- //TA: rip bots
- /*if( isBot ) {
- ent->r.svFlags |= SVF_BOT;
- ent->inuse = qtrue;
- if( !G_BotConnect( clientNum, !firstTime ) ) {
- return "BotConnectfailed";
- }
- }*/
-
// get and distribute relevent paramters
G_LogPrintf( "ClientConnect: %i\n", clientNum );
ClientUserinfoChanged( clientNum );
@@ -1190,11 +1135,6 @@ char *ClientConnect( int clientNum, qboolean firstTime, qboolean isBot ) {
trap_SendServerCommand( -1, va("print \"%s" S_COLOR_WHITE " connected\n\"", client->pers.netname) );
}
- if ( g_gametype.integer >= GT_TEAM &&
- client->sess.sessionTeam != TEAM_SPECTATOR ) {
- BroadcastTeamChange( client, -1 );
- }
-
// count current clients and rank for scoreboard
CalculateRanks();
@@ -1218,13 +1158,6 @@ void ClientBegin( int clientNum ) {
ent = g_entities + clientNum;
- //TA: rip bots
- /*if( ent->botDelayBegin ) {
- G_QueueBotBegin( clientNum );
- ent->botDelayBegin = qfalse;
- return;
- }*/
-
client = level.clients + clientNum;
if ( ent->r.linked ) {
@@ -1257,9 +1190,7 @@ void ClientBegin( int clientNum ) {
tent = G_TempEntity( ent->client->ps.origin, EV_PLAYER_TELEPORT_IN );
tent->s.clientNum = ent->s.clientNum;
- if ( g_gametype.integer != GT_TOURNAMENT ) {
- trap_SendServerCommand( -1, va("print \"%s" S_COLOR_WHITE " entered the game\n\"", client->pers.netname) );
- }
+ trap_SendServerCommand( -1, va("print \"%s" S_COLOR_WHITE " entered the game\n\"", client->pers.netname) );
}
G_LogPrintf( "ClientBegin: %i\n", clientNum );
@@ -1321,11 +1252,11 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn )
if ( client->sess.sessionTeam == TEAM_SPECTATOR )
{
if( teamLocal == PTE_NONE )
- spawnPoint = SelectSpectatorSpawnPoint ( spawn_origin, spawn_angles);
+ spawnPoint = SelectSpectatorSpawnPoint ( spawn_origin, spawn_angles );
else if( teamLocal == PTE_ALIENS )
- spawnPoint = SelectAlienLockSpawnPoint ( spawn_origin, spawn_angles);
+ spawnPoint = SelectAlienLockSpawnPoint ( spawn_origin, spawn_angles );
else if( teamLocal == PTE_HUMANS )
- spawnPoint = SelectHumanLockSpawnPoint ( spawn_origin, spawn_angles);
+ spawnPoint = SelectHumanLockSpawnPoint ( spawn_origin, spawn_angles );
}
else
{
@@ -1576,15 +1507,6 @@ void ClientDisconnect( int clientNum ) {
return;
}
- // stop any following clients
- for ( i = 0 ; i < level.maxclients ; i++ ) {
- if ( level.clients[i].sess.sessionTeam == TEAM_SPECTATOR
- && level.clients[i].sess.spectatorState == SPECTATOR_FOLLOW
- && level.clients[i].sess.spectatorClient == clientNum ) {
- StopFollowing( &g_entities[i] );
- }
- }
-
// send effect if they were completely connected
if ( ent->client->pers.connected == CON_CONNECTED
&& ent->client->sess.sessionTeam != TEAM_SPECTATOR ) {
@@ -1598,14 +1520,6 @@ void ClientDisconnect( int clientNum ) {
G_LogPrintf( "ClientDisconnect: %i\n", clientNum );
- // if we are playing in tourney mode and losing, give a win to the other player
- if ( ( g_gametype.integer == GT_TOURNAMENT )
- && !level.intermissiontime
- && !level.warmupTime && level.sortedClients[1] == clientNum ) {
- level.clients[ level.sortedClients[0] ].sess.wins++;
- ClientUserinfoChanged( level.sortedClients[0] );
- }
-
trap_UnlinkEntity (ent);
ent->s.modelindex = 0;
ent->inuse = qfalse;
@@ -1617,9 +1531,4 @@ void ClientDisconnect( int clientNum ) {
trap_SetConfigstring( CS_PLAYERS + clientNum, "");
CalculateRanks();
-
- //TA: rip bots
- /*if ( ent->r.svFlags & SVF_BOT ) {
- BotAIShutdownClient( clientNum );
- }*/
}
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 3b789207..37cc866e 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -16,51 +16,55 @@
#include "g_local.h"
-#include "../../ui/menudef.h" // for the voice chats
+//#include "../../ui/menudef.h" // for the voice chats
/*
==================
-DeathmatchScoreboardMessage
+ScoreboardMessage
==================
*/
-void DeathmatchScoreboardMessage( gentity_t *ent ) {
- char entry[1024];
- char string[1400];
+void ScoreboardMessage( gentity_t *ent )
+{
+ char entry[ 1024 ];
+ char string[ 1400 ];
int stringlength;
int i, j;
gclient_t *cl;
int numSorted;
// send the latest information on all clients
- string[0] = 0;
+ string[ 0 ] = 0;
stringlength = 0;
numSorted = level.numConnectedClients;
- for (i=0 ; i < numSorted ; i++) {
+ for( i = 0; i < numSorted; i++ )
+ {
int ping;
- cl = &level.clients[level.sortedClients[i]];
+ cl = &level.clients[ level.sortedClients[ i ] ];
- if ( cl->pers.connected == CON_CONNECTING ) {
+ if( cl->pers.connected == CON_CONNECTING )
ping = -1;
- } else {
+ else
ping = cl->ps.ping < 999 ? cl->ps.ping : 999;
- }
- Com_sprintf (entry, sizeof(entry),
- " %i %i %i %i", level.sortedClients[i],
- cl->ps.persistant[PERS_SCORE], ping, (level.time - cl->pers.enterTime)/60000 );
- j = strlen(entry);
- if (stringlength + j > 1024)
+
+ Com_sprintf( entry, sizeof( entry ),
+ " %i %i %i %i", level.sortedClients[ i ],
+ cl->ps.persistant[ PERS_SCORE ], ping, ( level.time - cl->pers.enterTime ) / 60000 );
+
+ j = strlen( entry );
+
+ if( stringlength + j > 1024 )
break;
- strcpy (string + stringlength, entry);
+
+ strcpy( string + stringlength, entry );
stringlength += j;
}
- trap_SendServerCommand( ent-g_entities, va("scores %i %i %i%s", i,
- level.teamScores[TEAM_HUMANS], level.teamScores[TEAM_ALIENS],
- string ) );
+ trap_SendServerCommand( ent-g_entities, va( "scores %i %i %i%s", i,
+ level.alienKills, level.humanKills, string ) );
}
@@ -71,8 +75,9 @@ Cmd_Score_f
Request current scoreboard information
==================
*/
-void Cmd_Score_f( gentity_t *ent ) {
- DeathmatchScoreboardMessage( ent );
+void Cmd_Score_f( gentity_t *ent )
+{
+ ScoreboardMessage( ent );
}
@@ -100,29 +105,35 @@ qboolean CheatsOk( gentity_t *ent ) {
ConcatArgs
==================
*/
-char *ConcatArgs( int start ) {
- int i, c, tlen;
- static char line[MAX_STRING_CHARS];
- int len;
- char arg[MAX_STRING_CHARS];
+char *ConcatArgs( int start )
+{
+ int i, c, tlen;
+ static char line[ MAX_STRING_CHARS ];
+ int len;
+ char arg[ MAX_STRING_CHARS ];
len = 0;
- c = trap_Argc();
- for ( i = start ; i < c ; i++ ) {
+ c = trap_Argc( );
+
+ for( i = start; i < c; i++ )
+ {
trap_Argv( i, arg, sizeof( arg ) );
tlen = strlen( arg );
- if ( len + tlen >= MAX_STRING_CHARS - 1 ) {
+
+ if( len + tlen >= MAX_STRING_CHARS - 1 )
break;
- }
+
memcpy( line + len, arg, tlen );
len += tlen;
- if ( i != c - 1 ) {
- line[len] = ' ';
+
+ if( i != c - 1 )
+ {
+ line[ len ] = ' ';
len++;
}
}
- line[len] = 0;
+ line[ len ] = 0;
return line;
}
@@ -363,19 +374,12 @@ and sends over a command to the client to resize the view,
hide the scoreboard, and take a special screenshot
==================
*/
-void Cmd_LevelShot_f( gentity_t *ent ) {
- if ( !CheatsOk( ent ) ) {
- return;
- }
-
- // doesn't work in single player
- if ( g_gametype.integer != 0 ) {
- trap_SendServerCommand( ent-g_entities,
- "print \"Must be in g_gametype 0 for levelshot\n\"" );
+void Cmd_LevelShot_f( gentity_t *ent )
+{
+ if( !CheatsOk( ent ) )
return;
- }
- BeginIntermission();
+ BeginIntermission( );
trap_SendServerCommand( ent-g_entities, "clientLevelShot" );
}
@@ -404,8 +408,9 @@ void Cmd_TeamTask_f( gentity_t *ent ) {
Cmd_Kill_f
=================
*/
-void Cmd_Kill_f( gentity_t *ent ) {
- if( ent->client->sess.sessionTeam == TEAM_SPECTATOR )
+void Cmd_Kill_f( gentity_t *ent )
+{
+ if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_NONE )
return;
if( ent->client->ps.stats[ STAT_STATE ] & SS_INFESTING )
@@ -427,167 +432,6 @@ void Cmd_Kill_f( gentity_t *ent ) {
/*
=================
-BroadCastTeamChange
-
-Let everyone know about a team change
-=================
-*/
-void BroadcastTeamChange( gclient_t *client, int oldTeam )
-{
- if ( client->sess.sessionTeam == TEAM_HUMANS ) {
- trap_SendServerCommand( -1, va("cp \"%s" S_COLOR_WHITE " joined the humans.\n\"",
- client->pers.netname) );
- } else if ( client->sess.sessionTeam == TEAM_ALIENS ) {
- trap_SendServerCommand( -1, va("cp \"%s" S_COLOR_WHITE " joined the aliens.\n\"",
- client->pers.netname));
- } else if ( client->sess.sessionTeam == TEAM_SPECTATOR && oldTeam != TEAM_SPECTATOR ) {
- trap_SendServerCommand( -1, va("cp \"%s" S_COLOR_WHITE " joined the spectators.\n\"",
- client->pers.netname));
- } else if ( client->sess.sessionTeam == TEAM_FREE ) {
- trap_SendServerCommand( -1, va("cp \"%s" S_COLOR_WHITE " joined the battle.\n\"",
- client->pers.netname));
- }
-}
-
-/*
-=================
-SetTeam
-=================
-*/
-void SetTeam( gentity_t *ent, char *s ) {
- int team, oldTeam;
- gclient_t *client;
- int clientNum;
- spectatorState_t specState;
- int specClient;
-
- //
- // see what change is requested
- //
- client = ent->client;
-
- clientNum = client - level.clients;
- specClient = 0;
-
- specState = SPECTATOR_NOT;
- if ( !Q_stricmp( s, "scoreboard" ) || !Q_stricmp( s, "score" ) ) {
- team = TEAM_SPECTATOR;
- specState = SPECTATOR_SCOREBOARD;
- } else if ( !Q_stricmp( s, "follow1" ) ) {
- team = TEAM_SPECTATOR;
- specState = SPECTATOR_FOLLOW;
- specClient = -1;
- } else if ( !Q_stricmp( s, "follow2" ) ) {
- team = TEAM_SPECTATOR;
- specState = SPECTATOR_FOLLOW;
- specClient = -2;
- } else if ( !Q_stricmp( s, "spectator" ) || !Q_stricmp( s, "s" ) ) {
- team = TEAM_SPECTATOR;
- specState = SPECTATOR_FREE;
- } else if ( g_gametype.integer >= GT_TEAM ) {
- // if running a team game, assign player to one of the teams
- specState = SPECTATOR_NOT;
- if ( !Q_stricmp( s, "humans" ) || !Q_stricmp( s, "h" ) ) {
- team = TEAM_HUMANS;
- } else if ( !Q_stricmp( s, "aliens" ) || !Q_stricmp( s, "d" ) ) {
- team = TEAM_ALIENS;
- } else {
- // pick the team with the least number of players
- team = PickTeam( clientNum );
- }
-
- if ( g_teamForceBalance.integer ) {
- int counts[TEAM_NUM_TEAMS];
-
- counts[TEAM_ALIENS] = TeamCount( ent->client->ps.clientNum, TEAM_ALIENS );
- counts[TEAM_HUMANS] = TeamCount( ent->client->ps.clientNum, TEAM_HUMANS );
-
- // We allow a spread of two
- if ( team == TEAM_HUMANS && counts[TEAM_HUMANS] - counts[TEAM_ALIENS] > 1 ) {
- trap_SendServerCommand( ent->client->ps.clientNum,
- "cp \"Humans team has too many players.\n\"" );
- return; // ignore the request
- }
- if ( team == TEAM_ALIENS && counts[TEAM_ALIENS] - counts[TEAM_HUMANS] > 1 ) {
- trap_SendServerCommand( ent->client->ps.clientNum,
- "cp \"Aliens team has too many players.\n\"" );
- return; // ignore the request
- }
-
- // It's ok, the team we are switching to has less or same number of players
- }
-
- } else {
- // force them to spectators if there aren't any spots free
- team = TEAM_FREE;
- }
-
- // override decision if limiting the players
- if ( (g_gametype.integer == GT_TOURNAMENT)
- && level.numNonSpectatorClients >= 2 ) {
- team = TEAM_SPECTATOR;
- } else if ( g_maxGameClients.integer > 0 &&
- level.numNonSpectatorClients >= g_maxGameClients.integer ) {
- team = TEAM_SPECTATOR;
- }
-
- //
- // decide if we will allow the change
- //
- oldTeam = client->sess.sessionTeam;
- if ( team == oldTeam && team != TEAM_SPECTATOR ) {
- return;
- }
-
- //
- // execute the team change
- //
-
- // he starts at 'base'
- client->pers.teamState.state = TEAM_BEGIN;
- if ( oldTeam != TEAM_SPECTATOR ) {
- // Kill him (makes sure he loses flags, etc)
- ent->flags &= ~FL_GODMODE;
- ent->client->ps.stats[STAT_HEALTH] = ent->health = 0;
- player_die (ent, ent, ent, 100000, MOD_SUICIDE);
-
- }
- // they go to the end of the line for tournements
- if ( team == TEAM_SPECTATOR ) {
- client->sess.spectatorTime = level.time;
- }
-
- client->sess.sessionTeam = team;
- client->sess.spectatorState = specState;
- client->sess.spectatorClient = specClient;
-
- BroadcastTeamChange( client, oldTeam );
-
- // get and distribute relevent paramters
- ClientUserinfoChanged( clientNum );
-
- ClientBegin( clientNum );
-}
-
-/*
-=================
-StopFollowing
-
-If the client being followed leaves the game, or you just want to drop
-to free floating spectator mode
-=================
-*/
-void StopFollowing( gentity_t *ent ) {
- ent->client->ps.persistant[ PERS_TEAM ] = TEAM_SPECTATOR;
- ent->client->sess.sessionTeam = TEAM_SPECTATOR;
- ent->client->sess.spectatorState = SPECTATOR_FREE;
- ent->client->ps.pm_flags &= ~PMF_FOLLOW;
- ent->r.svFlags &= ~SVF_BOT;
- ent->client->ps.clientNum = ent - g_entities;
-}
-
-/*
-=================
Cmd_Team_f
=================
*/
@@ -631,197 +475,94 @@ void Cmd_Team_f( gentity_t *ent )
/*
-=================
-Cmd_Follow_f
-=================
-*/
-void Cmd_Follow_f( gentity_t *ent ) {
- int i;
- char arg[MAX_TOKEN_CHARS];
-
- if ( trap_Argc() != 2 ) {
- if ( ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) {
- StopFollowing( ent );
- }
- return;
- }
-
- trap_Argv( 1, arg, sizeof( arg ) );
- i = ClientNumberFromString( ent, arg );
- if ( i == -1 ) {
- return;
- }
-
- // can't follow self
- if ( &level.clients[ i ] == ent->client ) {
- return;
- }
-
- // can't follow another spectator
- if ( level.clients[ i ].sess.sessionTeam == TEAM_SPECTATOR ) {
- return;
- }
-
- // if they are playing a tournement game, count as a loss
- if ( ( g_gametype.integer == GT_TOURNAMENT )
- && ent->client->sess.sessionTeam == TEAM_FREE ) {
- ent->client->sess.losses++;
- }
-
- // first set them to spectator
- if ( ent->client->sess.sessionTeam != TEAM_SPECTATOR ) {
- SetTeam( ent, "spectator" );
- }
-
- ent->client->sess.spectatorState = SPECTATOR_FOLLOW;
- ent->client->sess.spectatorClient = i;
-}
-
-/*
-=================
-Cmd_FollowCycle_f
-=================
-*/
-void Cmd_FollowCycle_f( gentity_t *ent, int dir ) {
- int clientnum;
- int original;
-
- // if they are playing a tournement game, count as a loss
- if ( ( g_gametype.integer == GT_TOURNAMENT )
- && ent->client->sess.sessionTeam == TEAM_FREE ) {
- ent->client->sess.losses++;
- }
- // first set them to spectator
- if ( ent->client->sess.spectatorState == SPECTATOR_NOT ) {
- SetTeam( ent, "spectator" );
- }
-
- if ( dir != 1 && dir != -1 ) {
- G_Error( "Cmd_FollowCycle_f: bad dir %i", dir );
- }
-
- clientnum = ent->client->sess.spectatorClient;
- original = clientnum;
- do {
- clientnum += dir;
- if ( clientnum >= level.maxclients ) {
- clientnum = 0;
- }
- if ( clientnum < 0 ) {
- clientnum = level.maxclients - 1;
- }
-
- // can only follow connected clients
- if ( level.clients[ clientnum ].pers.connected != CON_CONNECTED ) {
- continue;
- }
-
- // can't follow another spectator
- if ( level.clients[ clientnum ].sess.sessionTeam == TEAM_SPECTATOR ) {
- continue;
- }
-
- // this is good, we can use it
- ent->client->sess.spectatorClient = clientnum;
- ent->client->sess.spectatorState = SPECTATOR_FOLLOW;
- return;
- } while ( clientnum != original );
-
- // leave it where it was
-}
-
-
-/*
==================
G_Say
==================
*/
-static void G_SayTo( gentity_t *ent, gentity_t *other, int mode, int color, const char *name, const char *message ) {
- if (!other) {
- return;
- }
- if (!other->inuse) {
+static void G_SayTo( gentity_t *ent, gentity_t *other, int mode, int color, const char *name, const char *message )
+{
+ if( !other )
return;
- }
- if (!other->client) {
+
+ if( !other->inuse )
return;
- }
- if ( other->client->pers.connected != CON_CONNECTED ) {
+
+ if( !other->client )
return;
- }
- if ( mode == SAY_TEAM && !OnSameTeam(ent, other) ) {
+
+ if( other->client->pers.connected != CON_CONNECTED )
return;
- }
- // no chatting to players in tournements
- if ( ( g_gametype.integer == GT_TOURNAMENT )
- && other->client->sess.sessionTeam == TEAM_FREE
- && ent->client->sess.sessionTeam != TEAM_FREE ) {
+
+ if( mode == SAY_TEAM && !OnSameTeam( ent, other ) )
return;
- }
- trap_SendServerCommand( other-g_entities, va("%s \"%s%c%c%s\"",
+ trap_SendServerCommand( other-g_entities, va( "%s \"%s%c%c%s\"",
mode == SAY_TEAM ? "tchat" : "chat",
- name, Q_COLOR_ESCAPE, color, message));
+ name, Q_COLOR_ESCAPE, color, message ) );
}
#define EC "\x19"
-void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) {
+void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText )
+{
int j;
gentity_t *other;
int color;
- char name[64];
+ char name[ 64 ];
// don't let text be too long for malicious reasons
- char text[MAX_SAY_TEXT];
- char location[64];
-
- if ( g_gametype.integer < GT_TEAM && mode == SAY_TEAM ) {
- mode = SAY_ALL;
- }
-
- switch ( mode ) {
- default:
- case SAY_ALL:
- G_LogPrintf( "say: %s: %s\n", ent->client->pers.netname, chatText );
- Com_sprintf (name, sizeof(name), "%s%c%c"EC": ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE );
- color = COLOR_GREEN;
- break;
- case SAY_TEAM:
- G_LogPrintf( "sayteam: %s: %s\n", ent->client->pers.netname, chatText );
- if (Team_GetLocationMsg(ent, location, sizeof(location)))
- Com_sprintf (name, sizeof(name), EC"(%s%c%c"EC") (%s)"EC": ",
- ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE, location);
- else
- Com_sprintf (name, sizeof(name), EC"(%s%c%c"EC")"EC": ",
- ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE );
- color = COLOR_CYAN;
- break;
- case SAY_TELL:
- if (target && g_gametype.integer >= GT_TEAM &&
- target->client->sess.sessionTeam == ent->client->sess.sessionTeam &&
- Team_GetLocationMsg(ent, location, sizeof(location)))
- Com_sprintf (name, sizeof(name), EC"[%s%c%c"EC"] (%s)"EC": ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE, location );
- else
- Com_sprintf (name, sizeof(name), EC"[%s%c%c"EC"]"EC": ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE );
- color = COLOR_MAGENTA;
- break;
+ char text[ MAX_SAY_TEXT ];
+ char location[ 64 ];
+
+ switch( mode )
+ {
+ default:
+ case SAY_ALL:
+ G_LogPrintf( "say: %s: %s\n", ent->client->pers.netname, chatText );
+ Com_sprintf( name, sizeof( name ), "%s%c%c"EC": ", ent->client->pers.netname,
+ Q_COLOR_ESCAPE, COLOR_WHITE );
+ color = COLOR_GREEN;
+ break;
+
+ case SAY_TEAM:
+ G_LogPrintf( "sayteam: %s: %s\n", ent->client->pers.netname, chatText );
+ if( Team_GetLocationMsg( ent, location, sizeof( location ) ) )
+ Com_sprintf( name, sizeof( name ), EC"(%s%c%c"EC") (%s)"EC": ",
+ ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE, location );
+ else
+ Com_sprintf( name, sizeof( name ), EC"(%s%c%c"EC")"EC": ",
+ ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE );
+ color = COLOR_CYAN;
+ break;
+
+ case SAY_TELL:
+ if( target &&
+ target->client->ps.stats[ STAT_PTEAM ] == ent->client->ps.stats[ STAT_PTEAM ] &&
+ Team_GetLocationMsg( ent, location, sizeof( location ) ) )
+ Com_sprintf( name, sizeof( name ), EC"[%s%c%c"EC"] (%s)"EC": ",
+ ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE, location );
+ else
+ Com_sprintf( name, sizeof( name ), EC"[%s%c%c"EC"]"EC": ",
+ ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE );
+ color = COLOR_MAGENTA;
+ break;
}
- Q_strncpyz( text, chatText, sizeof(text) );
+ Q_strncpyz( text, chatText, sizeof( text ) );
- if ( target ) {
+ if( target )
+ {
G_SayTo( ent, target, mode, color, name, text );
return;
}
// echo the text to the console
- if ( g_dedicated.integer ) {
+ if( g_dedicated.integer )
G_Printf( "%s%s\n", name, text);
- }
// send it to all the apropriate clients
- for (j = 0; j < level.maxclients; j++) {
- other = &g_entities[j];
+ for( j = 0; j < level.maxclients; j++ )
+ {
+ other = &g_entities[ j ];
G_SayTo( ent, other, mode, color, name, text );
}
}
@@ -832,21 +573,17 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText )
Cmd_Say_f
==================
*/
-static void Cmd_Say_f( gentity_t *ent, int mode, qboolean arg0 ) {
+static void Cmd_Say_f( gentity_t *ent, int mode, qboolean arg0 )
+{
char *p;
- if ( trap_Argc () < 2 && !arg0 ) {
+ if( trap_Argc( ) < 2 && !arg0 )
return;
- }
- if (arg0)
- {
+ if( arg0 )
p = ConcatArgs( 0 );
- }
else
- {
p = ConcatArgs( 1 );
- }
G_Say( ent, NULL, mode, p );
}
@@ -856,26 +593,25 @@ static void Cmd_Say_f( gentity_t *ent, int mode, qboolean arg0 ) {
Cmd_Tell_f
==================
*/
-static void Cmd_Tell_f( gentity_t *ent ) {
+static void Cmd_Tell_f( gentity_t *ent )
+{
int targetNum;
gentity_t *target;
char *p;
char arg[MAX_TOKEN_CHARS];
- if ( trap_Argc () < 2 ) {
+ if( trap_Argc( ) < 2 )
return;
- }
trap_Argv( 1, arg, sizeof( arg ) );
targetNum = atoi( arg );
- if ( targetNum < 0 || targetNum >= level.maxclients ) {
+
+ if( targetNum < 0 || targetNum >= level.maxclients )
return;
- }
- target = &g_entities[targetNum];
- if ( !target || !target->inuse || !target->client ) {
+ target = &g_entities[ targetNum ];
+ if( !target || !target->inuse || !target->client )
return;
- }
p = ConcatArgs( 2 );
@@ -883,240 +619,8 @@ static void Cmd_Tell_f( gentity_t *ent ) {
G_Say( ent, target, SAY_TELL, p );
// don't tell to the player self if it was already directed to this player
// also don't send the chat back to a bot
- if ( ent != target && !(ent->r.svFlags & SVF_BOT)) {
+ if( ent != target && !( ent->r.svFlags & SVF_BOT ) )
G_Say( ent, ent, SAY_TELL, p );
- }
-}
-
-
-static void G_VoiceTo( gentity_t *ent, gentity_t *other, int mode, const char *id, qboolean voiceonly ) {
- int color;
- char *cmd;
-
- if (!other) {
- return;
- }
- if (!other->inuse) {
- return;
- }
- if (!other->client) {
- return;
- }
- if ( mode == SAY_TEAM && !OnSameTeam(ent, other) ) {
- return;
- }
- // no chatting to players in tournements
- if ( (g_gametype.integer == GT_TOURNAMENT )) {
- return;
- }
-
- if (mode == SAY_TEAM) {
- color = COLOR_CYAN;
- cmd = "vtchat";
- }
- else if (mode == SAY_TELL) {
- color = COLOR_MAGENTA;
- cmd = "vtell";
- }
- else {
- color = COLOR_GREEN;
- cmd = "vchat";
- }
-
- trap_SendServerCommand( other-g_entities, va("%s %d %d %d %s", cmd, voiceonly, ent->s.number, color, id));
-}
-
-
-void G_Voice( gentity_t *ent, gentity_t *target, int mode, const char *id, qboolean voiceonly ) {
- int j;
- gentity_t *other;
-
- if ( g_gametype.integer < GT_TEAM && mode == SAY_TEAM ) {
- mode = SAY_ALL;
- }
-
- if ( target ) {
- G_VoiceTo( ent, target, mode, id, voiceonly );
- return;
- }
-
- // echo the text to the console
- if ( g_dedicated.integer ) {
- G_Printf( "voice: %s %s\n", ent->client->pers.netname, id);
- }
-
- // send it to all the apropriate clients
- for (j = 0; j < level.maxclients; j++) {
- other = &g_entities[j];
- G_VoiceTo( ent, other, mode, id, voiceonly );
- }
-}
-
-
-/*
-==================
-Cmd_Voice_f
-==================
-*/
-static void Cmd_Voice_f( gentity_t *ent, int mode, qboolean arg0, qboolean voiceonly ) {
- char *p;
-
- if ( trap_Argc () < 2 && !arg0 ) {
- return;
- }
-
- if (arg0)
- {
- p = ConcatArgs( 0 );
- }
- else
- {
- p = ConcatArgs( 1 );
- }
-
- G_Voice( ent, NULL, mode, p, voiceonly );
-}
-
-
-/*
-==================
-Cmd_VoiceTell_f
-==================
-*/
-static void Cmd_VoiceTell_f( gentity_t *ent, qboolean voiceonly ) {
- int targetNum;
- gentity_t *target;
- char *id;
- char arg[MAX_TOKEN_CHARS];
-
- if ( trap_Argc () < 2 ) {
- return;
- }
-
- trap_Argv( 1, arg, sizeof( arg ) );
- targetNum = atoi( arg );
- if ( targetNum < 0 || targetNum >= level.maxclients ) {
- return;
- }
-
- target = &g_entities[targetNum];
- if ( !target || !target->inuse || !target->client ) {
- return;
- }
-
- id = ConcatArgs( 2 );
-
- G_LogPrintf( "vtell: %s to %s: %s\n", ent->client->pers.netname, target->client->pers.netname, id );
- G_Voice( ent, target, SAY_TELL, id, voiceonly );
- // don't tell to the player self if it was already directed to this player
- // also don't send the chat back to a bot
- if ( ent != target && !(ent->r.svFlags & SVF_BOT)) {
- G_Voice( ent, ent, SAY_TELL, id, voiceonly );
- }
-}
-
-
-/*
-==================
-Cmd_VoiceTaunt_f
-==================
-*/
-static void Cmd_VoiceTaunt_f( gentity_t *ent ) {
- gentity_t *who;
- int i;
-
- if (!ent->client) {
- return;
- }
-
- // insult someone who just killed you
- if (ent->enemy && ent->enemy->client && ent->enemy->client->lastkilled_client == ent->s.number) {
- // i am a dead corpse
- if (!(ent->enemy->r.svFlags & SVF_BOT)) {
- //G_Voice( ent, ent->enemy, SAY_TELL, VOICECHAT_DEATHINSULT, qfalse );
- }
- if (!(ent->r.svFlags & SVF_BOT)) {
- //G_Voice( ent, ent, SAY_TELL, VOICECHAT_DEATHINSULT, qfalse );
- }
- ent->enemy = NULL;
- return;
- }
- // insult someone you just killed
- if (ent->client->lastkilled_client >= 0 && ent->client->lastkilled_client != ent->s.number) {
- who = g_entities + ent->client->lastkilled_client;
- if (who->client) {
- // who is the person I just killed
- if (who->client->lasthurt_mod == MOD_GAUNTLET) {
- if (!(who->r.svFlags & SVF_BOT)) {
- //G_Voice( ent, who, SAY_TELL, VOICECHAT_KILLGAUNTLET, qfalse ); // and I killed them with a gauntlet
- }
- if (!(ent->r.svFlags & SVF_BOT)) {
- //G_Voice( ent, ent, SAY_TELL, VOICECHAT_KILLGAUNTLET, qfalse );
- }
- } else {
- if (!(who->r.svFlags & SVF_BOT)) {
- //G_Voice( ent, who, SAY_TELL, VOICECHAT_KILLINSULT, qfalse ); // and I killed them with something else
- }
- if (!(ent->r.svFlags & SVF_BOT)) {
- //G_Voice( ent, ent, SAY_TELL, VOICECHAT_KILLINSULT, qfalse );
- }
- }
- ent->client->lastkilled_client = -1;
- return;
- }
- }
-
- if (g_gametype.integer >= GT_TEAM) {
- // praise a team mate who just got a reward
- for(i = 0; i < MAX_CLIENTS; i++) {
- who = g_entities + i;
- if (who->client && who != ent && who->client->sess.sessionTeam == ent->client->sess.sessionTeam) {
- if (who->client->rewardTime > level.time) {
- if (!(who->r.svFlags & SVF_BOT)) {
- //G_Voice( ent, who, SAY_TELL, VOICECHAT_PRAISE, qfalse );
- }
- if (!(ent->r.svFlags & SVF_BOT)) {
- //G_Voice( ent, ent, SAY_TELL, VOICECHAT_PRAISE, qfalse );
- }
- return;
- }
- }
- }
- }
-
- // just say something
- //G_Voice( ent, NULL, SAY_ALL, VOICECHAT_TAUNT, qfalse );
-}
-
-
-static char *gc_orders[] = {
- "hold your position",
- "hold this position",
- "come here",
- "cover me",
- "guard location",
- "search and destroy",
- "report"
-};
-
-void Cmd_GameCommand_f( gentity_t *ent ) {
- int player;
- int order;
- char str[MAX_TOKEN_CHARS];
-
- trap_Argv( 1, str, sizeof( str ) );
- player = atoi( str );
- trap_Argv( 2, str, sizeof( str ) );
- order = atoi( str );
-
- if ( player < 0 || player >= MAX_CLIENTS ) {
- return;
- }
- if ( order < 0 || order > sizeof(gc_orders)/sizeof(char *) ) {
- return;
- }
- G_Say( ent, &g_entities[player], SAY_TELL, gc_orders[order] );
- G_Say( ent, ent, SAY_TELL, gc_orders[order] );
}
/*
@@ -1144,25 +648,32 @@ static const char *gameNames[] = {
Cmd_CallVote_f
==================
*/
-void Cmd_CallVote_f( gentity_t *ent ) {
+void Cmd_CallVote_f( gentity_t *ent )
+{
int i;
- char arg1[MAX_STRING_TOKENS];
- char arg2[MAX_STRING_TOKENS];
+ char arg1[ MAX_STRING_TOKENS ];
+ char arg2[ MAX_STRING_TOKENS ];
- if ( !g_allowVote.integer ) {
+ if( !g_allowVote.integer )
+ {
trap_SendServerCommand( ent-g_entities, "print \"Voting not allowed here.\n\"" );
return;
}
- if ( level.voteTime ) {
+ if( level.voteTime )
+ {
trap_SendServerCommand( ent-g_entities, "print \"A vote is already in progress.\n\"" );
return;
}
- if ( ent->client->pers.voteCount >= MAX_VOTE_COUNT ) {
+
+ if( ent->client->pers.voteCount >= MAX_VOTE_COUNT )
+ {
trap_SendServerCommand( ent-g_entities, "print \"You have called the maximum number of votes.\n\"" );
return;
}
- if ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {
+
+ if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_NONE )
+ {
trap_SendServerCommand( ent-g_entities, "print \"Not allowed to call a vote as spectator.\n\"" );
return;
}
@@ -1171,85 +682,86 @@ void Cmd_CallVote_f( gentity_t *ent ) {
trap_Argv( 1, arg1, sizeof( arg1 ) );
trap_Argv( 2, arg2, sizeof( arg2 ) );
- if( strchr( arg1, ';' ) || strchr( arg2, ';' ) ) {
+ if( strchr( arg1, ';' ) || strchr( arg2, ';' ) )
+ {
trap_SendServerCommand( ent-g_entities, "print \"Invalid vote string.\n\"" );
return;
}
- if ( !Q_stricmp( arg1, "map_restart" ) ) {
- } else if ( !Q_stricmp( arg1, "nextmap" ) ) {
- } else if ( !Q_stricmp( arg1, "map" ) ) {
- } else if ( !Q_stricmp( arg1, "g_gametype" ) ) {
- } else if ( !Q_stricmp( arg1, "kick" ) ) {
- } else if ( !Q_stricmp( arg1, "clientkick" ) ) {
- } else if ( !Q_stricmp( arg1, "g_doWarmup" ) ) {
- } else if ( !Q_stricmp( arg1, "timelimit" ) ) {
- } else if ( !Q_stricmp( arg1, "fraglimit" ) ) {
- } else {
+ if( !Q_stricmp( arg1, "map_restart" ) ) { }
+ else if( !Q_stricmp( arg1, "nextmap" ) ) { }
+ else if( !Q_stricmp( arg1, "map" ) ) { }
+ else if( !Q_stricmp( arg1, "kick" ) ) { }
+ else if( !Q_stricmp( arg1, "clientkick" ) ) { }
+ else if( !Q_stricmp( arg1, "timelimit" ) ) { }
+ else
+ {
trap_SendServerCommand( ent-g_entities, "print \"Invalid vote string.\n\"" );
- trap_SendServerCommand( ent-g_entities, "print \"Vote commands are: map_restart, nextmap, map <mapname>, g_gametype <n>, kick <player>, clientkick <clientnum>, g_doWarmup, timelimit <time>, fraglimit <frags>.\n\"" );
+ trap_SendServerCommand( ent-g_entities, "print \"Vote commands are: map_restart, nextmap, map <mapname>, "
+ "kick <player>, clientkick <clientnum>, "
+ "timelimit <time>.\n\"" );
return;
}
// if there is still a vote to be executed
- if ( level.voteExecuteTime ) {
+ if( level.voteExecuteTime )
+ {
level.voteExecuteTime = 0;
- trap_SendConsoleCommand( EXEC_APPEND, va("%s\n", level.voteString ) );
+ trap_SendConsoleCommand( EXEC_APPEND, va( "%s\n", level.voteString ) );
}
- // special case for g_gametype, check for bad values
- if ( !Q_stricmp( arg1, "g_gametype" ) ) {
- i = atoi( arg2 );
- if( i == GT_SINGLE_PLAYER || i < GT_FFA || i >= GT_MAX_GAME_TYPE) {
- trap_SendServerCommand( ent-g_entities, "print \"Invalid gametype.\n\"" );
- return;
- }
-
- Com_sprintf( level.voteString, sizeof( level.voteString ), "%s %d", arg1, i );
- Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s %s", arg1, gameNames[i] );
- } else if ( !Q_stricmp( arg1, "map" ) ) {
+ if( !Q_stricmp( arg1, "map" ) )
+ {
// special case for map changes, we want to reset the nextmap setting
// this allows a player to change maps, but not upset the map rotation
- char s[MAX_STRING_CHARS];
+ char s[ MAX_STRING_CHARS ];
- trap_Cvar_VariableStringBuffer( "nextmap", s, sizeof(s) );
- if (*s) {
+ trap_Cvar_VariableStringBuffer( "nextmap", s, sizeof( s ) );
+
+ if( *s )
Com_sprintf( level.voteString, sizeof( level.voteString ), "%s %s; set nextmap \"%s\"", arg1, arg2, s );
- } else {
+ else
Com_sprintf( level.voteString, sizeof( level.voteString ), "%s %s", arg1, arg2 );
- }
+
Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s", level.voteString );
- } else if ( !Q_stricmp( arg1, "nextmap" ) ) {
- char s[MAX_STRING_CHARS];
+ }
+ else if( !Q_stricmp( arg1, "nextmap" ) )
+ {
+ char s[ MAX_STRING_CHARS ];
- trap_Cvar_VariableStringBuffer( "nextmap", s, sizeof(s) );
- if (!*s) {
+ trap_Cvar_VariableStringBuffer( "nextmap", s, sizeof( s ) );
+
+ if( !*s )
+ {
trap_SendServerCommand( ent-g_entities, "print \"nextmap not set.\n\"" );
return;
}
- Com_sprintf( level.voteString, sizeof( level.voteString ), "vstr nextmap");
+
+ Com_sprintf( level.voteString, sizeof( level.voteString ), "vstr nextmap" );
Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s", level.voteString );
- } else {
+ }
+ else
+ {
Com_sprintf( level.voteString, sizeof( level.voteString ), "%s \"%s\"", arg1, arg2 );
Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s", level.voteString );
}
- trap_SendServerCommand( -1, va("print \"%s called a vote.\n\"", ent->client->pers.netname ) );
+ trap_SendServerCommand( -1, va( "print \"%s called a vote.\n\"", ent->client->pers.netname ) );
// start the voting, the caller autoamtically votes yes
level.voteTime = level.time;
level.voteYes = 1;
level.voteNo = 0;
- for ( i = 0 ; i < level.maxclients ; i++ ) {
+ for( i = 0 ; i < level.maxclients ; i++ )
level.clients[i].ps.eFlags &= ~EF_VOTED;
- }
+
ent->client->ps.eFlags |= EF_VOTED;
- trap_SetConfigstring( CS_VOTE_TIME, va("%i", level.voteTime ) );
+ trap_SetConfigstring( CS_VOTE_TIME, va( "%i", level.voteTime ) );
trap_SetConfigstring( CS_VOTE_STRING, level.voteDisplayString );
- trap_SetConfigstring( CS_VOTE_YES, va("%i", level.voteYes ) );
- trap_SetConfigstring( CS_VOTE_NO, va("%i", level.voteNo ) );
+ trap_SetConfigstring( CS_VOTE_YES, va( "%i", level.voteYes ) );
+ trap_SetConfigstring( CS_VOTE_NO, va( "%i", level.voteNo ) );
}
/*
@@ -1257,19 +769,24 @@ void Cmd_CallVote_f( gentity_t *ent ) {
Cmd_Vote_f
==================
*/
-void Cmd_Vote_f( gentity_t *ent ) {
- char msg[64];
+void Cmd_Vote_f( gentity_t *ent )
+{
+ char msg[ 64 ];
- if ( !level.voteTime ) {
+ if( !level.voteTime )
+ {
trap_SendServerCommand( ent-g_entities, "print \"No vote in progress.\n\"" );
return;
}
- if ( ent->client->ps.eFlags & EF_VOTED ) {
+
+ if( ent->client->ps.eFlags & EF_VOTED )
+ {
trap_SendServerCommand( ent-g_entities, "print \"Vote already cast.\n\"" );
return;
}
- if ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {
+ if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_NONE )
+ {
trap_SendServerCommand( ent-g_entities, "print \"Not allowed to vote as spectator.\n\"" );
return;
}
@@ -1280,12 +797,15 @@ void Cmd_Vote_f( gentity_t *ent ) {
trap_Argv( 1, msg, sizeof( msg ) );
- if ( msg[0] == 'y' || msg[1] == 'Y' || msg[1] == '1' ) {
+ if( msg[ 0 ] == 'y' || msg[ 1 ] == 'Y' || msg[ 1 ] == '1' )
+ {
level.voteYes++;
- trap_SetConfigstring( CS_VOTE_YES, va("%i", level.voteYes ) );
- } else {
+ trap_SetConfigstring( CS_VOTE_YES, va( "%i", level.voteYes ) );
+ }
+ else
+ {
level.voteNo++;
- trap_SetConfigstring( CS_VOTE_NO, va("%i", level.voteNo ) );
+ trap_SetConfigstring( CS_VOTE_NO, va( "%i", level.voteNo ) );
}
// a majority will be determined in G_CheckVote, which will also account
@@ -1297,53 +817,64 @@ void Cmd_Vote_f( gentity_t *ent ) {
Cmd_CallTeamVote_f
==================
*/
-void Cmd_CallTeamVote_f( gentity_t *ent ) {
+void Cmd_CallTeamVote_f( gentity_t *ent )
+{
int i, team, cs_offset;
- char arg1[MAX_STRING_TOKENS];
- char arg2[MAX_STRING_TOKENS];
+ char arg1[ MAX_STRING_TOKENS ];
+ char arg2[ MAX_STRING_TOKENS ];
- team = ent->client->sess.sessionTeam;
- if ( team == TEAM_HUMANS )
+ team = ent->client->ps.stats[ STAT_PTEAM ];
+ if( team == PTE_HUMANS )
cs_offset = 0;
- else if ( team == TEAM_ALIENS )
+ else if( team == PTE_ALIENS )
cs_offset = 1;
else
return;
- if ( !g_allowVote.integer ) {
+ if( !g_allowVote.integer )
+ {
trap_SendServerCommand( ent-g_entities, "print \"Voting not allowed here.\n\"" );
return;
}
- if ( level.teamVoteTime[cs_offset] ) {
+ if( level.teamVoteTime[ cs_offset ] )
+ {
trap_SendServerCommand( ent-g_entities, "print \"A team vote is already in progress.\n\"" );
return;
}
- if ( ent->client->pers.teamVoteCount >= MAX_VOTE_COUNT ) {
+
+ if( ent->client->pers.teamVoteCount >= MAX_VOTE_COUNT )
+ {
trap_SendServerCommand( ent-g_entities, "print \"You have called the maximum number of team votes.\n\"" );
return;
}
- if ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {
+
+ if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_NONE )
+ {
trap_SendServerCommand( ent-g_entities, "print \"Not allowed to call a vote as spectator.\n\"" );
return;
}
// make sure it is a valid command to vote on
trap_Argv( 1, arg1, sizeof( arg1 ) );
- arg2[0] = '\0';
- for ( i = 2; i < trap_Argc(); i++ ) {
- if (i > 2)
- strcat(arg2, " ");
- trap_Argv( i, &arg2[strlen(arg2)], sizeof( arg2 ) - strlen(arg2) );
+ arg2[ 0 ] = '\0';
+
+ for( i = 2; i < trap_Argc( ); i++ )
+ {
+ if( i > 2 )
+ strcat( arg2, " " );
+
+ trap_Argv( i, &arg2[ strlen( arg2 ) ], sizeof( arg2 ) - strlen( arg2 ) );
}
- if( strchr( arg1, ';' ) || strchr( arg2, ';' ) ) {
+ if( strchr( arg1, ';' ) || strchr( arg2, ';' ) )
+ {
trap_SendServerCommand( ent-g_entities, "print \"Invalid vote string.\n\"" );
return;
}
- if ( !Q_stricmp( arg1, "leader" ) ) {
+ /*if ( !Q_stricmp( arg1, "leader" ) ) {
char netname[MAX_NETNAME], leader[MAX_NETNAME];
if ( !arg2[0] ) {
@@ -1388,36 +919,42 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) {
}
}
Com_sprintf(arg2, sizeof(arg2), "%d", i);
- } else {
+ } else*/
+ {
trap_SendServerCommand( ent-g_entities, "print \"Invalid vote string.\n\"" );
trap_SendServerCommand( ent-g_entities, "print \"Team vote commands are: leader <player>.\n\"" );
return;
}
- Com_sprintf( level.teamVoteString[cs_offset], sizeof( level.teamVoteString[cs_offset] ), "%s %s", arg1, arg2 );
+/* Com_sprintf( level.teamVoteString[ cs_offset ],
+ sizeof( level.teamVoteString[ cs_offset ] ), "%s %s", arg1, arg2 );
- for ( i = 0 ; i < level.maxclients ; i++ ) {
- if ( level.clients[i].pers.connected == CON_DISCONNECTED )
+ for( i = 0 ; i < level.maxclients ; i++ )
+ {
+ if( level.clients[ i ].pers.connected == CON_DISCONNECTED )
continue;
- if (level.clients[i].sess.sessionTeam == team)
+
+ if( level.clients[ i ].ps.stats[ STAT_PTEAM ] == team )
trap_SendServerCommand( i, va("print \"%s called a team vote.\n\"", ent->client->pers.netname ) );
}
// start the voting, the caller autoamtically votes yes
- level.teamVoteTime[cs_offset] = level.time;
- level.teamVoteYes[cs_offset] = 1;
- level.teamVoteNo[cs_offset] = 0;
+ level.teamVoteTime[ cs_offset ] = level.time;
+ level.teamVoteYes[ cs_offset ] = 1;
+ level.teamVoteNo[ cs_offset ] = 0;
- for ( i = 0 ; i < level.maxclients ; i++ ) {
- if (level.clients[i].sess.sessionTeam == team)
- level.clients[i].ps.eFlags &= ~EF_TEAMVOTED;
+ for( i = 0 ; i < level.maxclients ; i++ )
+ {
+ if( level.clients[ i ].ps.stats[ STAT_PTEAM ] == team)
+ level.clients[ i ].ps.eFlags &= ~EF_TEAMVOTED;
}
+
ent->client->ps.eFlags |= EF_TEAMVOTED;
- trap_SetConfigstring( CS_TEAMVOTE_TIME + cs_offset, va("%i", level.teamVoteTime[cs_offset] ) );
- trap_SetConfigstring( CS_TEAMVOTE_STRING + cs_offset, level.teamVoteString[cs_offset] );
- trap_SetConfigstring( CS_TEAMVOTE_YES + cs_offset, va("%i", level.teamVoteYes[cs_offset] ) );
- trap_SetConfigstring( CS_TEAMVOTE_NO + cs_offset, va("%i", level.teamVoteNo[cs_offset] ) );
+ trap_SetConfigstring( CS_TEAMVOTE_TIME + cs_offset, va( "%i", level.teamVoteTime[ cs_offset ] ) );
+ trap_SetConfigstring( CS_TEAMVOTE_STRING + cs_offset, level.teamVoteString[ cs_offset ] );
+ trap_SetConfigstring( CS_TEAMVOTE_YES + cs_offset, va( "%i", level.teamVoteYes[ cs_offset ] ) );
+ trap_SetConfigstring( CS_TEAMVOTE_NO + cs_offset, va( "%i", level.teamVoteNo[ cs_offset ] ) );*/
}
@@ -1426,27 +963,33 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) {
Cmd_TeamVote_f
==================
*/
-void Cmd_TeamVote_f( gentity_t *ent ) {
+void Cmd_TeamVote_f( gentity_t *ent )
+{
int team, cs_offset;
- char msg[64];
+ char msg[ 64 ];
- team = ent->client->sess.sessionTeam;
- if ( team == TEAM_HUMANS )
+ team = ent->client->ps.stats[ STAT_PTEAM ];
+ if( team == PTE_HUMANS )
cs_offset = 0;
- else if ( team == TEAM_ALIENS )
+ else if( team == PTE_ALIENS )
cs_offset = 1;
else
return;
- if ( !level.teamVoteTime[cs_offset] ) {
+ if( !level.teamVoteTime[ cs_offset ] )
+ {
trap_SendServerCommand( ent-g_entities, "print \"No team vote in progress.\n\"" );
return;
}
- if ( ent->client->ps.eFlags & EF_TEAMVOTED ) {
+
+ if( ent->client->ps.eFlags & EF_TEAMVOTED )
+ {
trap_SendServerCommand( ent-g_entities, "print \"Team vote already cast.\n\"" );
return;
}
- if ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {
+
+ if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_NONE )
+ {
trap_SendServerCommand( ent-g_entities, "print \"Not allowed to vote as spectator.\n\"" );
return;
}
@@ -1457,12 +1000,15 @@ void Cmd_TeamVote_f( gentity_t *ent ) {
trap_Argv( 1, msg, sizeof( msg ) );
- if ( msg[0] == 'y' || msg[1] == 'Y' || msg[1] == '1' ) {
- level.teamVoteYes[cs_offset]++;
- trap_SetConfigstring( CS_TEAMVOTE_YES + cs_offset, va("%i", level.teamVoteYes[cs_offset] ) );
- } else {
- level.teamVoteNo[cs_offset]++;
- trap_SetConfigstring( CS_TEAMVOTE_NO + cs_offset, va("%i", level.teamVoteNo[cs_offset] ) );
+ if( msg[ 0 ] == 'y' || msg[ 1 ] == 'Y' || msg[ 1 ] == '1' )
+ {
+ level.teamVoteYes[ cs_offset ]++;
+ trap_SetConfigstring( CS_TEAMVOTE_YES + cs_offset, va( "%i", level.teamVoteYes[ cs_offset ] ) );
+ }
+ else
+ {
+ level.teamVoteNo[ cs_offset ]++;
+ trap_SetConfigstring( CS_TEAMVOTE_NO + cs_offset, va( "%i", level.teamVoteNo[ cs_offset ] ) );
}
// a majority will be determined in TeamCheckVote, which will also account
@@ -1502,29 +1048,6 @@ void Cmd_SetViewpos_f( gentity_t *ent ) {
}
-/*
-=================
-Cmd_Stats_f
-=================
-*/
-void Cmd_Stats_f( gentity_t *ent ) {
-/*
- int max, n, i;
-
- max = trap_AAS_PointReachabilityAreaIndex( NULL );
-
- n = 0;
- for ( i = 0; i < max; i++ ) {
- if ( ent->client->areabits[i >> 3] & (1 << (i & 7)) )
- n++;
- }
-
- //trap_SendServerCommand( ent-g_entities, va("print \"visited %d of %d areas\n\"", n, max));
- trap_SendServerCommand( ent-g_entities, va("print \"%d%% level coverage\n\"", n * 100 / max));
-*/
-}
-
-
#define NUM_AC 3
/*
@@ -1678,9 +1201,9 @@ void Cmd_Class_f( gentity_t *ent )
ent->client->pers.pclass = PCL_H_BASE;
//set the item to spawn with
- if( !Q_stricmp( s, "rifle" ) )
+ if( !Q_stricmp( s, BG_FindNameForWeapon( WP_MACHINEGUN ) ) )
ent->client->pers.pitem = WP_MACHINEGUN;
- else if( !Q_stricmp( s, "ckit" ) )
+ else if( !Q_stricmp( s, BG_FindNameForWeapon( WP_HBUILD ) ) )
ent->client->pers.pitem = WP_HBUILD;
else
{
@@ -2481,34 +2004,6 @@ void ClientCommand( int clientNum ) {
Cmd_Tell_f ( ent );
return;
}
- if (Q_stricmp (cmd, "vsay") == 0) {
- Cmd_Voice_f (ent, SAY_ALL, qfalse, qfalse);
- return;
- }
- if (Q_stricmp (cmd, "vsay_team") == 0) {
- Cmd_Voice_f (ent, SAY_TEAM, qfalse, qfalse);
- return;
- }
- if (Q_stricmp (cmd, "vtell") == 0) {
- Cmd_VoiceTell_f ( ent, qfalse );
- return;
- }
- if (Q_stricmp (cmd, "vosay") == 0) {
- Cmd_Voice_f (ent, SAY_ALL, qfalse, qtrue);
- return;
- }
- if (Q_stricmp (cmd, "vosay_team") == 0) {
- Cmd_Voice_f (ent, SAY_TEAM, qfalse, qtrue);
- return;
- }
- if (Q_stricmp (cmd, "votell") == 0) {
- Cmd_VoiceTell_f ( ent, qtrue );
- return;
- }
- if (Q_stricmp (cmd, "vtaunt") == 0) {
- Cmd_VoiceTaunt_f ( ent );
- return;
- }
if (Q_stricmp (cmd, "score") == 0) {
Cmd_Score_f (ent);
return;
@@ -2534,12 +2029,6 @@ void ClientCommand( int clientNum ) {
Cmd_TeamTask_f (ent);
else if (Q_stricmp (cmd, "levelshot") == 0)
Cmd_LevelShot_f (ent);
- else if (Q_stricmp (cmd, "follow") == 0)
- Cmd_Follow_f (ent);
- else if (Q_stricmp (cmd, "follownext") == 0)
- Cmd_FollowCycle_f (ent, 1);
- else if (Q_stricmp (cmd, "followprev") == 0)
- Cmd_FollowCycle_f (ent, -1);
else if (Q_stricmp (cmd, "team") == 0)
Cmd_Team_f (ent);
else if (Q_stricmp (cmd, "class") == 0)
@@ -2580,12 +2069,8 @@ void ClientCommand( int clientNum ) {
Cmd_CallTeamVote_f (ent);
else if (Q_stricmp (cmd, "teamvote") == 0)
Cmd_TeamVote_f (ent);
- else if (Q_stricmp (cmd, "gc") == 0)
- Cmd_GameCommand_f( ent );
else if (Q_stricmp (cmd, "setviewpos") == 0)
Cmd_SetViewpos_f( ent );
- else if (Q_stricmp (cmd, "stats") == 0)
- Cmd_Stats_f( ent );
else if (Q_stricmp (cmd, "spawnbody") == 0)
Cmd_Spawnbody_f( ent );
else if (Q_stricmp (cmd, "test") == 0)
diff --git a/src/game/g_combat.c b/src/game/g_combat.c
index e440ae32..0745b517 100644
--- a/src/game/g_combat.c
+++ b/src/game/g_combat.c
@@ -30,18 +30,17 @@ AddScore
Adds score to both the client and his team
============
*/
-void AddScore( gentity_t *ent, int score ) {
- if ( !ent->client ) {
+void AddScore( gentity_t *ent, int score )
+{
+ if( !ent->client )
return;
- }
+
// no scoring during pre-match warmup
- if ( level.warmupTime ) {
+ if( level.warmupTime )
return;
- }
- ent->client->ps.persistant[PERS_SCORE] += score;
- if (g_gametype.integer == GT_TEAM)
- level.teamScores[ ent->client->ps.persistant[PERS_TEAM] ] += score;
- CalculateRanks();
+
+ ent->client->ps.persistant[ PERS_SCORE ] += score;
+ CalculateRanks( );
}
/*
@@ -173,91 +172,6 @@ char *modNames[] = {
"MOD_DSPAWN"
};
-
-/*
-==================
-CheckAlmostCapture
-==================
-*/
-void CheckAlmostCapture( gentity_t *self, gentity_t *attacker ) {
- gentity_t *ent;
- vec3_t dir;
- char *classname;
-
- // if this player was carrying a flag
- /*if ( self->client->ps.powerups[PW_REDFLAG] ||
- self->client->ps.powerups[PW_BLUEFLAG] ||
- self->client->ps.powerups[PW_NEUTRALFLAG] ) {
- // get the goal flag this player should have been going for
- if ( g_gametype.integer == GT_CTF ) {
- if ( self->client->sess.sessionTeam == TEAM_ALIENS ) {
- classname = "team_CTF_blueflag";
- }
- else {
- classname = "team_CTF_redflag";
- }
- }
- else {
- if ( self->client->sess.sessionTeam == TEAM_ALIENS ) {
- classname = "team_CTF_redflag";
- }
- else {
- classname = "team_CTF_blueflag";
- }
- }
- ent = NULL;
- do
- {
- ent = G_Find(ent, FOFS(classname), classname);
- } while (ent && (ent->flags & FL_DROPPED_ITEM));
- // if we found the destination flag and it's not picked up
- if (ent && !(ent->r.svFlags & SVF_NOCLIENT) ) {
- // if the player was *very* close
- VectorSubtract( self->client->ps.origin, ent->s.origin, dir );
- if ( VectorLength(dir) < 200 ) {
- self->client->ps.persistant[PERS_PLAYEREVENTS] ^= PLAYEREVENT_HOLYSHIT;
- if ( attacker->client ) {
- attacker->client->ps.persistant[PERS_PLAYEREVENTS] ^= PLAYEREVENT_HOLYSHIT;
- }
- }
- }
- }*/
-}
-
-/*
-==================
-CheckAlmostScored
-==================
-*/
-void CheckAlmostScored( gentity_t *self, gentity_t *attacker ) {
- /*gentity_t *ent;
- vec3_t dir;
- char *classname;
-
- // if the player was carrying cubes
- if ( self->client->ps.generic1 ) {
- if ( self->client->sess.sessionTeam == TEAM_ALIENS ) {
- classname = "team_redobelisk";
- }
- else {
- classname = "team_blueobelisk";
- }
- ent = G_Find(NULL, FOFS(classname), classname);
- // if we found the destination obelisk
- if ( ent ) {
- // if the player was *very* close
- VectorSubtract( self->client->ps.origin, ent->s.origin, dir );
- if ( VectorLength(dir) < 200 ) {
- self->client->ps.persistant[PERS_PLAYEREVENTS] ^= PLAYEREVENT_HOLYSHIT;
- if ( attacker->client ) {
- attacker->client->ps.persistant[PERS_PLAYEREVENTS] ^= PLAYEREVENT_HOLYSHIT;
- }
- }
- }
- }*/
-}
-
-
/*
==================
player_die
diff --git a/src/game/g_local.h b/src/game/g_local.h
index 7e70f23d..574cd822 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -503,34 +503,12 @@ char *G_NewString( const char *string );
//
// g_cmds.c
//
-void Cmd_Score_f (gentity_t *ent);
-void StopFollowing( gentity_t *ent );
-void BroadcastTeamChange( gclient_t *client, int oldTeam );
-void SetTeam( gentity_t *ent, char *s );
-void Cmd_FollowCycle_f( gentity_t *ent, int dir );
+void Cmd_Score_f( gentity_t *ent );
//
-// g_items.c
+// g_physics.c
//
-void G_CheckTeamItems( void );
-void G_RunItem( gentity_t *ent, int msec );
-void RespawnItem( gentity_t *ent );
-
-void UseHoldableItem( gentity_t *ent );
-void PrecacheItem (gitem_t *it);
-gentity_t *Drop_Item( gentity_t *ent, gitem_t *item, float angle );
-gentity_t *LaunchItem( gitem_t *item, vec3_t origin, vec3_t velocity );
-void SetRespawn (gentity_t *ent, float delay);
-void G_SpawnBuildable(gentity_t *ent, buildable_t buildable);
-void FinishSpawningBuildable( gentity_t *ent );
-void Think_Weapon (gentity_t *ent);
-int ArmorIndex (gentity_t *ent);
-void Add_Ammo (gentity_t *ent, int weapon, int count);
-void Touch_Item (gentity_t *ent, gentity_t *other, trace_t *trace);
-
-void ClearRegisteredItems( void );
-void RegisterItem( gitem_t *item );
-void SaveRegisteredItems( void );
+void G_Physics( gentity_t *ent, int msec );
//
// g_buildable.c
@@ -565,13 +543,15 @@ gentity_t *G_buildItem( gentity_t *builder, buildable_t buildable, vec3_
void G_ValidateBuild( gentity_t *ent, buildable_t buildable );
void G_setBuildableAnim( gentity_t *ent, buildableAnimNumber_t anim, qboolean force );
void G_setIdleBuildableAnim( gentity_t *ent, buildableAnimNumber_t anim );
+void G_SpawnBuildable(gentity_t *ent, buildable_t buildable);
+void FinishSpawningBuildable( gentity_t *ent );
//
// g_utils.c
//
int G_ModelIndex( char *name );
int G_SoundIndex( char *name );
-void G_TeamCommand( team_t team, char *cmd );
+void G_TeamCommand( pTeam_t team, char *cmd );
void G_KillBox (gentity_t *ent);
gentity_t *G_Find (gentity_t *from, int fieldofs, const char *match);
gentity_t *G_PickTarget (char *targetname);
@@ -674,7 +654,6 @@ void Weapon_HookThink (gentity_t *ent);
//
team_t TeamCount( int ignoreClientNum, int team );
int TeamLeader( int team );
-team_t PickTeam( int ignoreClientNum );
void SetClientViewAngle( gentity_t *ent, vec3_t angle );
gentity_t *SelectSpawnPoint ( vec3_t avoidPoint, vec3_t origin, vec3_t angles );
void SpawnCorpse( gentity_t *ent );
@@ -713,7 +692,7 @@ void FireWeapon3( gentity_t *ent );
//
void MoveClientToIntermission (gentity_t *client);
void G_SetStats (gentity_t *ent);
-void DeathmatchScoreboardMessage (gentity_t *client);
+void ScoreboardMessage (gentity_t *client);
//
// g_cmds.c
@@ -825,7 +804,6 @@ extern gentity_t g_entities[MAX_GENTITIES];
#define FOFS(x) ((int)&(((gentity_t *)0)->x))
-extern vmCvar_t g_gametype;
extern vmCvar_t g_dedicated;
extern vmCvar_t g_cheats;
extern vmCvar_t g_maxclients; // allow this many total, including spectators
diff --git a/src/game/g_main.c b/src/game/g_main.c
index 1bc024ca..ba4616e5 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -31,7 +31,6 @@ typedef struct {
gentity_t g_entities[MAX_GENTITIES];
gclient_t g_clients[MAX_CLIENTS];
-vmCvar_t g_gametype;
vmCvar_t g_dmflags;
vmCvar_t g_fraglimit;
vmCvar_t g_timelimit;
@@ -98,8 +97,6 @@ static cvarTable_t gameCvarTable[] = {
{ NULL, "sv_mapname", "", CVAR_SERVERINFO | CVAR_ROM, 0, qfalse },
// latched vars
- { &g_gametype, "g_gametype", "0", CVAR_SERVERINFO | CVAR_USERINFO | CVAR_LATCH, 0, qfalse },
-
{ &g_maxclients, "sv_maxclients", "8", CVAR_SERVERINFO | CVAR_LATCH | CVAR_ARCHIVE, 0, qfalse },
{ &g_maxGameClients, "g_maxGameClients", "0", CVAR_SERVERINFO | CVAR_LATCH | CVAR_ARCHIVE, 0, qfalse },
@@ -218,9 +215,6 @@ int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int a
return 0;
case GAME_CONSOLE_COMMAND:
return ConsoleCommand();
- //TA: rip bots
- /*case BOTAI_START_FRAME:
- return BotAIStartFrame( arg0 );*/
}
return -1;
@@ -339,33 +333,28 @@ void G_RemapTeamShaders() {
G_RegisterCvars
=================
*/
-void G_RegisterCvars( void ) {
- int i;
+void G_RegisterCvars( void )
+{
+ int i;
cvarTable_t *cv;
- qboolean remapped = qfalse;
+ qboolean remapped = qfalse;
- for ( i = 0, cv = gameCvarTable ; i < gameCvarTableSize ; i++, cv++ ) {
+ for( i = 0, cv = gameCvarTable; i < gameCvarTableSize; i++, cv++ )
+ {
trap_Cvar_Register( cv->vmCvar, cv->cvarName,
cv->defaultString, cv->cvarFlags );
- if ( cv->vmCvar )
+
+ if( cv->vmCvar )
cv->modificationCount = cv->vmCvar->modificationCount;
- if (cv->teamShader) {
+ if( cv->teamShader )
remapped = qtrue;
- }
}
- if (remapped) {
- G_RemapTeamShaders();
- }
+ if( remapped )
+ G_RemapTeamShaders( );
// check some things
-
- if ( g_gametype.integer < 0 || g_gametype.integer >= GT_MAX_GAME_TYPE ) {
- G_Printf( "g_gametype %i is out of range, defaulting to 0\n", g_gametype.integer );
- trap_Cvar_Set( "g_gametype", "0" );
- }
-
level.warmupModificationCount = g_warmup.modificationCount;
}
@@ -410,20 +399,21 @@ G_InitGame
============
*/
-void G_InitGame( int levelTime, int randomSeed, int restart ) {
- int i;
+void G_InitGame( int levelTime, int randomSeed, int restart )
+{
+ int i;
- G_Printf ("------- Game Initialization -------\n");
- G_Printf ("gamename: %s\n", GAMEVERSION);
- G_Printf ("gamedate: %s\n", __DATE__);
+ G_Printf( "------- Game Initialization -------\n" );
+ G_Printf( "gamename: %s\n", GAMEVERSION );
+ G_Printf( "gamedate: %s\n", __DATE__ );
srand( randomSeed );
- G_RegisterCvars();
+ G_RegisterCvars( );
- G_ProcessIPBans();
+ G_ProcessIPBans( );
- G_InitMemory();
+ G_InitMemory( );
// set some level globals
memset( &level, 0, sizeof( level ) );
@@ -432,15 +422,17 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) {
level.snd_fry = G_SoundIndex("sound/player/fry.wav"); // FIXME standing in lava / slime
- if ( g_gametype.integer != GT_SINGLE_PLAYER && g_log.string[0] ) {
- if ( g_logSync.integer ) {
+ if( g_log.string[ 0 ] )
+ {
+ if( g_logSync.integer )
trap_FS_FOpenFile( g_log.string, &level.logFile, FS_APPEND_SYNC );
- } else {
+ else
trap_FS_FOpenFile( g_log.string, &level.logFile, FS_APPEND );
- }
- if ( !level.logFile ) {
+
+ if( !level.logFile )
G_Printf( "WARNING: Couldn't open logfile: %s\n", g_log.string );
- } else {
+ else
+ {
char serverinfo[MAX_INFO_STRING];
trap_GetServerinfo( serverinfo, sizeof( serverinfo ) );
@@ -448,25 +440,22 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) {
G_LogPrintf("------------------------------------------------------------\n" );
G_LogPrintf("InitGame: %s\n", serverinfo );
}
- } else {
- G_Printf( "Not logging to disk.\n" );
}
-
- G_InitWorldSession();
+ else
+ G_Printf( "Not logging to disk.\n" );
// initialize all entities for this game
- memset( g_entities, 0, MAX_GENTITIES * sizeof(g_entities[0]) );
+ memset( g_entities, 0, MAX_GENTITIES * sizeof( g_entities[ 0 ] ) );
level.gentities = g_entities;
// initialize all clients for this game
level.maxclients = g_maxclients.integer;
- memset( g_clients, 0, MAX_CLIENTS * sizeof(g_clients[0]) );
+ memset( g_clients, 0, MAX_CLIENTS * sizeof( g_clients[ 0 ] ) );
level.clients = g_clients;
// set client fields on player ents
- for ( i=0 ; i<level.maxclients ; i++ ) {
- g_entities[i].client = level.clients + i;
- }
+ for( i = 0; i < level.maxclients; i++ )
+ g_entities[ i ].client = level.clients + i;
// always leave room for the max number of clients,
// even if they aren't all used, so numbers inside that
@@ -475,43 +464,21 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) {
// let the server system know where the entites are
trap_LocateGameData( level.gentities, level.num_entities, sizeof( gentity_t ),
- &level.clients[0].ps, sizeof( level.clients[0] ) );
-
- ClearRegisteredItems();
+ &level.clients[ 0 ].ps, sizeof( level.clients[ 0 ] ) );
// parse the key/value pairs and spawn gentities
- G_SpawnEntitiesFromString();
+ G_SpawnEntitiesFromString( );
// general initialization
- G_FindTeams();
-
- // make sure we have flags for CTF, etc
- if( g_gametype.integer >= GT_TEAM ) {
- G_CheckTeamItems();
- }
-
- SaveRegisteredItems();
+ G_FindTeams( );
//TA:
- G_RegisterPlayerModels();
- G_InitDamageLocations();
+ G_RegisterPlayerModels( );
+ G_InitDamageLocations( );
G_Printf ("-----------------------------------\n");
- if( g_gametype.integer == GT_SINGLE_PLAYER || trap_Cvar_VariableIntegerValue( "com_buildScript" ) ) {
- G_ModelIndex( SP_PODIUM_MODEL );
- G_SoundIndex( "sound/player/gurp1.wav" );
- G_SoundIndex( "sound/player/gurp2.wav" );
- }
-
- //TA: rip bots
- /*if ( trap_Cvar_VariableIntegerValue( "bot_enable" ) ) {
- BotAISetup( restart );
- BotAILoadMap( restart );
- G_InitBots( restart );
- }*/
-
- G_RemapTeamShaders();
+ G_RemapTeamShaders( );
//TA: so the server counts the spawns without a client attached
countSpawns( );
@@ -535,11 +502,6 @@ void G_ShutdownGame( int restart ) {
// write all the client session data so we can get it back
G_WriteSessionData();
-
- //TA: rip bots
- /*if ( trap_Cvar_VariableIntegerValue( "bot_enable" ) ) {
- BotAIShutdown( restart );
- }*/
}
@@ -631,7 +593,7 @@ void AddTournamentPlayer( void ) {
level.warmupTime = -1;
// set them to free-for-all team
- SetTeam( &g_entities[ nextInLine - level.clients ], "f" );
+ /*SetTeam( &g_entities[ nextInLine - level.clients ], "f" );*/
}
@@ -656,7 +618,7 @@ void RemoveTournamentLoser( void ) {
}
// make them a spectator
- SetTeam( &g_entities[ clientNum ], "s" );
+ /*SetTeam( &g_entities[ clientNum ], "s" );*/
}
@@ -679,7 +641,7 @@ void RemoveTournamentWinner( void ) {
}
// make them a spectator
- SetTeam( &g_entities[ clientNum ], "s" );
+ /*SetTeam( &g_entities[ clientNum ], "s" );*/
}
@@ -932,12 +894,12 @@ void CalculateRanks( void ) {
if( level.clients[i].pers.pteam == PTE_HUMANS )
{
level.numHumanClients++;
- if ( level.clients[i].sess.sessionTeam != TEAM_SPECTATOR )
+ if ( level.clients[ i ].sess.sessionTeam != TEAM_SPECTATOR )
level.numLiveHumanClients++;
}
////////////////
- if ( level.clients[i].sess.sessionTeam != TEAM_SPECTATOR )
+ if ( level.clients[ i ].sess.sessionTeam != TEAM_SPECTATOR )
{
level.numNonSpectatorClients++;
@@ -945,16 +907,16 @@ void CalculateRanks( void ) {
if ( level.clients[i].pers.connected == CON_CONNECTED )
{
level.numPlayingClients++;
- if ( !(g_entities[i].r.svFlags & SVF_BOT) )
+ if( !(g_entities[ i ].r.svFlags & SVF_BOT) )
level.numVotingClients++;
- if ( level.clients[i].sess.sessionTeam == TEAM_HUMANS )
- level.numteamVotingClients[0]++;
- else if ( level.clients[i].sess.sessionTeam == TEAM_ALIENS )
- level.numteamVotingClients[1]++;
+ if( level.clients[ i ].ps.stats[ STAT_PTEAM ] == PTE_HUMANS )
+ level.numteamVotingClients[ 0 ]++;
+ else if( level.clients[ i ].ps.stats[ STAT_PTEAM ] == PTE_ALIENS )
+ level.numteamVotingClients[ 1 ]++;
- if ( level.follow1 == -1 )
+ if( level.follow1 == -1 )
level.follow1 = i;
- else if ( level.follow2 == -1 )
+ else if( level.follow2 == -1 )
level.follow2 = i;
}
@@ -966,55 +928,41 @@ void CalculateRanks( void ) {
sizeof(level.sortedClients[0]), SortRanks );
// set the rank value for all clients that are connected and not spectators
- if ( g_gametype.integer >= GT_TEAM ) {
- // in team games, rank is just the order of the teams, 0=red, 1=blue, 2=tied
- for ( i = 0; i < level.numConnectedClients; i++ ) {
- cl = &level.clients[ level.sortedClients[i] ];
- if ( level.teamScores[TEAM_HUMANS] == level.teamScores[TEAM_ALIENS] ) {
- cl->ps.persistant[PERS_RANK] = 2;
- } else if ( level.teamScores[TEAM_HUMANS] > level.teamScores[TEAM_ALIENS] ) {
- cl->ps.persistant[PERS_RANK] = 0;
- } else {
- cl->ps.persistant[PERS_RANK] = 1;
- }
- }
- } else {
- rank = -1;
- score = 0;
- for ( i = 0; i < level.numPlayingClients; i++ ) {
- cl = &level.clients[ level.sortedClients[i] ];
- newScore = cl->ps.persistant[PERS_SCORE];
- if ( i == 0 || newScore != score ) {
- rank = i;
- // assume we aren't tied until the next client is checked
- level.clients[ level.sortedClients[i] ].ps.persistant[PERS_RANK] = rank;
- } else {
- // we are tied with the previous client
- level.clients[ level.sortedClients[i-1] ].ps.persistant[PERS_RANK] = rank | RANK_TIED_FLAG;
- level.clients[ level.sortedClients[i] ].ps.persistant[PERS_RANK] = rank | RANK_TIED_FLAG;
- }
- score = newScore;
- if ( g_gametype.integer == GT_SINGLE_PLAYER && level.numPlayingClients == 1 ) {
- level.clients[ level.sortedClients[i] ].ps.persistant[PERS_RANK] = rank | RANK_TIED_FLAG;
- }
+ rank = -1;
+ score = 0;
+ for ( i = 0; i < level.numPlayingClients; i++ ) {
+ cl = &level.clients[ level.sortedClients[i] ];
+ newScore = cl->ps.persistant[PERS_SCORE];
+ if ( i == 0 || newScore != score ) {
+ rank = i;
+ // assume we aren't tied until the next client is checked
+ level.clients[ level.sortedClients[i] ].ps.persistant[PERS_RANK] = rank;
+ } else {
+ // we are tied with the previous client
+ level.clients[ level.sortedClients[i-1] ].ps.persistant[PERS_RANK] = rank | RANK_TIED_FLAG;
+ level.clients[ level.sortedClients[i] ].ps.persistant[PERS_RANK] = rank | RANK_TIED_FLAG;
}
+ score = newScore;
}
// set the CS_SCORES1/2 configstrings, which will be visible to everyone
- if ( g_gametype.integer >= GT_TEAM ) {
- trap_SetConfigstring( CS_SCORES1, va("%i", level.teamScores[TEAM_HUMANS] ) );
- trap_SetConfigstring( CS_SCORES2, va("%i", level.teamScores[TEAM_ALIENS] ) );
- } else {
- if ( level.numConnectedClients == 0 ) {
- trap_SetConfigstring( CS_SCORES1, va("%i", SCORE_NOT_PRESENT) );
- trap_SetConfigstring( CS_SCORES2, va("%i", SCORE_NOT_PRESENT) );
- } else if ( level.numConnectedClients == 1 ) {
- trap_SetConfigstring( CS_SCORES1, va("%i", level.clients[ level.sortedClients[0] ].ps.persistant[PERS_SCORE] ) );
- trap_SetConfigstring( CS_SCORES2, va("%i", SCORE_NOT_PRESENT) );
- } else {
- trap_SetConfigstring( CS_SCORES1, va("%i", level.clients[ level.sortedClients[0] ].ps.persistant[PERS_SCORE] ) );
- trap_SetConfigstring( CS_SCORES2, va("%i", level.clients[ level.sortedClients[1] ].ps.persistant[PERS_SCORE] ) );
- }
+ if( level.numConnectedClients == 0 )
+ {
+ trap_SetConfigstring( CS_SCORES1, va("%i", SCORE_NOT_PRESENT) );
+ trap_SetConfigstring( CS_SCORES2, va("%i", SCORE_NOT_PRESENT) );
+ }
+ else if( level.numConnectedClients == 1 )
+ {
+ trap_SetConfigstring( CS_SCORES1, va( "%i",
+ level.clients[ level.sortedClients[ 0 ] ].ps.persistant[ PERS_SCORE ] ) );
+ trap_SetConfigstring( CS_SCORES2, va( "%i", SCORE_NOT_PRESENT ) );
+ }
+ else
+ {
+ trap_SetConfigstring( CS_SCORES1, va( "%i",
+ level.clients[ level.sortedClients[ 0 ] ].ps.persistant[ PERS_SCORE ] ) );
+ trap_SetConfigstring( CS_SCORES2, va( "%i",
+ level.clients[ level.sortedClients[ 1 ] ].ps.persistant[ PERS_SCORE ] ) );
}
// see if it is time to end the level
@@ -1043,13 +991,14 @@ Do this at BeginIntermission time and whenever ranks are recalculated
due to enters/exits/forced team changes
========================
*/
-void SendScoreboardMessageToAllClients( void ) {
+void SendScoreboardMessageToAllClients( void )
+{
int i;
- for ( i = 0 ; i < level.maxclients ; i++ ) {
- if ( level.clients[ i ].pers.connected == CON_CONNECTED ) {
- DeathmatchScoreboardMessage( g_entities + i );
- }
+ for( i = 0; i < level.maxclients; i++ )
+ {
+ if( level.clients[ i ].pers.connected == CON_CONNECTED )
+ ScoreboardMessage( g_entities + i );
}
}
@@ -1061,13 +1010,8 @@ When the intermission starts, this will be called for all players.
If a new client connects, this will be called after the spawn function.
========================
*/
-void MoveClientToIntermission( gentity_t *ent ) {
- // take out of follow mode if needed
- if ( ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) {
- StopFollowing( ent );
- }
-
-
+void MoveClientToIntermission( gentity_t *ent )
+{
// move to the spot
VectorCopy( level.intermission_origin, ent->s.origin );
VectorCopy( level.intermission_origin, ent->client->ps.origin );
@@ -1129,20 +1073,9 @@ void BeginIntermission( void ) {
return; // already active
}
- // if in tournement mode, change the wins / losses
- if ( g_gametype.integer == GT_TOURNAMENT ) {
- AdjustTournamentScores();
- }
-
level.intermissiontime = level.time;
FindIntermissionPoint();
- // if single player game
- if ( g_gametype.integer == GT_SINGLE_PLAYER ) {
- UpdateTournamentInfo();
- SpawnModelsOnVictoryPads();
- }
-
// move all clients to the intermission point
for (i=0 ; i< level.maxclients ; i++) {
client = g_entities + i;
@@ -1173,48 +1106,29 @@ void ExitLevel (void) {
int i;
gclient_t *cl;
- //bot interbreeding
- //TA: rip bots
- //BotInterbreedEndMatch();
-
- // if we are running a tournement map, kick the loser to spectator status,
- // which will automatically grab the next spectator and restart
- if ( g_gametype.integer == GT_TOURNAMENT ) {
- if ( !level.restarted ) {
- RemoveTournamentLoser();
- trap_SendConsoleCommand( EXEC_APPEND, "map_restart 0\n" );
- level.restarted = qtrue;
- level.changemap = NULL;
- level.intermissiontime = 0;
- }
- return;
- }
-
-
trap_SendConsoleCommand( EXEC_APPEND, "vstr nextmap\n" );
level.changemap = NULL;
level.intermissiontime = 0;
// reset all the scores so we don't enter the intermission again
- level.teamScores[TEAM_HUMANS] = 0;
- level.teamScores[TEAM_ALIENS] = 0;
- for ( i=0 ; i< g_maxclients.integer ; i++ ) {
+ for( i = 0; i < g_maxclients.integer; i++ )
+ {
cl = level.clients + i;
- if ( cl->pers.connected != CON_CONNECTED ) {
+ if( cl->pers.connected != CON_CONNECTED )
continue;
- }
- cl->ps.persistant[PERS_SCORE] = 0;
+
+ cl->ps.persistant[ PERS_SCORE ] = 0;
}
// we need to do this here before chaning to CON_CONNECTING
- G_WriteSessionData();
+ G_WriteSessionData( );
// change all client states to connecting, so the early players into the
// next level will know the others aren't done reconnecting
- for (i=0 ; i< g_maxclients.integer ; i++) {
- if ( level.clients[i].pers.connected == CON_CONNECTED ) {
- level.clients[i].pers.connected = CON_CONNECTING;
- }
+ for( i = 0; i < g_maxclients.integer; i++ )
+ {
+ if( level.clients[ i ].pers.connected == CON_CONNECTED )
+ level.clients[ i ].pers.connected = CON_CONNECTING;
}
}
@@ -1279,31 +1193,25 @@ void LogExit( const char *string ) {
// don't send more than 32 scores (FIXME?)
numSorted = level.numConnectedClients;
- if ( numSorted > 32 ) {
+ if( numSorted > 32 )
numSorted = 32;
- }
- if ( g_gametype.integer >= GT_TEAM ) {
- G_LogPrintf( "red:%i blue:%i\n",
- level.teamScores[TEAM_HUMANS], level.teamScores[TEAM_ALIENS] );
- }
-
- for (i=0 ; i < numSorted ; i++) {
+ for( i = 0; i < numSorted; i++ )
+ {
int ping;
- cl = &level.clients[level.sortedClients[i]];
+ cl = &level.clients[ level.sortedClients[ i ] ];
- if ( cl->sess.sessionTeam == TEAM_SPECTATOR ) {
+ if( cl->sess.sessionTeam == TEAM_SPECTATOR )
continue;
- }
- if ( cl->pers.connected == CON_CONNECTING ) {
+
+ if( cl->pers.connected == CON_CONNECTING )
continue;
- }
ping = cl->ps.ping < 999 ? cl->ps.ping : 999;
G_LogPrintf( "score: %i ping: %i client: %i %s\n",
- cl->ps.persistant[PERS_SCORE], ping, level.sortedClients[i],
+ cl->ps.persistant[ PERS_SCORE ], ping, level.sortedClients[ i ],
cl->pers.netname );
}
@@ -1326,10 +1234,6 @@ void CheckIntermissionExit( void ) {
gclient_t *cl;
int readyMask;
- if ( g_gametype.integer == GT_SINGLE_PLAYER ) {
- return;
- }
-
// see which players are ready
ready = 0;
notReady = 0;
@@ -1401,19 +1305,15 @@ void CheckIntermissionExit( void ) {
ScoreIsTied
=============
*/
-qboolean ScoreIsTied( void ) {
+qboolean ScoreIsTied( void )
+{
int a, b;
- if ( level.numPlayingClients < 2 ) {
+ if( level.numPlayingClients < 2 )
return qfalse;
- }
-
- if ( g_gametype.integer >= GT_TEAM ) {
- return level.teamScores[TEAM_HUMANS] == level.teamScores[TEAM_ALIENS];
- }
- a = level.clients[level.sortedClients[0]].ps.persistant[PERS_SCORE];
- b = level.clients[level.sortedClients[1]].ps.persistant[PERS_SCORE];
+ a = level.clients[ level.sortedClients[ 0 ] ].ps.persistant[ PERS_SCORE ];
+ b = level.clients[ level.sortedClients[ 1 ] ].ps.persistant[ PERS_SCORE ];
return a == b;
}
@@ -1427,56 +1327,53 @@ and the time everyone is moved to the intermission spot, so you
can see the last frag.
=================
*/
-void CheckExitRules( void ) {
+void CheckExitRules( void )
+{
int i;
gclient_t *cl;
// if at the intermission, wait for all non-bots to
// signal ready, then go to next level
- if ( level.intermissiontime ) {
- CheckIntermissionExit ();
+ if( level.intermissiontime )
+ {
+ CheckIntermissionExit( );
return;
}
- if ( level.intermissionQueued ) {
- if ( level.time - level.intermissionQueued >= INTERMISSION_DELAY_TIME ) {
+ if( level.intermissionQueued )
+ {
+ if( level.time - level.intermissionQueued >= INTERMISSION_DELAY_TIME )
+ {
level.intermissionQueued = 0;
- BeginIntermission();
+ BeginIntermission( );
}
+
return;
}
- // check for sudden death
- if ( ScoreIsTied() ) {
- // always wait for sudden death
- return;
- }
-
- if ( g_timelimit.integer && !level.warmupTime ) {
- if ( level.time - level.startTime >= g_timelimit.integer*60000 ) {
- trap_SendServerCommand( -1, "print \"Timelimit hit.\n\"");
+ if( g_timelimit.integer && !level.warmupTime )
+ {
+ if( level.time - level.startTime >= g_timelimit.integer * 60000 )
+ {
+ trap_SendServerCommand( -1, "print \"Timelimit hit.\n\"" );
LogExit( "Timelimit hit." );
return;
}
}
- /*trap_SendServerCommand( -1, va("print \"%d %d %d %d %d %d\n\"",
- level.numAlienClients,
- level.numLiveAlienClients,
- level.numHumanClients,
- level.numLiveHumanClients,
- level.numAlienSpawns,
- level.numHumanSpawns ) );*/
-
//TA: end the game on these conditions
- if( ( level.time > level.startTime + 1000 ) && ( level.numAlienSpawns == 0 ) && ( level.numLiveAlienClients == 0 ) )
+ if( ( level.time > level.startTime + 1000 ) &&
+ ( level.numAlienSpawns == 0 ) &&
+ ( level.numLiveAlienClients == 0 ) )
{
//aliens lose
trap_SendServerCommand( -1, "print \"Humans win.\n\"");
LogExit( "Humans win." );
return;
}
- else if( ( level.time > level.startTime + 1000 ) && ( level.numHumanSpawns == 0 ) && ( level.numLiveHumanClients == 0 ) )
+ else if( ( level.time > level.startTime + 1000 ) &&
+ ( level.numHumanSpawns == 0 ) &&
+ ( level.numLiveHumanClients == 0 ) )
{
//humans lose
trap_SendServerCommand( -1, "print \"Aliens win.\n\"");
@@ -1484,55 +1381,8 @@ void CheckExitRules( void ) {
return;
}
- if ( level.numPlayingClients < 2 ) {
+ if( level.numPlayingClients < 2 )
return;
- }
-
- if ( g_gametype.integer < GT_CTF && g_fraglimit.integer ) {
- if ( level.teamScores[TEAM_HUMANS] >= g_fraglimit.integer ) {
- trap_SendServerCommand( -1, "print \"Red hit the fraglimit.\n\"" );
- LogExit( "Fraglimit hit." );
- return;
- }
-
- if ( level.teamScores[TEAM_ALIENS] >= g_fraglimit.integer ) {
- trap_SendServerCommand( -1, "print \"Blue hit the fraglimit.\n\"" );
- LogExit( "Fraglimit hit." );
- return;
- }
-
- for ( i=0 ; i< g_maxclients.integer ; i++ ) {
- cl = level.clients + i;
- if ( cl->pers.connected != CON_CONNECTED ) {
- continue;
- }
- if ( cl->sess.sessionTeam != TEAM_FREE ) {
- continue;
- }
-
- if ( cl->ps.persistant[PERS_SCORE] >= g_fraglimit.integer ) {
- LogExit( "Fraglimit hit." );
- trap_SendServerCommand( -1, va("print \"%s" S_COLOR_WHITE " hit the fraglimit.\n\"",
- cl->pers.netname ) );
- return;
- }
- }
- }
-
- if ( g_gametype.integer >= GT_CTF && g_capturelimit.integer ) {
-
- if ( level.teamScores[TEAM_HUMANS] >= g_capturelimit.integer ) {
- trap_SendServerCommand( -1, "print \"Red hit the capturelimit.\n\"" );
- LogExit( "Capturelimit hit." );
- return;
- }
-
- if ( level.teamScores[TEAM_ALIENS] >= g_capturelimit.integer ) {
- trap_SendServerCommand( -1, "print \"Blue hit the capturelimit.\n\"" );
- LogExit( "Capturelimit hit." );
- return;
- }
- }
}
@@ -1547,117 +1397,6 @@ FUNCTIONS CALLED EVERY FRAME
/*
-=============
-CheckTournament
-
-Once a frame, check for changes in tournement player state
-=============
-*/
-void CheckTournament( void ) {
- if ( level.numPlayingClients == 0 ) {
- return;
- }
-
- if ( g_gametype.integer == GT_TOURNAMENT ) {
-
- // pull in a spectator if needed
- if ( level.numPlayingClients < 2 ) {
- AddTournamentPlayer();
- }
-
- // if we don't have two players, go back to "waiting for players"
- if ( level.numPlayingClients != 2 ) {
- if ( level.warmupTime != -1 ) {
- level.warmupTime = -1;
- trap_SetConfigstring( CS_WARMUP, va("%i", level.warmupTime) );
- G_LogPrintf( "Warmup:\n" );
- }
- return;
- }
-
- if ( level.warmupTime == 0 ) {
- return;
- }
-
- // if the warmup is changed at the console, restart it
- if ( g_warmup.modificationCount != level.warmupModificationCount ) {
- level.warmupModificationCount = g_warmup.modificationCount;
- level.warmupTime = -1;
- }
-
- // if all players have arrived, start the countdown
- if ( level.warmupTime < 0 ) {
- if ( level.numPlayingClients == 2 ) {
- // fudge by -1 to account for extra delays
- level.warmupTime = level.time + ( g_warmup.integer - 1 ) * 1000;
- trap_SetConfigstring( CS_WARMUP, va("%i", level.warmupTime) );
- }
- return;
- }
-
- // if the warmup time has counted down, restart
- if ( level.time > level.warmupTime ) {
- level.warmupTime += 10000;
- trap_Cvar_Set( "g_restarted", "1" );
- trap_SendConsoleCommand( EXEC_APPEND, "map_restart 0\n" );
- level.restarted = qtrue;
- return;
- }
- } else if ( g_gametype.integer != GT_SINGLE_PLAYER && level.warmupTime != 0 ) {
- int counts[TEAM_NUM_TEAMS];
- qboolean notEnough = qfalse;
-
- if ( g_gametype.integer > GT_TEAM ) {
- counts[TEAM_ALIENS] = TeamCount( -1, TEAM_ALIENS );
- counts[TEAM_HUMANS] = TeamCount( -1, TEAM_HUMANS );
-
- if (counts[TEAM_HUMANS] < 1 || counts[TEAM_ALIENS] < 1) {
- notEnough = qtrue;
- }
- } else if ( level.numPlayingClients < 2 ) {
- notEnough = qtrue;
- }
-
- if ( notEnough ) {
- if ( level.warmupTime != -1 ) {
- level.warmupTime = -1;
- trap_SetConfigstring( CS_WARMUP, va("%i", level.warmupTime) );
- G_LogPrintf( "Warmup:\n" );
- }
- return; // still waiting for team members
- }
-
- if ( level.warmupTime == 0 ) {
- return;
- }
-
- // if the warmup is changed at the console, restart it
- if ( g_warmup.modificationCount != level.warmupModificationCount ) {
- level.warmupModificationCount = g_warmup.modificationCount;
- level.warmupTime = -1;
- }
-
- // if all players have arrived, start the countdown
- if ( level.warmupTime < 0 ) {
- // fudge by -1 to account for extra delays
- level.warmupTime = level.time + ( g_warmup.integer - 1 ) * 1000;
- trap_SetConfigstring( CS_WARMUP, va("%i", level.warmupTime) );
- return;
- }
-
- // if the warmup time has counted down, restart
- if ( level.time > level.warmupTime ) {
- level.warmupTime += 10000;
- trap_Cvar_Set( "g_restarted", "1" );
- trap_SendConsoleCommand( EXEC_APPEND, "map_restart 0\n" );
- level.restarted = qtrue;
- return;
- }
- }
-}
-
-
-/*
==================
CheckVote
==================
@@ -1772,44 +1511,55 @@ void CheckTeamLeader( int team ) {
CheckTeamVote
==================
*/
-void CheckTeamVote( int team ) {
+void CheckTeamVote( int team )
+{
int cs_offset;
- if ( team == TEAM_HUMANS )
+ if ( team == PTE_HUMANS )
cs_offset = 0;
- else if ( team == TEAM_ALIENS )
+ else if ( team == PTE_ALIENS )
cs_offset = 1;
else
return;
- if ( !level.teamVoteTime[cs_offset] ) {
+ if( !level.teamVoteTime[ cs_offset ] )
return;
- }
- if ( level.time - level.teamVoteTime[cs_offset] >= VOTE_TIME ) {
+
+ if( level.time - level.teamVoteTime[ cs_offset ] >= VOTE_TIME )
+ {
trap_SendServerCommand( -1, "print \"Team vote failed.\n\"" );
- } else {
- if ( level.teamVoteYes[cs_offset] > level.numteamVotingClients[cs_offset]/2 ) {
+ }
+ else
+ {
+ if( level.teamVoteYes[ cs_offset ] > level.numteamVotingClients[ cs_offset ] / 2 )
+ {
// execute the command, then remove the vote
trap_SendServerCommand( -1, "print \"Team vote passed.\n\"" );
//
- if ( !Q_strncmp( "leader", level.teamVoteString[cs_offset], 6) ) {
+ if( !Q_strncmp( "leader", level.teamVoteString[ cs_offset ], 6 ) )
+ {
//set the team leader
- SetLeader(team, atoi(level.teamVoteString[cs_offset] + 7));
+ SetLeader( team, atoi( level.teamVoteString[ cs_offset ] + 7 ) );
}
- else {
- trap_SendConsoleCommand( EXEC_APPEND, va("%s\n", level.teamVoteString[cs_offset] ) );
+ else
+ {
+ trap_SendConsoleCommand( EXEC_APPEND, va( "%s\n", level.teamVoteString[ cs_offset ] ) );
}
- } else if ( level.teamVoteNo[cs_offset] >= level.numteamVotingClients[cs_offset]/2 ) {
+ }
+ else if( level.teamVoteNo[ cs_offset ] >= level.numteamVotingClients[ cs_offset ] / 2 )
+ {
// same behavior as a timeout
trap_SendServerCommand( -1, "print \"Team vote failed.\n\"" );
- } else {
+ }
+ else
+ {
// still waiting for a majority
return;
}
}
- level.teamVoteTime[cs_offset] = 0;
+
+ level.teamVoteTime[ cs_offset ] = 0;
trap_SetConfigstring( CS_TEAMVOTE_TIME + cs_offset, "" );
-
}
@@ -1961,9 +1711,9 @@ start = trap_Milliseconds();
continue;
}
- if ( ent->s.eType == ET_ITEM || ent->s.eType == ET_BUILDABLE ||
- ent->s.eType == ET_CORPSE || ent->physicsObject ) {
- G_RunItem( ent, msec );
+ if( ent->s.eType == ET_BUILDABLE || ent->s.eType == ET_CORPSE || ent->physicsObject )
+ {
+ G_Physics( ent, msec );
continue;
}
@@ -1991,9 +1741,6 @@ start = trap_Milliseconds();
}
end = trap_Milliseconds();
- // see if it is time to do a tournement restart
- CheckTournament();
-
//TA:
countSpawns( );
calculateBuildPoints( );
@@ -2009,8 +1756,8 @@ end = trap_Milliseconds();
CheckVote();
// check team votes
- CheckTeamVote( TEAM_HUMANS );
- CheckTeamVote( TEAM_ALIENS );
+ CheckTeamVote( PTE_HUMANS );
+ CheckTeamVote( PTE_ALIENS );
// for tracking changes
CheckCvars();
diff --git a/src/game/g_mover.c b/src/game/g_mover.c
index 098e4050..13d99ff5 100644
--- a/src/game/g_mover.c
+++ b/src/game/g_mover.c
@@ -709,10 +709,6 @@ void Blocked_Door( gentity_t *ent, gentity_t *other ) {
// remove anything other than a client
if ( !other->client ) {
// except CTF flags!!!!
- if( other->s.eType == ET_ITEM && other->item->giType == IT_TEAM ) {
- Team_DroppedFlagThink( other );
- return;
- }
G_TempEntity( other->s.origin, EV_ITEM_POP );
G_FreeEntity( other );
return;
diff --git a/src/game/g_physics.c b/src/game/g_physics.c
new file mode 100644
index 00000000..7dcfa981
--- /dev/null
+++ b/src/game/g_physics.c
@@ -0,0 +1,187 @@
+// Copyright (C) 1999-2000 Id Software, Inc.
+//
+
+/*
+ * Portions Copyright (C) 2000-2001 Tim Angus
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the OSML - Open Source Modification License v1.0 as
+ * described in the file COPYING which is distributed with this source
+ * code.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include "g_local.h"
+
+/*
+================
+G_Bounce
+
+================
+*/
+static void G_Bounce( gentity_t *ent, trace_t *trace )
+{
+ vec3_t velocity;
+ float dot;
+ int hitTime;
+ float minNormal;
+ qboolean invert;
+
+ // reflect the velocity on the trace plane
+ hitTime = level.previousTime + ( level.time - level.previousTime ) * trace->fraction;
+ BG_EvaluateTrajectoryDelta( &ent->s.pos, hitTime, velocity );
+ dot = DotProduct( velocity, trace->plane.normal );
+ VectorMA( velocity, -2*dot, trace->plane.normal, ent->s.pos.trDelta );
+
+ if( ent->s.eType == ET_BUILDABLE )
+ {
+ minNormal = BG_FindMinNormalForBuildable( ent->s.modelindex );
+ invert = BG_FindInvertNormalForBuildable( ent->s.modelindex );
+ }
+ else
+ minNormal = 0.707f;
+
+ // cut the velocity to keep from bouncing forever
+ if( ( trace->plane.normal[ 2 ] >= minNormal ||
+ ( invert && trace->plane.normal[ 2 ] <= -minNormal ) ) &&
+ trace->entityNum == ENTITYNUM_WORLD )
+ VectorScale( ent->s.pos.trDelta, ent->physicsBounce, ent->s.pos.trDelta );
+ else
+ VectorScale( ent->s.pos.trDelta, 0.3f, ent->s.pos.trDelta );
+
+ if( VectorLength( ent->s.pos.trDelta ) < 10 )
+ {
+ VectorMA( trace->endpos, 0.5, trace->plane.normal, trace->endpos ); // make sure it is off ground
+ SnapVector( trace->endpos );
+ G_SetOrigin( ent, trace->endpos );
+ ent->s.groundEntityNum = trace->entityNum;
+ VectorCopy( trace->plane.normal, ent->s.origin2 );
+ VectorSet( ent->s.pos.trDelta, 0.0f, 0.0f, 0.0f );
+ return;
+ }
+
+ VectorCopy( ent->r.currentOrigin, ent->s.pos.trBase );
+ VectorAdd( ent->r.currentOrigin, trace->plane.normal, ent->r.currentOrigin);
+ ent->s.pos.trTime = level.time;
+}
+
+
+/*
+================
+G_Physics
+
+================
+*/
+void G_Physics( gentity_t *ent, int msec )
+{
+ vec3_t origin;
+ trace_t tr;
+ int contents;
+ int mask;
+ int bHealth = BG_FindHealthForBuildable( ent->s.modelindex );
+ int bRegen = BG_FindRegenRateForBuildable( ent->s.modelindex );
+
+ //pack health, power and dcc
+ if( ent->s.eType == ET_BUILDABLE )
+ {
+ ent->s.generic1 = (int)( ( (float)ent->health / (float)bHealth ) * 63.0f );
+
+ if( ent->s.generic1 < 0 )
+ ent->s.generic1 = 0;
+
+ if( ent->powered )
+ ent->s.generic1 |= B_POWERED_TOGGLEBIT;
+
+ if( ent->dcced )
+ ent->s.generic1 |= B_DCCED_TOGGLEBIT;
+
+ ent->time1000 += msec;
+
+ if( ent->time1000 >= 1000 )
+ {
+ ent->time1000 -= 1000;
+
+ //regenerate health
+ if( ent->health < bHealth && bRegen )
+ {
+ ent->health += bRegen;
+
+ if( ent->health > bHealth )
+ ent->health = bHealth;
+ }
+ }
+ }
+
+ // if groundentity has been set to -1, it may have been pushed off an edge
+ if( ent->s.groundEntityNum == -1 )
+ {
+ if( ent->s.eType == ET_BUILDABLE )
+ {
+ if( ent->s.pos.trType != BG_FindTrajectoryForBuildable( ent->s.modelindex ) )
+ {
+ ent->s.pos.trType = BG_FindTrajectoryForBuildable( ent->s.modelindex );
+ ent->s.pos.trTime = level.time;
+ }
+ }
+ else if( ent->s.pos.trType != TR_GRAVITY )
+ {
+ ent->s.pos.trType = TR_GRAVITY;
+ ent->s.pos.trTime = level.time;
+ }
+ }
+
+ // trace a line from the previous position to the current position
+ if( ent->clipmask )
+ mask = ent->clipmask;
+ else
+ mask = MASK_PLAYERSOLID & ~CONTENTS_BODY;//MASK_SOLID;
+
+ if( ent->s.pos.trType == TR_STATIONARY )
+ {
+ // check think function
+ G_RunThink( ent );
+
+ VectorCopy( ent->r.currentOrigin, origin );
+
+ VectorMA( origin, -2.0f, ent->s.origin2, origin );
+
+ trap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, origin, ent->s.number, mask );
+
+ if( tr.fraction == 1.0 )
+ ent->s.groundEntityNum = -1;
+
+ return;
+ }
+
+ // get current position
+ BG_EvaluateTrajectory( &ent->s.pos, level.time, origin );
+
+ trap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, origin, ent->s.number, mask );
+
+ VectorCopy( tr.endpos, ent->r.currentOrigin );
+
+ if( tr.startsolid )
+ tr.fraction = 0;
+
+ trap_LinkEntity( ent ); // FIXME: avoid this for stationary?
+
+ // check think function
+ G_RunThink( ent );
+
+ if( tr.fraction == 1 )
+ return;
+
+ // if it is in a nodrop volume, remove it
+ contents = trap_PointContents( ent->r.currentOrigin, -1 );
+ if( contents & CONTENTS_NODROP )
+ {
+ G_FreeEntity( ent );
+ return;
+ }
+
+ G_Bounce( ent, &tr );
+}
+
diff --git a/src/game/g_session.c b/src/game/g_session.c
index e53a2bf5..0ac65709 100644
--- a/src/game/g_session.c
+++ b/src/game/g_session.c
@@ -103,42 +103,20 @@ void G_InitSessionData( gclient_t *client, char *userinfo ) {
sess = &client->sess;
// initial team determination
- if ( g_gametype.integer >= GT_TEAM ) {
- if ( g_teamAutoJoin.integer ) {
- sess->sessionTeam = PickTeam( -1 );
- BroadcastTeamChange( client, -1 );
- } else {
- // always spawn as spectator in team games
- sess->sessionTeam = TEAM_SPECTATOR;
- }
- } else {
- value = Info_ValueForKey( userinfo, "team" );
- if ( value[0] == 's' ) {
- // a willing spectator, not a waiting-in-line
- sess->sessionTeam = TEAM_SPECTATOR;
- } else {
- switch ( g_gametype.integer ) {
- default:
- case GT_FFA:
- case GT_SINGLE_PLAYER:
- if ( g_maxGameClients.integer > 0 &&
- level.numNonSpectatorClients >= g_maxGameClients.integer ) {
- sess->sessionTeam = TEAM_SPECTATOR;
- } else {
- sess->sessionTeam = TEAM_FREE;
- }
- break;
- case GT_TOURNAMENT:
- // if the game is full, go into a waiting mode
- if ( level.numNonSpectatorClients >= 2 ) {
- sess->sessionTeam = TEAM_SPECTATOR;
- } else {
- sess->sessionTeam = TEAM_FREE;
- }
- break;
- }
- }
- }
+ value = Info_ValueForKey( userinfo, "team" );
+ if( value[ 0 ] == 's' )
+ {
+ // a willing spectator, not a waiting-in-line
+ sess->sessionTeam = TEAM_SPECTATOR;
+ }
+ else
+ {
+ if( g_maxGameClients.integer > 0 &&
+ level.numNonSpectatorClients >= g_maxGameClients.integer )
+ sess->sessionTeam = TEAM_SPECTATOR;
+ else
+ sess->sessionTeam = TEAM_FREE;
+ }
sess->spectatorState = SPECTATOR_FREE;
sess->spectatorTime = level.time;
@@ -149,27 +127,6 @@ void G_InitSessionData( gclient_t *client, char *userinfo ) {
/*
==================
-G_InitWorldSession
-
-==================
-*/
-void G_InitWorldSession( void ) {
- char s[MAX_STRING_CHARS];
- int gt;
-
- trap_Cvar_VariableStringBuffer( "session", s, sizeof(s) );
- gt = atoi( s );
-
- // if the gametype changed since the last session, don't use any
- // client sessions
- if ( g_gametype.integer != gt ) {
- level.newSession = qtrue;
- G_Printf( "Gametype changed, clearing session data.\n" );
- }
-}
-
-/*
-==================
G_WriteSessionData
==================
@@ -177,11 +134,12 @@ G_WriteSessionData
void G_WriteSessionData( void ) {
int i;
- trap_Cvar_Set( "session", va("%i", g_gametype.integer) );
+ //TA: ?
+ trap_Cvar_Set( "session", va( "%i", 0 ) );
- for ( i = 0 ; i < level.maxclients ; i++ ) {
- if ( level.clients[i].pers.connected == CON_CONNECTED ) {
- G_WriteClientSessionData( &level.clients[i] );
- }
+ for( i = 0 ; i < level.maxclients ; i++ )
+ {
+ if( level.clients[ i ].pers.connected == CON_CONNECTED )
+ G_WriteClientSessionData( &level.clients[ i ] );
}
}
diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c
index f0cb7178..b9fb1851 100644
--- a/src/game/g_spawn.c
+++ b/src/game/g_spawn.c
@@ -195,12 +195,6 @@ void SP_shooter_rocket( gentity_t *ent );
void SP_shooter_plasma( gentity_t *ent );
void SP_shooter_grenade( gentity_t *ent );
-void SP_team_CTF_redplayer( gentity_t *ent );
-void SP_team_CTF_blueplayer( gentity_t *ent );
-
-void SP_team_CTF_redspawn( gentity_t *ent );
-void SP_team_CTF_bluespawn( gentity_t *ent );
-
//TA:
void SP_misc_spriter( gentity_t *ent );
void SP_misc_anim_model( gentity_t *ent );
@@ -271,12 +265,6 @@ spawn_t spawns[] = {
{"shooter_grenade", SP_shooter_grenade},
{"shooter_plasma", SP_shooter_plasma},
- {"team_CTF_redplayer", SP_team_CTF_redplayer},
- {"team_CTF_blueplayer", SP_team_CTF_blueplayer},
-
- {"team_CTF_redspawn", SP_team_CTF_redspawn},
- {"team_CTF_bluespawn", SP_team_CTF_bluespawn},
-
{"misc_spriter", SP_misc_spriter},
{"misc_anim_model", SP_misc_anim_model},
{"misc_light_flare", SP_misc_light_flare},
@@ -315,9 +303,6 @@ qboolean G_CallSpawn( gentity_t *ent )
{
if( !strcmp( s->name, ent->classname ) )
{
- if( G_ItemDisabled( item ) )
- return qfalse;
-
// found it
s->spawn( ent );
return qtrue;
@@ -449,46 +434,12 @@ void G_SpawnGEntityFromSpawnVars( void ) {
G_ParseField( level.spawnVars[i][0], level.spawnVars[i][1], ent );
}
- // check for "notteam" / "notfree" flags
- if ( g_gametype.integer == GT_SINGLE_PLAYER ) {
- G_SpawnInt( "notsingle", "0", &i );
- if ( i ) {
- G_FreeEntity( ent );
- return;
- }
- }
- if ( g_gametype.integer >= GT_TEAM ) {
- G_SpawnInt( "notteam", "0", &i );
- if ( i ) {
- G_FreeEntity( ent );
- return;
- }
- } else {
- G_SpawnInt( "notfree", "0", &i );
- if ( i ) {
- G_FreeEntity( ent );
- return;
- }
- }
-
G_SpawnInt( "notq3a", "0", &i );
if ( i ) {
G_FreeEntity( ent );
return;
}
- if( G_SpawnString( "gametype", NULL, &value ) ) {
- if( g_gametype.integer >= GT_FFA && g_gametype.integer < GT_MAX_GAME_TYPE ) {
- gametypeName = gametypeNames[g_gametype.integer];
-
- s = strstr( value, gametypeName );
- if( !s ) {
- G_FreeEntity( ent );
- return;
- }
- }
- }
-
// move editor origin to pos
VectorCopy( ent->s.origin, ent->s.pos.trBase );
VectorCopy( ent->s.origin, ent->r.currentOrigin );
diff --git a/src/game/g_svcmds.c b/src/game/g_svcmds.c
index b2fa3c4c..3fb05cf8 100644
--- a/src/game/g_svcmds.c
+++ b/src/game/g_svcmds.c
@@ -400,7 +400,7 @@ void Svcmd_ForceTeam_f( void ) {
// set the team
trap_Argv( 2, str, sizeof( str ) );
- SetTeam( &g_entities[cl - level.clients], str );
+ /*SetTeam( &g_entities[cl - level.clients], str );*/
}
char *ConcatArgs( int start );
@@ -431,22 +431,6 @@ qboolean ConsoleCommand( void ) {
return qtrue;
}
- //TA: rip bots
- /*if (Q_stricmp (cmd, "addbot") == 0) {
- Svcmd_AddBot_f();
- return qtrue;
- }
-
- if (Q_stricmp (cmd, "botlist") == 0) {
- Svcmd_BotList_f();
- return qtrue;
- }*/
-
- if (Q_stricmp (cmd, "abort_podium") == 0) {
- Svcmd_AbortPodium_f();
- return qtrue;
- }
-
if (Q_stricmp (cmd, "addip") == 0) {
Svcmd_AddIP_f();
return qtrue;
diff --git a/src/game/g_target.c b/src/game/g_target.c
index e2bc25ff..2f938a65 100644
--- a/src/game/g_target.c
+++ b/src/game/g_target.c
@@ -21,25 +21,24 @@
/*QUAKED target_give (1 0 0) (-8 -8 -8) (8 8 8)
Gives the activator all the items pointed to.
*/
-void Use_Target_Give( gentity_t *ent, gentity_t *other, gentity_t *activator ) {
+void Use_Target_Give( gentity_t *ent, gentity_t *other, gentity_t *activator )
+{
gentity_t *t;
trace_t trace;
- if ( !activator->client ) {
+ if( !activator->client )
return;
- }
- if ( !ent->target ) {
+ if( !ent->target )
return;
- }
memset( &trace, 0, sizeof( trace ) );
t = NULL;
- while ( (t = G_Find (t, FOFS(targetname), ent->target)) != NULL ) {
- if ( !t->item ) {
+
+ while( ( t = G_Find( t, FOFS( targetname ), ent->target ) ) != NULL )
+ {
+ if( !t->item )
continue;
- }
- Touch_Item( t, activator, &trace );
// make sure it isn't going to respawn or show any events
t->nextthink = 0;
@@ -47,7 +46,8 @@ void Use_Target_Give( gentity_t *ent, gentity_t *other, gentity_t *activator ) {
}
}
-void SP_target_give( gentity_t *ent ) {
+void SP_target_give( gentity_t *ent )
+{
ent->use = Use_Target_Give;
}
@@ -63,14 +63,6 @@ void Use_target_remove_powerups( gentity_t *ent, gentity_t *other, gentity_t *ac
return;
}
- /*if( activator->client->ps.powerups[PW_REDFLAG] ) {
- Team_ReturnFlag( TEAM_HUMANS );
- } else if( activator->client->ps.powerups[PW_BLUEFLAG] ) {
- Team_ReturnFlag( TEAM_ALIENS );
- } else if( activator->client->ps.powerups[PW_NEUTRALFLAG] ) {
- Team_ReturnFlag( TEAM_FREE );
- }*/
-
memset( activator->client->ps.powerups, 0, sizeof( activator->client->ps.powerups ) );
}
@@ -133,23 +125,25 @@ void SP_target_score( gentity_t *ent ) {
"message" text to print
If "private", only the activator gets the message. If no checks, all clients get the message.
*/
-void Use_Target_Print (gentity_t *ent, gentity_t *other, gentity_t *activator) {
- if ( activator->client && ( ent->spawnflags & 4 ) ) {
- trap_SendServerCommand( activator-g_entities, va("cp \"%s\"", ent->message ));
+void Use_Target_Print (gentity_t *ent, gentity_t *other, gentity_t *activator)
+{
+ if( activator->client && ( ent->spawnflags & 4 ) )
+ {
+ trap_SendServerCommand( activator-g_entities, va( "cp \"%s\"", ent->message ) );
return;
}
- if ( ent->spawnflags & 3 ) {
- if ( ent->spawnflags & 1 ) {
- G_TeamCommand( TEAM_HUMANS, va("cp \"%s\"", ent->message) );
- }
- if ( ent->spawnflags & 2 ) {
- G_TeamCommand( TEAM_ALIENS, va("cp \"%s\"", ent->message) );
- }
+ if( ent->spawnflags & 3 )
+ {
+ if( ent->spawnflags & 1 )
+ G_TeamCommand( PTE_HUMANS, va( "cp \"%s\"", ent->message ) );
+ if( ent->spawnflags & 2 )
+ G_TeamCommand( PTE_ALIENS, va( "cp \"%s\"", ent->message ) );
+
return;
}
- trap_SendServerCommand( -1, va("cp \"%s\"", ent->message ));
+ trap_SendServerCommand( -1, va("cp \"%s\"", ent->message ) );
}
void SP_target_print( gentity_t *ent ) {
@@ -368,28 +362,32 @@ This doesn't perform any actions except fire its targets.
The activator can be forced to be from a certain team.
if RANDOM is checked, only one of the targets will be fired, not all of them
*/
-void target_relay_use (gentity_t *self, gentity_t *other, gentity_t *activator) {
- if ( ( self->spawnflags & 1 ) && activator->client
- && activator->client->sess.sessionTeam != TEAM_HUMANS ) {
+void target_relay_use( gentity_t *self, gentity_t *other, gentity_t *activator )
+{
+ if( ( self->spawnflags & 1 ) && activator->client &&
+ activator->client->ps.stats[ STAT_PTEAM ] != PTE_HUMANS )
return;
- }
- if ( ( self->spawnflags & 2 ) && activator->client
- && activator->client->sess.sessionTeam != TEAM_ALIENS ) {
+
+ if( ( self->spawnflags & 2 ) && activator->client &&
+ activator->client->ps.stats[ STAT_PTEAM ] != PTE_ALIENS )
return;
- }
- if ( self->spawnflags & 4 ) {
+
+ if( self->spawnflags & 4 )
+ {
gentity_t *ent;
ent = G_PickTarget( self->target );
- if ( ent && ent->use ) {
+ if( ent && ent->use )
ent->use( ent, self, activator );
- }
+
return;
}
+
G_UseTargets (self, activator);
}
-void SP_target_relay (gentity_t *self) {
+void SP_target_relay( gentity_t *self )
+{
self->use = target_relay_use;
}
diff --git a/src/game/g_team.c b/src/game/g_team.c
index 82277726..33292381 100644
--- a/src/game/g_team.c
+++ b/src/game/g_team.c
@@ -32,58 +32,6 @@ teamgame_t teamgame;
void Team_SetFlagStatus( int team, flagStatus_t status );
-void Team_InitGame(void)
-{
- memset(&teamgame, 0, sizeof teamgame);
- switch( g_gametype.integer ) {
- case GT_CTF:
- teamgame.redStatus = teamgame.blueStatus = -1; // Invalid to force update
- Team_SetFlagStatus( TEAM_HUMANS, FLAG_ATBASE );
- Team_SetFlagStatus( TEAM_ALIENS, FLAG_ATBASE );
- break;
- default:
- break;
- }
-}
-
-int OtherTeam(int team) {
- if (team==TEAM_HUMANS)
- return TEAM_ALIENS;
- else if (team==TEAM_ALIENS)
- return TEAM_HUMANS;
- return team;
-}
-
-const char *TeamName(int team) {
- if (team==TEAM_HUMANS)
- return "RED";
- else if (team==TEAM_ALIENS)
- return "BLUE";
- else if (team==TEAM_SPECTATOR)
- return "SPECTATOR";
- return "FREE";
-}
-
-const char *OtherTeamName(int team) {
- if (team==TEAM_HUMANS)
- return "BLUE";
- else if (team==TEAM_ALIENS)
- return "RED";
- else if (team==TEAM_SPECTATOR)
- return "SPECTATOR";
- return "FREE";
-}
-
-const char *TeamColorString(int team) {
- if (team==TEAM_HUMANS)
- return S_COLOR_RED;
- else if (team==TEAM_ALIENS)
- return S_COLOR_BLUE;
- else if (team==TEAM_SPECTATOR)
- return S_COLOR_YELLOW;
- return S_COLOR_WHITE;
-}
-
// NULL for everyone
void QDECL PrintMsg( gentity_t *ent, const char *fmt, ... ) {
char msg[1024];
@@ -106,54 +54,6 @@ void QDECL PrintMsg( gentity_t *ent, const char *fmt, ... ) {
/*
==============
-AddTeamScore
-
- used for gametype > GT_TEAM
- for gametype GT_TEAM the level.teamScores is updated in AddScore in g_combat.c
-==============
-*/
-void AddTeamScore(vec3_t origin, int team, int score) {
- gentity_t *te;
-
- //te = G_TempEntity(origin, EV_GLOBAL_TEAM_SOUND );
- te->r.svFlags |= SVF_BROADCAST;
-
- if ( team == TEAM_HUMANS ) {
- if ( level.teamScores[ TEAM_HUMANS ] + score == level.teamScores[ TEAM_ALIENS ] ) {
- //teams are tied sound
- //te->s.eventParm = GTS_TEAMS_ARE_TIED;
- }
- else if ( level.teamScores[ TEAM_HUMANS ] <= level.teamScores[ TEAM_ALIENS ] &&
- level.teamScores[ TEAM_HUMANS ] + score > level.teamScores[ TEAM_ALIENS ]) {
- // red took the lead sound
- //te->s.eventParm = GTS_REDTEAM_TOOK_LEAD;
- }
- else {
- // red scored sound
- //te->s.eventParm = GTS_REDTEAM_SCORED;
- }
- }
- else {
- if ( level.teamScores[ TEAM_ALIENS ] + score == level.teamScores[ TEAM_HUMANS ] ) {
- //teams are tied sound
- //te->s.eventParm = GTS_TEAMS_ARE_TIED;
- }
- else if ( level.teamScores[ TEAM_ALIENS ] <= level.teamScores[ TEAM_HUMANS ] &&
- level.teamScores[ TEAM_ALIENS ] + score > level.teamScores[ TEAM_HUMANS ]) {
- // blue took the lead sound
- //te->s.eventParm = GTS_BLUETEAM_TOOK_LEAD;
- }
- else {
- // blue scored sound
- //te->s.eventParm = GTS_BLUETEAM_SCORED;
- }
- }
- level.teamScores[ team ] += score;
-}
-
-
-/*
-==============
OnSameTeam
==============
*/
@@ -168,578 +68,6 @@ qboolean OnSameTeam( gentity_t *ent1, gentity_t *ent2 )
return qfalse;
}
-static char ctfFlagStatusRemap[] = { '0', '1', '*', '*', '2' };
-static char oneFlagStatusRemap[] = { '0', '1', '2', '3', '4' };
-
-void Team_SetFlagStatus( int team, flagStatus_t status ) {
- qboolean modified = qfalse;
-
- switch( team ) {
- case TEAM_HUMANS: // CTF
- if( teamgame.redStatus != status ) {
- teamgame.redStatus = status;
- modified = qtrue;
- }
- break;
-
- case TEAM_ALIENS: // CTF
- if( teamgame.blueStatus != status ) {
- teamgame.blueStatus = status;
- modified = qtrue;
- }
- break;
-
- case TEAM_FREE: // One Flag CTF
- if( teamgame.flagStatus != status ) {
- teamgame.flagStatus = status;
- modified = qtrue;
- }
- break;
- }
-
- if( modified ) {
- char st[4];
-
- if( g_gametype.integer == GT_CTF ) {
- st[0] = ctfFlagStatusRemap[teamgame.redStatus];
- st[1] = ctfFlagStatusRemap[teamgame.blueStatus];
- st[2] = 0;
- }
- else { // GT_1FCTF
- st[0] = oneFlagStatusRemap[teamgame.flagStatus];
- st[1] = 0;
- }
-
- trap_SetConfigstring( CS_FLAGSTATUS, st );
- }
-}
-
-
-void Team_CheckDroppedItem( gentity_t *dropped )
-{
- /*if (dropped->item->giTag == PW_REDFLAG)
- Team_SetFlagStatus( TEAM_HUMANS, FLAG_DROPPED );
- else if (dropped->item->giTag == PW_BLUEFLAG)
- Team_SetFlagStatus( TEAM_ALIENS, FLAG_DROPPED );*/
-}
-
-
-/*
-================
-Team_ForceGesture
-================
-*/
-void Team_ForceGesture(int team) {
- int i;
- gentity_t *ent;
-
- for (i = 0; i < MAX_CLIENTS; i++) {
- ent = &g_entities[i];
- if (!ent->inuse)
- continue;
- if (!ent->client)
- continue;
- if (ent->client->sess.sessionTeam != team)
- continue;
- //
- ent->flags |= FL_FORCE_GESTURE;
- }
-}
-
-
-/*
-================
-Team_FragBonuses
-
-Calculate the bonuses for flag defense, flag carrier defense, etc.
-Note that bonuses are not cumlative. You get one, they are in importance
-order.
-================
-*/
-void Team_FragBonuses(gentity_t *targ, gentity_t *inflictor, gentity_t *attacker)
-{
- int i;
- gentity_t *ent;
- int flag_pw, enemy_flag_pw;
- int otherteam;
- int tokens;
- gentity_t *flag, *carrier = NULL;
- char *c;
- vec3_t v1, v2;
- int team;
-
- // no bonus for fragging yourself
- if (!targ->client || !attacker->client || targ == attacker || OnSameTeam(targ, attacker))
- return;
-
- team = targ->client->sess.sessionTeam;
- otherteam = OtherTeam(targ->client->sess.sessionTeam);
- if (otherteam < 0)
- return; // whoever died isn't on a team
-
- // same team, if the flag at base, check to he has the enemy flag
- /*if (team == TEAM_HUMANS) {
- flag_pw = PW_REDFLAG;
- enemy_flag_pw = PW_BLUEFLAG;
- } else {
- flag_pw = PW_BLUEFLAG;
- enemy_flag_pw = PW_REDFLAG;
- }*/
-
- // did the attacker frag the flag carrier?
- tokens = 0;
- if (targ->client->ps.powerups[enemy_flag_pw]) {
- attacker->client->pers.teamState.lastfraggedcarrier = level.time;
- AddScore(attacker, CTF_FRAG_CARRIER_BONUS);
- attacker->client->pers.teamState.fragcarrier++;
- PrintMsg(NULL, "%s" S_COLOR_WHITE " fragged %s's flag carrier!\n",
- attacker->client->pers.netname, TeamName(team));
-
- // the target had the flag, clear the hurt carrier
- // field on the other team
- for (i = 0; i < g_maxclients.integer; i++) {
- ent = g_entities + i;
- if (ent->inuse && ent->client->sess.sessionTeam == otherteam)
- ent->client->pers.teamState.lasthurtcarrier = 0;
- }
- return;
- }
-
- // did the attacker frag a head carrier? other->client->ps.generic1
- if (tokens) {
- attacker->client->pers.teamState.lastfraggedcarrier = level.time;
- AddScore(attacker, CTF_FRAG_CARRIER_BONUS * tokens * tokens);
- attacker->client->pers.teamState.fragcarrier++;
- PrintMsg(NULL, "%s" S_COLOR_WHITE " fragged %s's skull carrier!\n",
- attacker->client->pers.netname, TeamName(team));
-
- // the target had the flag, clear the hurt carrier
- // field on the other team
- for (i = 0; i < g_maxclients.integer; i++) {
- ent = g_entities + i;
- if (ent->inuse && ent->client->sess.sessionTeam == otherteam)
- ent->client->pers.teamState.lasthurtcarrier = 0;
- }
- return;
- }
-
- if (targ->client->pers.teamState.lasthurtcarrier &&
- level.time - targ->client->pers.teamState.lasthurtcarrier < CTF_CARRIER_DANGER_PROTECT_TIMEOUT &&
- !attacker->client->ps.powerups[flag_pw]) {
- // attacker is on the same team as the flag carrier and
- // fragged a guy who hurt our flag carrier
- AddScore(attacker, CTF_CARRIER_DANGER_PROTECT_BONUS);
-
- attacker->client->pers.teamState.carrierdefense++;
- targ->client->pers.teamState.lasthurtcarrier = 0;
-
- //attacker->client->ps.persistant[PERS_DEFEND_COUNT]++;
- team = attacker->client->sess.sessionTeam;
- // add the sprite over the player's head
- //attacker->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );
- //attacker->client->ps.eFlags |= EF_AWARD_DEFEND;
- attacker->client->rewardTime = level.time + REWARD_SPRITE_TIME;
-
- return;
- }
-
- if (targ->client->pers.teamState.lasthurtcarrier &&
- level.time - targ->client->pers.teamState.lasthurtcarrier < CTF_CARRIER_DANGER_PROTECT_TIMEOUT) {
- // attacker is on the same team as the skull carrier and
- AddScore(attacker, CTF_CARRIER_DANGER_PROTECT_BONUS);
-
- attacker->client->pers.teamState.carrierdefense++;
- targ->client->pers.teamState.lasthurtcarrier = 0;
-
- //attacker->client->ps.persistant[PERS_DEFEND_COUNT]++;
- team = attacker->client->sess.sessionTeam;
- // add the sprite over the player's head
- //attacker->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );
- //attacker->client->ps.eFlags |= EF_AWARD_DEFEND;
- attacker->client->rewardTime = level.time + REWARD_SPRITE_TIME;
-
- return;
- }
-
- // flag and flag carrier area defense bonuses
-
- // we have to find the flag and carrier entities
-
- // find the flag
- switch (attacker->client->sess.sessionTeam) {
- case TEAM_HUMANS:
- c = "team_CTF_redflag";
- break;
- case TEAM_ALIENS:
- c = "team_CTF_blueflag";
- break;
- default:
- return;
- }
-
- // find attacker's team's flag carrier
- for (i = 0; i < g_maxclients.integer; i++) {
- carrier = g_entities + i;
- if (carrier->inuse && carrier->client->ps.powerups[flag_pw])
- break;
- carrier = NULL;
- }
-
- flag = NULL;
- while ((flag = G_Find (flag, FOFS(classname), c)) != NULL) {
- if (!(flag->flags & FL_DROPPED_ITEM))
- break;
- }
-
- if (!flag)
- return; // can't find attacker's flag
-
- // ok we have the attackers flag and a pointer to the carrier
-
- // check to see if we are defending the base's flag
- VectorSubtract(targ->r.currentOrigin, flag->r.currentOrigin, v1);
- VectorSubtract(attacker->r.currentOrigin, flag->r.currentOrigin, v2);
-
- if ( ( ( VectorLength(v1) < CTF_TARGET_PROTECT_RADIUS &&
- trap_InPVS(flag->r.currentOrigin, targ->r.currentOrigin ) ) ||
- ( VectorLength(v2) < CTF_TARGET_PROTECT_RADIUS &&
- trap_InPVS(flag->r.currentOrigin, attacker->r.currentOrigin ) ) ) &&
- attacker->client->sess.sessionTeam != targ->client->sess.sessionTeam) {
-
- // we defended the base flag
- AddScore(attacker, CTF_FLAG_DEFENSE_BONUS);
- attacker->client->pers.teamState.basedefense++;
- //attacker->client->ps.persistant[PERS_DEFEND_COUNT]++;
- // add the sprite over the player's head
- //attacker->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );
- //attacker->client->ps.eFlags |= EF_AWARD_DEFEND;
- attacker->client->rewardTime = level.time + REWARD_SPRITE_TIME;
- return;
- }
-
- if (carrier && carrier != attacker) {
- VectorSubtract(targ->r.currentOrigin, carrier->r.currentOrigin, v1);
- VectorSubtract(attacker->r.currentOrigin, carrier->r.currentOrigin, v1);
-
- if ( ( ( VectorLength(v1) < CTF_ATTACKER_PROTECT_RADIUS &&
- trap_InPVS(carrier->r.currentOrigin, targ->r.currentOrigin ) ) ||
- ( VectorLength(v2) < CTF_ATTACKER_PROTECT_RADIUS &&
- trap_InPVS(carrier->r.currentOrigin, attacker->r.currentOrigin ) ) ) &&
- attacker->client->sess.sessionTeam != targ->client->sess.sessionTeam) {
- AddScore(attacker, CTF_CARRIER_PROTECT_BONUS);
- attacker->client->pers.teamState.carrierdefense++;
- //attacker->client->ps.persistant[PERS_DEFEND_COUNT]++;
- // add the sprite over the player's head
- //attacker->client->ps.eFlags &= ~(EF_AWARD_IMPRESSIVE | EF_AWARD_EXCELLENT | EF_AWARD_GAUNTLET | EF_AWARD_ASSIST | EF_AWARD_DEFEND | EF_AWARD_CAP );
- //attacker->client->ps.eFlags |= EF_AWARD_DEFEND;
- attacker->client->rewardTime = level.time + REWARD_SPRITE_TIME;
- return;
- }
- }
-}
-
-/*
-================
-Team_CheckHurtCarrier
-
-Check to see if attacker hurt the flag carrier. Needed when handing out bonuses for assistance to flag
-carrier defense.
-================
-*/
-void Team_CheckHurtCarrier(gentity_t *targ, gentity_t *attacker)
-{
- int flag_pw;
-
- if (!targ->client || !attacker->client)
- return;
-
- /*if (targ->client->sess.sessionTeam == TEAM_HUMANS)
- flag_pw = PW_BLUEFLAG;
- else
- flag_pw = PW_REDFLAG;
-
- if (targ->client->ps.powerups[flag_pw] &&
- targ->client->sess.sessionTeam != attacker->client->sess.sessionTeam)
- attacker->client->pers.teamState.lasthurtcarrier = level.time;
-
- // skulls
- if (targ->client->ps.generic1 &&
- targ->client->sess.sessionTeam != attacker->client->sess.sessionTeam)
- attacker->client->pers.teamState.lasthurtcarrier = level.time;*/
-}
-
-
-gentity_t *Team_ResetFlag(int team)
-{
- char *c;
- gentity_t *ent, *rent = NULL;
-
- switch (team) {
- case TEAM_HUMANS:
- c = "team_CTF_redflag";
- break;
- case TEAM_ALIENS:
- c = "team_CTF_blueflag";
- break;
- case TEAM_FREE:
- c = "team_CTF_neutralflag";
- break;
- default:
- return NULL;
- }
-
- ent = NULL;
- while ((ent = G_Find (ent, FOFS(classname), c)) != NULL) {
- if (ent->flags & FL_DROPPED_ITEM)
- G_FreeEntity(ent);
- else {
- rent = ent;
- RespawnItem(ent);
- }
- }
-
- Team_SetFlagStatus( team, FLAG_ATBASE );
-
- return rent;
-}
-
-void Team_ResetFlags( void ) {
- if( g_gametype.integer == GT_CTF ) {
- Team_ResetFlag( TEAM_HUMANS );
- Team_ResetFlag( TEAM_ALIENS );
- }
-}
-
-void Team_ReturnFlagSound(gentity_t *ent, int team)
-{
- // play powerup spawn sound to all clients
- gentity_t *te;
-
- if (ent == NULL) {
- G_Printf ("Warning: NULL passed to Team_ReturnFlagSound\n");
- return;
- }
-
- //te = G_TempEntity( ent->s.pos.trBase, EV_GLOBAL_TEAM_SOUND );
- if( team == TEAM_ALIENS ) {
- //te->s.eventParm = GTS_RED_RETURN;
- }
- else {
- //te->s.eventParm = GTS_BLUE_RETURN;
- }
- te->r.svFlags |= SVF_BROADCAST;
-}
-
-void Team_TakeFlagSound( gentity_t *ent, int team ) {
- gentity_t *te;
-
- if (ent == NULL) {
- G_Printf ("Warning: NULL passed to Team_TakeFlagSound\n");
- return;
- }
-
- // only play sound when the flag was at the base
- // or not picked up the last 10 seconds
- switch(team) {
- case TEAM_HUMANS:
- if( teamgame.blueStatus != FLAG_ATBASE ) {
- if (teamgame.blueTakenTime > level.time - 10000)
- return;
- }
- teamgame.blueTakenTime = level.time;
- break;
-
- case TEAM_ALIENS: // CTF
- if( teamgame.redStatus != FLAG_ATBASE ) {
- if (teamgame.redTakenTime > level.time - 10000)
- return;
- }
- teamgame.redTakenTime = level.time;
- break;
- }
-
- //te = G_TempEntity( ent->s.pos.trBase, EV_GLOBAL_TEAM_SOUND );
- if( team == TEAM_ALIENS ) {
- //te->s.eventParm = GTS_RED_TAKEN;
- }
- else {
- //te->s.eventParm = GTS_BLUE_TAKEN;
- }
- te->r.svFlags |= SVF_BROADCAST;
-}
-
-void Team_CaptureFlagSound( gentity_t *ent, int team ) {
- gentity_t *te;
-
- if (ent == NULL) {
- G_Printf ("Warning: NULL passed to Team_CaptureFlagSound\n");
- return;
- }
-
- //te = G_TempEntity( ent->s.pos.trBase, EV_GLOBAL_TEAM_SOUND );
- if( team == TEAM_ALIENS ) {
- //te->s.eventParm = GTS_BLUE_CAPTURE;
- }
- else {
- //te->s.eventParm = GTS_RED_CAPTURE;
- }
- te->r.svFlags |= SVF_BROADCAST;
-}
-
-void Team_ReturnFlag( int team ) {
- Team_ReturnFlagSound(Team_ResetFlag(team), team);
- if( team == TEAM_FREE ) {
- PrintMsg(NULL, "The flag has returned!\n" );
- }
- else {
- PrintMsg(NULL, "The %s flag has returned!\n", TeamName(team));
- }
-}
-
-void Team_FreeEntity(gentity_t *ent)
-{
- /*if (ent->item->giTag == PW_REDFLAG)
- Team_ReturnFlag(TEAM_HUMANS);
- else if (ent->item->giTag == PW_BLUEFLAG)
- Team_ReturnFlag(TEAM_ALIENS);*/
-}
-
-/*
-==============
-Team_DroppedFlagThink
-
-Automatically set in Launch_Item if the item is one of the flags
-
-Flags are unique in that if they are dropped, the base flag must be respawned when they time out
-==============
-*/
-void Team_DroppedFlagThink(gentity_t *ent)
-{
- /*if (ent->item->giTag == PW_REDFLAG)
- Team_ReturnFlagSound(Team_ResetFlag(TEAM_HUMANS), TEAM_HUMANS);
- else if (ent->item->giTag == PW_BLUEFLAG)
- Team_ReturnFlagSound(Team_ResetFlag(TEAM_ALIENS), TEAM_ALIENS);*/
- // Reset Flag will delete this entity
-}
-
-int Team_TouchOurFlag( gentity_t *ent, gentity_t *other, int team ) {
- int i;
- gentity_t *player;
- gclient_t *cl = other->client;
- int our_flag, enemy_flag;
-
- /*if (cl->sess.sessionTeam == TEAM_HUMANS) {
- our_flag = PW_REDFLAG;
- enemy_flag = PW_BLUEFLAG;
- } else {
- our_flag = PW_BLUEFLAG;
- enemy_flag = PW_REDFLAG;
- }*/
-
- if ( ent->flags & FL_DROPPED_ITEM ) {
- // hey, its not home. return it by teleporting it back
- PrintMsg( NULL, "%s" S_COLOR_WHITE " returned the %s flag!\n",
- cl->pers.netname, TeamName(team));
- AddScore(other, CTF_RECOVERY_BONUS);
- other->client->pers.teamState.flagrecovery++;
- other->client->pers.teamState.lastreturnedflag = level.time;
- //ResetFlag will remove this entity! We must return zero
- Team_ReturnFlagSound(Team_ResetFlag(team), team);
- return 0;
- }
-
- // the flag is at home base. if the player has the enemy
- // flag, he's just won!
- if (!cl->ps.powerups[enemy_flag])
- return 0; // We don't have the flag
-
- PrintMsg( NULL, "%s" S_COLOR_WHITE " captured the %s flag!\n", cl->pers.netname, TeamName(OtherTeam(team)));
-
- cl->ps.powerups[enemy_flag] = 0;
-
- teamgame.last_flag_capture = level.time;
- teamgame.last_capture_team = team;
-
- // Increase the team's score
- AddTeamScore(ent->s.pos.trBase, other->client->sess.sessionTeam, 1);
- Team_ForceGesture(other->client->sess.sessionTeam);
-
- other->client->pers.teamState.captures++;
-
- // other gets another 10 frag bonus
-
- // Ok, let's do the player loop, hand out the bonuses
- for (i = 0; i < g_maxclients.integer; i++) {
- player = &g_entities[i];
- if (!player->inuse)
- continue;
-
- if (player->client->sess.sessionTeam !=
- cl->sess.sessionTeam) {
- player->client->pers.teamState.lasthurtcarrier = -5;
- } else if (player->client->sess.sessionTeam ==
- cl->sess.sessionTeam) {
- if (player != other)
- AddScore(player, CTF_TEAM_BONUS);
- // award extra points for capture assists
- if (player->client->pers.teamState.lastreturnedflag +
- CTF_RETURN_FLAG_ASSIST_TIMEOUT > level.time) {
- AddScore (player, CTF_RETURN_FLAG_ASSIST_BONUS);
- other->client->pers.teamState.assists++;
- }
- else if (player->client->pers.teamState.lastfraggedcarrier +
- CTF_FRAG_CARRIER_ASSIST_TIMEOUT > level.time) {
- AddScore(player, CTF_FRAG_CARRIER_ASSIST_BONUS);
- other->client->pers.teamState.assists++;
- }
- }
- }
- Team_ResetFlags();
-
- CalculateRanks();
-
- return 0; // Do not respawn this automatically
-}
-
-int Team_TouchEnemyFlag( gentity_t *ent, gentity_t *other, int team ) {
- gclient_t *cl = other->client;
-
- // hey, its not our flag, pick it up
- PrintMsg (NULL, "%s" S_COLOR_WHITE " got the %s flag!\n",
- other->client->pers.netname, TeamName(team));
- AddScore(other, CTF_FLAG_BONUS);
-
- /*if (team == TEAM_HUMANS)
- cl->ps.powerups[PW_REDFLAG] = INT_MAX; // flags never expire
- else
- cl->ps.powerups[PW_BLUEFLAG] = INT_MAX; // flags never expire*/
-
- cl->pers.teamState.flagsince = level.time;
-
- Team_SetFlagStatus( team, FLAG_TAKEN );
-
- return -1; // Do not respawn this automatically, but do delete it if it was FL_DROPPED
-}
-
-int Pickup_Team( gentity_t *ent, gentity_t *other ) {
- int team;
- gclient_t *cl = other->client;
-
- // figure out what team this flag is
- if (strcmp(ent->classname, "team_CTF_redflag") == 0)
- team = TEAM_HUMANS;
- else if (strcmp(ent->classname, "team_CTF_blueflag") == 0)
- team = TEAM_ALIENS;
- else {
- PrintMsg ( other, "Don't know what team the flag is on.\n");
- return 0;
- }
-
- return ((team == cl->sess.sessionTeam) ?
- Team_TouchOurFlag : Team_TouchEnemyFlag)
- (ent, other, team);
-}
-
/*
===========
Team_GetLocation
@@ -747,29 +75,28 @@ Team_GetLocation
Report a location for the player. Uses placed nearby target_location entities
============
*/
-gentity_t *Team_GetLocation(gentity_t *ent)
+gentity_t *Team_GetLocation( gentity_t *ent )
{
gentity_t *eloc, *best;
- float bestlen, len;
+ float bestlen, len;
vec3_t origin;
best = NULL;
- bestlen = 3*8192.0*8192.0;
+ bestlen = 3.0f * 8192.0f * 8192.0f;
VectorCopy( ent->r.currentOrigin, origin );
- for (eloc = level.locationHead; eloc; eloc = eloc->nextTrain) {
- len = ( origin[0] - eloc->r.currentOrigin[0] ) * ( origin[0] - eloc->r.currentOrigin[0] )
- + ( origin[1] - eloc->r.currentOrigin[1] ) * ( origin[1] - eloc->r.currentOrigin[1] )
- + ( origin[2] - eloc->r.currentOrigin[2] ) * ( origin[2] - eloc->r.currentOrigin[2] );
+ for( eloc = level.locationHead; eloc; eloc = eloc->nextTrain )
+ {
+ len = ( origin[ 0 ] - eloc->r.currentOrigin[ 0 ] ) * ( origin[ 0 ] - eloc->r.currentOrigin[ 0 ] )
+ + ( origin[ 1 ] - eloc->r.currentOrigin[ 1 ] ) * ( origin[ 1 ] - eloc->r.currentOrigin[ 1 ] )
+ + ( origin[ 2 ] - eloc->r.currentOrigin[ 2 ] ) * ( origin[ 2 ] - eloc->r.currentOrigin[ 2 ] );
- if ( len > bestlen ) {
+ if( len > bestlen )
continue;
- }
- if ( !trap_InPVS( origin, eloc->r.currentOrigin ) ) {
+ if( !trap_InPVS( origin, eloc->r.currentOrigin ) )
continue;
- }
bestlen = len;
best = eloc;
@@ -781,28 +108,32 @@ gentity_t *Team_GetLocation(gentity_t *ent)
/*
===========
-Team_GetLocation
+Team_GetLocationMsg
-Report a location for the player. Uses placed nearby target_location entities
+Report a location message for the player. Uses placed nearby target_location entities
============
*/
-qboolean Team_GetLocationMsg(gentity_t *ent, char *loc, int loclen)
+qboolean Team_GetLocationMsg( gentity_t *ent, char *loc, int loclen )
{
gentity_t *best;
best = Team_GetLocation( ent );
- if (!best)
+ if( !best )
return qfalse;
- if (best->count) {
- if (best->count < 0)
+ if( best->count )
+ {
+ if( best->count < 0 )
best->count = 0;
- if (best->count > 7)
+
+ if( best->count > 7 )
best->count = 7;
- Com_sprintf(loc, loclen, "%c%c%s" S_COLOR_WHITE, Q_COLOR_ESCAPE, best->count + '0', best->message );
- } else
- Com_sprintf(loc, loclen, "%s", best->message);
+
+ Com_sprintf( loc, loclen, "%c%c%s" S_COLOR_WHITE, Q_COLOR_ESCAPE, best->count + '0', best->message );
+ }
+ else
+ Com_sprintf( loc, loclen, "%s", best->message );
return qtrue;
}
@@ -810,83 +141,8 @@ qboolean Team_GetLocationMsg(gentity_t *ent, char *loc, int loclen)
/*---------------------------------------------------------------------------*/
-/*
-================
-SelectRandomDeathmatchSpawnPoint
-
-go to a random point that doesn't telefrag
-================
-*/
-#define MAX_TEAM_SPAWN_POINTS 32
-gentity_t *SelectRandomTeamSpawnPoint( int teamstate, team_t team ) {
- gentity_t *spot;
- int count;
- int selection;
- gentity_t *spots[MAX_TEAM_SPAWN_POINTS];
- char *classname;
-
- if (teamstate == TEAM_BEGIN) {
- if (team == TEAM_HUMANS)
- classname = "team_CTF_redplayer";
- else if (team == TEAM_ALIENS)
- classname = "team_CTF_blueplayer";
- else
- return NULL;
- } else {
- if (team == TEAM_HUMANS)
- classname = "team_CTF_redspawn";
- else if (team == TEAM_ALIENS)
- classname = "team_CTF_bluespawn";
- else
- return NULL;
- }
- count = 0;
-
- spot = NULL;
-
- while ((spot = G_Find (spot, FOFS(classname), classname)) != NULL) {
- if ( SpotWouldTelefrag( spot ) ) {
- continue;
- }
- spots[ count ] = spot;
- if (++count == MAX_TEAM_SPAWN_POINTS)
- break;
- }
-
- if ( !count ) { // no spots that won't telefrag
- return G_Find( NULL, FOFS(classname), classname);
- }
-
- selection = rand() % count;
- return spots[ selection ];
-}
-
-
-/*
-===========
-SelectCTFSpawnPoint
-
-============
-*/
-gentity_t *SelectCTFSpawnPoint ( team_t team, int teamstate, vec3_t origin, vec3_t angles ) {
- gentity_t *spot;
-
- spot = SelectRandomTeamSpawnPoint ( teamstate, team );
-
- if (!spot) {
- return SelectSpawnPoint( vec3_origin, origin, angles );
- }
-
- VectorCopy (spot->s.origin, origin);
- origin[2] += 9;
- VectorCopy (spot->s.angles, angles);
-
- return spot;
-}
-
-/*---------------------------------------------------------------------------*/
-
-static int QDECL SortClients( const void *a, const void *b ) {
+static int QDECL SortClients( const void *a, const void *b )
+{
return *(int *)a - *(int *)b;
}
@@ -956,73 +212,43 @@ void TeamplayInfoMessage( gentity_t *ent ) {
trap_SendServerCommand( ent-g_entities, va("tinfo %i %s", cnt, string) );
}
-void CheckTeamStatus(void)
+void CheckTeamStatus( void )
{
int i;
gentity_t *loc, *ent;
- if (level.time - level.lastTeamLocationTime > TEAM_LOCATION_UPDATE_TIME) {
-
+ if( level.time - level.lastTeamLocationTime > TEAM_LOCATION_UPDATE_TIME )
+ {
level.lastTeamLocationTime = level.time;
- for (i = 0; i < g_maxclients.integer; i++) {
+ for( i = 0; i < g_maxclients.integer; i++ )
+ {
ent = g_entities + i;
- if ( ent->client->pers.connected != CON_CONNECTED ) {
+ if( ent->client->pers.connected != CON_CONNECTED )
continue;
- }
- if (ent->inuse && (ent->client->sess.sessionTeam == TEAM_HUMANS || ent->client->sess.sessionTeam == TEAM_ALIENS)) {
+ if( ent->inuse && ( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ||
+ ent->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) )
+ {
loc = Team_GetLocation( ent );
- if (loc)
+
+ if( loc )
ent->client->pers.teamState.location = loc->health;
else
ent->client->pers.teamState.location = 0;
}
}
- for (i = 0; i < g_maxclients.integer; i++) {
+ for( i = 0; i < g_maxclients.integer; i++ )
+ {
ent = g_entities + i;
- if ( ent->client->pers.connected != CON_CONNECTED ) {
+ if( ent->client->pers.connected != CON_CONNECTED )
continue;
- }
- if (ent->inuse && (ent->client->sess.sessionTeam == TEAM_HUMANS || ent->client->sess.sessionTeam == TEAM_ALIENS)) {
+ if( ent->inuse && ( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ||
+ ent->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) )
TeamplayInfoMessage( ent );
- }
}
}
}
-
-/*-----------------------------------------------------------------*/
-
-/*QUAKED team_CTF_redplayer (1 0 0) (-16 -16 -16) (16 16 32)
-Only in CTF games. Red players spawn here at game start.
-*/
-void SP_team_CTF_redplayer( gentity_t *ent ) {
-}
-
-
-/*QUAKED team_CTF_blueplayer (0 0 1) (-16 -16 -16) (16 16 32)
-Only in CTF games. Blue players spawn here at game start.
-*/
-void SP_team_CTF_blueplayer( gentity_t *ent ) {
-}
-
-
-/*QUAKED team_CTF_redspawn (1 0 0) (-16 -16 -24) (16 16 32)
-potential spawning position for red team in CTF games.
-Targets will be fired when someone spawns in on them.
-*/
-void SP_team_CTF_redspawn(gentity_t *ent) {
-}
-
-/*QUAKED team_CTF_bluespawn (0 0 1) (-16 -16 -24) (16 16 32)
-potential spawning position for blue team in CTF games.
-Targets will be fired when someone spawns in on them.
-*/
-void SP_team_CTF_bluespawn(gentity_t *ent) {
-}
-
-
-
diff --git a/src/game/g_trigger.c b/src/game/g_trigger.c
index b3636d61..27b136c6 100644
--- a/src/game/g_trigger.c
+++ b/src/game/g_trigger.c
@@ -36,29 +36,32 @@ void multi_wait( gentity_t *ent ) {
// the trigger was just activated
// ent->activator should be set to the activator so it can be held through a delay
// so wait for the delay time before firing
-void multi_trigger( gentity_t *ent, gentity_t *activator ) {
+void multi_trigger( gentity_t *ent, gentity_t *activator )
+{
ent->activator = activator;
- if ( ent->nextthink ) {
+ if( ent->nextthink )
return; // can't retrigger until the wait is over
- }
- if ( activator->client ) {
- if ( ( ent->spawnflags & 1 ) &&
- activator->client->sess.sessionTeam != TEAM_HUMANS ) {
+ if( activator->client )
+ {
+ if( ( ent->spawnflags & 1 ) &&
+ activator->client->ps.stats[ STAT_PTEAM ] != PTE_HUMANS )
return;
- }
- if ( ( ent->spawnflags & 2 ) &&
- activator->client->sess.sessionTeam != TEAM_ALIENS ) {
+
+ if( ( ent->spawnflags & 2 ) &&
+ activator->client->ps.stats[ STAT_PTEAM ] != PTE_ALIENS )
return;
- }
}
- G_UseTargets (ent, ent->activator);
+ G_UseTargets( ent, ent->activator );
- if ( ent->wait > 0 ) {
+ if( ent->wait > 0 )
+ {
ent->think = multi_wait;
- ent->nextthink = level.time + ( ent->wait + ent->random * crandom() ) * 1000;
- } else {
+ ent->nextthink = level.time + ( ent->wait + ent->random * crandom( ) ) * 1000;
+ }
+ else
+ {
// we can't just remove (self) here, because this is a touch function
// called while looping through area links...
ent->touch = 0;
diff --git a/src/game/g_utils.c b/src/game/g_utils.c
index 4259f0ea..14a1b9fa 100644
--- a/src/game/g_utils.c
+++ b/src/game/g_utils.c
@@ -129,14 +129,16 @@ G_TeamCommand
Broadcasts a command to only a specific team
================
*/
-void G_TeamCommand( team_t team, char *cmd ) {
+void G_TeamCommand( pTeam_t team, char *cmd )
+{
int i;
- for ( i = 0 ; i < level.maxclients ; i++ ) {
- if ( level.clients[i].pers.connected == CON_CONNECTED ) {
- if ( level.clients[i].sess.sessionTeam == team ) {
- trap_SendServerCommand( i, va("%s", cmd ));
- }
+ for( i = 0 ; i < level.maxclients ; i++ )
+ {
+ if( level.clients[ i ].pers.connected == CON_CONNECTED )
+ {
+ if( level.clients[ i ].ps.stats[ STAT_PTEAM ] == team )
+ trap_SendServerCommand( i, va( "%s", cmd ) );
}
}
}