]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/teams.qh
Make these aliases into macros instead, saves execution time ^_^
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / teams.qh
1 #ifdef TEAMNUMBERS_THAT_ARENT_STUPID
2 const float FL_TEAM_1 = 1;  // red
3 const float FL_TEAM_2 = 2; // blue
4 const float FL_TEAM_3 = 3; // yellow
5 const float FL_TEAM_4 = 4; // pink
6 const float FL_SPECTATOR = 5;
7 #else
8 #ifdef CSQC
9 const float FL_TEAM_1 = 4;  // red
10 const float FL_TEAM_2 = 13; // blue
11 const float FL_TEAM_3 = 12; // yellow
12 const float FL_TEAM_4 = 9; // pink
13 #else
14 const float FL_TEAM_1 = 5;  // red
15 const float FL_TEAM_2 = 14; // blue
16 const float FL_TEAM_3 = 13; // yellow
17 const float FL_TEAM_4 = 10; // pink
18 #endif
19 const float FL_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 STR_TEAM_1 = _("Red");
27 const string STR_TEAM_2 = _("Blue");
28 const string STR_TEAM_3 = _("Yellow");
29 const string STR_TEAM_4 = _("Pink");
30 const string STR_TEAM = _("Team");
31 const string STR_NEUTRAL = _("Neutral");
32
33 #ifdef CSQC
34 float teamplay;
35 float myteam;
36 #endif
37
38 string Team_ColorCode(float teamid)
39 {
40     switch(teamid)
41     {
42                 case FL_TEAM_1: return COL_TEAM_1;
43         case FL_TEAM_2: return COL_TEAM_2;
44         case FL_TEAM_3: return COL_TEAM_3;
45         case FL_TEAM_4: return COL_TEAM_4;
46         }
47         
48         return "^7";
49 }
50
51 vector Team_ColorRGB(float teamid)
52 {
53         switch(teamid)
54         {
55                 #ifdef TEAMNUMBERS_THAT_ARENT_STUPID
56                 case FL_TEAM_1: return '1 0 0'; // red
57                 case FL_TEAM_2: return '0 0 1'; // blue
58                 case FL_TEAM_3: return '1 1 0'; // yellow
59                 case FL_TEAM_4: return '1 0 1'; // pink
60                 #else
61                 case FL_TEAM_1: return '1 0.0625 0.0625';
62                 case FL_TEAM_2: return '0.0625 0.0625 1';
63                 case FL_TEAM_3: return '1 1 0.0625';
64                 case FL_TEAM_4: return '1 0.0625 1';
65                 #endif
66         }
67
68     return '0 0 0';
69 }
70
71 string Team_ColorName(float teamid)
72 {
73     switch(teamid)
74     {
75                 case FL_TEAM_1: return STR_TEAM_1;
76         case FL_TEAM_2: return STR_TEAM_2;
77         case FL_TEAM_3: return STR_TEAM_3;
78         case FL_TEAM_4: return STR_TEAM_4;
79         }
80         
81     return STR_NEUTRAL;
82 }
83
84 float Team_ColorToTeam(string team_color)
85 {
86         switch(strtolower(team_color))
87         {
88                 case "red": return FL_TEAM_1;
89         case "blue": return FL_TEAM_2;
90         case "yellow": return FL_TEAM_3;
91         case "pink": return FL_TEAM_4;
92         case "auto": return 0;
93         }
94         
95         return -1;
96 }
97
98 float Team_NumberToTeam(float number)
99 {
100         switch(number)
101         {
102                 case 1: return FL_TEAM_1;
103                 case 2: return FL_TEAM_2;
104                 case 3: return FL_TEAM_3;
105                 case 4: return FL_TEAM_4;
106         }
107         
108         return -1;
109 }
110
111 float Team_TeamToNumber(float teamid)
112 {
113         switch(teamid)
114         {
115                 case FL_TEAM_1: return 1;
116                 case FL_TEAM_2: return 2;
117                 case FL_TEAM_3: return 3;
118                 case FL_TEAM_4: return 4;
119         }
120         
121         return -1;
122 }
123
124
125 // legacy aliases for shitty code
126 #define TeamByColor(teamid) (Team_TeamToNumber(teamid) - 1)
127 #define ColorByTeam(number) Team_NumberToTeam(number + 1)
128
129 // useful aliases
130 #define Team_ColorName_Lower(teamid) strtolower(Team_ColorName(teamid))
131 #define Team_ColorName_Upper(teamid) strtoupper(Team_ColorName(teamid))
132
133 #define Team_FullName(teamid) strcat(Team_ColorName(teamid), " ", STR_TEAM, "^7")
134 #define Team_ColoredFullName(teamid) strcat(Team_ColorCode(teamid), Team_ColorName(teamid), " ", STR_TEAM, "^7")
135
136 #define Team_NumberToFullName(number) Team_FullName(Team_NumberToTeam(number))
137 #define Team_NumberToColoredFullName(number) Team_ColoredFullName(Team_NumberToTeam(number))