]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/teams.qh
Declare more ints as ints
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / teams.qh
1 #ifdef TEAMNUMBERS_THAT_ARENT_STUPID
2 const int NUM_TEAM_1 = 1;  // red
3 const int NUM_TEAM_2 = 2; // blue
4 const int NUM_TEAM_3 = 3; // yellow
5 const int NUM_TEAM_4 = 4; // pink
6 const int NUM_SPECTATOR = 5;
7 #else
8 #ifdef CSQC
9 const int NUM_TEAM_1 = 4;  // red
10 const int NUM_TEAM_2 = 13; // blue
11 const int NUM_TEAM_3 = 12; // yellow
12 const int NUM_TEAM_4 = 9; // pink
13 #else
14 const int NUM_TEAM_1 = 5;  // red
15 const int NUM_TEAM_2 = 14; // blue
16 const int NUM_TEAM_3 = 13; // yellow
17 const int NUM_TEAM_4 = 10; // pink
18 #endif
19 const int NUM_SPECTATOR = 1337;
20 #endif
21
22 const string COL_TEAM_1 = "^1";
23 const string COL_TEAM_2 = "^4";
24 const string COL_TEAM_3 = "^3";
25 const string COL_TEAM_4 = "^6";
26 const string NAME_TEAM_1 = _("Red");
27 const string NAME_TEAM_2 = _("Blue");
28 const string NAME_TEAM_3 = _("Yellow");
29 const string NAME_TEAM_4 = _("Pink");
30 const string NAME_TEAM = _("Team");
31 const string NAME_NEUTRAL = _("Neutral");
32
33 // used for replacement in filenames or such where the name CANNOT be allowed to be translated
34 const string STATIC_NAME_TEAM_1 = "Red";
35 const string STATIC_NAME_TEAM_2 = "Blue";
36 const string STATIC_NAME_TEAM_3 = "Yellow";
37 const string STATIC_NAME_TEAM_4 = "Pink";
38
39 #ifdef CSQC
40 float teamplay;
41 float myteam;
42 #endif
43
44 string Team_ColorCode(float teamid)
45 {
46     switch(teamid)
47     {
48                 case NUM_TEAM_1: return COL_TEAM_1;
49         case NUM_TEAM_2: return COL_TEAM_2;
50         case NUM_TEAM_3: return COL_TEAM_3;
51         case NUM_TEAM_4: return COL_TEAM_4;
52         }
53
54         return "^7";
55 }
56
57 vector Team_ColorRGB(float teamid)
58 {
59         switch(teamid)
60         {
61                 case NUM_TEAM_1: return '1 0.0625 0.0625'; // 0xFF0F0F
62                 case NUM_TEAM_2: return '0.0625 0.0625 1'; // 0x0F0FFF
63                 case NUM_TEAM_3: return '1 1 0.0625'; // 0xFFFF0F
64                 case NUM_TEAM_4: return '1 0.0625 1'; // 0xFF0FFF
65         }
66
67     return '0 0 0';
68 }
69
70 string Team_ColorName(float teamid)
71 {
72     switch(teamid)
73     {
74                 case NUM_TEAM_1: return NAME_TEAM_1;
75         case NUM_TEAM_2: return NAME_TEAM_2;
76         case NUM_TEAM_3: return NAME_TEAM_3;
77         case NUM_TEAM_4: return NAME_TEAM_4;
78         }
79
80     return NAME_NEUTRAL;
81 }
82
83 // used for replacement in filenames or such where the name CANNOT be allowed to be translated
84 string Static_Team_ColorName(float teamid)
85 {
86     switch(teamid)
87     {
88                 case NUM_TEAM_1: return STATIC_NAME_TEAM_1;
89         case NUM_TEAM_2: return STATIC_NAME_TEAM_2;
90         case NUM_TEAM_3: return STATIC_NAME_TEAM_3;
91         case NUM_TEAM_4: return STATIC_NAME_TEAM_4;
92         }
93
94     return NAME_NEUTRAL;
95 }
96
97 float Team_ColorToTeam(string team_color)
98 {
99         switch(strtolower(team_color))
100         {
101                 case "red": return NUM_TEAM_1;
102         case "blue": return NUM_TEAM_2;
103         case "yellow": return NUM_TEAM_3;
104         case "pink": return NUM_TEAM_4;
105         case "auto": return 0;
106         }
107
108         return -1;
109 }
110
111 float Team_NumberToTeam(float number)
112 {
113         switch(number)
114         {
115                 case 1: return NUM_TEAM_1;
116                 case 2: return NUM_TEAM_2;
117                 case 3: return NUM_TEAM_3;
118                 case 4: return NUM_TEAM_4;
119         }
120
121         return -1;
122 }
123
124 float Team_TeamToNumber(float teamid)
125 {
126         switch(teamid)
127         {
128                 case NUM_TEAM_1: return 1;
129                 case NUM_TEAM_2: return 2;
130                 case NUM_TEAM_3: return 3;
131                 case NUM_TEAM_4: return 4;
132         }
133
134         return -1;
135 }
136
137
138 // legacy aliases for shitty code
139 #define TeamByColor(teamid) (Team_TeamToNumber(teamid) - 1)
140 #define ColorByTeam(number) Team_NumberToTeam(number + 1)
141
142 // useful aliases
143 #define Team_ColorName_Lower(teamid) strtolower(Team_ColorName(teamid))
144 #define Team_ColorName_Upper(teamid) strtoupper(Team_ColorName(teamid))
145
146 // used for replacement in filenames or such where the name CANNOT be allowed to be translated
147 #define Static_Team_ColorName_Lower(teamid) strtolower(Static_Team_ColorName(teamid))
148 #define Static_Team_ColorName_Upper(teamid) strtoupper(Static_Team_ColorName(teamid))
149
150 #define Team_FullName(teamid) strcat(Team_ColorName(teamid), " ", NAME_TEAM, "^7")
151 #define Team_ColoredFullName(teamid) strcat(Team_ColorCode(teamid), Team_ColorName(teamid), " ", NAME_TEAM, "^7")
152
153 #define Team_NumberToFullName(number) Team_FullName(Team_NumberToTeam(number))
154 #define Team_NumberToColoredFullName(number) Team_ColoredFullName(Team_NumberToTeam(number))
155
156 // replace these flags in a string with the strings provided
157 #define TCR(input,teamcolor,teamtext) strreplace("^TC", teamcolor, strreplace("^TT", teamtext, input))
158
159 // safe team comparisons
160 #define SAME_TEAM(a,b) (teamplay ? ((a.team == b.team) ? 1 : 0) : ((a == b) ? 1 : 0))
161 #define DIFF_TEAM(a,b) (teamplay ? ((a.team != b.team) ? 1 : 0) : ((a != b) ? 1 : 0))
162
163 // used for notification system multi-team identifiers
164 #define APP_TEAM_NUM_2(num,prefix) ((num == NUM_TEAM_1) ? prefix##RED : prefix##BLUE)
165 #define APP_TEAM_NUM_4(num,prefix) ((num == NUM_TEAM_1) ? prefix##RED : ((num == NUM_TEAM_2) ? prefix##BLUE : ((num == NUM_TEAM_3) ? prefix##YELLOW : prefix##PINK)))
166 #define APP_TEAM_ENT_2(ent,prefix) ((ent.team == NUM_TEAM_1) ? prefix##RED : prefix##BLUE)
167 #define APP_TEAM_ENT_4(ent,prefix) ((ent.team == NUM_TEAM_1) ? prefix##RED : ((ent.team == NUM_TEAM_2) ? prefix##BLUE : ((ent.team == NUM_TEAM_3) ? prefix##YELLOW : prefix##PINK)))