summaryrefslogtreecommitdiff
path: root/src/game/g_cmds.c
diff options
context:
space:
mode:
authorChristopher Schwarz <lakitu7@gmail.com>2009-10-03 12:08:15 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:15:42 +0000
commit82f7c11748f391a183855f78b2afdd59c6ffb4f8 (patch)
treed59b83c03b126e6a8f78c0ccaa76e2b9d60e48af /src/game/g_cmds.c
parentfe258dcdc974ab0a86d88bfb1bf503e0fa63f163 (diff)
* Added improved team join messages (original patch thanks to peoro)
* Uses a proper events-system message interpreted by cgame * Includes notification of leaving teams instead of just joining them * These messages are also now logged to games.log and the server console * Minor cleanups of cmd_team_f * /team human*, /team alien*, and /team spec* now join those teams, since those are specific enough and people seemed to have a difficult time figuring out /team spectate
Diffstat (limited to 'src/game/g_cmds.c')
-rw-r--r--src/game/g_cmds.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 738239a7..c3a0af65 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -641,15 +641,25 @@ void Cmd_Team_f( gentity_t *ent )
qboolean force = G_admin_permission(ent, ADMF_FORCETEAMCHANGE);
int aliens = level.numAlienClients;
int humans = level.numHumanClients;
+ char *teamname, *oldteamname;
+ gentity_t *tempent;
// stop team join spam
if( level.time - ent->client->pers.teamChangeTime < 1000 )
return;
if( oldteam == TEAM_ALIENS )
+ {
aliens--;
+ oldteamname = "aliens";
+ }
else if( oldteam == TEAM_HUMANS )
+ {
humans--;
+ oldteamname = "humans";
+ }
+ else
+ oldteamname = "spectators";
trap_Argv( 1, s, sizeof( s ) );
@@ -660,7 +670,7 @@ void Cmd_Team_f( gentity_t *ent )
return;
}
- if( !Q_stricmp( s, "spectate" ) )
+ if( !Q_stricmpn( s, "spec", 4 ) )
team = TEAM_NONE;
else if( !force && oldteam == TEAM_NONE && g_maxGameClients.integer &&
level.numPlayingClients >= g_maxGameClients.integer )
@@ -670,7 +680,7 @@ void Cmd_Team_f( gentity_t *ent )
g_maxGameClients.integer ) );
return;
}
- else if( !Q_stricmp( s, "aliens" ) )
+ else if( !Q_stricmpn( s, "alien", 5 ) )
{
if( level.alienTeamLocked )
{
@@ -693,7 +703,7 @@ void Cmd_Team_f( gentity_t *ent )
team = TEAM_ALIENS;
}
- else if( !Q_stricmp( s, "humans" ) )
+ else if( !Q_stricmpn( s, "human", 5 ) )
{
if( level.humanTeamLocked )
{
@@ -742,7 +752,7 @@ void Cmd_Team_f( gentity_t *ent )
if( oldteam == team )
return;
- //guard against build timer exploit
+ // guard against build timer exploit
if( oldteam != TEAM_NONE && ent->client->sess.spectatorState == SPECTATOR_NOT &&
( ent->client->ps.stats[ STAT_CLASS ] == PCL_ALIEN_BUILDER0 ||
ent->client->ps.stats[ STAT_CLASS ] == PCL_ALIEN_BUILDER0_UPG ||
@@ -756,13 +766,29 @@ void Cmd_Team_f( gentity_t *ent )
return;
}
-
+ // Apply the change
G_ChangeTeam( ent, team );
+ // Send the team join message event to everyone
+ tempent = G_TempEntity( ent->r.currentOrigin, EV_TEAMJOIN );
+ tempent->s.eventParm = ent->s.number;
+ tempent->s.otherEntityNum = team;
+ tempent->s.otherEntityNum2 = oldteam;
+ tempent->r.svFlags = SVF_BROADCAST;
+
if( team == TEAM_ALIENS )
- trap_SendServerCommand( -1, va( "print \"%s" S_COLOR_WHITE " joined the aliens\n\"", ent->client->pers.netname ) );
+ teamname = "aliens";
else if( team == TEAM_HUMANS )
- trap_SendServerCommand( -1, va( "print \"%s" S_COLOR_WHITE " joined the humans\n\"", ent->client->pers.netname ) );
+ teamname = "humans";
+ else
+ teamname = "spectators";
+
+ if( oldteam != TEAM_NONE && team != TEAM_NONE )
+ G_LogPrintf( "team: %i %i %i: %s" S_COLOR_WHITE " left the %s and joined the %s\n", ent->s.number, team, oldteam, ent->client->pers.netname, oldteamname, teamname );
+ else if( team == TEAM_NONE )
+ G_LogPrintf( "team: %i %i %i: %s" S_COLOR_WHITE " left the %s\n", ent->s.number, team, oldteam, ent->client->pers.netname, oldteamname );
+ else
+ G_LogPrintf( "team: %i %i %i: %s" S_COLOR_WHITE " joined the %s\n", ent->s.number, team, oldteam, ent->client->pers.netname, teamname );
}