1 var float(string text, float handleColors) stringwidth;
12 for(e = prev.sort_next; e; prev = e, e = e.sort_next)
14 if(prev != e.sort_prev)
15 error(strcat("sort list chain error\nplease submit the output of 'prvm_edicts client' to the developers"));
19 for(e = prev.sort_next; e; prev = e, e = e.sort_next)
21 if(prev != e.sort_prev)
22 error(strcat("sort list chain error\nplease submit the output of 'prvm_edicts client' to the developers"));
27 float RegisterPlayer(entity player)
31 for(pl = players.sort_next; pl; pl = pl.sort_next)
33 error("Player already registered!");
34 player.sort_next = players.sort_next;
35 player.sort_prev = players;
37 players.sort_next.sort_prev = player;
38 players.sort_next = player;
43 void RemovePlayer(entity player)
48 for(pl = players.sort_next; pl && pl != player; pl = pl.sort_next)
53 error("Trying to remove a player which is not in the playerlist!");
56 parent.sort_next = player.sort_next;
58 player.sort_next.sort_prev = parent;
62 void MoveToLast(entity e)
74 float RegisterTeam(entity Team)
78 for(tm = teams.sort_next; tm; tm = tm.sort_next)
80 error("Team already registered!");
81 Team.sort_next = teams.sort_next;
82 Team.sort_prev = teams;
84 teams.sort_next.sort_prev = Team;
85 teams.sort_next = Team;
90 void RemoveTeam(entity Team)
95 for(tm = teams.sort_next; tm && tm != Team; tm = tm.sort_next)
100 print("Trying to remove a team which is not in the teamlist!");
103 parent.sort_next = Team.sort_next;
105 Team.sort_next.sort_prev = parent;
109 entity GetTeam(float Team, float add)
113 num = (Team == COLOR_SPECTATOR) ? 16 : Team;
115 return teamslots[num];
125 float stringwidth_oldfont(string text, float handleColors)
127 float i, len, ch, width;
132 for(i = 0; i < len; ++i)
134 if(substring(text, i, 1) == "^")
136 ch = str2chr(text, i+1);
137 if(ch >= '0' && ch <= '9')
139 else if(i+4 < len && ch == 'x')
141 ch = str2chr(text, i+2);
142 if ( (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F') )
144 ch = str2chr(text, i+3);
145 if ( (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F') )
147 ch = str2chr(text, i+4);
148 if ( (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F') )
159 void CSQC_CheckEngine()
162 registercvar("csqc_flags", "0");
163 csqc_flags = cvar("csqc_flags");
168 if(checkextension("DP_SV_WRITEPICTURE"))
170 stringwidth = stringwidth_engine;
171 sbar_font = FONT_USER+1;
172 sbar_bigfont = FONT_USER+2;
173 csqc_flags |= CSQC_FLAG_READPICTURE;
175 stringwidth = stringwidth_oldfont;
176 sbar_font = FONT_DEFAULT;
177 sbar_bigfont = FONT_DEFAULT;
180 if(strlennocol("^xFFF") == 0)
181 csqc_flags |= CSQC_FLAG_COLORCODES;
184 vector Sbar_GetFontsize()
186 if(csqc_flags & CSQC_FLAG_READPICTURE)
189 v = stov(cvar_string("sbar_fontsize"));
200 float Sbar_GetWidth(float teamcolumnwidth)
202 if(csqc_flags & CSQC_FLAG_READPICTURE)
205 f = stof(cvar_string("sbar_width"));
210 if(f > vid_conwidth - 2 * teamcolumnwidth)
211 f = vid_conwidth - 2 * teamcolumnwidth;
217 float PreviewExists(string name)
222 if(cvar("cl_readpicture_force"))
225 file = strcat(name, ".tga");
226 f = fopen(file, FILE_READ);
232 file = strcat(name, ".png");
233 f = fopen(file, FILE_READ);
239 file = strcat(name, ".jpg");
240 f = fopen(file, FILE_READ);
246 file = strcat(name, ".pcx");
247 f = fopen(file, FILE_READ);
256 float PI = 3.14159265359;
257 float DEG2RAD = 0.01745329252;
258 vector rotate(vector v, float a)
261 // FTEQCC SUCKS AGAIN
262 w_x = v_x * cos(a) + v_y * sin(a);
263 w_y = -1 * v_x * sin(a) + v_y * cos(a);
267 float ColorTranslateMode;
269 string ColorTranslateRGB(string s)
271 if not(ColorTranslateMode & 2)
272 if(csqc_flags & CSQC_FLAG_COLORCODES)
274 if(ColorTranslateMode & 1)
275 return strdecolorize(s);
280 // running on an OLD engine!
281 // must translate ^xRGB codes to regular color codes
284 vector theTempColor, hsv;
290 for(i = 0; i < n; ++i)
292 ch = substring(s, i, 1);
295 ch2 = substring(s, i+1, 1);
298 s2 = strcat(s2, ch, ch2);
300 else if(ch2 == "0" || stof(ch2)) // digit?
302 if not(ColorTranslateMode & 1)
303 s2 = strcat(s2, ch, ch2);
305 else if(ch2 == "x") // ^x found
307 theTempColor = '0 0 0';
309 component = HEXDIGIT_TO_DEC(substring(s, i+2, 1));
310 if (component >= 0) // ^xr found
312 theTempColor_x = component/15;
314 component = HEXDIGIT_TO_DEC(substring(s, i+3, 1));
315 if (component >= 0) // ^xrg found
317 theTempColor_y = component/15;
319 component = HEXDIGIT_TO_DEC(substring(s, i+4, 1));
320 if (component >= 0) // ^xrgb found
322 theTempColor_z = component/15;
324 if not(ColorTranslateMode & 1)
326 hsv = rgb_to_hsv(theTempColor);
331 s2 = strcat(s2, "^0");
333 s2 = strcat(s2, "^7");
338 s2 = strcat(s2, "^1");
339 else if(hsv_x < 1.33333333333333333333)
340 s2 = strcat(s2, "^3");
342 s2 = strcat(s2, "^2");
343 else if(hsv_x < 3.33333333333333333333)
344 s2 = strcat(s2, "^5");
346 s2 = strcat(s2, "^4");
348 s2 = strcat(s2, "^6");
350 s2 = strcat(s2, "^1");
359 s2 = strcat(s2, substring(s, i, 4));
366 s2 = strcat(s, substring(s2, i, 3));
373 s2 = strcat(s, substring(s2, i, 2));
378 s2 = strcat(s2, ch, ch2);