5 vector real_origin(entity ent);
8 IntrusiveList g_saved_cvars;
9 STATIC_INIT(g_saved_cvars) { g_saved_cvars = IL_NEW(); }
11 // 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
12 // NOTE: s IS allowed to be a tempstring
13 string wordwrap(string s, float l);
15 void wordwrap_sprint(entity to, string s, float l);
17 void wordwrap_cb(string s, float l, void(string) callback);
20 string draw_currentSkin;
21 string draw_UseSkinFor(string pic);
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 string ftos_decimals(float number, float decimals);
32 string ftos_mindecimals(float number);
34 bool fexists(string f);
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(int db, string filename);
41 void db_dump(int db, string pFilename);
43 int db_load(string filename);
44 void db_close(int db);
45 string db_get(int db, string key);
46 void db_put(int db, string key, string value);
48 // stringbuffer loading/saving
49 int buf_load(string filename);
50 void buf_save(int buf, string filename);
52 // adding just 0.4 for race times so it rounds down in the .5 case (matching the timer display)
53 // FIXME it doesn't round properly
54 #define TIME_TO_NTHS(t,n) floor((t) * (n) + 0.4)
55 string format_time(float seconds);
56 string mmsss(float t);
57 string mmssss(float t);
59 const float TIME_DECIMALS = 2;
60 const float TIME_FACTOR = 100;
61 #define TIME_ENCODED_TOSTRING(n) mmssss(n)
62 #define RACE_RECORD "/race100record/"
63 #define CTS_RECORD "/cts100record/"
64 #define CTF_RECORD "/ctf100record/"
65 #define TIME_ENCODE(t) TIME_TO_NTHS(t, TIME_FACTOR)
66 #define TIME_DECODE(n) ((n) / TIME_FACTOR)
68 string ScoreString(float vflags, float value);
70 vector decompressShortVector(float data);
71 float compressShortVector(vector vec);
74 float CheckWireframeBox(entity forent, vector v0, vector dvx, vector dvy, vector dvz);
77 string fixPriorityList(string pl, float from, float to, float subtract, float complete);
78 string mapPriorityList(string order, string(string) mapfunc);
79 string swapInPriorityList(string order, float i, float j);
81 float cvar_value_issafe(string s);
83 float cvar_settemp(string pKey, string pValue);
84 float cvar_settemp_restore();
87 // modes: 0 = trust q3map2 (_mini images)
88 // 1 = trust tracebox (_radar images)
89 // in both modes, mapinfo's "size" overrides
94 void get_mi_min_max(float mode);
96 vector mi_picmin; // adjusted mins that map to the picture (square)
97 vector mi_picmax; // adjusted maxs that map to the picture (square)
98 vector mi_pictexcoord0; // texcoords of the image corners (after transforming, these are 2D coords too)
99 vector mi_pictexcoord1; // texcoords of the image corners (after transforming, these are 2D coords too)
100 vector mi_pictexcoord2; // texcoords of the image corners (after transforming, these are 2D coords too)
101 vector mi_pictexcoord3; // texcoords of the image corners (after transforming, these are 2D coords too)
102 void get_mi_min_max_texcoords(float mode);
105 float almost_equals(float a, float b);
106 float almost_in_bounds(float a, float b, float c);
108 float boxesoverlap(vector m1, vector m2, vector m3, vector m4);
109 float boxinsidebox(vector smins, vector smaxs, vector bmins, vector bmaxs);
111 USING(textLengthUpToWidth_widthFunction_t, float(string s, vector size));
112 USING(textLengthUpToLength_lenFunction_t, float(string s));
113 float textLengthUpToWidth(string theText, float maxWidth, vector size, textLengthUpToWidth_widthFunction_t tw);
114 string textShortenToWidth(string theText, float maxWidth, vector size, textLengthUpToWidth_widthFunction_t tw);
115 float textLengthUpToLength(string theText, float maxWidth, textLengthUpToLength_lenFunction_t tw);
116 string textShortenToLength(string theText, float maxWidth, textLengthUpToLength_lenFunction_t tw);
118 string getWrappedLine_remaining;
119 string getWrappedLine(float w, vector size, textLengthUpToWidth_widthFunction_t tw);
120 string getWrappedLineLen(float w, textLengthUpToLength_lenFunction_t tw);
122 float isGametypeInFilter(entity gt, float tp, float ts, string pattern);
124 string swapwords(string str, float i, float j);
125 string shufflewords(string str);
127 string substring_range(string s, float b, float e);
129 vector solve_quadratic(float a, float b, float c);
132 // z = 1 if a real solution exists, 0 if not
133 // if no real solution exists, x contains the real part and y the imaginary part of the complex solutions x+iy and x-iy
135 vector solve_shotdirection(vector myorg, vector myvel, vector eorg, vector evel, float spd, float newton_style);
136 vector get_shotvelocity(vector myvel, vector mydir, float spd, float newton_style, float mi, float ma);
138 float compressShotOrigin(vector v);
139 vector decompressShotOrigin(float f);
142 string rankings_reply, ladder_reply, lsmaps_reply, maplist_reply, monsterlist_reply; // cached replies
143 string records_reply[10];
147 vector healtharmor_maxdamage(float h, float a, float armorblock, int deathtype); // returns vector: maxdamage, armorideal, 1 if fully armored
148 vector healtharmor_applydamage(float a, float armorblock, int deathtype, float damage); // returns vector: take, save, 0
151 string getcurrentmod();
153 float float2range11(float f);
154 float float2range01(float f);
156 float gsl_ran_gaussian(float sigma);
158 float matchacl(string acl, string str); // matches str against ACL acl (with entries +foo*, +foo, +*foo, +*foo*, and same with - for forbidding)
160 string get_model_datafilename(string mod, float skn, string fil); // skin -1 will return wildcard, mod string_null will also put wildcard there
161 string get_model_parameters_modelname;
162 float get_model_parameters_modelskin;
163 string get_model_parameters_name;
164 float get_model_parameters_species;
165 string get_model_parameters_sex;
166 float get_model_parameters_weight;
167 float get_model_parameters_age;
168 bool get_model_parameters_hidden;
169 string get_model_parameters_description;
170 string get_model_parameters_bone_upperbody;
171 string get_model_parameters_bone_weapon;
172 const int MAX_AIM_BONES = 4;
173 string get_model_parameters_bone_aim[MAX_AIM_BONES];
174 float get_model_parameters_bone_aimweight[MAX_AIM_BONES];
175 float get_model_parameters_fixbone;
176 string get_model_parameters_desc;
177 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
180 vector NearestPointOnBox(entity box, vector org);
183 float vercmp(string v1, string v2);
185 float u8_strsize(string s);
187 // x-encoding (encoding as zero length invisible string)
188 // encodes approx. 14 bits into 5 bytes of color code string
189 const float XENCODE_MAX = 21295; // 2*22*22*22-1
190 const float XENCODE_LEN = 5;
191 string xencode(float f);
192 float xdecode(string s);
195 string strtolower(string s);
198 string MakeConsoleSafe(string input);
200 // generic shutdown handler
204 .float skeleton_bones;
205 void Skeleton_SetBones(entity e);
206 // loops through the tags of model v using counter tagnum
207 #define FOR_EACH_TAG(v) float tagnum; Skeleton_SetBones(v); for(tagnum = 0; tagnum < v.skeleton_bones; tagnum++, gettaginfo(v, tagnum))
210 void WriteApproxPastTime(float dst, float t);
213 float ReadApproxPastTime();
216 // execute-stuff-next-frame subsystem
217 void execute_next_frame();
218 void queue_to_execute_next_frame(string s);
220 // a function f with:
223 // f'(0) = startspeedfactor
224 // f'(1) = endspeedfactor
225 float cubic_speedfunc(float startspeedfactor, float endspeedfactor, float spd);
227 // checks whether f'(x) = 0 anywhere from 0 to 1
228 // because if this is the case, the function is not usable for platforms
229 // as it may exceed 0..1 bounds, or go in reverse
230 float cubic_speedfunc_is_sane(float startspeedfactor, float endspeedfactor);
232 USING(findNextEntityNearFunction_t, entity(entity cur, entity near, entity pass));
233 USING(isConnectedFunction_t, float(entity a, entity b, entity pass));
234 void FindConnectedComponent(entity e, .entity fld, findNextEntityNearFunction_t nxt, isConnectedFunction_t iscon, entity pass);
236 // expand multiple arguments into one argument by stripping parenthesis
237 #define XPD(...) __VA_ARGS__
239 // Some common varargs functions. Lowercase as they match C.
240 #define fprintf(file, ...) fputs(file, sprintf(__VA_ARGS__))
241 #define bprintf(...) bprint(sprintf(__VA_ARGS__))
244 string CCR(string input);
249 #define GENTLE (autocvar_cl_gentle || autocvar_cl_gentle_messages)
251 #define GENTLE autocvar_sv_gentle
253 #define normal_or_gentle(normal, gentle) (GENTLE ? ((gentle != "") ? gentle : normal) : normal)
257 vector animfixfps(entity e, vector a, vector b);
261 const float CNT_NORMAL = 1;
262 const float CNT_GAMESTART = 2;
263 const float CNT_IDLE = 3;
264 const float CNT_KILL = 4;
265 const float CNT_RESPAWN = 5;
266 const float CNT_ROUNDSTART = 6;
267 entity Announcer_PickNumber(float type, float num);
271 int Mod_Q1BSP_SuperContentsFromNativeContents(int nativecontents);
272 int Mod_Q1BSP_NativeContentsFromSuperContents(int supercontents);
275 // Quadratic splines (bezier)
276 vector bezier_quadratic_getpoint(vector a, vector p, vector b, float t);
277 vector bezier_quadratic_getderivative(vector a, vector p, vector b, float t);
279 #define APPEND_TO_STRING(list,sep,add) ((list) = (((list) != "") ? strcat(list, sep, add) : (add)))
281 // Returns the correct difference between two always increasing numbers
282 #define COMPARE_INCREASING(to,from) (to < from ? from + to + 2 : to - from)