1 // a dummy macro that prevents the "hanging ;" warning
2 #define ENDS_WITH_CURLY_BRACE
4 // TODO make ascii art pic of xzibit
6 // I HERD YO LIEK MACROS
7 // SO I PUT A MACRO DEFINITION IN YO MACRO DEFINITION
8 // SO YO CAN EXPAND MACROS WHILE YO EXPAND MACROS
9 #define ACCUMULATE_FUNCTION(func,otherfunc) \
11 void __merge__##otherfunc() { func(); otherfunc(); } \
13 #define func __merge__##otherfunc \
15 #define func otherfunc \
18 // this returns a tempstring containing a copy of s with additional \n newlines added, it also replaces \n in the text with a real newline
19 // NOTE: s IS allowed to be a tempstring
20 string wordwrap(string s, float l);
23 void wordwrap_sprint(string s, float l);
26 void wordwrap_cb(string s, float l, void(string) callback)
29 string draw_currentSkin;
30 string draw_UseSkinFor(string pic);
33 // iterative depth-first search, with fields that go "up", "down left" and "right" in a tree
34 // for each element, funcPre is called first, then funcPre and funcPost for all its children, and funcPost last
35 void depthfirst(entity start, .entity up, .entity downleft, .entity right, void(entity, entity) funcPre, void(entity, entity) funcPost, entity pass);
37 float median(float a, float b, float c);
39 // converts a number to a string with the indicated number of decimals
40 // works for up to 10 decimals!
41 string ftos_decimals(float number, float decimals);
43 float fexists(string f);
45 vector colormapPaletteColor(float c, float isPants);
47 // unzone the string, and return it as tempstring. Safe to be called on string_null
48 string fstrunzone(string s);
50 // database (NOTE: keys are case sensitive)
51 void db_save(float db, string filename);
52 void db_dump(float db, string pFilename);
54 float db_load(string filename);
55 void db_close(float db);
56 string db_get(float db, string key);
57 void db_put(float db, string key, string value);
59 // stringbuffer loading/saving
60 float buf_load(string filename);
61 void buf_save(float buf, string filename);
65 float mod(float a, float b) { return a - (floor(a / b) * b); }
68 #define TIME_TO_NTHS(t,n) floor((t) * (n) + 0.4)
69 string mmsss(float t);
70 string mmssss(float t);
72 #define TIME_DECIMALS 2
73 #define TIME_FACTOR 100
74 #define TIME_ENCODED_TOSTRING(n) mmssss(n)
75 #define RACE_RECORD "/race100record/"
76 #define CTS_RECORD "/cts100record/"
77 #define TIME_ENCODE(t) TIME_TO_NTHS(t, TIME_FACTOR)
78 #define TIME_DECODE(n) ((n) / TIME_FACTOR)
80 string ScoreString(float vflags, float value);
82 vector cross(vector a, vector b);
84 void compressShortVector_init();
85 vector decompressShortVector(float data);
86 float compressShortVector(vector vec);
89 float CheckWireframeBox(entity forent, vector v0, vector dvx, vector dvy, vector dvz);
92 string fixPriorityList(string pl, float from, float to, float subtract, float complete);
93 string mapPriorityList(string order, string(string) mapfunc);
94 string swapInPriorityList(string order, float i, float j);
96 float cvar_value_issafe(string s);
98 float cvar_settemp(string pKey, string pValue);
99 float cvar_settemp_restore();
102 // modes: 0 = trust q3map2 (_mini images)
103 // 1 = trust tracebox (_radar images)
104 // in both modes, mapinfo's "size" overrides
109 void get_mi_min_max(float mode);
111 vector mi_picmin; // adjusted mins that map to the picture (square)
112 vector mi_picmax; // adjusted maxs that map to the picture (square)
113 vector mi_pictexcoord0; // texcoords of the image corners (after transforming, these are 2D coords too)
114 vector mi_pictexcoord1; // texcoords of the image corners (after transforming, these are 2D coords too)
115 vector mi_pictexcoord2; // texcoords of the image corners (after transforming, these are 2D coords too)
116 vector mi_pictexcoord3; // texcoords of the image corners (after transforming, these are 2D coords too)
117 void get_mi_min_max_texcoords(float mode);
120 #define FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(x) void reference_##x() { x = x; }
122 float almost_equals(float a, float b);
123 float almost_in_bounds(float a, float b, float c);
125 float power2of(float e);
126 float log2of(float x);
128 string HEXDIGITS = "0123456789ABCDEF0123456789abcdef";
129 #define HEXDIGIT_TO_DEC_RAW(d) (strstrofs(HEXDIGITS, (d), 0))
130 #define HEXDIGIT_TO_DEC(d) ((HEXDIGIT_TO_DEC_RAW(d) | 0x10) - 0x10)
131 #define DEC_TO_HEXDIGIT(d) (substring(HEXDIGITS, (d), 1))
133 vector rgb_to_hsl(vector rgb);
134 vector hsl_to_rgb(vector hsl);
135 vector rgb_to_hsv(vector rgb);
136 vector hsv_to_rgb(vector hsv);
137 string rgb_to_hexcolor(vector rgb);
139 float boxesoverlap(vector m1, vector m2, vector m3, vector m4);
140 float boxinsidebox(vector smins, vector smaxs, vector bmins, vector bmaxs);
142 typedef float(string s, vector size) textLengthUpToWidth_widthFunction_t;
143 typedef float(string s) textLengthUpToLength_lenFunction_t;
144 float textLengthUpToWidth(string theText, float maxWidth, vector size, textLengthUpToWidth_widthFunction_t tw);
145 string textShortenToWidth(string theText, float maxWidth, vector size, textLengthUpToWidth_widthFunction_t tw);
146 float textLengthUpToLength(string theText, float maxWidth, textLengthUpToLength_lenFunction_t tw);
147 string textShortenToLength(string theText, float maxWidth, textLengthUpToLength_lenFunction_t tw);
149 string getWrappedLine_remaining;
150 string getWrappedLine(float w, vector size, textLengthUpToWidth_widthFunction_t tw);
151 string getWrappedLineLen(float w, textLengthUpToLength_lenFunction_t tw);
153 float isGametypeInFilter(float gt, float tp, float ts, string pattern);
155 typedef void(float i1, float i2, entity pass) swapfunc_t; // is only ever called for i1 < i2
156 typedef float(float i1, float i2, entity pass) comparefunc_t; // <0 for <, ==0 for ==, >0 for > (like strcmp)
157 void shuffle(float n, swapfunc_t swap, entity pass);
158 void heapsort(float n, swapfunc_t swap, comparefunc_t cmp, entity pass);
160 string swapwords(string str, float i, float j);
161 string shufflewords(string str);
163 string substring_range(string s, float b, float e);
165 vector solve_quadratic(float a, float b, float c);
168 // z = 1 if a real solution exists, 0 if not
169 // if no real solution exists, x contains the real part and y the imaginary part of the complex solutions x+iy and x-iy
171 void check_unacceptable_compiler_bugs();
173 float compressShotOrigin(vector v);
174 vector decompressShotOrigin(float f);
177 string rankings_reply, ladder_reply, lsmaps_reply, lsnewmaps_reply, maplist_reply; // cached replies
178 string records_reply[10];
181 float RandomSelection_totalweight;
182 float RandomSelection_best_priority;
183 entity RandomSelection_chosen_ent;
184 float RandomSelection_chosen_float;
185 string RandomSelection_chosen_string;
186 void RandomSelection_Init();
187 void RandomSelection_Add(entity e, float f, string s, float weight, float priority);
189 vector healtharmor_maxdamage(float h, float a, float armorblock); // returns vector: maxdamage, armorideal, 1 if fully armored
190 vector healtharmor_applydamage(float a, float armorblock, float damage); // returns vector: take, save, 0
192 string getcurrentmod();
198 void WriteInt24_t(float dest, float val);
203 const var void func_null(void); FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(func_null)
204 const var string string_null;
205 float float2range11(float f);
206 float float2range01(float f);
208 float gsl_ran_gaussian(float sigma);
210 string car(string s); // returns first word
211 string cdr(string s); // returns all but first word
212 float matchacl(string acl, string str); // matches str against ACL acl (with entries +foo*, +foo, +*foo, +*foo*, and same with - for forbidding)
213 float startsWith(string haystack, string needle);
214 float startsWithNocase(string haystack, string needle);
216 string get_model_datafilename(string mod, float skn, string fil); // skin -1 will return wildcard, mod string_null will also put wildcard there
217 string get_model_parameters_modelname;
218 float get_model_parameters_modelskin;
219 string get_model_parameters_name;
220 float get_model_parameters_species;
221 string get_model_parameters_sex;
222 float get_model_parameters_weight;
223 float get_model_parameters_age;
224 string get_model_parameters_desc;
225 float get_model_parameters(string mod, float skn); // call with string_null to clear; skin -1 means mod is the filename of the txt file and is to be split
227 // stupid stupid stupid FTEQCC has a max limit on macro sizes, let's work around by splitting the macro into two macros! :(
228 #define HUD_Panel_GetName_Part2(id) \
230 case HUD_PANEL_ENGINEINFO: panel_name = HUD_PANELNAME_ENGINEINFO; break; \
231 case HUD_PANEL_INFOMESSAGES: panel_name = HUD_PANELNAME_INFOMESSAGES; break; \
232 case HUD_PANEL_PHYSICS: panel_name = HUD_PANELNAME_PHYSICS; break; \
233 case HUD_PANEL_CENTERPRINT: panel_name = HUD_PANELNAME_CENTERPRINT; break; \
234 } ENDS_WITH_CURLY_BRACE
236 // Get name of specified panel id
237 #define HUD_Panel_GetName(id) \
239 case HUD_PANEL_WEAPONS: panel_name = HUD_PANELNAME_WEAPONS; break; \
240 case HUD_PANEL_AMMO: panel_name = HUD_PANELNAME_AMMO; break; \
241 case HUD_PANEL_POWERUPS: panel_name = HUD_PANELNAME_POWERUPS; break; \
242 case HUD_PANEL_HEALTHARMOR: panel_name = HUD_PANELNAME_HEALTHARMOR; break; \
243 case HUD_PANEL_NOTIFY: panel_name = HUD_PANELNAME_NOTIFY; break; \
244 case HUD_PANEL_TIMER: panel_name = HUD_PANELNAME_TIMER; break; \
245 case HUD_PANEL_RADAR: panel_name = HUD_PANELNAME_RADAR; break; \
246 case HUD_PANEL_SCORE: panel_name = HUD_PANELNAME_SCORE; break; \
247 case HUD_PANEL_RACETIMER: panel_name = HUD_PANELNAME_RACETIMER; break; \
248 case HUD_PANEL_VOTE: panel_name = HUD_PANELNAME_VOTE; break; \
249 case HUD_PANEL_MODICONS: panel_name = HUD_PANELNAME_MODICONS; break; \
250 case HUD_PANEL_PRESSEDKEYS: panel_name = HUD_PANELNAME_PRESSEDKEYS; break; \
251 case HUD_PANEL_CHAT: panel_name = HUD_PANELNAME_CHAT; break; \
252 default: HUD_Panel_GetName_Part2(id)\
255 vector vec2(vector v);
258 vector NearestPointOnBox(entity box, vector org);
261 float vercmp(string v1, string v2);
263 float u8_strsize(string s);
265 // translation helpers
266 string prvm_language;
267 string language_filename(string s);
268 string CTX(string s);
269 #define ZCTX(s) strzone(CTX(s))
271 // x-encoding (encoding as zero length invisible string)
272 // encodes approx. 14 bits into 5 bytes of color code string
273 const float XENCODE_MAX = 21295; // 2*22*22*22-1
274 const float XENCODE_LEN = 5;
275 string xencode(float f);
276 float xdecode(string s);
278 #ifndef COMPAT_XON010_CHANNELS
279 #define sound(e,c,s,v,a) sound7(e,c,s,v,a,0,0)
282 float lowestbit(float f);
285 entity ReadCSQCEntity()
289 string strtolower(string s);
292 string MakeConsoleSafe(string input);
295 float InterpretBoolean(string input);
298 // generic shutdown handler
302 .float skeleton_bones;
303 void Skeleton_SetBones(entity e);
304 // loops through the tags of model v using counter tagnum
305 #define FOR_EACH_TAG(v) float tagnum; Skeleton_SetBones(v); for(tagnum = 0; tagnum < v.skeleton_bones; tagnum++, gettaginfo(v, tagnum))
308 void WriteApproxPastTime(float dst, float t);
311 float ReadApproxPastTime();
314 // execute-stuff-next-frame subsystem
315 void execute_next_frame();
316 void queue_to_execute_next_frame(string s);