diff --git a/code/cgame/cg_players.c b/code/cgame/cg_players.c index f0038698..a72a27bc 100644 --- a/code/cgame/cg_players.c +++ b/code/cgame/cg_players.c @@ -713,8 +713,13 @@ static void CG_SetColorInfo( const char *color, clientInfo_t *info ) CG_ColorFromChar( color[4], info->color2 ); } +static const int CG_ToBase7( int number ) { + if( number == 0 ) + return number; + return ( number % 7 ) + 10 * CG_ToBase7( number / 7 ); +} -static const char *CG_GetTeamColors( const char *color, team_t team ) { +static const char *CG_GetColors( const char *color, team_t team, int clientNum ) { static char str[6]; Q_strncpyz( str, color, sizeof( str ) ); @@ -726,6 +731,13 @@ static const char *CG_GetTeamColors( const char *color, team_t team ) { default: break; } + if ( !strcmp( color, "cid" ) ) { + if ( clientNum < 7 ) { + return va( "00%i", clientNum ); + } + return va( "0%i", CG_ToBase7( clientNum ) ); + } + return str; } @@ -1019,9 +1031,9 @@ static void CG_SetSkinAndModel( clientInfo_t *newInfo, if ( setColor ) { if ( cg_enemyColors.string[0] && myTeam != TEAM_SPECTATOR ) // free-fly? - colors = CG_GetTeamColors( cg_enemyColors.string, newInfo->team ); + colors = CG_GetColors( cg_enemyColors.string, newInfo->team, clientNum ); else - colors = CG_GetTeamColors( "???", newInfo->team ); + colors = CG_GetColors( "???", newInfo->team, clientNum ); CG_SetColorInfo( colors, newInfo ); newInfo->coloredSkin = qtrue; @@ -1050,9 +1062,9 @@ static void CG_SetSkinAndModel( clientInfo_t *newInfo, if ( setColor ) { if ( cg_teamColors.string[0] && myTeam != TEAM_SPECTATOR ) // free-fly? - colors = CG_GetTeamColors( cg_teamColors.string, newInfo->team ); + colors = CG_GetColors( cg_teamColors.string, newInfo->team, clientNum ); else - colors = CG_GetTeamColors( "???", newInfo->team ); + colors = CG_GetColors( "???", newInfo->team, clientNum ); CG_SetColorInfo( colors, newInfo ); newInfo->coloredSkin = qtrue; @@ -1101,7 +1113,7 @@ static void CG_SetSkinAndModel( clientInfo_t *newInfo, Q_strncpyz( modelName, "sarge", modelNameSize ); if ( setColor ) { - colors = CG_GetTeamColors( cg_enemyColors.string, newInfo->team ); + colors = CG_GetColors( cg_enemyColors.string, newInfo->team, clientNum ); CG_SetColorInfo( colors, newInfo ); newInfo->coloredSkin = qtrue; } @@ -1119,7 +1131,7 @@ static void CG_SetSkinAndModel( clientInfo_t *newInfo, } if ( setColor ) { - colors = CG_GetTeamColors( cg_enemyColors.string, newInfo->team ); + colors = CG_GetColors( cg_enemyColors.string, newInfo->team, clientNum ); CG_SetColorInfo( colors, newInfo ); newInfo->coloredSkin = qtrue; } @@ -1261,7 +1273,7 @@ void CG_NewClientInfo( int clientNum ) { // always apply team colors [4] and [5] if specified, this will work in non-team games too if ( cg_teamColors.string[0] && team != TEAM_SPECTATOR ) { if ( allowNativeModel || ( ( team == TEAM_RED || team == TEAM_BLUE ) && team == myTeam && ( clientNum != myClientNum || cg.demoPlayback ) ) ) { - v = CG_GetTeamColors( cg_teamColors.string, team ); + v = CG_GetColors( cg_teamColors.string, team, clientNum ); len = strlen( v ); if ( len >= 4 ) CG_ColorFromChar( v[3], newInfo.color1 ); diff --git a/docs/client.txt b/docs/client.txt index 7a78e490..c2fb2c59 100644 --- a/docs/client.txt +++ b/docs/client.txt @@ -39,7 +39,7 @@ cg_enemyModel [ pm | modelname ] ======================== cg_enemyColors [colorstring] - colorstring is a 3 [or 5] char-length string, where + colorstring is a 3 [or 5] char-length string, or value 'cid', where 1st char - head color, all colors forced to '???' if not set 2nd char - torso color, forced to white if not set @@ -50,6 +50,8 @@ cg_enemyColors [colorstring] '?' will be replaced to white in FFA games or corresponding team color (red or blue) in team games + 'cid' will use a unique combination of colors per enemy (works up to 48 clients, the remaining clients will be white) + !!! will work only if cg_enemyModel is set !!!