1 //////////////////////////////////////////////////////////
6 /////////////////////////////////////////////////////////
8 /////////////////////////////////////////////////////////
11 /////////////////////////////////////////////////////////
13 /////////////////////////////////////////////////////////
17 void(float keynr, float ascii) m_keydown;
18 void(float width, float height) m_draw;
19 void(float mode) m_toggle;
21 // optional: float(float) m_gethostcachecategory;
23 /////////////////////////////////////////////////////////
25 ///////////////////////////
28 float KEY_UNKNOWN = -1;
31 float KEY_MENU_GRABBED = 3;
33 ///////////////////////////
37 float FILE_APPEND = 1;
40 ///////////////////////////
41 // logical constants (just for completeness)
46 ///////////////////////////
52 ///////////////////////////
55 float MSG_BROADCAST = 0; // unreliable to all
56 float MSG_ONE = 1; // reliable to one (msg_entity)
57 float MSG_ALL = 2; // reliable to all
58 float MSG_INIT = 3; // write to the init string
60 /////////////////////////////
61 // mouse target constants
66 /////////////////////////
67 // client state constants
69 float CS_DEDICATED = 0;
70 float CS_DISCONNECTED = 1;
71 float CS_CONNECTED = 2;
73 ///////////////////////////
76 float DRAWFLAG_NORMAL = 0;
77 float DRAWFLAG_ADDITIVE = 1;
78 float DRAWFLAG_MODULATE = 2;
79 float DRAWFLAG_2XMODULATE = 3;
81 ///////////////////////////
82 // null entity (actually it is the same like the world entity)
86 ///////////////////////////
90 float ERR_CANNOTOPEN = -1; // fopen
91 float ERR_NOTENOUGHFILEHANDLES = -2; // fopen
92 float ERR_INVALIDMODE = -3; // fopen
93 float ERR_BADFILENAME = -4; // fopen
97 float ERR_NULLSTRING = -1;
98 float ERR_BADDRAWFLAG = -2;
99 float ERR_BADSCALE = -3;
100 float ERR_BADSIZE = -3; // same as ERR_BADSCALE
101 float ERR_NOTCACHED = -4;
104 float SLIST_HOSTCACHEVIEWCOUNT = 0;
105 float SLIST_HOSTCACHETOTALCOUNT = 1;
106 float SLIST_MASTERQUERYCOUNT = 2;
107 float SLIST_MASTERREPLYCOUNT = 3;
108 float SLIST_SERVERQUERYCOUNT = 4;
109 float SLIST_SERVERREPLYCOUNT = 5;
110 float SLIST_SORTFIELD = 6;
111 float SLIST_SORTDESCENDING = 7;
112 float SLIST_LEGACY_LINE1 = 1024;
113 float SLIST_LEGACY_LINE2 = 1025;
114 float SLIST_TEST_CONTAINS = 0;
115 float SLIST_TEST_NOTCONTAIN = 1;
116 float SLIST_TEST_LESSEQUAL = 2;
117 float SLIST_TEST_LESS = 3;
118 float SLIST_TEST_EQUAL = 4;
119 float SLIST_TEST_GREATER = 5;
120 float SLIST_TEST_GREATEREQUAL = 6;
121 float SLIST_TEST_NOTEQUAL = 7;
122 float SLIST_TEST_STARTSWITH = 8;
123 float SLIST_TEST_NOTSTARTSWITH = 9;
124 float SLIST_MASK_AND = 0;
125 float SLIST_MASK_OR = 512;
128 float FONT_DEFAULT = 0;
129 float FONT_CONSOLE = 1;
131 float FONT_NOTIFY = 3;
133 float FONT_CENTERPRINT = 5;
134 float FONT_INFOBAR = 6;
136 float FONT_USER = 8; // add to this the index, like FONT_USER+3 = user3. At least 8 of them are supported.
139 /* not supported at the moment
140 ///////////////////////////
143 float OS_WINDOWS = 0;
157 //////////////////////////////////////////////////
159 //////////////////////////////////////////////////
160 // AK FIXME: Create perhaps a special builtin file for the common cmds
162 float checkextension(string ext) = #1;
165 void error(string err,...) = #2;
166 void objerror(string err,...) = #3;
170 void print(string text,...) = #4;
171 void bprint(string text,...) = #5;
172 void sprint(float clientnum, string text,...) = #6;
173 void centerprint(string text,...) = #7;
177 vector normalize(vector v) = #8;
178 float vlen(vector v) = #9;
179 float vectoyaw(vector v) = #10;
180 vector vectoangles(vector v) = #11;
182 float random(void) = #12; // Returns a random number > 0 and < 1
184 void cmd(string command, ...) = #13;
185 void localcmd(string command, ...) = #13;
189 float cvar(string name) = #14;
190 const string str_cvar(string name) = #71;
191 void cvar_set(string name, string value) = #15;
193 void dprint(string text,...) = #16;
195 // conversion functions
197 string ftos(float f) = #17;
198 float fabs(float f) = #18;
199 string vtos(vector v) = #19;
200 string etos(entity e) = #20;
202 float stof(string val,...) = #21;
204 entity spawn(void) = #22;
205 void remove(entity e) = #23;
207 entity find(entity start, .string field, string match) = #24;
208 entity findfloat(entity start, .float field, float match) = #25;
209 entity findentity(entity start, .entity field, entity match) = #25;
211 entity findchainstring(.string field, string match) = #26;
212 entity findchainfloat(.float field, float match) = #27;
213 entity findchainentity(.entity field, entity match) = #27;
215 string precache_file(string file) = #28;
216 string precache_sound(string sample) = #29;
218 void crash(void) = #72;
219 void coredump(void) = #30;
220 void stackdump(void) = #73;
221 void traceon(void) = #31;
222 void traceoff(void) = #32;
224 void eprint(entity e) = #33;
225 float rint(float f) = #34;
226 float floor(float f) = #35;
227 float ceil(float f) = #36;
228 entity nextent(entity e) = #37;
229 float sin(float f) = #38;
230 float cos(float f) = #39;
231 float sqrt(float f) = #40;
232 vector randomvec(void) = #41;
234 float registercvar(string name, string value, float flags) = #42; // returns 1 if success
236 float min(float f,...) = #43;
237 float max(float f,...) = #44;
239 float bound(float min,float value, float max) = #45;
240 float pow(float a, float b) = #46;
242 void copyentity(entity src, entity dst) = #47;
244 float fopen(string filename, float mode) = #48;
245 void fclose(float fhandle) = #49;
246 string fgets(float fhandle) = #50;
247 void fputs(float fhandle, string s) = #51;
249 float strlen(string s) = #52;
250 string strcat(string s, string...) = #53;
251 string substring(string s, float start, float length) = #54;
253 vector stov(string s) = #55;
255 string strzone(string s) = #56;
256 void strunzone(string s) = #57;
258 float tokenize(string s) = #58;
259 string argv(float n) = #59;
261 float isserver(void) = #60;
262 float clientcount(void) = #61;
263 float clientstate(void) = #62;
264 void clientcommand(float client, string s) = #63;
265 void changelevel(string map) = #64;
266 void localsound(string sample) = #65;
267 vector getmousepos(void) = #66;
268 float gettime(void) = #67;
269 void loadfromdata(string data) = #68;
270 void loadfromfile(string file) = #69;
272 float mod(float val, float m) = #70;
274 float search_begin(string pattern, float caseinsensitive, float quiet) = #74;
275 void search_end(float handle) = #75;
276 float search_getsize(float handle) = #76;
277 string search_getfilename(float handle, float num) = #77;
279 string chr(float ascii) = #78;
281 /////////////////////////////////////////////////
283 /////////////////////////////////////////////////
284 void WriteByte(float data, float dest, float desto) = #401;
285 void WriteChar(float data, float dest, float desto) = #402;
286 void WriteShort(float data, float dest, float desto) = #403;
287 void WriteLong(float data, float dest, float desto) = #404;
288 void WriteAngle(float data, float dest, float desto) = #405;
289 void WriteCoord(float data, float dest, float desto) = #406;
290 void WriteString(string data, float dest, float desto)= #407;
291 void WriteEntity(entity data, float dest, float desto) = #408;
293 //////////////////////////////////////////////////
295 //////////////////////////////////////////////////
297 float iscachedpic(string name) = #451;
298 string precache_pic(string name, ...) = #452;
299 void freepic(string name) = #453;
301 float drawcharacter(vector position, float character, vector scale, vector rgb, float alpha, float flag) = #454;
303 float drawstring(vector position, string text, vector scale, vector rgb, float alpha, float flag) = #455;
305 float drawcolorcodedstring(vector position, string text, vector scale, float alpha, float flag) = #467;
307 vector drawcolorcodedstring2(vector position, string text, vector scale, vector rgb, float alpha, float flag) = #467;
309 float drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag) = #456;
311 float drawfill(vector position, vector size, vector rgb, float alpha, float flag) = #457;
313 void drawsetcliparea(float x, float y, float width, float height) = #458;
315 void drawresetcliparea(void) = #459;
317 vector drawgetimagesize(string pic) = #460;
319 ////////////////////////////////////////////////
321 ////////////////////////////////////////////////
323 void setkeydest(float dest) = #601;
324 float getkeydest(void) = #602;
326 void setmousetarget(float trg) = #603;
327 float getmousetarget(void) = #604;
329 float isfunction(string function_name) = #607;
330 void callfunction(...) = #605;
331 void writetofile(float fhandle, entity ent) = #606;
332 vector getresolution(float number) = #608;
333 string keynumtostring(float keynum) = #609;
335 float gethostcachevalue(float type) = #611;
336 string gethostcachestring(float type, float hostnr) = #612;
339 //idea: daemon, motorsep
340 //darkplaces implementation: divVerent
341 //builtin definitions:
342 string(float key, float bindmap) getkeybind_bindmap = #342;
343 float(float key, string bind, float bindmap) setkeybind_bindmap = #630;
344 vector(void) getbindmaps = #631;
345 float(vector bm) setbindmaps = #632;
346 string(string command, float bindmap) findkeysforcommand = #610;
347 float(string key) stringtokeynum = #341;
348 //<also allowed builtin number to match EXT_CSQC> string(float keynum) keynumtostring = #340;
349 //description: key bind setting/getting including support for switchable
354 //darkplaces implementation: divVerent
355 //field definitions: (MENUQC)
356 string(string serveraddress) crypto_getkeyfp = #633; // retrieves the cached host key's CA fingerprint of a server given by IP address
357 string(string serveraddress) crypto_getidfp = #634; // retrieves the cached host key fingerprint of a server given by IP address
358 float(string serveraddress) crypto_getidstatus = #643; // retrieves the cached host key's key status. See below for CRYPTO_IDSTATUS_ defines.
359 string(string serveraddress) crypto_getencryptlevel = #635; // 0 if never encrypting, 1 supported, 2 requested, 3 required, appended by list of allowed methods in order of preference ("AES128"), preceded by a space each
360 string(float i) crypto_getmykeyfp = #636; // retrieves the CA key fingerprint of a given CA slot, or "" if slot is unused but more to come, or string_null if end of list
361 string(float i) crypto_getmyidfp = #637; // retrieves the ID fingerprint of a given CA slot, or "" if slot is unused but more to come, or string_null if end of list
362 float CRYPTO_IDSTATUS_OUTOFRANGE = -1;
363 float CRYPTO_IDSTATUS_EMPTY = 0;
364 float CRYPTO_IDSTATUS_UNSIGNED = 1;
365 float CRYPTO_IDSTATUS_SIGNED = 2;
366 float(float i) crypto_getmyidstatus = #641; // retrieves the ID's status of a given CA slot, or 0 if slot is unused but more to come, or -1 if end of list
367 float(string url, float id, string content_type, string delim, float buf, float keyid) crypto_uri_postbuf = #513;
369 //use -1 as buffer handle to justs end delim as postdata
372 //idea: Res2k, BlackHC
373 //darkplaces implementation: Res2k, BlackHC
374 //constant definitions:
375 float GECKO_BUTTON_DOWN = 0;
376 float GECKO_BUTTON_UP = 1;
377 // either use down and up or just press but not all of them!
378 float GECKO_BUTTON_PRESS = 2;
379 // use this for mouse events if needed?
380 float GECKO_BUTTON_DOUBLECLICK = 3;
381 //builtin definitions:
382 float gecko_create( string name ) = #487;
383 void gecko_destroy( string name ) = #488;
384 void gecko_navigate( string name, string URI ) = #489;
385 float gecko_keyevent( string name, float key, float eventtype ) = #490;
386 void gecko_mousemove( string name, float x, float y ) = #491;
387 void gecko_resize( string name, float w, float h ) = #492;
388 vector gecko_get_texture_extent( string name ) = #493;
389 //engine-called QC prototypes:
390 //string(string name, string query) Qecko_Query;
392 //provides an interface to the offscreengecko library and allows for internet browsing in games
396 //darkplaces implementation: KrimZon
398 //various string manipulation functions
399 float(string str, string sub, float startpos) strstrofs = #221;
400 float(string str, float ofs) str2chr = #222;
401 string(float c, ...) chr2str = #223;
402 string(float ccase, float calpha, float cnum, string s, ...) strconv = #224;
403 string(float chars, string s, ...) strpad = #225;
404 string(string info, string key, string value, ...) infoadd = #226;
405 string(string info, string key) infoget = #227;
406 float(string s1, string s2) strcmp = #228;
407 float(string s1, string s2, float len) strncmp = #228;
408 float(string s1, string s2) strcasecmp = #229;
409 float(string s1, string s2, float len) strncasecmp = #230;
411 //DP_PRECACHE_PIC_FLAGS
413 //darkplaces implementation: divVerent
414 //constant definitions:
415 float PRECACHE_PIC_FROMWAD = 1; // this one actually is part of EXT_CSQC
416 float PRECACHE_PIC_NOTPERSISTENT = 2; // picture may get deallocated when unused
417 float PRECACHE_PIC_MIPMAP = 8; // mipmap the texture for possibly better downscaling at memory expense
418 //notes: these constants are given as optional second argument to precache_pic()
422 //darkplaces implementation: div0
423 //Some hash function to build hash tables with. This has to be be the CRC-16-CCITT that is also required for the QuakeWorld download protocol.
424 //When caseinsensitive is set, the CRC is calculated of the lower cased string.
425 float(float caseinsensitive, string s, ...) crc16 = #494;
428 float(string name) cvar_type = #495;
429 float CVAR_TYPEFLAG_EXISTS = 1;
430 float CVAR_TYPEFLAG_SAVED = 2;
431 float CVAR_TYPEFLAG_PRIVATE = 4;
432 float CVAR_TYPEFLAG_ENGINE = 8;
433 float CVAR_TYPEFLAG_HASDESCRIPTION = 16;
434 float CVAR_TYPEFLAG_READONLY = 32;
436 //DP_QC_STRINGBUFFERS
438 //darkplaces implementation: LadyHavoc
439 //functions to manage string buffer objects - that is, arbitrary length string arrays that are handled by the engine
440 float() buf_create = #440;
441 void(float bufhandle) buf_del = #441;
442 float(float bufhandle) buf_getsize = #442;
443 void(float bufhandle_from, float bufhandle_to) buf_copy = #443;
444 void(float bufhandle, float sortpower, float backward) buf_sort = #444;
445 string(float bufhandle, string glue) buf_implode = #445;
446 string(float bufhandle, float string_index) bufstr_get = #446;
447 void(float bufhandle, float string_index, string str) bufstr_set = #447;
448 float(float bufhandle, string str, float order) bufstr_add = #448;
449 void(float bufhandle, float string_index) bufstr_free = #449;
450 void(float bufhandle, string pattern, string antipattern) buf_cvarlist = #517;
452 //DP_QC_STRING_CASE_FUNCTIONS
454 //darkplaces implementation: LadyHavoc / Dresk
455 //builtin definitions:
456 string(string s) strtolower = #480; // returns the passed in string in pure lowercase form
457 string(string s) strtoupper = #481; // returns the passed in string in pure uppercase form
459 //provides simple string uppercase and lowercase functions
461 //DP_QC_CVAR_DESCRIPTION
463 //DarkPlaces implementation: divVerent
464 //builtin definitions:
465 string(string name) cvar_description = #518;
467 //returns the description of a cvar
470 //idea: motorsep, Spike
471 //DarkPlaces implementation: divVerent
472 //builtin definitions:
473 string(string digest, string data, ...) digest_hex = #639;
475 //returns a given hex digest of given data
476 //the returned digest is always encoded in hexadecimal
477 //only the "MD4" digest is always supported!
478 //if the given digest is not supported, string_null is returned
479 //the digest string is matched case sensitively, use "MD4", not "md4"!
483 //darkplaces implementation: divVerent
484 //builtin definitions:
485 string(string filename) whichpack = #503;
487 //for files in a pak/pk3/whatever, returns the pack's file name in FRIK_FILE name space.
488 //for physical files, returns "".
489 //in case of error, returns string_null.
493 //darkplaces implementation: div0
494 //URI::Escape's functionality
495 string(string in) uri_escape = #510;
496 string(string in) uri_unescape = #511;
500 //darkplaces implementation: divVerent
501 //loads text from an URL into a string
502 //returns 1 on success of initiation, 0 if there are too many concurrent
503 //connections already or if the URL is invalid
504 //the following callback will receive the data and MUST exist!
505 // void(float id, float status, string data) URI_Get_Callback;
507 // negative for an internal error,
509 // the HTTP response code on server error (e.g. 404)
510 //if 1 is returned by uri_get, the callback will be called in the future
511 float(string url, float id) uri_get = #513;
514 //darkplaces implementation: divVerent
515 //loads text from an URL into a string after POSTing via HTTP
516 //works like uri_get, but uri_post sends data with Content-Type: content_type to the server
517 //and uri_post sends the string buffer buf, joined using the delimiter delim
518 float(string url, float id, string content_type, string data) uri_post = #513;
519 float(string url, float id, string content_type, string delim, float buf) uri_postbuf = #513;
523 //darkplaces implementation: KrimZon
524 //builtin definitions:
525 float() numentityfields = #496;
526 string(float fieldnum) entityfieldname = #497;
527 float(float fieldnum) entityfieldtype = #498;
528 string(float fieldnum, entity ent) getentityfieldstring = #499;
529 float(float fieldnum, entity ent, string s) putentityfieldstring = #500;
531 //Returned by entityfieldtype
532 float FIELD_STRING = 1;
533 float FIELD_FLOAT = 2;
534 float FIELD_VECTOR = 3;
535 float FIELD_ENTITY = 4;
536 float FIELD_FUNCTION = 6;
538 //Versatile functions intended for storing data from specific entities between level changes, but can be customized for some kind of partial savegame.
539 //WARNING: .entity fields cannot be saved and restored between map loads as they will leave dangling pointers.
540 //numentityfields returns the number of entity fields. NOT offsets. Vectors comprise 4 fields: v, v_x, v_y and v_z.
541 //entityfieldname returns the name as a string, eg. "origin" or "classname" or whatever.
542 //entityfieldtype returns a value that the constants represent, but the field may be of another type in more exotic progs.dat formats or compilers.
543 //getentityfieldstring returns data as would be written to a savegame, eg... "0.05" (float), "0 0 1" (vector), or "Hello World!" (string). Function names can also be returned.
544 //putentityfieldstring puts the data returned by getentityfieldstring back into the entity.
548 //darkplaces implementation: divVerent
549 //function definitions:
550 void coverage() = #642; // Reports a coverage event. The engine counts for each of the calls to this builtin whether it has been called.
552 //DP_QC_FS_SEARCH_PACKFILE
554 //darkplaces implementation: Mario
555 //builtin definitions:
556 float(string pattern, float caseinsensitive, float quiet, string packfile) search_packfile_begin = #74;
558 //extension to search_begin (DP_QC_FS_SEARCH), performs a filename search with the specified pattern (for example "maps/*.bsp") and stores the results in a search slot (minimum of 128 supported by any engine with this extension), the other functions take this returned search slot number, be sure to search_free when done (they are also freed on progs reload).
559 //only searches for files within the specified packfile, which is expected to match the results of whichpack().
561 // assorted undocumented extensions
562 string(string, float) netaddress_resolve = #625;
563 string(string search, string replace, string subject) strreplace = #484;
564 string(string search, string replace, string subject) strireplace = #485;
565 string(float uselocaltime, string format, ...) strftime = #478;
566 float(string s) tokenize_console = #514;
567 float(float i) argv_start_index = #515;
568 float(float i) argv_end_index = #516;
569 string(float, float) getgamedirinfo = #626;
570 #define GETGAMEDIRINFO_NAME 0
571 #define GETGAMEDIRINFO_DESCRIPTION 1
572 float log(float f) = #532;
573 string(string format, ...) sprintf = #627;
574 string(string s) strdecolorize = #477;
575 entity findflags(entity start, .float field, float match) = #87;
576 entity findchainflags(.float field, float match) = #88;
577 float(string s, string separator1, ...) tokenizebyseparator = #479;
578 float etof(entity ent) = #79;
579 entity ftoe(float num) = #80;
580 float validstring(string str) = #81;
581 float altstr_count(string str) = #82;
582 string altstr_prepare(string str) = #83;
583 string altstr_get(string str, float num) = #84;
584 string altstr_set(string str, float num, string set) = #85;
585 string altstr_ins(string str, float num, string set) = #86;
586 float isdemo() = #349;
587 float drawsubpic(vector position, vector size, string pic, vector srcPosition, vector srcSize, vector rgb, float alpha, float flag) = #469;
588 //vector getresolution(float number, ...) = #608; // optional argument "isfullscreen"
589 void parseentitydata(entity ent, string data) = #613;
590 void resethostcachemasks(void) = #615;
591 void sethostcachemaskstring(float mask, float fld, string str, float op) = #616;
592 void sethostcachemasknumber(float mask, float fld, float num, float op) = #617;
593 void resorthostcache(void) = #618;
594 float SLSF_DESCENDING = 1;
595 float SLSF_FAVORITES = 2;
596 float SLSF_CATEGORIES = 4;
597 void sethostcachesort(float fld, float slsf) = #619;
598 void refreshhostcache(...) = #620; // optional boolean argument "clear_list"
599 float gethostcachenumber(float fld, float hostnr) = #621;
600 float gethostcacheindexforkey(string key) = #622;
601 void addwantedhostcachekey(string key) = #623;
602 string getextresponse(void) = #624;
603 const string cvar_string(string name) = #71;
604 const string cvar_defstring(string name) = #89;
605 float stringwidth(string text, float handleColors, vector size) = #468;