diff --git a/config/ui/hud/gamehud.cfg b/config/ui/hud/gamehud.cfg index 28e4bb2a..249a1231 100644 --- a/config/ui/hud/gamehud.cfg +++ b/config/ui/hud/gamehud.cfg @@ -615,16 +615,16 @@ radar_icon = [ // flag bases loop i $numflags [ - do [ radar_icon @(flagbase $i) 0 (+s "blip_" (? (= (flagteam $i) 1) "blue" "red")) 0.01 ] + do [ radar_icon @(flagbase $i) 0 (+s "blip_" (? (isteamblue (flagteam $i)) "blue" "red")) 0.01 ] ] // players looplist cn (listclients 1 1) [ if (&& $radarteammates [! (isspectator $cn)] [= $cteam (getclientteam $cn)] [!=s $cn (? $isspectator $getfollow $getclientnum)] [! (getclientflag $cn)]) [ if (isdead $cn) [ - do [ radar_icon @(getclientpos $cn) 0 (+s "blip_" (? (= (getclientteam $cn) 1) "blue" "red") "_dead") ] + do [ radar_icon @(getclientpos $cn) 0 (+s "blip_" (? (isteamblue (getclientteam $cn)) "blue" "red") "_dead") ] ] [ - do [ radar_icon @(getclientpos $cn) (- $getcamyaw (getclientyaw $cn)) (+s "blip_" (? (= (getclientteam $cn) 1) "blue" "red") "_alive") ] + do [ radar_icon @(getclientpos $cn) (- $getcamyaw (getclientyaw $cn)) (+s "blip_" (? (isteamblue (getclientteam $cn)) "blue" "red") "_alive") ] ] ] ] @@ -633,16 +633,16 @@ radar_icon = [ loop i $numflags [ case (flagstate $i) 0 [ // flag is at base - do [ radar_icon @(flagbase $i) 0 (+s "blip_" (? (= (flagteam $i) 1) "blue" "red") "_flag") 0.02 0.017 -0.017 ] + do [ radar_icon @(flagbase $i) 0 (+s "blip_" (? (isteamblue (flagteam $i)) "blue" "red") "_flag") 0.02 0.017 -0.017 ] ] 1 [ // a player has the flag if (< (mod $getmillis 1000) 500) [ - do [ radar_icon @(getclientpos (flagowner $i)) 0 (+s "blip_" (? (= (flagteam $i) 1) "blue" "red") "_flag") 0.02 0.017 -0.017 ] + do [ radar_icon @(getclientpos (flagowner $i)) 0 (+s "blip_" (? (isteamblue (flagteam $i)) "blue" "red") "_flag") 0.02 0.017 -0.017 ] ] ] 2 [ // flag is dropped somewhere if (< (mod $getmillis 300) 150) [ - do [ radar_icon @(flagdroploc $i) 0 (+s "blip_" (? (= (flagteam $i) 1) "blue" "red") "_flag") 0.02 0.017 -0.017 ] + do [ radar_icon @(flagdroploc $i) 0 (+s "blip_" (? (isteamblue (flagteam $i)) "blue" "red") "_flag") 0.02 0.017 -0.017 ] ] ] // 3 - flag fell under the map, don't show icon ] @@ -754,7 +754,7 @@ MAX_WEAPONS = 9 if (getclientflag $cn) [ uioffset 0 $uiPad:USS [ if (< (mod $getmillis 1000) 500) [ - uiFastImg [] "hud/" "flag_" (? (= (getclientflag $cn) 1) "blue" "red") $uiPad:DM + uiFastImg [] "hud/" "flag_" (? (isteamblue (getclientflag $cn)) "blue" "red") $uiPad:DM ] ] ; uialign- 1 1 ] @@ -1187,6 +1187,11 @@ newui "scoreboard" [ ] $n) ] ] + // 1:TEAM + .teamcolorindex = [ + result (? (= $arg1 0) 0 (? (isteamblue $arg1) 1 2)) + ] + // 1:TEAM .scoreboard.header = [ local bflip @@ -1200,13 +1205,13 @@ newui "scoreboard" [ uispace $uiPad:M $uiPad:M- [ uiFancyText "wide" @@@( at "FFA Aesir Vanir" $arg1 - ) 1.4 @@@(INT:TRANS ( - at [0x40D060 0x4060D0 0xD04040] $arg1 + ) 1.4 (INT:TRANS ( + at [0x40D060 0x4060D0 0xD04040] (.teamcolorindex @@@arg1) ) % 80) ] ; uialign- @@(? $bflip 1 -1) -1 uispace $uiPad:O5 (*f $uiPad:O5 2.9) [ - uiFancyText "wide" (getteamscore @@@arg1) 1 @@@( - at [0x40D060 0x4060D0 0xD04040] $arg1 + uiFancyText "wide" (getteamscore @@@arg1) 1 ( + at [0x40D060 0x4060D0 0xD04040] (.teamcolorindex @@@arg1) ) ] ; uialign- @@(? $bflip -1 1) -1 if (numscoreboard @@arg1) [ @@ -1242,7 +1247,7 @@ newui "scoreboard" [ [0x303030 0x282828] // ffa [0x1C2E70 0x122466] // aesir [0x701C1C 0x661212] // vanir - ] @arg1 (& $n 1))) + ] (.teamcolorindex @arg1) (& $n 1))) )] [ @(intmul 0x303840) ]) "hud/" "row" "" [ uifill @@(? $arg3 $arg3 $.sb_rowwidth) @@(? $arg2 [ uigroup [ uiclamp.e ; @@arg2 ] ]) diff --git a/config/ui/menus/settings.cfg b/config/ui/menus/settings.cfg index 4faff1c8..56ccdd53 100644 --- a/config/ui/menus/settings.cfg +++ b/config/ui/menus/settings.cfg @@ -227,6 +227,19 @@ uiMenu "settings" [ uiHorSld fullbrightmodels 0 200 1 [] [+s $$arg1 "%"] ] uiBar 1 0 $uiPad:6XL $uiPad:2XL + uiOptionRow 0 [ uitext "Team colors" 0.6 ] 2 [ + uivlist 0 [ + uiButton "hold2" [ + uiRadio [= $teamcolors 0] + uitext "^fs^f1Aesir^fr / ^f3Vanir" 0.6 + ] $uiPad:D6XL 0 [ teamcolors 0 ] -1 + uiButton "hold2" [ + uiRadio [= $teamcolors 1] + uitext "^fs^f1Your team^fr / ^f3Enemy team" 0.6 + ] $uiPad:D6XL 0 [ teamcolors 1 ] -1 + ] + ] + uiBar 1 0 $uiPad:6XL $uiPad:2XL uiOptionRow 0 [ uitext "Radar" 0.6 ] 2 [ uiButton "hold2" [ uiCheckbox $showminimap diff --git a/source/game/ctf.h b/source/game/ctf.h index 56895ab6..46088d8e 100644 --- a/source/game/ctf.h +++ b/source/game/ctf.h @@ -258,7 +258,10 @@ struct ctfclientmode : clientmode { if(checkovertime()) return; startintermission(); - sendservmsgf("%s%s \fs\f2team reached the score limit\fr", teamtextcode[team], teamnames[team]); + loopvj(clients) if(clients[j]->state.aitype == AI_NONE) + { + sendf(clients[j]->clientnum, 1, "ris", N_SERVMSG, tempformatstring("%s%s \fs\f2team reached the score limit\fr", getTeamTextCode(clients[j], team), teamnames[team])); + } } } @@ -428,12 +431,12 @@ struct ctfclientmode : clientmode } } if(!f.owner && f.droptime && f.droploc.x < 0) continue; - const char *flagname = f.team==1 ? "item/flag/azul" : "item/flag/rojo"; + const char *flagname = isTeamBlue(f.team) ? "item/flag/azul" : "item/flag/rojo"; float angle; vec pos = interpflagpos(f, angle); rendermodel(flagname, ANIM_MAPMODEL|ANIM_LOOP, pos, angle, 0, 0, MDL_CULL_VFC | MDL_CULL_OCCLUDED); - vec lightcolor = vec::hexcolor(teameffectcolor[f.team]); + vec lightcolor = vec::hexcolor(getTeamEffectColorRGB(f.team)); addgamelight(pos, lightcolor.mul(255.f * (0.625f - 0.375f * cos(2 * PI * lastmillis / 1000.f))), 32); if (self && self->state != CS_EDITING) { @@ -449,14 +452,14 @@ struct ctfclientmode : clientmode if(hud->holdingflag && f.team == hud->team) { vec base = f.spawnloc; - particle_hud_mark(base, 2, 1, PART_GAME_ICONS, 1, teamtextcolor[hud->team], 4.0f); + particle_hud_mark(base, 2, 1, PART_GAME_ICONS, 1, getTeamTextColorRGB(hud->team), 4.0f); } else if(f.owner) { if(lastmillis%1000 >= 500) continue; } else if(f.droptime && (f.droploc.x < 0 || lastmillis%300 >= 150)) continue; - particle_hud_mark(pos, f.team == 1 ? 1 : 0, 0, PART_GAME_ICONS, 1, 0xFFFFFF, 2.0f); + particle_hud_mark(pos, isTeamBlue(f.team) ? 1 : 0, 0, PART_GAME_ICONS, 1, 0xFFFFFF, 2.0f); } } @@ -552,7 +555,7 @@ struct ctfclientmode : clientmode void flagexplosion(int i, int team, const vec &loc) { - int fcolor = teameffectcolor[team]; + int fcolor = getTeamEffectColorRGB(team); particle_fireball(loc, 30, PART_EXPLOSION1, -1, fcolor, 4.8f); particle_splash(PART_SPARK, 150, 300, loc, fcolor, 0.24f); vec lightcolor = vec::hexcolor(fcolor); diff --git a/source/game/elimination.h b/source/game/elimination.h index 8829204d..0add0439 100644 --- a/source/game/elimination.h +++ b/source/game/elimination.h @@ -69,13 +69,19 @@ struct eliminationclientmode : clientmode { if(checkovertime()) return; startintermission(); - defformatstring(win, "%s%s \fs\f2team reached the score limit\fr", teamtextcode[winner], teamnames[winner]); - sendf(-1, 1, "ri2s", N_NOTICE, S_INVALID, win); + loopvj(clients) if(clients[j]->state.aitype == AI_NONE) + { + defformatstring(win, "%s%s \fs\f2team reached the score limit\fr", getTeamTextCode(clients[j], winner), teamnames[winner]); + sendf(clients[j]->clientnum, 1, "ri2s", N_NOTICE, S_INVALID, win); + } } else { - defformatstring(win, "%s%s \f2team won the round", teamtextcode[winner], teamnames[winner]); - sendf(-1, 1, "ri2s", N_NOTICE, S_ROUND, win); + loopvj(clients) if(clients[j]->state.aitype == AI_NONE) + { + defformatstring(win, "%s%s \f2team won the round", getTeamTextCode(clients[j], winner), teamnames[winner]); + sendf(clients[j]->clientnum, 1, "ri2s", N_NOTICE, S_ROUND, win); + } } } diff --git a/source/game/game.cpp b/source/game/game.cpp index ac07c610..8507c81e 100644 --- a/source/game/game.cpp +++ b/source/game/game.cpp @@ -1424,13 +1424,13 @@ namespace game const char *teamcolorname(gameent *d, const char *alt) { const int team = teamcolortext && m_teammode && validteam(d->team) ? d->team : 0; - return colorname(d, NULL, alt, teamtextcode[team]); + return colorname(d, NULL, alt, getTeamTextCode(team)); } const char *teamcolor(const char *prefix, const char *suffix, int team, const char *alt) { if(!teamcolortext || !m_teammode || !validteam(team)) return alt; - return tempformatstring("\fs%s%s%s%s\fr", teamtextcode[team], prefix, teamnames[team], suffix); + return tempformatstring("\fs%s%s%s%s\fr", getTeamTextCode(team), prefix, teamnames[team], suffix); } void hurt(gameent* d) diff --git a/source/game/game.h b/source/game/game.h index 4edac8d7..be205a0f 100644 --- a/source/game/game.h +++ b/source/game/game.h @@ -149,7 +149,7 @@ enum N_PAUSEGAME, N_GAMESPEED, N_ADDBOT, N_DELBOT, N_INITAI, N_FROMAI, N_BOTLIMIT, N_BOTBALANCE, N_MAPCRC, N_CHECKMAPS, - N_SWITCHNAME, N_SWITCHMODEL, N_SWITCHCOLOR, N_SWITCHTEAM, + N_SWITCHNAME, N_SWITCHMODEL, N_SWITCHCOLOR, N_SWITCHTEAM, N_SWITCHTEAMCOLORS, N_SERVCMD, N_DEMOPACKET, N_COUNTRY, @@ -181,7 +181,7 @@ static const int msgsizes[] = // size inclusive message token, 0 f N_PAUSEGAME, 0, N_GAMESPEED, 0, N_ADDBOT, 2, N_DELBOT, 1, N_INITAI, 0, N_FROMAI, 2, N_BOTLIMIT, 2, N_BOTBALANCE, 2, N_MAPCRC, 0, N_CHECKMAPS, 1, - N_SWITCHNAME, 0, N_SWITCHMODEL, 2, N_SWITCHCOLOR, 2, N_SWITCHTEAM, 2, + N_SWITCHNAME, 0, N_SWITCHMODEL, 2, N_SWITCHCOLOR, 2, N_SWITCHTEAM, 2, N_SWITCHTEAMCOLORS, 2, N_SERVCMD, 0, N_DEMOPACKET, 0, N_COUNTRY, 0, @@ -191,7 +191,7 @@ static const int msgsizes[] = // size inclusive message token, 0 f #define VALHALLA_SERVER_PORT 21217 #define VALHALLA_LANINFO_PORT 21216 #define VALHALLA_MASTER_PORT 21215 -#define PROTOCOL_VERSION 3 // bump when protocol changes +#define PROTOCOL_VERSION 4 // bump when protocol changes #define DEMO_VERSION 1 // bump when demo format changes #define DEMO_MAGIC "VALHALLA_DEMO\0\0" @@ -550,13 +550,8 @@ const int MAXCOUNTRYCODELEN = 8; const int MAXTEAMS = 2; inline bool validteam(int team) { return team >= 1 && team <= MAXTEAMS; } static const char * const teamnames[1+MAXTEAMS] = { "", "Aesir", "Vanir" }; -static const char * const teamtextcode[1+MAXTEAMS] = { "\ff", "\f1", "\f3" }; -static const char * const teamblipcolor[1+MAXTEAMS] = { "_neutral", "_blue", "_red" }; inline const char *teamname(int team) { return teamnames[validteam(team) ? team : 0]; } static inline int teamnumber(const char *name) { loopi(MAXTEAMS) if(!strcmp(teamnames[1+i], name)) return 1+i; return 0; } -static const int teamtextcolor[1+MAXTEAMS] = { 0xFFFFFF, 0x6496FF, 0xFF4B19 }; -static const int teamscoreboardcolor[1+MAXTEAMS] = { 0, 0x3030C0, 0xC03030 }; -static const int teameffectcolor[1+MAXTEAMS] = { 0xFFFFFF, 0x2020FF, 0xFF2020 }; const int TAUNT_DELAY = 1000; const int VOICECOM_DELAY = 2800; @@ -583,6 +578,12 @@ enum Interaction Count }; +enum TeamColors +{ + Default = 0, + EnemyRed +}; + namespace physics { struct SlideInfo @@ -1310,6 +1311,16 @@ namespace game extern const playermodelinfo &getplayermodelinfo(gameent *d); + #ifndef STANDALONE + extern int teamcolors; + extern bool isTeamBlue(int team); + extern const char *getTeamTextCode(int team); + extern const char *getTeamBlipColor(int team); + extern int getTeamTextColorRGB(int team); + extern int getTeamScoreboardColorRGB(int team); + extern int getTeamEffectColorRGB(int team); + #endif + // hud.cpp extern void drawradar(const float x, const float y, const float s); extern void setbliptex(const int team, const char* type = ""); diff --git a/source/game/gameclient.cpp b/source/game/gameclient.cpp index 3e3a40c8..3dfe3395 100644 --- a/source/game/gameclient.cpp +++ b/source/game/gameclient.cpp @@ -58,18 +58,18 @@ namespace game void printteam() { if((self->clientnum >= 0 && !m_teammode) || !validteam(self->team)) conoutf(CON_ECHO, "\fs\f1You are not in a team\fr"); - else conoutf("\fs\f1Your team is:\fr \fs%s%s\fr", teamtextcode[self->team], teamnames[self->team]); + else conoutf("\fs\f1Your team is:\fr \fs%s%s\fr", getTeamTextCode(self->team), teamnames[self->team]); } ICOMMAND(team, "sN", (char *s, int *numargs), { if(*numargs > 0) switchteam(s); else if(!*numargs) printteam(); - else if((self->clientnum < 0 || m_teammode) && validteam(self->team)) result(tempformatstring("\fs%s%s\fr", teamtextcode[self->team], teamnames[self->team])); + else if((self->clientnum < 0 || m_teammode) && validteam(self->team)) result(tempformatstring("\fs%s%s\fr", getTeamTextCode(self->team), teamnames[self->team])); }); ICOMMAND(getteam, "", (), intret((self->clientnum < 0 || m_teammode) && validteam(self->team) ? self->team : 0)); ICOMMAND(getteamname, "i", (int *num), result(teamname(*num))); - ICOMMAND(getteamcolor, "", (), intret(teamtextcolor[m_teammode ? self->team : 0])); - ICOMMAND(getteamtextcode, "", (), result(teamtextcode[m_teammode ? self->team : 0])); + ICOMMAND(getteamcolor, "", (), intret(getTeamTextColorRGB(m_teammode ? self->team : 0))); + ICOMMAND(getteamtextcode, "", (), result(getTeamTextCode(m_teammode ? self->team : 0))); struct authkey { @@ -1176,9 +1176,9 @@ namespace game } else { - textColor = teamtextcode[team]; + textColor = getTeamTextCode(team); } - conoutf(CON_CHAT, "%s \fs%s(team)\fr: \fs%s%s\fr", d->name, teamtextcode[team], textColor, text); + conoutf(CON_CHAT, "%s \fs%s(team)\fr: \fs%s%s\fr", d->name, getTeamTextCode(team), textColor, text); playchatsound(d, isMention); } @@ -1427,6 +1427,7 @@ namespace game sendstring(self->name, p); putint(p, self->playermodel); putint(p, self->playercolor); + putint(p, teamcolors); sendstring(self->preferred_flag, p); string hash = ""; if(connectpass[0]) @@ -2459,7 +2460,7 @@ namespace game w->team = validteam(team) ? team : 0; static const char * const fmt[2] = { "%s \fs\f0switched to team\fr %s%s", "%s \fs\f0forced to team\fr %s%s"}; if(reason >= 0 && size_t(reason) < sizeof(fmt)/sizeof(fmt[0])) - conoutf(fmt[reason], colorname(w), teamtextcode[w->team], teamnames[w->team]); + conoutf(fmt[reason], colorname(w), getTeamTextCode(w->team), teamnames[w->team]); break; } diff --git a/source/game/gameserver.cpp b/source/game/gameserver.cpp index af5ef45e..ce49b89a 100644 --- a/source/game/gameserver.cpp +++ b/source/game/gameserver.cpp @@ -455,7 +455,7 @@ namespace server { int clientnum, ownernum, connectmillis, sessionid, overflow; string name, mapvote; - int team, playermodel, playercolor; + int team, playermodel, playercolor, teamcolors; int modevote, mutsvote; int privilege; bool connected, local, timesync, ghost, mute; @@ -591,6 +591,7 @@ namespace server team = 0; playermodel = -1; playercolor = 0; + teamcolors = TeamColors::Default; privilege = PRIV_NONE; connected = local = ghost = false; connectauth = 0; @@ -1148,6 +1149,27 @@ namespace server virtual bool extinfoteam(int team, ucharbuf &p) { return false; } }; + bool isTeamBlue(clientinfo *ci, int team) + { + switch(ci->teamcolors) + { + case TeamColors::EnemyRed: + return validteam(team) && ci->team == team; + case TeamColors::Default: default: + return team == 1; + } + } + const char *getTeamTextCode(clientinfo *ci, int team) + { + switch(team) + { + case 1: // fall through + case 2: + return isTeamBlue(ci, team) ? "\f1" : "\f3"; + default: return "\f7"; + } + } + #define SERVMODE 1 #include "ctf.h" #include "elimination.h" @@ -2676,8 +2698,11 @@ namespace server { if(checkovertime()) return; startintermission(); - defformatstring(winner, "%s%s \fs\f2reached the score limit\fr", team ? teamtextcode[ci->team] : "", team ? teamnames[ci->team] : colorname(ci)); - sendf(-1, 1, "ri2s", N_NOTICE, S_INVALID, winner); + loopvj(clients) if(clients[j]->state.aitype == AI_NONE) + { + defformatstring(winner, "%s%s \fs\f2reached the score limit\fr", team ? getTeamTextCode(clients[j], ci->team) : "", team ? teamnames[ci->team] : colorname(ci)); + sendf(clients[j]->clientnum, 1, "ri2s", N_NOTICE, S_INVALID, winner); + } } } @@ -4402,6 +4427,7 @@ namespace server copystring(ci->name, text, MAXNAMELEN+1); ci->playermodel = getint(p); ci->playercolor = getint(p); + ci->teamcolors = getint(p); getstring(text, p); filtertext(ci->preferred_flag, text, false, false, false, false, MAXCOUNTRYCODELEN); @@ -4988,6 +5014,12 @@ namespace server break; } + case N_SWITCHTEAMCOLORS: + { + ci->teamcolors = getint(p); + break; + } + case N_MAPVOTE: { getstring(text, p); diff --git a/source/game/hud.cpp b/source/game/hud.cpp index 3c7e7168..6938c592 100644 --- a/source/game/hud.cpp +++ b/source/game/hud.cpp @@ -512,7 +512,7 @@ namespace game if (pointedPlayer != nullptr && isally(pointedPlayer, hudPlayer)) { crosshair = Pointer_Ally; - color = vec4(vec::hexcolor(teamtextcolor[hudPlayer->team]), 1); + color = vec4(vec::hexcolor(getTeamTextColorRGB(hudPlayer->team)), 1); } } @@ -746,7 +746,7 @@ namespace game void setbliptex(const int team, const char* type) { - defformatstring(blipname, "data/interface/radar/blip%s%s.png", teamblipcolor[validteam(team) ? team : 0], type); + defformatstring(blipname, "data/interface/radar/blip%s%s.png", getTeamBlipColor(validteam(team) ? team : 0), type); settexture(blipname, 3); } diff --git a/source/game/render.cpp b/source/game/render.cpp index c6771089..37791183 100644 --- a/source/game/render.cpp +++ b/source/game/render.cpp @@ -137,17 +137,94 @@ namespace game return *mdl; } + VARFP(teamcolors, 0, 0, 1, addmsg(N_SWITCHTEAMCOLORS, "ri", teamcolors)); + + bool isTeamBlue(int team) + { + switch(teamcolors) + { + case TeamColors::EnemyRed: + return validteam(team) && self->team == team; + case TeamColors::Default: default: + return team == 1; + } + } + ICOMMAND(isteamblue, "i", (int *team), intret(isTeamBlue(*team) ? 1 : 0)); + ICOMMAND(isteamred , "i", (int *team), intret((isTeamBlue(*team) || !validteam(*team)) ? 0 : 1)); + + static const char * const teamtextcode[1+MAXTEAMS] = { "\ff", "\f1", "\f3" }; + static const char * const teamblipcolor[1+MAXTEAMS] = { "_neutral", "_blue", "_red" }; + static const int teamtextcolor[1+MAXTEAMS] = { 0xFFFFFF, 0x6496FF, 0xFF4B19 }; + static const int teamscoreboardcolor[1+MAXTEAMS] = { 0, 0x3030C0, 0xC03030 }; + static const int teameffectcolor[1+MAXTEAMS] = { 0xFFFFFF, 0x2020FF, 0xFF2020 }; + + const char *getTeamTextCode(int team) + { + switch(team) + { + case 1: // fall through + case 2: + return teamtextcode[isTeamBlue(team) ? 1 : 2]; + default: return teamtextcode[0]; + } + } + const char *getTeamBlipColor(int team) + { + switch(team) + { + case 1: // fall through + case 2: + return teamblipcolor[isTeamBlue(team) ? 1 : 2]; + default: return teamblipcolor[0]; + } + } + int getTeamTextColorRGB(int team) + { + switch(team) + { + case 1: // fall through + case 2: + return teamtextcolor[isTeamBlue(team) ? 1 : 2]; + default: return teamtextcolor[0]; + } + } + int getTeamScoreboardColorRGB(int team) + { + switch(team) + { + case 1: // fall through + case 2: + return teamscoreboardcolor[isTeamBlue(team) ? 1 : 2]; + default: return teamscoreboardcolor[0]; + } + } + int getTeamEffectColorRGB(int team) + { + switch(team) + { + case 1: // fall through + case 2: + return teameffectcolor[isTeamBlue(team) ? 1 : 2]; + default: return teameffectcolor[0]; + } + } + + #define GETPLAYERCOLOR(playercolors) \ + return playercolors[color%(sizeof(playercolors)/sizeof(playercolors[0]))]; int getplayercolor(int team, int color) { - #define GETPLAYERCOLOR(playercolors) \ - return playercolors[color%(sizeof(playercolors)/sizeof(playercolors[0]))]; switch(team) { - case 1: GETPLAYERCOLOR(playercolorsblue) - case 2: GETPLAYERCOLOR(playercolorsred) - default: GETPLAYERCOLOR(playercolors) + case 1: // fall through + case 2: + { + const int (&teamcolors)[4] = isTeamBlue(team) ? playercolorsblue : playercolorsred; + GETPLAYERCOLOR(teamcolors); + } + default: GETPLAYERCOLOR(playercolors); } } + #undef GETPLAYERCOLOR ICOMMAND(getplayercolor, "ii", (int *color, int *team), intret(getplayercolor(*team, *color))); @@ -155,8 +232,9 @@ namespace game { if(d==self) switch(team) { - case 1: return getplayercolor(1, playercolorblue); - case 2: return getplayercolor(2, playercolorred); + case 1: // fall through + case 2: + return getplayercolor(team, isTeamBlue(team) ? playercolorblue : playercolorred); default: return getplayercolor(0, playercolor); } else return getplayercolor(team, (d->playercolor>>(5*team))&0x1F); @@ -604,7 +682,7 @@ namespace game else if (d->state == CS_ALIVE && !hidenames()) { int team = m_teammode && validteam(d->team) ? d->team : 0; - particle_text(position, d->info, PART_TEXT, 1, teamtextcolor[team], 2.0f); + particle_text(position, d->info, PART_TEXT, 1, getTeamTextColorRGB(team), 2.0f); } updateMovementEffects(d); }