diff options
author | M. Kristall <mkpdev@gmail.com> | 2010-03-01 15:23:03 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:17:29 +0000 |
commit | 0d5105c697d871b59898ca49023314571fb8dbaf (patch) | |
tree | e25b5a9ba8a12c0c3a4aa6321772cf4c67066baa /src/cgame | |
parent | 117b2c94c3a8fafd9401112699158cbc81a89cd5 (diff) |
* Generate "player renamed to ..." messages client-side
Diffstat (limited to 'src/cgame')
-rw-r--r-- | src/cgame/cg_local.h | 1 | ||||
-rw-r--r-- | src/cgame/cg_players.c | 52 |
2 files changed, 18 insertions, 35 deletions
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 0eac4db7..5d296fe0 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -1645,7 +1645,6 @@ void CG_Corpse( centity_t *cent ); void CG_ResetPlayerEntity( centity_t *cent ); void CG_NewClientInfo( int clientNum ); void CG_PrecacheClientInfo( class_t class, char *model, char *skin ); -void CG_TeamJoinMessage( clientInfo_t *newInfo, clientInfo_t *ci ); sfxHandle_t CG_CustomSound( int clientNum, const char *soundName ); void CG_PlayerDisconnect( vec3_t org ); void CG_Bleed( vec3_t origin, vec3_t normal, int entityNum ); diff --git a/src/cgame/cg_players.c b/src/cgame/cg_players.c index f05c9025..d22a87d8 100644 --- a/src/cgame/cg_players.c +++ b/src/cgame/cg_players.c @@ -721,52 +721,35 @@ void CG_PrecacheClientInfo( class_t class, char *model, char *skin ) CG_LoadClientInfo( ci ); } - /* ============= -CG_TeamJoinMessage +CG_StatusMessages -Prints messages when players change teams +Print messages for player status changes ============= */ -void CG_TeamJoinMessage( clientInfo_t *newInfo, clientInfo_t *ci ) +static void CG_StatusMessages( clientInfo_t *new, clientInfo_t *old ) { - int team; - int oldteam; - char *playerName; - - if( !ci->infoValid ) + if( !old->infoValid ) return; - // Collect info - team = newInfo->team; - oldteam = ci->team; + if( strcmp( new->name, old->name ) ) + CG_Printf( "%s" S_COLOR_WHITE " renamed to %s\n", old->name, new->name ); - // If no change occurred, print nothing - if( team == oldteam ) - return; - - playerName = newInfo->name; - - // Print the appropriate message - if( team == TEAM_NONE ) - { - CG_Printf( "%s" S_COLOR_WHITE " left the %ss\n", - playerName, BG_TeamName( oldteam ) ); - } - else if( oldteam == TEAM_NONE ) - { - CG_Printf( "%s" S_COLOR_WHITE " joined the %ss\n", - playerName, BG_TeamName( team ) ); - } - else + if( old->team != new->team ) { - CG_Printf( "%s" S_COLOR_WHITE " left the %ss and joined the %ss\n", - playerName, BG_TeamName( oldteam ), BG_TeamName( team ) ); + if( new->team == TEAM_NONE ) + CG_Printf( "%s" S_COLOR_WHITE " left the %ss\n", new->name, + BG_TeamName( old->team ) ); + else if( old->team == TEAM_NONE ) + CG_Printf( "%s" S_COLOR_WHITE " joined the %ss\n", new->name, + BG_TeamName( new->team ) ); + else + CG_Printf( "%s" S_COLOR_WHITE " left the %ss and joined the %ss\n", + new->name, BG_TeamName( old->team ), BG_TeamName( new->team ) ); } } - /* ====================== CG_NewClientInfo @@ -817,7 +800,6 @@ void CG_NewClientInfo( int clientNum ) // team v = Info_ValueForKey( configstring, "t" ); newInfo.team = atoi( v ); - CG_TeamJoinMessage( &newInfo, ci ); // if this is us, execute team-specific config files // unfortunately, these get re-executed after a vid_restart, because the @@ -857,6 +839,8 @@ void CG_NewClientInfo( int clientNum ) v = Info_ValueForKey( configstring, "v" ); Q_strncpyz( newInfo.voice, v, sizeof( newInfo.voice ) ); + CG_StatusMessages( &newInfo, ci ); + // replace whatever was there with the new one newInfo.infoValid = qtrue; *ci = newInfo; |