]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/menu/mbuiltin.qc
database, stringbuffer and FTE_STRINGS for menu QC;
[divverent/nexuiz.git] / data / qcsrc / menu / mbuiltin.qc
1 //////////////////////////////////////////////////
2 // common cmd
3 //////////////////////////////////////////////////
4 // AK FIXME: Create perhaps a special builtin file for the common cmds
5
6 //#define PROFILESTRZONE
7 #define FIXEDFOPEN
8
9 void    checkextension(string ext) = #1;
10
11 // error cmds
12 void    error(string err,...)   = #2;
13 void    objerror(string err,...)        = #3;
14
15 // print
16
17 void    print(string text,...)  = #4;
18 void    bprint(string text,...) = #5;
19 void    sprint(float clientnum, string text,...) = #6;
20 void    centerprint(string text,...) = #7;
21
22 // vector stuff
23
24 vector  normalize(vector v)     = #8;
25 float   vlen(vector v)                  = #9;
26 float   vectoyaw(vector v)              = #10;
27 vector  vectoangles(vector v)   = #11;
28
29 float   random(void)  = #12;
30
31 void    cmd(string command, ...) = #13;
32
33 // cvar cmds
34
35 float   cvar(string name) = #14;
36 const string cvar_string(string name) = #71;
37 const string cvar_defstring(string name) = #89;
38 void    cvar_set(string name, string value) = #15;
39
40 //void  dprint(string text,...) = #16;
41
42 // conversion functions
43
44 string  ftos(float f)  = #17;
45 float   fabs(float f)   = #18;
46 string  vtos(vector v)  = #19;
47 string  etos(entity e) = #20;
48
49 float   stof(string val,...)  = #21;
50
51 entity  spawn(void) = #22;
52 void    remove(entity e) = #23;
53
54 entity  findstring(entity start, .string _field, string match)  = #24;
55 entity  findfloat(entity start, .float _field, float match) = #25;
56 entity  findentity(entity start, .entity _field, entity match) = #25;
57
58 entity  findchainstring(.string _field, string match) = #26;
59 entity  findchainfloat(.float _field, float match) = #27;
60 entity  findchainentity(.entity _field, entity match) = #27;
61
62 entity  findflags(entity start, .float field, float match) = #87;
63 entity  findchainflags(.float field, float match) = #88;
64
65 string  precache_file(string file) = #28;
66 string  precache_sound(string sample) = #29;
67
68 void    crash(void)     = #72;
69 void    coredump(void) = #30;
70 void    stackdump(void) = #73;
71 void    traceon(void) = #31;
72 void    traceoff(void) = #32;
73
74 void    eprint(entity e)  = #33;
75 float   rint(float f) = #34;
76 float   floor(float f)  = #35;
77 float   ceil(float f)  = #36;
78 entity  nextent(entity e)  = #37;
79 float   sin(float f)  = #38;
80 float   cos(float f)  = #39;
81 float   sqrt(float f)  = #40;
82 vector  randomvec(void)  = #41;
83
84 float   registercvar(string name, string value, float flags)  = #42; // returns 1 if success
85 float   min(float f,...)  = #43;
86 float   max(float f,...)  = #44;
87 float   bound(float min,float value, float max)  = #45;
88 float   pow(float a, float b)  = #46;
89 void    copyentity(entity src, entity dst)  = #47;
90
91 #ifdef FIXEDFOPEN
92 float   _fopen( string filename, float mode ) = #48;
93 #else
94 float   fopen(string filename, float mode)  = #48;
95 #endif
96 void    fclose(float fhandle)  = #49;
97 string  fgets(float fhandle)  = #50;
98 void    fputs(float fhandle, string s)  = #51;
99
100 float   strlen(string s)  = #52;
101 //string        strcat(string s1,string s2,...)  = #53;
102 string  strcat(string s1, ...)  = #53;
103 string  substring(string s, float start, float length)  = #54;
104
105 float(string str, string sub, float startpos) strstrofs = #221;
106 float(string s1, string s2, float len) strncmp = #228;
107 float(string s1, string s2) strcasecmp = #229;
108 float(string s1, string s2, float len) strncasecmp = #230;
109
110
111 vector  stov(string s)  = #55;
112
113 #ifdef PROFILESTRZONE
114 string  _strzone(string s)  = #56;
115 void    _strunzone(string s) = #57;
116
117 string( string s ) strzone =
118 {
119         return _strzone( s );
120 };
121
122 void( string s ) strunzone =
123 {
124         return _strunzone( s );
125 };
126 #else
127 string  strzone(string s)  = #56;
128 void    strunzone(string s) = #57;
129 #endif
130
131 float   tokenize(string s) = #58;
132 float(string s, string separator1, ...) tokenizebyseparator = #479;
133 string  argv(float n)  = #59;
134
135 float   isserver(void)  = #60;
136 float   clientcount(void)  = #61;
137 float   clientstate(void)  = #62;
138 void    clientcommand(float client, string s)  = #63;
139 void    changelevel(string map)  = #64;
140 void    localsound(string sample)  = #65;
141 vector  getmousepos(void)       = #66;
142 float   gettime(void)           = #67;
143 void    loadfromdata(string data) = #68;
144 void    loadfromfile(string file) = #69;
145
146 float   mod(float val, float m) = #70;
147
148 float   search_begin(string pattern, float caseinsensitive, float quiet) = #74;
149 void    search_end(float handle) = #75;
150 float   search_getsize(float handle) = #76;
151 string  search_getfilename(float handle, float num) = #77;
152
153 string  chr(float ascii) = #78;
154
155 float   etof(entity ent) = #79;
156 entity  ftoe(float num)  = #80;
157
158 float   validstring(string str) = #81;
159
160 float   altstr_count(string str) = #82;
161 string  altstr_prepare(string str) = #83;
162 string  altstr_get(string str, float num) = #84;
163 string  altstr_set(string str, float num, string set) = #85;
164 string  altstr_ins(string str, float num, string set) = #86;
165
166 /////////////////////////////////////////////////
167 // Write* Functions
168 /////////////////////////////////////////////////
169 void    WriteByte(float data, float dest, float desto)  = #401;
170 void    WriteChar(float data, float dest, float desto)  = #402;
171 void    WriteShort(float data, float dest, float desto) = #403;
172 void    WriteLong(float data, float dest, float desto)  = #404;
173 void    WriteAngle(float data, float dest, float desto) = #405;
174 void    WriteCoord(float data, float dest, float desto) = #406;
175 void    WriteString(string data, float dest, float desto)= #407;
176 void    WriteEntity(entity data, float dest, float desto) = #408;
177
178 //////////////////////////////////////////////////
179 // Draw funtions
180 //////////////////////////////////////////////////
181
182 float   iscachedpic(string name)        = #451;
183 string  precache_pic(string name)       = #452;
184 void    freepic(string name)            = #453;
185
186 float   drawcharacter(vector position, float character, vector scale, vector rgb, float alpha, float flag) = #454;
187
188 float   drawstring(vector position, string text, vector scale, vector rgb, float alpha, float flag) = #455;
189 float   drawcolorcodedstring(vector position, string text, vector scale, float alpha, float flag) = #467;
190 float   stringwidth(string text, float handleColors) = #468;
191
192 float   drawpic(vector position, string pic, vector size, vector rgb, float alpha, float flag) = #456;
193 float   drawsubpic(vector position, vector size, string pic, vector srcPosition, vector srcSize, vector rgb, float alpha, float flag) = #469;
194
195 float   drawfill(vector position, vector size, vector rgb, float alpha, float flag) = #457;
196
197 void    drawsetcliparea(float x, float y, float width, float height) = #458;
198
199 void    drawresetcliparea(void) = #459;
200
201 vector  drawgetimagesize(string pic) = #460;
202
203 float   cin_open(string file, string name)      = #461;
204 void    cin_close(string name)                  = #462;
205 void    cin_setstate(string name, float type)   = #463;
206 float   cin_getstate(string name)               = #464;
207
208 ////////////////////////////////////////////////
209 // Menu functions
210 ////////////////////////////////////////////////
211
212 void    setkeydest(float dest)  = #601;
213 float   getkeydest(void)        = #602;
214
215 void    setmousetarget(float trg) = #603;
216 float   getmousetarget(void)      = #604;
217
218 float   isfunction(string function_name) = #607;
219 void    callfunction(...) = #605;
220 void    writetofile(float fhandle, entity ent) = #606;
221 vector  getresolution(float number) = #608;
222 string  keynumtostring(float keynum) = #609;
223 string  findkeysforcommand(string command) = #610;
224
225 float   gethostcachevalue(float type) = #611;
226 string  gethostcachestring(float type, float hostnr) = #612;
227
228 void    parseentitydata(entity ent, string data) = #613;
229
230 float   stringtokeynum(string key) = #614;
231
232 void    resethostcachemasks(void) = #615;
233 void    sethostcachemaskstring(float mask, float fld, string str, float op) = #616;
234 void    sethostcachemasknumber(float mask, float fld, float num, float op) = #617;
235 void    resorthostcache(void) = #618;
236 void    sethostcachesort(float fld, float descending) = #619;
237 void    refreshhostcache(void) = #620;
238 float   gethostcachenumber(float fld, float hostnr) = #621;
239 float   gethostcacheindexforkey(string key) = #622;
240 void    addwantedhostcachekey(string key) = #623;
241 string  getextresponse(void) = #624;
242
243 // AK the builtin numbers may change - the code might be removed again
244 float gecko_create( string name ) = #487;
245 void gecko_destroy( string name ) = #488;
246 void gecko_navigate( string name, string URI ) = #489;
247 float gecko_keyevent( string name, float key, float eventtype ) = #490;
248 void gecko_mousemove( string name, float x, float y ) = #491;
249 void gecko_resize( string name, float w, float h ) = #492;
250 vector gecko_get_texture_extent( string name ) = #493;
251
252 //DP_QC_STRINGBUFFERS
253 //idea: ??
254 //darkplaces implementation: LordHavoc
255 //functions to manage string buffer objects - that is, arbitrary length string arrays that are handled by the engine
256 float() buf_create = #440;
257 void(float bufhandle) buf_del = #441;
258 float(float bufhandle) buf_getsize = #442;
259 void(float bufhandle_from, float bufhandle_to) buf_copy = #443;
260 void(float bufhandle, float sortpower, float backward) buf_sort = #444;
261 string(float bufhandle, string glue) buf_implode = #445;
262 string(float bufhandle, float string_index) bufstr_get = #446;
263 void(float bufhandle, float string_index, string str) bufstr_set = #447;
264 float(float bufhandle, string str, float order) bufstr_add = #448;
265 void(float bufhandle, float string_index) bufstr_free = #449;
266
267 //DP_QC_CRC16
268 //idea: div0
269 //darkplaces implementation: div0
270 //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.
271 //When caseinsensitive is set, the CRC is calculated of the lower cased string.
272 float(float caseinsensitive, string s, ...) crc16 = #494;
273
274 #ifdef FIXEDFOPEN
275 float   fopen( string filename, float mode ) =
276 {
277         local float handle;
278         if( mode == FILE_READ ) {
279                 return _fopen( filename, mode );
280         }
281
282         // check for data/
283         filename = strzone( filename );
284         if( substring( filename, 0, 5 ) != "data/" ) {
285                 print( "menu: fopen: all output must go into data/!\n" );
286                 return -1;
287         }
288         handle = _fopen( substring( filename, 5, 10000 ), mode );
289         strunzone( filename );
290         return handle;
291 };
292 #endif