Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cg_enemyColors #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions code/cgame/cg_players.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
kameltoe marked this conversation as resolved.
Show resolved Hide resolved

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 ) );
Expand All @@ -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 ) );
}
kameltoe marked this conversation as resolved.
Show resolved Hide resolved

return str;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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 );
Expand Down
4 changes: 3 additions & 1 deletion docs/client.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 !!!


Expand Down