From 095fa2507b47828c0eec4273ea209391a08a09f1 Mon Sep 17 00:00:00 2001 From: kameltoe Date: Tue, 31 Dec 2019 17:45:19 -0500 Subject: [PATCH 1/2] cg_enemyColors * add 'cid' value (color is determined with clientNum) --- code/cgame/cg_players.c | 30 ++++++++++++++++++++++-------- docs/client.txt | 4 +++- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/code/cgame/cg_players.c b/code/cgame/cg_players.c index f0038698..88d8152d 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,15 @@ 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); + } + else { + return va("0%i",CG_ToBase7(clientNum)); + } + } + return str; } @@ -1019,9 +1033,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 +1064,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 +1115,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 +1133,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 +1275,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 d97d6757..e8a4cd14 100644 --- a/docs/client.txt +++ b/docs/client.txt @@ -37,7 +37,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 @@ -48,6 +48,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 !!! From 897f0c5859d9191eb5568bc75247914e5010fb69 Mon Sep 17 00:00:00 2001 From: kameltoe Date: Thu, 21 Dec 2023 11:41:32 -0500 Subject: [PATCH 2/2] cg_enemyColors * remove useless else * add John Carmack space styling --- code/cgame/cg_players.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/code/cgame/cg_players.c b/code/cgame/cg_players.c index 88d8152d..a72a27bc 100644 --- a/code/cgame/cg_players.c +++ b/code/cgame/cg_players.c @@ -713,10 +713,10 @@ 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) +static const int CG_ToBase7( int number ) { + if( number == 0 ) return number; - return (number % 7) + 10*CG_ToBase7(number / 7); + return ( number % 7 ) + 10 * CG_ToBase7( number / 7 ); } static const char *CG_GetColors( const char *color, team_t team, int clientNum ) { @@ -731,13 +731,11 @@ static const char *CG_GetColors( const char *color, team_t team, int clientNum ) default: break; } - if ( !strcmp(color,"cid") ) { - if (clientNum < 7) { - return va("00%i",clientNum); - } - else { - return va("0%i",CG_ToBase7(clientNum)); + if ( !strcmp( color, "cid" ) ) { + if ( clientNum < 7 ) { + return va( "00%i", clientNum ); } + return va( "0%i", CG_ToBase7( clientNum ) ); } return str;