1 #define ACCUMULATE_FUNCTION(func,otherfunc) \
3 void __merge__##otherfunc() { func(); otherfunc(); } \
5 #define func __merge__##otherfunc \
7 #define func otherfunc \
10 // 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
11 // NOTE: s IS allowed to be a tempstring
12 string wordwrap(string s, float l);
15 void wordwrap_sprint(string s, float l);
18 void wordwrap_cb(string s, float l, void(string) callback)
20 float GameCommand_Generic(string cmd);
21 // returns TRUE if handled, FALSE otherwise
22 // uses tokenize on its argument!
24 // iterative depth-first search, with fields that go "up", "down left" and "right" in a tree
25 // for each element, funcPre is called first, then funcPre and funcPost for all its children, and funcPost last
26 void depthfirst(entity start, .entity up, .entity downleft, .entity right, void(entity, entity) funcPre, void(entity, entity) funcPost, entity pass);
28 float median(float a, float b, float c);
30 // converts a number to a string with the indicated number of decimals
31 // works for up to 10 decimals!
32 string ftos_decimals(float number, float decimals);
34 vector colormapPaletteColor(float c, float isPants);
36 // unzone the string, and return it as tempstring. Safe to be called on string_null
37 string fstrunzone(string s);
39 // database (NOTE: keys are case sensitive)
40 void db_save(float db, string filename);
41 void db_dump(float db, string pFilename);
43 float db_load(string filename);
44 void db_close(float db);
45 string db_get(float db, string key);
46 void db_put(float db, string key, string value);
48 // stringbuffer loading/saving
49 float buf_load(string filename);
50 void buf_save(float buf, string filename);
54 float mod(float a, float b) { return a - (floor(a / b) * b); }
57 string GametypeNameFromType(float g);
58 #define TIME_TO_NTHS(t,n) floor((t) * (n) + 0.4)
59 string mmsss(float t);
60 string mmssss(float t);
62 #define TIME_DECIMALS 2
63 #define TIME_FACTOR 100
64 #define TIME_ENCODED_TOSTRING(n) mmssss(n)
65 #define RACE_RECORD "/race100record/"
66 #define CTS_RECORD "/cts100record/"
67 #define TIME_ENCODE(t) TIME_TO_NTHS(t, TIME_FACTOR)
68 #define TIME_DECODE(n) ((n) / TIME_FACTOR)
70 string ScoreString(float vflags, float value);
72 vector cross(vector a, vector b);
74 void compressShortVector_init();
75 vector decompressShortVector(float data);
76 float compressShortVector(vector vec);
79 float CheckWireframeBox(entity forent, vector v0, vector dvx, vector dvy, vector dvz);
81 void fixedmakevectors(vector a);
82 #define fixedvectoangles2 vectoangles2
83 #define fixedvectoangles vectoangles
86 string fixPriorityList(string pl, float from, float to, float subtract, float complete);
87 string swapInPriorityList(string order, float i, float j);
89 float cvar_value_issafe(string s);
91 void cvar_settemp(string pKey, string pValue);
92 void cvar_settemp_restore();
95 // modes: 0 = trust q3map2 (_mini images)
96 // 1 = trust tracebox (_radar images)
97 // in both modes, mapinfo's "size" overrides
102 void get_mi_min_max(float mode);
104 vector mi_picmin; // adjusted mins that map to the picture (square)
105 vector mi_picmax; // adjusted maxs that map to the picture (square)
106 vector mi_pictexcoord0; // texcoords of the image corners (after transforming, these are 2D coords too)
107 vector mi_pictexcoord1; // texcoords of the image corners (after transforming, these are 2D coords too)
108 vector mi_pictexcoord2; // texcoords of the image corners (after transforming, these are 2D coords too)
109 vector mi_pictexcoord3; // texcoords of the image corners (after transforming, these are 2D coords too)
110 void get_mi_min_max_texcoords(float mode);
113 #define FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(x) void reference_##x() { x = x; }
115 float almost_equals(float a, float b);
116 float almost_in_bounds(float a, float b, float c);
118 float power2of(float e);
119 float log2of(float x);
121 string HEXDIGITS = "0123456789ABCDEF0123456789abcdef";
122 #define HEXDIGIT_TO_DEC_RAW(d) (strstrofs(HEXDIGITS, (d), 0))
123 #define HEXDIGIT_TO_DEC(d) ((HEXDIGIT_TO_DEC_RAW(d) | 0x10) - 0x10)
124 #define DEC_TO_HEXDIGIT(d) (substring(HEXDIGITS, (d), 1))
126 vector rgb_to_hsl(vector rgb);
127 vector hsl_to_rgb(vector hsl);
128 vector rgb_to_hsv(vector rgb);
129 vector hsv_to_rgb(vector hsv);
130 string rgb_to_hexcolor(vector rgb);
132 float boxesoverlap(vector m1, vector m2, vector m3, vector m4);
133 float boxinsidebox(vector smins, vector smaxs, vector bmins, vector bmaxs);
136 vector AnglesTransform_Apply(vector transform, vector v);
137 vector AnglesTransform_Multiply(vector t1, vector t2);
138 vector AnglesTransform_Invert(vector transform);
139 vector AnglesTransform_TurnDirection(vector transform);
140 vector AnglesTransform_Divide(vector to_transform, vector from_transform);
143 typedef float(string s, vector size) textLengthUpToWidth_widthFunction_t;
144 typedef float(string s) textLengthUpToLength_lenFunction_t;
145 float textLengthUpToWidth(string theText, float maxWidth, vector size, textLengthUpToWidth_widthFunction_t tw);
146 string textShortenToWidth(string theText, float maxWidth, vector size, textLengthUpToWidth_widthFunction_t tw);
147 float textLengthUpToLength(string theText, float maxWidth, textLengthUpToLength_lenFunction_t tw);
148 string textShortenToLength(string theText, float maxWidth, textLengthUpToLength_lenFunction_t tw);
150 string getWrappedLine_remaining;
151 string getWrappedLine(float w, vector size, textLengthUpToWidth_widthFunction_t tw);
152 string getWrappedLineLen(float w, textLengthUpToLength_lenFunction_t tw);
154 float isGametypeInFilter(float gt, float tp, string pattern);
156 typedef void(float i1, float i2, entity pass) swapfunc_t; // is only ever called for i1 < i2
157 typedef float(float i1, float i2, entity pass) comparefunc_t; // <0 for <, ==0 for ==, >0 for > (like strcmp)
158 void shuffle(float n, swapfunc_t swap, entity pass);
159 void heapsort(float n, swapfunc_t swap, comparefunc_t cmp, entity pass);
161 string swapwords(string str, float i, float j);
162 string shufflewords(string str);
164 string substring_range(string s, float b, float e);
166 vector solve_quadratic(float a, float b, float c);
169 // z = 1 if a real solution exists, 0 if not
170 // if no real solution exists, x contains the real part and y the imaginary part of the complex solutions x+iy and x-iy
172 void check_unacceptable_compiler_bugs();
174 float compressShotOrigin(vector v);
175 vector decompressShotOrigin(float f);
177 string records_reply, rankings_reply, lsmaps_reply, maplist_reply; // cached replies
179 float RandomSelection_totalweight;
180 float RandomSelection_best_priority;
181 entity RandomSelection_chosen_ent;
182 float RandomSelection_chosen_float;
183 string RandomSelection_chosen_string;
184 void RandomSelection_Init();
185 void RandomSelection_Add(entity e, float f, string s, float weight, float priority);
187 vector healtharmor_maxdamage(float h, float a, float armorblock); // returns vector: maxdamage, armorideal, 1 if fully armored
188 vector healtharmor_applydamage(float a, float armorblock, float damage); // returns vector: take, save, 0
190 string getcurrentmod();
196 void WriteInt24_t(float dest, float val);
201 const var void func_null(void); FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(func_null)
202 const var string string_null;
203 float float2range11(float f);
204 float float2range01(float f);
206 float gsl_ran_gaussian(float sigma);
208 string car(string s); // returns first word
209 string cdr(string s); // returns all but first word
210 float matchacl(string acl, string str); // matches str against ACL acl (with entries +foo*, +foo, +*foo, +*foo*, and same with - for forbidding)
211 float startsWith(string haystack, string needle);
212 float startsWithNocase(string haystack, string needle);