diff options
author | Ben Millwood <thebenmachine@gmail.com> | 2009-10-03 12:26:21 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:15:57 +0000 |
commit | 6f56815bdb0ba0b37d4afcd4c2cac3f4ddd1846d (patch) | |
tree | ba9aa844a62d71b2e1fac1c5db45e85b848a7ca2 /src/cgame/cg_players.c | |
parent | a2ace419da13b911514392033940f7f307766b33 (diff) |
* Don't display team join message if previous clientinfo was invalid (bug 3960)
* Move CG_TeamJoinMessage to cg_players.c near where it is used
* When changing team, execute cg_(alien|human|spectator)Config as appropriate
Diffstat (limited to 'src/cgame/cg_players.c')
-rw-r--r-- | src/cgame/cg_players.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/cgame/cg_players.c b/src/cgame/cg_players.c index bd53eb20..2cef1539 100644 --- a/src/cgame/cg_players.c +++ b/src/cgame/cg_players.c @@ -723,6 +723,51 @@ void CG_PrecacheClientInfo( class_t class, char *model, char *skin ) /* +============= +CG_TeamJoinMessage + +Prints messages when players change teams +============= +*/ +void CG_TeamJoinMessage( clientInfo_t *newInfo, clientInfo_t *ci ) +{ + int team; + int oldteam; + char *playerName; + + if( !ci->infoValid ) + return; + + // Collect info + team = newInfo->team; + oldteam = ci->team; + + // 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 + { + CG_Printf( "%s" S_COLOR_WHITE " left the %ss and joined the %ss\n", + playerName, BG_TeamName( oldteam ), BG_TeamName( team ) ); + } +} + + +/* ====================== CG_NewClientInfo ====================== @@ -774,6 +819,22 @@ void CG_NewClientInfo( int clientNum ) 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 + // cgame can't tell the difference between that and joining a new server + if( clientNum == cg.clientNum && + ( !ci->infoValid || ci->team != newInfo.team ) ) + { + char config[ MAX_STRING_CHARS ]; + + trap_Cvar_VariableStringBuffer( + va( "cg_%sConfig", BG_TeamName( newInfo.team ) ), + config, sizeof( config ) ); + + if( config[ 0 ] ) + trap_SendConsoleCommand( va( "exec %s\n", config ) ); + } + // model v = Info_ValueForKey( configstring, "model" ); Q_strncpyz( newInfo.modelName, v, sizeof( newInfo.modelName ) ); |