summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorM. Kristall <mkpdev@gmail.com>2009-10-03 12:09:04 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:15:42 +0000
commit18e91721c4bda2513d6a6e890f3538ee97770123 (patch)
tree42498a7b2440dd007ae3d35b611915adce8ebf31 /src
parent32b40f909ad57f01456cf1dbde5d8653ab329634 (diff)
* Handle some broken admin.dat files the same as before
* Make G_TeamName BG_TeamName and use it in cgame for team change messages * Don't use an event for team change notification since clients already know
Diffstat (limited to 'src')
-rw-r--r--src/cgame/cg_event.c36
-rw-r--r--src/cgame/cg_local.h1
-rw-r--r--src/cgame/cg_players.c1
-rw-r--r--src/game/bg_misc.c18
-rw-r--r--src/game/bg_public.h4
-rw-r--r--src/game/g_admin.c15
-rw-r--r--src/game/g_cmds.c10
-rw-r--r--src/game/g_local.h1
-rw-r--r--src/game/g_team.c40
9 files changed, 58 insertions, 68 deletions
diff --git a/src/cgame/cg_event.c b/src/cgame/cg_event.c
index a8632cb4..8acbbeaf 100644
--- a/src/cgame/cg_event.c
+++ b/src/cgame/cg_event.c
@@ -375,23 +375,18 @@ CG_TeamJoinMessage
Prints messages when players change teams
=============
*/
-static void CG_TeamJoinMessage( entityState_t *ent )
+void CG_TeamJoinMessage( clientInfo_t *newInfo, clientInfo_t *ci )
{
- int player;
int team;
int oldteam;
char *playerName;
// Collect info
- player = ent->eventParm;
- team = ent->otherEntityNum;
- oldteam = ent->otherEntityNum2;
+ team = newInfo->team;
+ oldteam = ci->team;
- if( player < 0 || player >= MAX_CLIENTS )
- CG_Error( "CG_TeamJoinMessage: target out of range" );
-
- playerName = cgs.clientinfo[player].name;
+ playerName = newInfo->name;
// If no change occurred, print nothing
if( team == oldteam )
@@ -400,24 +395,18 @@ static void CG_TeamJoinMessage( entityState_t *ent )
// Print the appropriate message
if( team == TEAM_NONE )
{
- if( oldteam == TEAM_HUMANS )
- CG_Printf( "%s" S_COLOR_WHITE " left the humans\n", playerName );
- else if( oldteam == TEAM_ALIENS )
- CG_Printf( "%s" S_COLOR_WHITE " left the aliens\n", playerName );
+ CG_Printf( "%s" S_COLOR_WHITE " left the %ss\n",
+ playerName, BG_TeamName( oldteam ) );
}
else if( oldteam == TEAM_NONE )
{
- if( team == TEAM_ALIENS )
- CG_Printf( "%s" S_COLOR_WHITE " joined the aliens\n", playerName );
- else if( team == TEAM_HUMANS )
- CG_Printf( "%s" S_COLOR_WHITE " joined the humans\n", playerName );
+ CG_Printf( "%s" S_COLOR_WHITE " joined the %ss\n",
+ playerName, BG_TeamName( team ) );
}
else
{
- if( oldteam == TEAM_HUMANS && team == TEAM_ALIENS )
- CG_Printf( "%s" S_COLOR_WHITE " abandoned the humans and joined the aliens\n", playerName );
- else if( oldteam == TEAM_ALIENS && team == TEAM_HUMANS )
- CG_Printf( "%s" S_COLOR_WHITE " abandoned the aliens and joined the humans\n", playerName );
+ CG_Printf( "%s" S_COLOR_WHITE " left the %ss and joined the %ss\n",
+ playerName, BG_TeamName( oldteam ), BG_TeamName( team ) );
}
}
@@ -973,11 +962,6 @@ void CG_EntityEvent( centity_t *cent, vec3_t position )
CG_Obituary( es );
break;
- case EV_TEAMJOIN:
- DEBUGNAME( "EV_TEAMJOIN" );
- CG_TeamJoinMessage( es );
- break;
-
case EV_GIB_PLAYER:
DEBUGNAME( "EV_GIB_PLAYER" );
// no gibbing
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index e4a19844..73933525 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -1702,6 +1702,7 @@ void CG_PredictPlayerState( void );
void CG_CheckEvents( centity_t *cent );
void CG_EntityEvent( centity_t *cent, vec3_t position );
void CG_PainEvent( centity_t *cent, int health );
+void CG_TeamJoinMessage( clientInfo_t *newInfo, clientInfo_t *ci );
//
diff --git a/src/cgame/cg_players.c b/src/cgame/cg_players.c
index 28d19ba9..8bd0457c 100644
--- a/src/cgame/cg_players.c
+++ b/src/cgame/cg_players.c
@@ -772,6 +772,7 @@ void CG_NewClientInfo( int clientNum )
// team
v = Info_ValueForKey( configstring, "t" );
newInfo.team = atoi( v );
+ CG_TeamJoinMessage( &newInfo, ci );
// model
v = Info_ValueForKey( configstring, "model" );
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c
index 450844d5..cac8f17b 100644
--- a/src/game/bg_misc.c
+++ b/src/game/bg_misc.c
@@ -2784,8 +2784,6 @@ char *eventnames[ ] =
"EV_DEATH3",
"EV_OBITUARY",
- "EV_TEAMJOIN", // teamjoin message
-
"EV_GIB_PLAYER", // gib a previously living player
"EV_BUILD_CONSTRUCT",
@@ -3914,3 +3912,19 @@ int BG_LoadEmoticons( char names[ ][ MAX_EMOTICON_NAME_LEN ], int widths[ ] )
return loaded;
}
+/*
+============
+BG_TeamName
+============
+*/
+char *BG_TeamName( team_t team )
+{
+ if( team == TEAM_NONE )
+ return "spectator";
+ if( team == TEAM_ALIENS )
+ return "alien";
+ if( team == TEAM_HUMANS )
+ return "human";
+ return "<team>";
+}
+
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index b8938c63..707b6256 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -509,8 +509,6 @@ typedef enum
EV_DEATH3,
EV_OBITUARY,
- EV_TEAMJOIN, // teamjoin message
-
EV_GIB_PLAYER, // gib a previously living player
EV_BUILD_CONSTRUCT,
@@ -1300,3 +1298,5 @@ voiceTrack_t *BG_VoiceTrackFind( voiceTrack_t *head, team_t team,
int enthusiasm, int *trackNum );
int BG_LoadEmoticons( char names[ ][ MAX_EMOTICON_NAME_LEN ], int widths[ ] );
+
+char *BG_TeamName( team_t team );
diff --git a/src/game/g_admin.c b/src/game/g_admin.c
index ca201d8d..5ac2461a 100644
--- a/src/game/g_admin.c
+++ b/src/game/g_admin.c
@@ -484,12 +484,13 @@ static void admin_readconfig_string( char **cnf, char *s, int size )
char *t;
//COM_MatchToken(cnf, "=");
+ s[ 0 ] = '\0';
t = COM_ParseExt( cnf, qfalse );
if( strcmp( t, "=" ) )
{
COM_ParseWarning( "expected '=' before \"%s\"", t );
+ Q_strncpyz( s, t, size );
}
- s[ 0 ] = '\0';
while( 1 )
{
t = COM_ParseExt( cnf, qfalse );
@@ -497,12 +498,10 @@ static void admin_readconfig_string( char **cnf, char *s, int size )
break;
if( strlen( t ) + strlen( s ) >= size )
break;
+ if( *s )
+ Q_strcat( s, size, " " );
Q_strcat( s, size, t );
- Q_strcat( s, size, " " );
}
- // trim the trailing space
- if( strlen( s ) > 0 && s[ strlen( s ) - 1 ] == ' ' )
- s[ strlen( s ) - 1 ] = '\0';
}
static void admin_readconfig_int( char **cnf, int *v )
@@ -1958,7 +1957,7 @@ qboolean G_admin_putteam( gentity_t *ent, int skiparg )
AP( va( "print \"^3!putteam: ^7%s^7 put %s^7 on to the %s team\n\"",
( ent ) ? ent->client->pers.netname : "console",
- vic->client->pers.netname, G_TeamName( teamnum ) ) );
+ vic->client->pers.netname, BG_TeamName( teamnum ) ) );
return qtrue;
}
@@ -2932,7 +2931,7 @@ qboolean G_admin_lock( gentity_t *ent, int skiparg )
}
AP( va( "print \"^3!lock: ^7the %s team has been locked by %s\n\"",
- G_TeamName( team ),
+ BG_TeamName( team ),
( ent ) ? ent->client->pers.netname : "console" ) );
return qtrue;
}
@@ -2976,7 +2975,7 @@ qboolean G_admin_unlock( gentity_t *ent, int skiparg )
}
AP( va( "print \"^3!unlock: ^7the %s team has been unlocked by %s\n\"",
- G_TeamName( team ),
+ BG_TeamName( team ),
( ent ) ? ent->client->pers.netname : "console" ) );
return qtrue;
}
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 49fc49f7..db8a37b9 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -543,7 +543,6 @@ void Cmd_Team_f( gentity_t *ent )
qboolean force = G_admin_permission(ent, ADMF_FORCETEAMCHANGE);
int aliens = level.numAlienClients;
int humans = level.numHumanClients;
- gentity_t *tempent;
// stop team join spam
if( level.time - ent->client->pers.teamChangeTime < 1000 )
@@ -645,13 +644,6 @@ void Cmd_Team_f( gentity_t *ent )
// 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;
}
@@ -711,7 +703,7 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText )
if( g_chatTeamPrefix.integer )
{
- prefix = G_TeamName( ent->client->pers.teamSelection );
+ prefix = BG_TeamName( ent->client->pers.teamSelection );
prefix = va( "[%c] ", toupper( *prefix ) );
}
else
diff --git a/src/game/g_local.h b/src/game/g_local.h
index 648774c1..48e17ac4 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -960,7 +960,6 @@ void G_RunClient( gentity_t *ent );
// g_team.c
//
team_t G_TeamFromString( char *str );
-char *G_TeamName( team_t team );
qboolean OnSameTeam( gentity_t *ent1, gentity_t *ent2 );
void G_LeaveTeam( gentity_t *self );
void G_ChangeTeam( gentity_t *ent, team_t newTeam );
diff --git a/src/game/g_team.c b/src/game/g_team.c
index e57da1bd..c3c490e5 100644
--- a/src/game/g_team.c
+++ b/src/game/g_team.c
@@ -63,26 +63,6 @@ team_t G_TeamFromString( char *str )
}
/*
-================
-G_TeamName
-================
-*/
-char *G_TeamName( team_t team )
-{
- switch( team )
- {
- case TEAM_NONE:
- return "spectator";
- case TEAM_ALIENS:
- return "alien";
- case TEAM_HUMANS:
- return "human";
- default:
- return "unknown";
- }
-}
-
-/*
==============
OnSameTeam
==============
@@ -194,6 +174,26 @@ void G_ChangeTeam( gentity_t *ent, team_t newTeam )
}
ClientUserinfoChanged( ent->client->ps.clientNum );
+
+ if( oldTeam != TEAM_NONE && newTeam != TEAM_NONE )
+ {
+ G_LogPrintf(
+ "team: %i %i %i: %s" S_COLOR_WHITE " left the %ss and joined the %ss\n",
+ ent->s.number, newTeam, oldTeam, ent->client->pers.netname,
+ BG_TeamName( oldTeam ), BG_TeamName( newTeam ) );
+ }
+ else if( newTeam == TEAM_NONE )
+ {
+ G_LogPrintf( "team: %i %i %i: %s" S_COLOR_WHITE " left the %ss\n",
+ ent->s.number, newTeam, oldTeam, ent->client->pers.netname,
+ BG_TeamName( oldTeam ) );
+ }
+ else
+ {
+ G_LogPrintf( "team: %i %i %i: %s" S_COLOR_WHITE " joined the %ss\n",
+ ent->s.number, newTeam, oldTeam, ent->client->pers.netname,
+ BG_TeamName( newTeam ) );
+ }
}
/*