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"));
28 float RegisterPlayer(entity player)
32 for(pl = players.sort_next; pl; pl = pl.sort_next)
34 error("Player already registered!");
35 player.sort_next = players.sort_next;
36 player.sort_prev = players;
38 players.sort_next.sort_prev = player;
39 players.sort_next = player;
44 void RemovePlayer(entity player)
49 for(pl = players.sort_next; pl && pl != player; pl = pl.sort_next)
54 error("Trying to remove a player which is not in the playerlist!");
57 parent.sort_next = player.sort_next;
59 player.sort_next.sort_prev = parent;
63 void MoveToLast(entity e)
75 float RegisterTeam(entity Team)
79 for(tm = teams.sort_next; tm; tm = tm.sort_next)
81 error("Team already registered!");
82 Team.sort_next = teams.sort_next;
83 Team.sort_prev = teams;
85 teams.sort_next.sort_prev = Team;
86 teams.sort_next = Team;
91 void RemoveTeam(entity Team)
96 for(tm = teams.sort_next; tm && tm != Team; tm = tm.sort_next)
101 print("Trying to remove a team which is not in the teamlist!");
104 parent.sort_next = Team.sort_next;
106 Team.sort_next.sort_prev = parent;
110 entity GetTeam(float Team, float add)
114 num = (Team == COLOR_SPECTATOR) ? 16 : Team;
116 return teamslots[num];
126 float stringwidth_oldfont(string text, float handleColors)
128 float i, len, ch, width;
133 for(i = 0; i < len; ++i)
135 if(substring(text, i, 1) == "^")
137 ch = str2chr(text, i+1);
138 if(ch >= '0' && ch <= '9')
140 else if(i+4 < len && ch == 'x')
142 ch = str2chr(text, i+2);
143 if ( (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F') )
145 ch = str2chr(text, i+3);
146 if ( (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F') )
148 ch = str2chr(text, i+4);
149 if ( (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F') )
160 void CSQC_CheckEngine()
163 registercvar("csqc_flags", "0");
164 csqc_flags = cvar("csqc_flags");
169 if(checkextension("DP_SV_WRITEPICTURE"))
171 stringwidth = stringwidth_engine;
172 sbar_font = FONT_USER+1;
173 sbar_bigfont = FONT_USER+2;
174 csqc_flags |= CSQC_FLAG_READPICTURE;
176 stringwidth = stringwidth_oldfont;
177 sbar_font = FONT_DEFAULT;
178 sbar_bigfont = FONT_DEFAULT;
181 if(strlennocol("^xFFF") == 0)
182 csqc_flags |= CSQC_FLAG_COLORCODES;
185 vector Sbar_GetFontsize()
187 if(csqc_flags & CSQC_FLAG_READPICTURE)
190 v = stov(cvar_string("sbar_fontsize"));
201 float Sbar_GetWidth(float teamcolumnwidth)
203 if(csqc_flags & CSQC_FLAG_READPICTURE)
206 f = stof(cvar_string("sbar_width"));
211 if(f > vid_conwidth - 2 * teamcolumnwidth)
212 f = vid_conwidth - 2 * teamcolumnwidth;
218 float PreviewExists(string name)
223 if(cvar("cl_readpicture_force"))
226 file = strcat(name, ".tga");
227 f = fopen(file, FILE_READ);
233 file = strcat(name, ".png");
234 f = fopen(file, FILE_READ);
240 file = strcat(name, ".jpg");
241 f = fopen(file, FILE_READ);
247 file = strcat(name, ".pcx");
248 f = fopen(file, FILE_READ);
257 float PI = 3.14159265359;
258 float DEG2RAD = 0.01745329252;
259 vector rotate(vector v, float a)
262 // FTEQCC SUCKS AGAIN
263 w_x = v_x * cos(a) + v_y * sin(a);
264 w_y = -1 * v_x * sin(a) + v_y * cos(a);
268 float ColorTranslateMode;
270 string ColorTranslateRGB(string s)
272 if not(ColorTranslateMode & 2)
273 if(csqc_flags & CSQC_FLAG_COLORCODES)
275 if(ColorTranslateMode & 1)
276 return strdecolorize(s);
281 // running on an OLD engine!
282 // must translate ^xRGB codes to regular color codes
285 vector theTempColor, hsv;
291 for(i = 0; i < n; ++i)
293 ch = substring(s, i, 1);
296 ch2 = substring(s, i+1, 1);
299 s2 = strcat(s2, ch, ch2);
301 else if(ch2 == "0" || stof(ch2)) // digit?
303 if not(ColorTranslateMode & 1)
304 s2 = strcat(s2, ch, ch2);
306 else if(ch2 == "x") // ^x found
308 theTempColor = '0 0 0';
310 component = HEXDIGIT_TO_DEC(substring(s, i+2, 1));
311 if (component >= 0) // ^xr found
313 theTempColor_x = component/15;
315 component = HEXDIGIT_TO_DEC(substring(s, i+3, 1));
316 if (component >= 0) // ^xrg found
318 theTempColor_y = component/15;
320 component = HEXDIGIT_TO_DEC(substring(s, i+4, 1));
321 if (component >= 0) // ^xrgb found
323 theTempColor_z = component/15;
325 if not(ColorTranslateMode & 1)
327 hsv = rgb_to_hsv(theTempColor);
332 s2 = strcat(s2, "^0");
334 s2 = strcat(s2, "^7");
339 s2 = strcat(s2, "^1");
340 else if(hsv_x < 1.33333333333333333333)
341 s2 = strcat(s2, "^3");
343 s2 = strcat(s2, "^2");
344 else if(hsv_x < 3.33333333333333333333)
345 s2 = strcat(s2, "^5");
347 s2 = strcat(s2, "^4");
349 s2 = strcat(s2, "^6");
351 s2 = strcat(s2, "^1");
360 s2 = strcat(s2, substring(s, i, 4));
367 s2 = strcat(s, substring(s2, i, 3));
374 s2 = strcat(s, substring(s2, i, 2));
379 s2 = strcat(s2, ch, ch2);