3 const int NUM_TEAMS = 4; ///< Number of teams in the game.
5 #ifdef TEAMNUMBERS_THAT_ARENT_STUPID
6 const int NUM_TEAM_1 = 1; // red
7 const int NUM_TEAM_2 = 2; // blue
8 const int NUM_TEAM_3 = 3; // yellow
9 const int NUM_TEAM_4 = 4; // pink
10 const int NUM_SPECTATOR = 5;
13 const int NUM_TEAM_1 = 4; // red
14 const int NUM_TEAM_2 = 13; // blue
15 const int NUM_TEAM_3 = 12; // yellow
16 const int NUM_TEAM_4 = 9; // pink
18 const int NUM_TEAM_1 = 5; // red
19 const int NUM_TEAM_2 = 14; // blue
20 const int NUM_TEAM_3 = 13; // yellow
21 const int NUM_TEAM_4 = 10; // pink
23 const int NUM_SPECTATOR = 1337;
26 const string COL_TEAM_1 = "^1";
27 const string COL_TEAM_2 = "^4";
28 const string COL_TEAM_3 = "^3";
29 const string COL_TEAM_4 = "^6";
30 // must be #defined, const globals drop the translation attribute
31 #define NAME_TEAM_1 CTX(_("TEAM^Red"))
32 #define NAME_TEAM_2 CTX(_("TEAM^Blue"))
33 #define NAME_TEAM_3 CTX(_("TEAM^Yellow"))
34 #define NAME_TEAM_4 CTX(_("TEAM^Pink"))
35 #define NAME_TEAM _("Team")
36 #define NAME_NEUTRAL _("Neutral")
38 // items colors, so they are handled properly in languages which decline things with grammatical gender
39 #define KEY_TEAM_1 CTX(_("KEY^Red"))
40 #define KEY_TEAM_2 CTX(_("KEY^Blue"))
41 #define KEY_TEAM_3 CTX(_("KEY^Yellow"))
42 #define KEY_TEAM_4 CTX(_("KEY^Pink"))
43 #define FLAG_TEAM_1 CTX(_("FLAG^Red"))
44 #define FLAG_TEAM_2 CTX(_("FLAG^Blue"))
45 #define FLAG_TEAM_3 CTX(_("FLAG^Yellow"))
46 #define FLAG_TEAM_4 CTX(_("FLAG^Pink"))
47 #define GENERATOR_TEAM_1 CTX(_("GENERATOR^Red"))
48 #define GENERATOR_TEAM_2 CTX(_("GENERATOR^Blue"))
49 #define GENERATOR_TEAM_3 CTX(_("GENERATOR^Yellow"))
50 #define GENERATOR_TEAM_4 CTX(_("GENERATOR^Pink"))
52 // used for replacement in filenames or such where the name CANNOT be allowed to be translated
53 const string STATIC_NAME_TEAM_1 = "Red";
54 const string STATIC_NAME_TEAM_2 = "Blue";
55 const string STATIC_NAME_TEAM_3 = "Yellow";
56 const string STATIC_NAME_TEAM_4 = "Pink";
63 string Team_ColorCode(int teamid)
67 case NUM_TEAM_1: return COL_TEAM_1;
68 case NUM_TEAM_2: return COL_TEAM_2;
69 case NUM_TEAM_3: return COL_TEAM_3;
70 case NUM_TEAM_4: return COL_TEAM_4;
76 vector Team_ColorRGB(int teamid)
80 case NUM_TEAM_1: return '1 0.0625 0.0625'; // 0xFF0F0F
81 case NUM_TEAM_2: return '0.0625 0.0625 1'; // 0x0F0FFF
82 case NUM_TEAM_3: return '1 1 0.0625'; // 0xFFFF0F
83 case NUM_TEAM_4: return '1 0.0625 1'; // 0xFF0FFF
89 string Team_ColorName(int teamid)
93 case NUM_TEAM_1: return NAME_TEAM_1;
94 case NUM_TEAM_2: return NAME_TEAM_2;
95 case NUM_TEAM_3: return NAME_TEAM_3;
96 case NUM_TEAM_4: return NAME_TEAM_4;
102 // used for replacement in filenames or such where the name CANNOT be allowed to be translated
103 string Static_Team_ColorName(int teamid)
107 case NUM_TEAM_1: return STATIC_NAME_TEAM_1;
108 case NUM_TEAM_2: return STATIC_NAME_TEAM_2;
109 case NUM_TEAM_3: return STATIC_NAME_TEAM_3;
110 case NUM_TEAM_4: return STATIC_NAME_TEAM_4;
116 float Team_ColorToTeam(string team_color)
118 switch(strtolower(team_color))
120 case "red": return NUM_TEAM_1;
121 case "blue": return NUM_TEAM_2;
122 case "yellow": return NUM_TEAM_3;
123 case "pink": return NUM_TEAM_4;
124 case "auto": return 0;
130 /// \brief Returns whether team value is valid.
131 /// \param[in] team_num Team to check.
132 /// \return True if team is valid, false otherwise.
133 bool Team_IsValidTeam(int team_num)
148 /// \brief Returns whether the team index is valid.
149 /// \param[in] index Team index to check.
150 /// \return True if team index is valid, false otherwise.
151 bool Team_IsValidIndex(int index)
166 /// \brief Converts team index into team value.
167 /// \param[in] index Team index to convert.
168 /// \return Team value.
169 int Team_IndexToTeam(int index)
173 case 1: return NUM_TEAM_1;
174 case 2: return NUM_TEAM_2;
175 case 3: return NUM_TEAM_3;
176 case 4: return NUM_TEAM_4;
181 /// \brief Converts team value into team index.
182 /// \param[in] team_num Team value to convert.
183 /// \return Team index.
184 int Team_TeamToIndex(int team_num)
188 case NUM_TEAM_1: return 1;
189 case NUM_TEAM_2: return 2;
190 case NUM_TEAM_3: return 3;
191 case NUM_TEAM_4: return 4;
196 /// \brief Converts team value into bit value that is used in team bitmasks.
197 /// \param[in] team_num Team value to convert.
198 /// \return Team bit.
199 int Team_TeamToBit(int team_num)
201 if (!Team_IsValidTeam(team_num))
205 return BIT(Team_TeamToIndex(team_num) - 1);
208 /// \brief Converts team index into bit value that is used in team bitmasks.
209 /// \param[in] index Team index to convert.
210 /// \return Team bit.
211 int Team_IndexToBit(int index)
213 return BIT(index - 1);
217 // legacy aliases for shitty code
218 #define TeamByColor(teamid) (Team_TeamToIndex(teamid) - 1)
219 #define ColorByTeam(number) Team_IndexToTeam(number + 1)
222 #define Team_ColorName_Lower(teamid) strtolower(Team_ColorName(teamid))
223 #define Team_ColorName_Upper(teamid) strtoupper(Team_ColorName(teamid))
225 // used for replacement in filenames or such where the name CANNOT be allowed to be translated
226 #define Static_Team_ColorName_Lower(teamid) strtolower(Static_Team_ColorName(teamid))
227 #define Static_Team_ColorName_Upper(teamid) strtoupper(Static_Team_ColorName(teamid))
229 #define Team_FullName(teamid) strcat(Team_ColorName(teamid), " ", NAME_TEAM, "^7")
230 #define Team_ColoredFullName(teamid) strcat(Team_ColorCode(teamid), Team_ColorName(teamid), " ", NAME_TEAM, "^7")
232 #define Team_IndexToFullName(index) Team_FullName(Team_IndexToTeam(index))
233 #define Team_IndexToColoredFullName(index) Team_ColoredFullName(Team_IndexToTeam(index))
235 // replace these flags in a string with the strings provided
236 #define TCR(input,type,team) strreplace("^TC", COL_TEAM_##team, strreplace("^TT", strtoupper(type##_TEAM_##team), input))
238 // safe team comparisons
239 #define SAME_TEAM(a,b) (teamplay ? (a.team == b.team) : (a == b))
240 #define DIFF_TEAM(a,b) (teamplay ? (a.team != b.team) : (a != b))