1 // a dummy macro that prevents the "hanging ;" warning
2 #define ENDS_WITH_CURLY_BRACE
4 #define ACCUMULATE_FUNCTION(func,otherfunc) \
6 void __merge__##otherfunc() { func(); otherfunc(); } \
8 #define func __merge__##otherfunc \
10 #define func otherfunc \
13 // 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
14 // NOTE: s IS allowed to be a tempstring
15 string wordwrap(string s, float l);
18 void wordwrap_sprint(string s, float l);
21 void wordwrap_cb(string s, float l, void(string) callback)
23 float GameCommand_Generic(string cmd);
24 // returns TRUE if handled, FALSE otherwise
25 // uses tokenize on its argument!
27 // iterative depth-first search, with fields that go "up", "down left" and "right" in a tree
28 // for each element, funcPre is called first, then funcPre and funcPost for all its children, and funcPost last
29 void depthfirst(entity start, .entity up, .entity downleft, .entity right, void(entity, entity) funcPre, void(entity, entity) funcPost, entity pass);
31 float median(float a, float b, float c);
33 // converts a number to a string with the indicated number of decimals
34 // works for up to 10 decimals!
35 string ftos_decimals(float number, float decimals);
37 vector colormapPaletteColor(float c, float isPants);
39 // unzone the string, and return it as tempstring. Safe to be called on string_null
40 string fstrunzone(string s);
42 // database (NOTE: keys are case sensitive)
43 void db_save(float db, string filename);
44 void db_dump(float db, string pFilename);
46 float db_load(string filename);
47 void db_close(float db);
48 string db_get(float db, string key);
49 void db_put(float db, string key, string value);
51 // stringbuffer loading/saving
52 float buf_load(string filename);
53 void buf_save(float buf, string filename);
57 float mod(float a, float b) { return a - (floor(a / b) * b); }
60 string GametypeNameFromType(float g);
61 #define TIME_TO_NTHS(t,n) floor((t) * (n) + 0.4)
62 string mmsss(float t);
63 string mmssss(float t);
65 #define TIME_DECIMALS 2
66 #define TIME_FACTOR 100
67 #define TIME_ENCODED_TOSTRING(n) mmssss(n)
68 #define RACE_RECORD "/race100record/"
69 #define CTS_RECORD "/cts100record/"
70 #define TIME_ENCODE(t) TIME_TO_NTHS(t, TIME_FACTOR)
71 #define TIME_DECODE(n) ((n) / TIME_FACTOR)
73 string ScoreString(float vflags, float value);
75 vector cross(vector a, vector b);
77 void compressShortVector_init();
78 vector decompressShortVector(float data);
79 float compressShortVector(vector vec);
82 float CheckWireframeBox(entity forent, vector v0, vector dvx, vector dvy, vector dvz);
85 string fixPriorityList(string pl, float from, float to, float subtract, float complete);
86 string swapInPriorityList(string order, float i, float j);
88 float cvar_value_issafe(string s);
90 void cvar_settemp(string pKey, string pValue);
91 void cvar_settemp_restore();
94 // modes: 0 = trust q3map2 (_mini images)
95 // 1 = trust tracebox (_radar images)
96 // in both modes, mapinfo's "size" overrides
101 void get_mi_min_max(float mode);
103 vector mi_picmin; // adjusted mins that map to the picture (square)
104 vector mi_picmax; // adjusted maxs that map to the picture (square)
105 vector mi_pictexcoord0; // texcoords of the image corners (after transforming, these are 2D coords too)
106 vector mi_pictexcoord1; // texcoords of the image corners (after transforming, these are 2D coords too)
107 vector mi_pictexcoord2; // texcoords of the image corners (after transforming, these are 2D coords too)
108 vector mi_pictexcoord3; // texcoords of the image corners (after transforming, these are 2D coords too)
109 void get_mi_min_max_texcoords(float mode);
112 #define FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(x) void reference_##x() { x = x; }
114 float almost_equals(float a, float b);
115 float almost_in_bounds(float a, float b, float c);
117 float power2of(float e);
118 float log2of(float x);
120 string HEXDIGITS = "0123456789ABCDEF0123456789abcdef";
121 #define HEXDIGIT_TO_DEC_RAW(d) (strstrofs(HEXDIGITS, (d), 0))
122 #define HEXDIGIT_TO_DEC(d) ((HEXDIGIT_TO_DEC_RAW(d) | 0x10) - 0x10)
123 #define DEC_TO_HEXDIGIT(d) (substring(HEXDIGITS, (d), 1))
125 vector rgb_to_hsl(vector rgb);
126 vector hsl_to_rgb(vector hsl);
127 vector rgb_to_hsv(vector rgb);
128 vector hsv_to_rgb(vector hsv);
129 string rgb_to_hexcolor(vector rgb);
131 float boxesoverlap(vector m1, vector m2, vector m3, vector m4);
132 float boxinsidebox(vector smins, vector smaxs, vector bmins, vector bmaxs);
134 typedef float(string s, vector size) textLengthUpToWidth_widthFunction_t;
135 typedef float(string s) textLengthUpToLength_lenFunction_t;
136 float textLengthUpToWidth(string theText, float maxWidth, vector size, textLengthUpToWidth_widthFunction_t tw);
137 string textShortenToWidth(string theText, float maxWidth, vector size, textLengthUpToWidth_widthFunction_t tw);
138 float textLengthUpToLength(string theText, float maxWidth, textLengthUpToLength_lenFunction_t tw);
139 string textShortenToLength(string theText, float maxWidth, textLengthUpToLength_lenFunction_t tw);
141 string getWrappedLine_remaining;
142 string getWrappedLine(float w, vector size, textLengthUpToWidth_widthFunction_t tw);
143 string getWrappedLineLen(float w, textLengthUpToLength_lenFunction_t tw);
145 float isGametypeInFilter(float gt, float tp, float ts, string pattern);
147 typedef void(float i1, float i2, entity pass) swapfunc_t; // is only ever called for i1 < i2
148 typedef float(float i1, float i2, entity pass) comparefunc_t; // <0 for <, ==0 for ==, >0 for > (like strcmp)
149 void shuffle(float n, swapfunc_t swap, entity pass);
150 void heapsort(float n, swapfunc_t swap, comparefunc_t cmp, entity pass);
152 string swapwords(string str, float i, float j);
153 string shufflewords(string str);
155 string substring_range(string s, float b, float e);
157 vector solve_quadratic(float a, float b, float c);
160 // z = 1 if a real solution exists, 0 if not
161 // if no real solution exists, x contains the real part and y the imaginary part of the complex solutions x+iy and x-iy
163 void check_unacceptable_compiler_bugs();
165 float compressShotOrigin(vector v);
166 vector decompressShotOrigin(float f);
168 string rankings_reply, ladder_reply, lsmaps_reply, lsnewmaps_reply, maplist_reply; // cached replies
169 string records_reply[10];
171 float RandomSelection_totalweight;
172 float RandomSelection_best_priority;
173 entity RandomSelection_chosen_ent;
174 float RandomSelection_chosen_float;
175 string RandomSelection_chosen_string;
176 void RandomSelection_Init();
177 void RandomSelection_Add(entity e, float f, string s, float weight, float priority);
179 vector healtharmor_maxdamage(float h, float a, float armorblock); // returns vector: maxdamage, armorideal, 1 if fully armored
180 vector healtharmor_applydamage(float a, float armorblock, float damage); // returns vector: take, save, 0
182 string getcurrentmod();
188 void WriteInt24_t(float dest, float val);
193 const var void func_null(void); FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(func_null)
194 const var string string_null;
195 float float2range11(float f);
196 float float2range01(float f);
198 float gsl_ran_gaussian(float sigma);
200 string car(string s); // returns first word
201 string cdr(string s); // returns all but first word
202 float matchacl(string acl, string str); // matches str against ACL acl (with entries +foo*, +foo, +*foo, +*foo*, and same with - for forbidding)
203 float startsWith(string haystack, string needle);
204 float startsWithNocase(string haystack, string needle);
206 string get_model_datafilename(string mod, float skn, string fil); // skin -1 will return wildcard, mod string_null will also put wildcard there
207 string get_model_parameters_modelname;
208 float get_model_parameters_modelskin;
209 string get_model_parameters_name;
210 float get_model_parameters_species;
211 string get_model_parameters_sex;
212 float get_model_parameters_weight;
213 float get_model_parameters_age;
214 string get_model_parameters_desc;
215 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
217 // stupid stupid stupid FTEQCC has a max limit on macro sizes, let's work around by splitting the macro into two macros! :(
218 #define HUD_Panel_GetName_Part2(id) \
220 case HUD_PANEL_ENGINEINFO: panel_name = HUD_PANELNAME_ENGINEINFO; break; \
221 case HUD_PANEL_INFOMESSAGES: panel_name = HUD_PANELNAME_INFOMESSAGES; break; \
222 } ENDS_WITH_CURLY_BRACE
224 // Get name of specified panel id
225 #define HUD_Panel_GetName(id) \
227 case HUD_PANEL_WEAPONS: panel_name = HUD_PANELNAME_WEAPONS; break; \
228 case HUD_PANEL_AMMO: panel_name = HUD_PANELNAME_AMMO; break; \
229 case HUD_PANEL_POWERUPS: panel_name = HUD_PANELNAME_POWERUPS; break; \
230 case HUD_PANEL_HEALTHARMOR: panel_name = HUD_PANELNAME_HEALTHARMOR; break; \
231 case HUD_PANEL_NOTIFY: panel_name = HUD_PANELNAME_NOTIFY; break; \
232 case HUD_PANEL_TIMER: panel_name = HUD_PANELNAME_TIMER; break; \
233 case HUD_PANEL_RADAR: panel_name = HUD_PANELNAME_RADAR; break; \
234 case HUD_PANEL_SCORE: panel_name = HUD_PANELNAME_SCORE; break; \
235 case HUD_PANEL_RACETIMER: panel_name = HUD_PANELNAME_RACETIMER; break; \
236 case HUD_PANEL_VOTE: panel_name = HUD_PANELNAME_VOTE; break; \
237 case HUD_PANEL_MODICONS: panel_name = HUD_PANELNAME_MODICONS; break; \
238 case HUD_PANEL_PRESSEDKEYS: panel_name = HUD_PANELNAME_PRESSEDKEYS; break; \
239 case HUD_PANEL_CHAT: panel_name = HUD_PANELNAME_CHAT; break; \
241 HUD_Panel_GetName_Part2(id)
243 vector vec2(vector v);
246 vector NearestPointOnBox(entity box, vector org);
249 float vercmp(string v1, string v2);
251 float u8_strsize(string s);
253 // translation helpers
254 string prvm_language;
255 string language_filename(string s);
256 string CTX(string s);
257 #define ZCTX(s) strzone(CTX(s))