]> git.xonotic.org Git - xonotic/darkplaces.git/blob - mvm_cmds.c
physics: fix and refactor unsticking
[xonotic/darkplaces.git] / mvm_cmds.c
1 #include "quakedef.h"
2
3 #include "prvm_cmds.h"
4 #include "clvm_cmds.h"
5 #include "menu.h"
6 #include "csprogs.h"
7
8 // TODO check which strings really should be engine strings
9
10 //============================================================================
11 // Menu
12
13 const char *vm_m_extensions[] = {
14 "BX_WAL_SUPPORT",
15 "DP_CINEMATIC_DPV",
16 "DP_COVERAGE",
17 "DP_CRYPTO",
18 "DP_CSQC_BINDMAPS",
19 "DP_GFX_FONTS",
20 "DP_GFX_FONTS_FREETYPE",
21 "DP_UTF8",
22 "DP_FONT_VARIABLEWIDTH",
23 "DP_MENU_EXTRESPONSEPACKET",
24 "DP_QC_ASINACOSATANATAN2TAN",
25 "DP_QC_AUTOCVARS",
26 "DP_QC_CMD",
27 "DP_QC_CRC16",
28 "DP_QC_CVAR_TYPE",
29 "DP_QC_CVAR_DESCRIPTION",
30 "DP_QC_DIGEST",
31 "DP_QC_DIGEST_SHA256",
32 "DP_QC_FINDCHAIN_TOFIELD",
33 "DP_QC_I18N",
34 "DP_QC_LOG",
35 "DP_QC_RENDER_SCENE",
36 "DP_QC_SPRINTF",
37 "DP_QC_STRFTIME",
38 "DP_QC_STRINGBUFFERS",
39 "DP_QC_STRINGBUFFERS_CVARLIST",
40 "DP_QC_STRINGBUFFERS_EXT_WIP",
41 "DP_QC_STRINGCOLORFUNCTIONS",
42 "DP_QC_STRING_CASE_FUNCTIONS",
43 "DP_QC_STRREPLACE",
44 "DP_QC_TOKENIZEBYSEPARATOR",
45 "DP_QC_TOKENIZE_CONSOLE",
46 "DP_QC_UNLIMITEDTEMPSTRINGS",
47 "DP_QC_URI_ESCAPE",
48 "DP_QC_URI_GET",
49 "DP_QC_URI_POST",
50 "DP_QC_WHICHPACK",
51 "FTE_STRINGS",
52 "DP_QC_FS_SEARCH_PACKFILE",
53 NULL
54 };
55
56 qbool MP_ConsoleCommand(const char *text, size_t textlen)
57 {
58         prvm_prog_t *prog = MVM_prog;
59         return PRVM_ConsoleCommand(prog, text, textlen, &prog->funcoffsets.GameCommand, false, -1, 0, "QC function GameCommand is missing");
60 }
61
62 /*
63 =========
64 VM_M_setmousetarget
65
66 setmousetarget(float target)
67 =========
68 */
69 static void VM_M_setmousetarget(prvm_prog_t *prog)
70 {
71         VM_SAFEPARMCOUNT(1, VM_M_setmousetarget);
72
73         switch((int)PRVM_G_FLOAT(OFS_PARM0))
74         {
75         case 1:
76                 in_client_mouse = false;
77                 break;
78         case 2:
79                 in_client_mouse = true;
80                 break;
81         default:
82                 prog->error_cmd("VM_M_setmousetarget: wrong destination %f !",PRVM_G_FLOAT(OFS_PARM0));
83         }
84 }
85
86 /*
87 =========
88 VM_M_getmousetarget
89
90 float   getmousetarget
91 =========
92 */
93 static void VM_M_getmousetarget(prvm_prog_t *prog)
94 {
95         VM_SAFEPARMCOUNT(0,VM_M_getmousetarget);
96
97         if(in_client_mouse)
98                 PRVM_G_FLOAT(OFS_RETURN) = 2;
99         else
100                 PRVM_G_FLOAT(OFS_RETURN) = 1;
101 }
102
103
104
105 /*
106 =========
107 VM_M_setkeydest
108
109 setkeydest(float dest)
110 =========
111 */
112 static void VM_M_setkeydest(prvm_prog_t *prog)
113 {
114         VM_SAFEPARMCOUNT(1,VM_M_setkeydest);
115
116         switch((int)PRVM_G_FLOAT(OFS_PARM0))
117         {
118         case 0:
119                 // key_game
120                 key_dest = key_game;
121                 break;
122         case 2:
123                 // key_menu
124                 key_dest = key_menu;
125                 break;
126         case 3:
127                 // key_menu_grabbed
128                 key_dest = key_menu_grabbed;
129                 break;
130         case 1:
131                 // key_message
132                 // key_dest = key_message
133                 // break;
134         default:
135                 prog->error_cmd("VM_M_setkeydest: wrong destination %f !", PRVM_G_FLOAT(OFS_PARM0));
136         }
137 }
138
139 /*
140 =========
141 VM_M_getkeydest
142
143 float   getkeydest
144 =========
145 */
146 static void VM_M_getkeydest(prvm_prog_t *prog)
147 {
148         VM_SAFEPARMCOUNT(0,VM_M_getkeydest);
149
150         // key_game = 0, key_message = 1, key_menu = 2, key_menu_grabbed = 3, unknown = -1
151         switch(key_dest)
152         {
153         case key_game:
154                 PRVM_G_FLOAT(OFS_RETURN) = 0;
155                 break;
156         case key_menu:
157                 PRVM_G_FLOAT(OFS_RETURN) = 2;
158                 break;
159         case key_menu_grabbed:
160                 PRVM_G_FLOAT(OFS_RETURN) = 3;
161                 break;
162         case key_message:
163                 // not supported
164                 // PRVM_G_FLOAT(OFS_RETURN) = 1;
165                 // break;
166         default:
167                 PRVM_G_FLOAT(OFS_RETURN) = -1;
168         }
169 }
170
171
172 /*
173 =========
174 VM_M_getresolution
175
176 vector  getresolution(float number)
177 =========
178 */
179 static void VM_M_getresolution(prvm_prog_t *prog)
180 {
181         int nr, fs;
182         VM_SAFEPARMCOUNTRANGE(1, 2, VM_M_getresolution);
183
184         nr = (int)PRVM_G_FLOAT(OFS_PARM0);
185
186         fs = ((prog->argc <= 1) || ((int)PRVM_G_FLOAT(OFS_PARM1)));
187
188         if(nr < -1 || nr >= (fs ? video_resolutions_count : video_resolutions_hardcoded_count))
189         {
190                 PRVM_G_VECTOR(OFS_RETURN)[0] = 0;
191                 PRVM_G_VECTOR(OFS_RETURN)[1] = 0;
192                 PRVM_G_VECTOR(OFS_RETURN)[2] = 0;
193         }
194         else if(nr == -1)
195         {
196                 vid_mode_t m = VID_GetDesktopMode();
197                 PRVM_G_VECTOR(OFS_RETURN)[0] = m.width;
198                 PRVM_G_VECTOR(OFS_RETURN)[1] = m.height;
199                 PRVM_G_VECTOR(OFS_RETURN)[2] = m.pixelheight_num / (prvm_vec_t) m.pixelheight_denom;
200         }
201         else
202         {
203                 video_resolution_t *r = &((fs ? video_resolutions : video_resolutions_hardcoded)[nr]);
204                 PRVM_G_VECTOR(OFS_RETURN)[0] = r->width;
205                 PRVM_G_VECTOR(OFS_RETURN)[1] = r->height;
206                 PRVM_G_VECTOR(OFS_RETURN)[2] = r->pixelheight;
207         }
208 }
209
210 static void VM_M_getgamedirinfo(prvm_prog_t *prog)
211 {
212         int nr, item;
213         VM_SAFEPARMCOUNT(2, VM_getgamedirinfo);
214
215         nr = (int)PRVM_G_FLOAT(OFS_PARM0);
216         item = (int)PRVM_G_FLOAT(OFS_PARM1);
217
218         PRVM_G_INT( OFS_RETURN ) = OFS_NULL;
219
220         if(nr >= 0 && nr < fs_all_gamedirs_count)
221         {
222                 if(item == 0)
223                         PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, fs_all_gamedirs[nr].name, strlen(fs_all_gamedirs[nr].name));
224                 else if(item == 1)
225                         PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, fs_all_gamedirs[nr].description, strlen(fs_all_gamedirs[nr].description));
226         }
227 }
228
229 /*
230 =========
231 VM_M_getserverliststat
232
233 float   getserverliststat(float type)
234 =========
235 */
236 /*
237         type:
238 0       serverlist_viewcount
239 1   serverlist_totalcount
240 2       masterquerycount
241 3       masterreplycount
242 4       serverquerycount
243 5       serverreplycount
244 6       sortfield
245 7       sortflags
246 */
247 static void VM_M_getserverliststat(prvm_prog_t *prog)
248 {
249         int type;
250         VM_SAFEPARMCOUNT ( 1, VM_M_getserverliststat );
251
252         PRVM_G_FLOAT( OFS_RETURN ) = 0;
253
254         type = (int)PRVM_G_FLOAT( OFS_PARM0 );
255         switch(type)
256         {
257         case 0:
258                 PRVM_G_FLOAT ( OFS_RETURN ) = serverlist_viewcount;
259                 return;
260         case 1:
261                 PRVM_G_FLOAT ( OFS_RETURN ) = serverlist_cachecount;
262                 return;
263         case 2:
264                 PRVM_G_FLOAT ( OFS_RETURN ) = masterquerycount;
265                 return;
266         case 3:
267                 PRVM_G_FLOAT ( OFS_RETURN ) = masterreplycount;
268                 return;
269         case 4:
270                 PRVM_G_FLOAT ( OFS_RETURN ) = serverquerycount;
271                 return;
272         case 5:
273                 PRVM_G_FLOAT ( OFS_RETURN ) = serverreplycount;
274                 return;
275         case 6:
276                 PRVM_G_FLOAT ( OFS_RETURN ) = serverlist_sortbyfield;
277                 return;
278         case 7:
279                 PRVM_G_FLOAT ( OFS_RETURN ) = serverlist_sortflags;
280                 return;
281         default:
282                 VM_Warning(prog, "VM_M_getserverliststat: bad type %i!\n", type );
283         }
284 }
285
286 /*
287 ========================
288 VM_M_resetserverlistmasks
289
290 resetserverlistmasks()
291 ========================
292 */
293 static void VM_M_resetserverlistmasks(prvm_prog_t *prog)
294 {
295         VM_SAFEPARMCOUNT(0, VM_M_resetserverlistmasks);
296         ServerList_ResetMasks();
297 }
298
299
300 /*
301 ========================
302 VM_M_setserverlistmaskstring
303
304 setserverlistmaskstring(float mask, float fld, string str, float op)
305 0-511           and
306 512 - 1024      or
307 ========================
308 */
309 static void VM_M_setserverlistmaskstring(prvm_prog_t *prog)
310 {
311         const char *str;
312         int masknr;
313         serverlist_mask_t *mask;
314         int field;
315
316         VM_SAFEPARMCOUNT( 4, VM_M_setserverlistmaskstring );
317         str = PRVM_G_STRING( OFS_PARM2 );
318
319         masknr = (int)PRVM_G_FLOAT( OFS_PARM0 );
320         if( masknr >= 0 && masknr < SERVERLIST_ANDMASKCOUNT )
321                 mask = &serverlist_andmasks[masknr];
322         else if( masknr >= 512 && masknr - 512 < SERVERLIST_ORMASKCOUNT )
323                 mask = &serverlist_ormasks[masknr - 512 ];
324         else
325         {
326                 VM_Warning(prog, "VM_M_setserverlistmaskstring: invalid mask number %i\n", masknr );
327                 return;
328         }
329
330         field = (int) PRVM_G_FLOAT( OFS_PARM1 );
331
332         switch( field ) {
333                 case SLIF_CNAME:
334                         mask->info.cname_len = dp_strlcpy(mask->info.cname, str, sizeof(mask->info.cname));
335                         break;
336                 case SLIF_NAME:
337                         mask->info.name_len = dp_strlcpy(mask->info.name, str, sizeof(mask->info.name));
338                         break;
339                 case SLIF_QCSTATUS:
340                         mask->info.qcstatus_len = dp_strlcpy(mask->info.qcstatus, str, sizeof(mask->info.qcstatus));
341                         break;
342                 case SLIF_PLAYERS:
343                         mask->info.players_len = dp_strlcpy(mask->info.players, str, sizeof(mask->info.players));
344                         break;
345                 case SLIF_MAP:
346                         mask->info.map_len = dp_strlcpy(mask->info.map, str, sizeof(mask->info.map));
347                         break;
348                 case SLIF_MOD:
349                         mask->info.mod_len = dp_strlcpy(mask->info.mod, str, sizeof(mask->info.mod));
350                         break;
351                 case SLIF_GAME:
352                         mask->info.game_len = dp_strlcpy(mask->info.game, str, sizeof(mask->info.game));
353                         break;
354                 default:
355                         VM_Warning(prog, "VM_M_setserverlistmaskstring: Bad field number %i passed!\n", field );
356                         return;
357         }
358
359         mask->active = true;
360         mask->tests[field] = (serverlist_maskop_t)((int)PRVM_G_FLOAT( OFS_PARM3 ));
361 }
362
363 /*
364 ========================
365 VM_M_setserverlistmasknumber
366
367 setserverlistmasknumber(float mask, float fld, float num, float op)
368
369 0-511           and
370 512 - 1024      or
371 ========================
372 */
373 static void VM_M_setserverlistmasknumber(prvm_prog_t *prog)
374 {
375         int number;
376         serverlist_mask_t *mask;
377         int     masknr;
378         int field;
379         VM_SAFEPARMCOUNT( 4, VM_M_setserverlistmasknumber );
380
381         masknr = (int)PRVM_G_FLOAT( OFS_PARM0 );
382         if( masknr >= 0 && masknr < SERVERLIST_ANDMASKCOUNT )
383                 mask = &serverlist_andmasks[masknr];
384         else if( masknr >= 512 && masknr - 512 < SERVERLIST_ORMASKCOUNT )
385                 mask = &serverlist_ormasks[masknr - 512 ];
386         else
387         {
388                 VM_Warning(prog, "VM_M_setserverlistmasknumber: invalid mask number %i\n", masknr );
389                 return;
390         }
391
392         number = (int)PRVM_G_FLOAT( OFS_PARM2 );
393         field = (int) PRVM_G_FLOAT( OFS_PARM1 );
394
395         switch( field ) {
396                 case SLIF_MAXPLAYERS:
397                         mask->info.maxplayers = number;
398                         break;
399                 case SLIF_NUMPLAYERS:
400                         mask->info.numplayers = number;
401                         break;
402                 case SLIF_NUMBOTS:
403                         mask->info.numbots = number;
404                         break;
405                 case SLIF_NUMHUMANS:
406                         mask->info.numhumans = number;
407                         break;
408                 case SLIF_PING:
409                         mask->info.ping = number;
410                         break;
411                 case SLIF_PROTOCOL:
412                         mask->info.protocol = number;
413                         break;
414                 case SLIF_FREESLOTS:
415                         mask->info.freeslots = number;
416                         break;
417                 case SLIF_CATEGORY:
418                         mask->info.category = number;
419                         break;
420                 case SLIF_ISFAVORITE:
421                         mask->info.isfavorite = number != 0;
422                         break;
423                 default:
424                         VM_Warning(prog, "VM_M_setserverlistmasknumber: Bad field number %i passed!\n", field );
425                         return;
426         }
427
428         mask->active = true;
429         mask->tests[field] = (serverlist_maskop_t)((int)PRVM_G_FLOAT( OFS_PARM3 ));
430 }
431
432
433 /*
434 ========================
435 VM_M_resortserverlist
436
437 resortserverlist
438 ========================
439 */
440 static void VM_M_resortserverlist(prvm_prog_t *prog)
441 {
442         VM_SAFEPARMCOUNT(0, VM_M_resortserverlist);
443         ServerList_RebuildViewList(NULL);
444 }
445
446 /*
447 =========
448 VM_M_getserverliststring
449
450 string  getserverliststring(float field, float hostnr)
451 =========
452 */
453 static void VM_M_getserverliststring(prvm_prog_t *prog)
454 {
455         const serverlist_entry_t *cache;
456         int hostnr;
457
458         VM_SAFEPARMCOUNT(2, VM_M_getserverliststring);
459
460         PRVM_G_INT(OFS_RETURN) = OFS_NULL;
461
462         hostnr = (int)PRVM_G_FLOAT(OFS_PARM1);
463
464         if(hostnr == -1 && serverlist_callbackentry)
465         {
466                 cache = serverlist_callbackentry;
467         }
468         else
469         {
470                 if(hostnr < 0 || (unsigned)hostnr >= serverlist_viewcount)
471                 {
472                         Con_Print("VM_M_getserverliststring: bad hostnr passed!\n");
473                         return;
474                 }
475                 cache = ServerList_GetViewEntry(hostnr);
476         }
477         switch( (int) PRVM_G_FLOAT(OFS_PARM0) ) {
478                 case SLIF_CNAME:
479                         PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, cache->info.cname, cache->info.cname_len);
480                         break;
481                 case SLIF_NAME:
482                         PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, cache->info.name, cache->info.name_len);
483                         break;
484                 case SLIF_QCSTATUS:
485                         PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, cache->info.qcstatus, cache->info.qcstatus_len);
486                         break;
487                 case SLIF_PLAYERS:
488                         PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, cache->info.players, cache->info.players_len);
489                         break;
490                 case SLIF_GAME:
491                         PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, cache->info.game, cache->info.game_len);
492                         break;
493                 case SLIF_MOD:
494                         PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, cache->info.mod, cache->info.mod_len);
495                         break;
496                 case SLIF_MAP:
497                         PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, cache->info.map, cache->info.map_len);
498                         break;
499                 // TODO remove this again
500                 case 1024:
501                         PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, cache->line1, cache->line1_len);
502                         break;
503                 case 1025:
504                         PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, cache->line2, cache->line2_len);
505                         break;
506                 default:
507                         Con_Print("VM_M_getserverliststring: bad field number passed!\n");
508         }
509 }
510
511 /*
512 =========
513 VM_M_getserverlistnumber
514
515 float   getserverlistnumber(float field, float hostnr)
516 =========
517 */
518 static void VM_M_getserverlistnumber(prvm_prog_t *prog)
519 {
520         const serverlist_entry_t *cache;
521         int hostnr;
522
523         VM_SAFEPARMCOUNT(2, VM_M_getserverlistnumber);
524
525         PRVM_G_INT(OFS_RETURN) = OFS_NULL;
526
527         hostnr = (int)PRVM_G_FLOAT(OFS_PARM1);
528
529         if(hostnr == -1 && serverlist_callbackentry)
530         {
531                 cache = serverlist_callbackentry;
532         }
533         else
534         {
535                 if(hostnr < 0 || (unsigned)hostnr >= serverlist_viewcount)
536                 {
537                         Con_Print("VM_M_getserverliststring: bad hostnr passed!\n");
538                         return;
539                 }
540                 cache = ServerList_GetViewEntry(hostnr);
541         }
542         switch( (int) PRVM_G_FLOAT(OFS_PARM0) ) {
543                 case SLIF_MAXPLAYERS:
544                         PRVM_G_FLOAT( OFS_RETURN ) = cache->info.maxplayers;
545                         break;
546                 case SLIF_NUMPLAYERS:
547                         PRVM_G_FLOAT( OFS_RETURN ) = cache->info.numplayers;
548                         break;
549                 case SLIF_NUMBOTS:
550                         PRVM_G_FLOAT( OFS_RETURN ) = cache->info.numbots;
551                         break;
552                 case SLIF_NUMHUMANS:
553                         PRVM_G_FLOAT( OFS_RETURN ) = cache->info.numhumans;
554                         break;
555                 case SLIF_FREESLOTS:
556                         PRVM_G_FLOAT( OFS_RETURN ) = cache->info.freeslots;
557                         break;
558                 case SLIF_PING:
559                         // display inf when a listed server times out and net_slist_pause blocks its removal
560                         PRVM_G_FLOAT( OFS_RETURN ) = cache->info.ping ? cache->info.ping : INFINITY;
561                         break;
562                 case SLIF_PROTOCOL:
563                         PRVM_G_FLOAT( OFS_RETURN ) = cache->info.protocol;
564                         break;
565                 case SLIF_CATEGORY:
566                         PRVM_G_FLOAT( OFS_RETURN ) = cache->info.category;
567                         break;
568                 case SLIF_ISFAVORITE:
569                         PRVM_G_FLOAT( OFS_RETURN ) = cache->info.isfavorite;
570                         break;
571                 default:
572                         Con_Print("VM_M_getserverlistnumber: bad field number passed!\n");
573         }
574 }
575
576 /*
577 ========================
578 VM_M_setserverlistsort
579
580 setserverlistsort(float field, float flags)
581 ========================
582 */
583 static void VM_M_setserverlistsort(prvm_prog_t *prog)
584 {
585         VM_SAFEPARMCOUNT( 2, VM_M_setserverlistsort );
586
587         serverlist_sortbyfield = (serverlist_infofield_t)((int)PRVM_G_FLOAT( OFS_PARM0 ));
588         serverlist_sortflags = (int) PRVM_G_FLOAT( OFS_PARM1 );
589 }
590
591 /*
592 ========================
593 VM_M_refreshserverlist
594
595 refreshserverlist()
596 ========================
597 */
598 static void VM_M_refreshserverlist(prvm_prog_t *prog)
599 {
600         qbool do_reset = false;
601         VM_SAFEPARMCOUNTRANGE( 0, 1, VM_M_refreshserverlist );
602         if (prog->argc >= 1 && PRVM_G_FLOAT(OFS_PARM0))
603                 do_reset = true;
604         ServerList_QueryList(do_reset, true, false, false);
605 }
606
607 /*
608 ========================
609 VM_M_getserverlistindexforkey
610
611 float getserverlistindexforkey(string key)
612 ========================
613 */
614 static void VM_M_getserverlistindexforkey(prvm_prog_t *prog)
615 {
616         const char *key;
617         VM_SAFEPARMCOUNT( 1, VM_M_getserverlistindexforkey );
618
619         key = PRVM_G_STRING( OFS_PARM0 );
620         VM_CheckEmptyString( prog, key );
621
622         if( !strcmp( key, "cname" ) )
623                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_CNAME;
624         else if( !strcmp( key, "ping" ) )
625                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_PING;
626         else if( !strcmp( key, "game" ) )
627                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_GAME;
628         else if( !strcmp( key, "mod" ) )
629                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_MOD;
630         else if( !strcmp( key, "map" ) )
631                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_MAP;
632         else if( !strcmp( key, "name" ) )
633                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_NAME;
634         else if( !strcmp( key, "qcstatus" ) )
635                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_QCSTATUS;
636         else if( !strcmp( key, "players" ) )
637                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_PLAYERS;
638         else if( !strcmp( key, "maxplayers" ) )
639                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_MAXPLAYERS;
640         else if( !strcmp( key, "numplayers" ) )
641                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_NUMPLAYERS;
642         else if( !strcmp( key, "numbots" ) )
643                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_NUMBOTS;
644         else if( !strcmp( key, "numhumans" ) )
645                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_NUMHUMANS;
646         else if( !strcmp( key, "freeslots" ) )
647                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_FREESLOTS;
648         else if( !strcmp( key, "protocol" ) )
649                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_PROTOCOL;
650         else if( !strcmp( key, "category" ) )
651                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_CATEGORY;
652         else if( !strcmp( key, "isfavorite" ) )
653                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_ISFAVORITE;
654         else
655                 PRVM_G_FLOAT( OFS_RETURN ) = -1;
656 }
657
658 /*
659 ========================
660 VM_M_addwantedserverlistkey
661
662 addwantedserverlistkey(string key)
663 ========================
664 */
665 static void VM_M_addwantedserverlistkey(prvm_prog_t *prog)
666 {
667         VM_SAFEPARMCOUNT( 1, VM_M_addwantedserverlistkey );
668 }
669
670 /*
671 ===============================================================================
672 MESSAGE WRITING
673
674 used only for client and menu
675 server uses VM_SV_...
676
677 Write*(* data, float type, float to)
678
679 ===============================================================================
680 */
681
682 #define MSG_BROADCAST   0               // unreliable to all
683 #define MSG_ONE                 1               // reliable to one (msg_entity)
684 #define MSG_ALL                 2               // reliable to all
685 #define MSG_INIT                3               // write to the init string
686
687 static sizebuf_t *VM_M_WriteDest (prvm_prog_t *prog)
688 {
689         int             dest;
690         int             destclient;
691
692         if(!sv.active)
693                 prog->error_cmd("VM_M_WriteDest: game is not server (%s)", prog->name);
694
695         dest = (int)PRVM_G_FLOAT(OFS_PARM1);
696         switch (dest)
697         {
698         case MSG_BROADCAST:
699                 return &sv.datagram;
700
701         case MSG_ONE:
702                 destclient = (int) PRVM_G_FLOAT(OFS_PARM2);
703                 if (destclient < 0 || destclient >= svs.maxclients || !svs.clients[destclient].active || !svs.clients[destclient].netconnection)
704                         prog->error_cmd("VM_clientcommand: %s: invalid client !", prog->name);
705
706                 return &svs.clients[destclient].netconnection->message;
707
708         case MSG_ALL:
709                 return &sv.reliable_datagram;
710
711         case MSG_INIT:
712                 return &sv.signon;
713
714         default:
715                 prog->error_cmd("WriteDest: bad destination");
716                 break;
717         }
718
719         return NULL;
720 }
721
722 static void VM_M_WriteByte (prvm_prog_t *prog)
723 {
724         VM_SAFEPARMCOUNT(1, VM_M_WriteByte);
725         MSG_WriteByte (VM_M_WriteDest(prog), (int)PRVM_G_FLOAT(OFS_PARM0));
726 }
727
728 static void VM_M_WriteChar (prvm_prog_t *prog)
729 {
730         VM_SAFEPARMCOUNT(1, VM_M_WriteChar);
731         MSG_WriteChar (VM_M_WriteDest(prog), (int)PRVM_G_FLOAT(OFS_PARM0));
732 }
733
734 static void VM_M_WriteShort (prvm_prog_t *prog)
735 {
736         VM_SAFEPARMCOUNT(1, VM_M_WriteShort);
737         MSG_WriteShort (VM_M_WriteDest(prog), (int)PRVM_G_FLOAT(OFS_PARM0));
738 }
739
740 static void VM_M_WriteLong (prvm_prog_t *prog)
741 {
742         VM_SAFEPARMCOUNT(1, VM_M_WriteLong);
743         MSG_WriteLong (VM_M_WriteDest(prog), (int)PRVM_G_FLOAT(OFS_PARM0));
744 }
745
746 static void VM_M_WriteAngle (prvm_prog_t *prog)
747 {
748         VM_SAFEPARMCOUNT(1, VM_M_WriteAngle);
749         MSG_WriteAngle (VM_M_WriteDest(prog), PRVM_G_FLOAT(OFS_PARM0), sv.protocol);
750 }
751
752 static void VM_M_WriteCoord (prvm_prog_t *prog)
753 {
754         VM_SAFEPARMCOUNT(1, VM_M_WriteCoord);
755         MSG_WriteCoord (VM_M_WriteDest(prog), PRVM_G_FLOAT(OFS_PARM0), sv.protocol);
756 }
757
758 static void VM_M_WriteString (prvm_prog_t *prog)
759 {
760         VM_SAFEPARMCOUNT(1, VM_M_WriteString);
761         MSG_WriteString (VM_M_WriteDest(prog), PRVM_G_STRING(OFS_PARM0));
762 }
763
764 static void VM_M_WriteEntity (prvm_prog_t *prog)
765 {
766         VM_SAFEPARMCOUNT(1, VM_M_WriteEntity);
767         MSG_WriteShort (VM_M_WriteDest(prog), PRVM_G_EDICTNUM(OFS_PARM0));
768 }
769
770 /*
771 =================
772 VM_M_copyentity
773
774 copies data from one entity to another
775
776 copyentity(entity src, entity dst)
777 =================
778 */
779 static void VM_M_copyentity (prvm_prog_t *prog)
780 {
781         prvm_edict_t *in, *out;
782         VM_SAFEPARMCOUNT(2,VM_M_copyentity);
783         in = PRVM_G_EDICT(OFS_PARM0);
784         out = PRVM_G_EDICT(OFS_PARM1);
785         memcpy(out->fields.fp, in->fields.fp, prog->entityfields * sizeof(prvm_vec_t));
786 }
787
788 //#66 vector() getmousepos (EXT_CSQC)
789 static void VM_M_getmousepos(prvm_prog_t *prog)
790 {
791         VM_SAFEPARMCOUNT(0,VM_M_getmousepos);
792
793         if (key_consoleactive || (key_dest != key_menu && key_dest != key_menu_grabbed))
794                 VectorSet(PRVM_G_VECTOR(OFS_RETURN), 0, 0, 0);
795         else if (in_client_mouse)
796                 VectorSet(PRVM_G_VECTOR(OFS_RETURN), in_windowmouse_x * vid_conwidth.integer / vid.width, in_windowmouse_y * vid_conheight.integer / vid.height, 0);
797         else
798                 VectorSet(PRVM_G_VECTOR(OFS_RETURN), in_mouse_x * vid_conwidth.integer / vid.width, in_mouse_y * vid_conheight.integer / vid.height, 0);
799 }
800
801 static void VM_M_crypto_getkeyfp(prvm_prog_t *prog)
802 {
803         lhnetaddress_t addr;
804         const char *s;
805         char keyfp[FP64_SIZE + 1];
806
807         VM_SAFEPARMCOUNT(1,VM_M_crypto_getkeyfp);
808
809         s = PRVM_G_STRING( OFS_PARM0 );
810         VM_CheckEmptyString( prog, s );
811
812         if(LHNETADDRESS_FromString(&addr, s, 26000) && Crypto_RetrieveHostKey(&addr, NULL, keyfp, sizeof(keyfp), NULL, 0, NULL, NULL))
813                 PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, keyfp, strlen(keyfp));
814         else
815                 PRVM_G_INT( OFS_RETURN ) = OFS_NULL;
816 }
817 static void VM_M_crypto_getidfp(prvm_prog_t *prog)
818 {
819         lhnetaddress_t addr;
820         const char *s;
821         char idfp[FP64_SIZE + 1];
822
823         VM_SAFEPARMCOUNT(1,VM_M_crypto_getidfp);
824
825         s = PRVM_G_STRING( OFS_PARM0 );
826         VM_CheckEmptyString( prog, s );
827
828         if(LHNETADDRESS_FromString(&addr, s, 26000) && Crypto_RetrieveHostKey(&addr, NULL, NULL, 0, idfp, sizeof(idfp), NULL, NULL))
829                 PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString( prog, idfp, strlen(idfp));
830         else
831                 PRVM_G_INT( OFS_RETURN ) = OFS_NULL;
832 }
833 static void VM_M_crypto_getidstatus(prvm_prog_t *prog)
834 {
835         lhnetaddress_t addr;
836         const char *s;
837         qbool issigned;
838
839         VM_SAFEPARMCOUNT(1,VM_M_crypto_getidstatus);
840
841         s = PRVM_G_STRING( OFS_PARM0 );
842         VM_CheckEmptyString( prog, s );
843
844         if(LHNETADDRESS_FromString(&addr, s, 26000) && Crypto_RetrieveHostKey(&addr, NULL, NULL, 0, NULL, 0, NULL, &issigned))
845                 PRVM_G_FLOAT( OFS_RETURN ) = issigned ? 2 : 1;
846         else
847                 PRVM_G_FLOAT( OFS_RETURN ) = 0;
848 }
849 static void VM_M_crypto_getencryptlevel(prvm_prog_t *prog)
850 {
851         lhnetaddress_t addr;
852         const char *s;
853         int aeslevel;
854         char vabuf[1024];
855
856         VM_SAFEPARMCOUNT(1,VM_M_crypto_getencryptlevel);
857
858         s = PRVM_G_STRING( OFS_PARM0 );
859         VM_CheckEmptyString( prog, s );
860
861         if(LHNETADDRESS_FromString(&addr, s, 26000) && Crypto_RetrieveHostKey(&addr, NULL, NULL, 0, NULL, 0, &aeslevel, NULL))
862         {
863                 if (aeslevel)
864                 {
865                         size_t vabuf_len = dpsnprintf(vabuf, sizeof(vabuf), "%d AES128", aeslevel);
866                         PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, vabuf, vabuf_len);
867                 }
868                 else
869                         PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, "0", 1);
870         }
871         else
872                 PRVM_G_INT( OFS_RETURN ) = OFS_NULL;
873 }
874 static void VM_M_crypto_getmykeyfp(prvm_prog_t *prog)
875 {
876         int i;
877         char keyfp[FP64_SIZE + 1];
878
879         VM_SAFEPARMCOUNT(1, VM_M_crypto_getmykeyfp);
880
881         i = PRVM_G_FLOAT( OFS_PARM0 );
882         switch(Crypto_RetrieveLocalKey(i, keyfp, sizeof(keyfp), NULL, 0, NULL))
883         {
884                 case -1:
885                         PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString(prog, "", 0);
886                         break;
887                 case 0:
888                         PRVM_G_INT( OFS_RETURN ) = OFS_NULL;
889                         break;
890                 default:
891                 case 1:
892                         PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString(prog, keyfp, strlen(keyfp));
893                         break;
894         }
895 }
896 static void VM_M_crypto_getmyidfp(prvm_prog_t *prog)
897 {
898         int i;
899         char idfp[FP64_SIZE + 1];
900
901         VM_SAFEPARMCOUNT(1, VM_M_crypto_getmyidfp);
902
903         i = PRVM_G_FLOAT( OFS_PARM0 );
904         switch(Crypto_RetrieveLocalKey(i, NULL, 0, idfp, sizeof(idfp), NULL))
905         {
906                 case -1:
907                         PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString(prog, "", 0);
908                         break;
909                 case 0:
910                         PRVM_G_INT( OFS_RETURN ) = OFS_NULL;
911                         break;
912                 default:
913                 case 1:
914                         PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString(prog, idfp, strlen(idfp));
915                         break;
916         }
917 }
918 static void VM_M_crypto_getmyidstatus(prvm_prog_t *prog)
919 {
920         int i;
921         qbool issigned;
922
923         VM_SAFEPARMCOUNT(1, VM_M_crypto_getmyidstatus);
924
925         i = PRVM_G_FLOAT( OFS_PARM0 );
926         switch(Crypto_RetrieveLocalKey(i, NULL, 0, NULL, 0, &issigned))
927         {
928                 case -1:
929                         PRVM_G_FLOAT( OFS_RETURN ) = 0; // have no ID there
930                         break;
931                 case 0:
932                         PRVM_G_FLOAT( OFS_RETURN ) = -1; // out of range
933                         break;
934                 default:
935                 case 1:
936                         PRVM_G_FLOAT( OFS_RETURN ) = issigned ? 2 : 1;
937                         break;
938         }
939 }
940
941 // CL_Video interface functions
942
943 /*
944 ========================
945 VM_cin_open
946
947 float cin_open(string file, string name)
948 ========================
949 */
950 void VM_cin_open(prvm_prog_t *prog)
951 {
952         const char *file;
953         const char *name;
954
955         VM_SAFEPARMCOUNT( 2, VM_cin_open );
956
957         file = PRVM_G_STRING( OFS_PARM0 );
958         name = PRVM_G_STRING( OFS_PARM1 );
959
960         VM_CheckEmptyString(prog,  file );
961     VM_CheckEmptyString(prog,  name );
962
963         if( CL_OpenVideo( file, name, MENUOWNER, "" ) )
964                 PRVM_G_FLOAT( OFS_RETURN ) = 1;
965         else
966                 PRVM_G_FLOAT( OFS_RETURN ) = 0;
967 }
968
969 /*
970 ========================
971 VM_cin_close
972
973 void cin_close(string name)
974 ========================
975 */
976 void VM_cin_close(prvm_prog_t *prog)
977 {
978         const char *name;
979
980         VM_SAFEPARMCOUNT( 1, VM_cin_close );
981
982         name = PRVM_G_STRING( OFS_PARM0 );
983         VM_CheckEmptyString(prog,  name );
984
985         CL_CloseVideo( CL_GetVideoByName( name ) );
986 }
987
988 /*
989 ========================
990 VM_cin_setstate
991 void cin_setstate(string name, float type)
992 ========================
993 */
994 void VM_cin_setstate(prvm_prog_t *prog)
995 {
996         const char *name;
997         clvideostate_t  state;
998         clvideo_t               *video;
999
1000         VM_SAFEPARMCOUNT( 2, VM_cin_setstate );
1001
1002         name = PRVM_G_STRING( OFS_PARM0 );
1003         VM_CheckEmptyString(prog,  name );
1004
1005         state = (clvideostate_t)((int)PRVM_G_FLOAT( OFS_PARM1 ));
1006
1007         video = CL_GetVideoByName( name );
1008         if( video && state > CLVIDEO_UNUSED && state < CLVIDEO_STATECOUNT )
1009                 CL_SetVideoState( video, state );
1010 }
1011
1012 /*
1013 ========================
1014 VM_cin_getstate
1015
1016 float cin_getstate(string name)
1017 ========================
1018 */
1019 void VM_cin_getstate(prvm_prog_t *prog)
1020 {
1021         const char *name;
1022         clvideo_t               *video;
1023
1024         VM_SAFEPARMCOUNT( 1, VM_cin_getstate );
1025
1026         name = PRVM_G_STRING( OFS_PARM0 );
1027         VM_CheckEmptyString(prog,  name );
1028
1029         video = CL_GetVideoByName( name );
1030         if( video )
1031                 PRVM_G_FLOAT( OFS_RETURN ) = (int)video->state;
1032         else
1033                 PRVM_G_FLOAT( OFS_RETURN ) = 0;
1034 }
1035
1036 /*
1037 ========================
1038 VM_cin_restart
1039
1040 void cin_restart(string name)
1041 ========================
1042 */
1043 void VM_cin_restart(prvm_prog_t *prog)
1044 {
1045         const char *name;
1046         clvideo_t               *video;
1047
1048         VM_SAFEPARMCOUNT( 1, VM_cin_restart );
1049
1050         name = PRVM_G_STRING( OFS_PARM0 );
1051         VM_CheckEmptyString(prog,  name );
1052
1053         video = CL_GetVideoByName( name );
1054         if( video )
1055                 CL_RestartVideo( video );
1056 }
1057
1058 static void VM_M_registercommand(prvm_prog_t *prog)
1059 {
1060         VM_SAFEPARMCOUNT(1, VM_M_registercommand);
1061         Cmd_AddCommand(CF_CLIENT, PRVM_G_STRING(OFS_PARM0), NULL, "console command created by QuakeC");
1062 }
1063
1064 prvm_builtin_t vm_m_builtins[] = {
1065 NULL,                                                                   //   #0 NULL function (not callable)
1066 VM_checkextension,                              //   #1
1067 VM_error,                                                       //   #2
1068 VM_objerror,                                            //   #3
1069 VM_print,                                                       //   #4
1070 VM_bprint,                                                      //   #5
1071 VM_sprint,                                                      //   #6
1072 VM_centerprint,                                 //   #7
1073 VM_normalize,                                           //   #8
1074 VM_vlen,                                                                //   #9
1075 VM_vectoyaw,                                            //  #10
1076 VM_vectoangles,                                 //  #11
1077 VM_random,                                                      //  #12
1078 VM_localcmd_local,                                              //  #13
1079 VM_cvar,                                                                //  #14
1080 VM_cvar_set,                                            //  #15
1081 VM_dprint,                                                      //  #16
1082 VM_ftos,                                                                //  #17
1083 VM_fabs,                                                                //  #18
1084 VM_vtos,                                                                //  #19
1085 VM_etos,                                                                //  #20
1086 VM_stof,                                                                //  #21
1087 VM_spawn,                                                       //  #22
1088 VM_remove,                                                      //  #23
1089 VM_find,                                                                //  #24
1090 VM_findfloat,                                           //  #25
1091 VM_findchain,                                           //  #26
1092 VM_findchainfloat,                              //  #27
1093 VM_precache_file,                                       //  #28
1094 VM_precache_sound,                              //  #29
1095 VM_coredump,                                            //  #30
1096 VM_traceon,                                                     //  #31
1097 VM_traceoff,                                            //  #32
1098 VM_eprint,                                                      //  #33
1099 VM_rint,                                                                //  #34
1100 VM_floor,                                                       //  #35
1101 VM_ceil,                                                                //  #36
1102 VM_nextent,                                                     //  #37
1103 VM_sin,                                                         //  #38
1104 VM_cos,                                                         //  #39
1105 VM_sqrt,                                                                //  #40
1106 VM_randomvec,                                           //  #41
1107 VM_registercvar,                                        //  #42
1108 VM_min,                                                         //  #43
1109 VM_max,                                                         //  #44
1110 VM_bound,                                                       //  #45
1111 VM_pow,                                                         //  #46
1112 VM_M_copyentity,                                        //  #47
1113 VM_fopen,                                                       //  #48
1114 VM_fclose,                                                      //  #49
1115 VM_fgets,                                                       //  #50
1116 VM_fputs,                                                       //  #51
1117 VM_strlen,                                                      //  #52
1118 VM_strcat,                                                      //  #53
1119 VM_substring,                                           //  #54
1120 VM_stov,                                                                //  #55
1121 VM_strzone,                                                     //  #56
1122 VM_strunzone,                                           //  #57
1123 VM_tokenize,                                            //  #58
1124 VM_argv,                                                                //  #59
1125 VM_isserver,                                            //  #60
1126 VM_clientcount,                                 //  #61
1127 VM_clientstate,                                 //  #62
1128 NULL,                                           //  #63 FIXME
1129 VM_changelevel,                                 //  #64
1130 VM_localsound,                                          //  #65
1131 VM_M_getmousepos,                                       //  #66
1132 VM_gettime,                                                     //  #67
1133 VM_loadfromdata,                                        //  #68
1134 VM_loadfromfile,                                        //  #69
1135 VM_modulo,                                                      //  #70
1136 VM_cvar_string,                                 //  #71
1137 VM_crash,                                                       //  #72
1138 VM_stackdump,                                           //  #73
1139 VM_search_begin,                                        //  #74
1140 VM_search_end,                                          //  #75
1141 VM_search_getsize,                              //  #76
1142 VM_search_getfilename,                  //  #77
1143 VM_chr,                                                         //  #78
1144 VM_itof,                                                                //  #79
1145 VM_ftoe,                                                                //  #80
1146 VM_itof,                                                                //  #81 isString
1147 VM_altstr_count,                                        //  #82
1148 VM_altstr_prepare,                              //  #83
1149 VM_altstr_get,                                          //  #84
1150 VM_altstr_set,                                          //  #85
1151 VM_altstr_ins,                                          //  #86
1152 VM_findflags,                                           //  #87
1153 VM_findchainflags,                              //  #88
1154 VM_cvar_defstring,                              //  #89
1155 // deactivate support for model rendering in the menu until someone has time to do it right [3/2/2008 Andreas]
1156 #if 0
1157 VM_CL_setmodel,                                 // #90 void(entity e, string m) setmodel (QUAKE)
1158 VM_CL_precache_model,                   // #91 void(string s) precache_model (QUAKE)
1159 VM_CL_setorigin,                                // #92 void(entity e, vector o) setorigin (QUAKE)
1160 #else
1161 NULL,
1162 NULL,
1163 NULL,
1164 #endif
1165 NULL,                                                                   //  #93
1166 NULL,                                                                   //  #94
1167 NULL,                                                                   //  #95
1168 NULL,                                                                   //  #96
1169 NULL,                                                                   //  #97
1170 NULL,                                                                   //  #98
1171 NULL,                                                                   //  #99
1172 NULL,                                                                   // #100
1173 NULL,                                                                   // #101
1174 NULL,                                                                   // #102
1175 NULL,                                                                   // #103
1176 NULL,                                                                   // #104
1177 NULL,                                                                   // #105
1178 NULL,                                                                   // #106
1179 NULL,                                                                   // #107
1180 NULL,                                                                   // #108
1181 NULL,                                                                   // #109
1182 NULL,                                                                   // #110
1183 NULL,                                                                   // #111
1184 NULL,                                                                   // #112
1185 NULL,                                                                   // #113
1186 NULL,                                                                   // #114
1187 NULL,                                                                   // #115
1188 NULL,                                                                   // #116
1189 NULL,                                                                   // #117
1190 NULL,                                                                   // #118
1191 NULL,                                                                   // #119
1192 NULL,                                                                   // #120
1193 NULL,                                                                   // #121
1194 NULL,                                                                   // #122
1195 NULL,                                                                   // #123
1196 NULL,                                                                   // #124
1197 NULL,                                                                   // #125
1198 NULL,                                                                   // #126
1199 NULL,                                                                   // #127
1200 NULL,                                                                   // #128
1201 NULL,                                                                   // #129
1202 NULL,                                                                   // #130
1203 NULL,                                                                   // #131
1204 NULL,                                                                   // #132
1205 NULL,                                                                   // #133
1206 NULL,                                                                   // #134
1207 NULL,                                                                   // #135
1208 NULL,                                                                   // #136
1209 NULL,                                                                   // #137
1210 NULL,                                                                   // #138
1211 NULL,                                                                   // #139
1212 NULL,                                                                   // #140
1213 NULL,                                                                   // #141
1214 NULL,                                                                   // #142
1215 NULL,                                                                   // #143
1216 NULL,                                                                   // #144
1217 NULL,                                                                   // #145
1218 NULL,                                                                   // #146
1219 NULL,                                                                   // #147
1220 NULL,                                                                   // #148
1221 NULL,                                                                   // #149
1222 NULL,                                                                   // #150
1223 NULL,                                                                   // #151
1224 NULL,                                                                   // #152
1225 NULL,                                                                   // #153
1226 NULL,                                                                   // #154
1227 NULL,                                                                   // #155
1228 NULL,                                                                   // #156
1229 NULL,                                                                   // #157
1230 NULL,                                                                   // #158
1231 NULL,                                                                   // #159
1232 NULL,                                                                   // #160
1233 NULL,                                                                   // #161
1234 NULL,                                                                   // #162
1235 NULL,                                                                   // #163
1236 NULL,                                                                   // #164
1237 NULL,                                                                   // #165
1238 NULL,                                                                   // #166
1239 NULL,                                                                   // #167
1240 NULL,                                                                   // #168
1241 NULL,                                                                   // #169
1242 NULL,                                                                   // #170
1243 NULL,                                                                   // #171
1244 NULL,                                                                   // #172
1245 NULL,                                                                   // #173
1246 NULL,                                                                   // #174
1247 NULL,                                                                   // #175
1248 NULL,                                                                   // #176
1249 NULL,                                                                   // #177
1250 NULL,                                                                   // #178
1251 NULL,                                                                   // #179
1252 NULL,                                                                   // #180
1253 NULL,                                                                   // #181
1254 NULL,                                                                   // #182
1255 NULL,                                                                   // #183
1256 NULL,                                                                   // #184
1257 NULL,                                                                   // #185
1258 NULL,                                                                   // #186
1259 NULL,                                                                   // #187
1260 NULL,                                                                   // #188
1261 NULL,                                                                   // #189
1262 NULL,                                                                   // #190
1263 NULL,                                                                   // #191
1264 NULL,                                                                   // #192
1265 NULL,                                                                   // #193
1266 NULL,                                                                   // #194
1267 NULL,                                                                   // #195
1268 NULL,                                                                   // #196
1269 NULL,                                                                   // #197
1270 NULL,                                                                   // #198
1271 NULL,                                                                   // #199
1272 NULL,                                                                   // #200
1273 NULL,                                                                   // #201
1274 NULL,                                                                   // #202
1275 NULL,                                                                   // #203
1276 NULL,                                                                   // #204
1277 NULL,                                                                   // #205
1278 NULL,                                                                   // #206
1279 NULL,                                                                   // #207
1280 NULL,                                                                   // #208
1281 NULL,                                                                   // #209
1282 NULL,                                                                   // #210
1283 NULL,                                                                   // #211
1284 NULL,                                                                   // #212
1285 NULL,                                                                   // #213
1286 NULL,                                                                   // #214
1287 NULL,                                                                   // #215
1288 NULL,                                                                   // #216
1289 NULL,                                                                   // #217
1290 NULL,                                                                   // #218
1291 NULL,                                                                   // #219
1292 NULL,                                                                   // #220
1293 VM_strstrofs,                                           // #221 float(string str, string sub[, float startpos]) strstrofs (FTE_STRINGS)
1294 VM_str2chr,                                             // #222 float(string str, float ofs) str2chr (FTE_STRINGS)
1295 VM_chr2str,                                             // #223 string(float c, ...) chr2str (FTE_STRINGS)
1296 VM_strconv,                                             // #224 string(float ccase, float calpha, float cnum, string s, ...) strconv (FTE_STRINGS)
1297 VM_strpad,                                              // #225 string(float chars, string s, ...) strpad (FTE_STRINGS)
1298 VM_infoadd,                                             // #226 string(string info, string key, string value, ...) infoadd (FTE_STRINGS)
1299 VM_infoget,                                             // #227 string(string info, string key) infoget (FTE_STRINGS)
1300 VM_strncmp,                                                     // #228 float(string s1, string s2, float len) strncmp (FTE_STRINGS)
1301 VM_strncasecmp,                                 // #229 float(string s1, string s2) strcasecmp (FTE_STRINGS)
1302 VM_strncasecmp,                                 // #230 float(string s1, string s2, float len) strncasecmp (FTE_STRINGS)
1303 NULL,                                                                   // #231
1304 NULL,                                                                   // #232
1305 NULL,                                                                   // #233
1306 NULL,                                                                   // #234
1307 NULL,                                                                   // #235
1308 NULL,                                                                   // #236
1309 NULL,                                                                   // #237
1310 NULL,                                                                   // #238
1311 NULL,                                                                   // #239
1312 NULL,                                                                   // #240
1313 NULL,                                                                   // #241
1314 NULL,                                                                   // #242
1315 NULL,                                                                   // #243
1316 NULL,                                                                   // #244
1317 NULL,                                                                   // #245
1318 NULL,                                                                   // #246
1319 NULL,                                                                   // #247
1320 NULL,                                                                   // #248
1321 NULL,                                                                   // #249
1322 NULL,                                                                   // #250
1323 NULL,                                                                   // #251
1324 NULL,                                                                   // #252
1325 NULL,                                                                   // #253
1326 NULL,                                                                   // #254
1327 NULL,                                                                   // #255
1328 NULL,                                                                   // #256
1329 NULL,                                                                   // #257
1330 NULL,                                                                   // #258
1331 NULL,                                                                   // #259
1332 NULL,                                                                   // #260
1333 NULL,                                                                   // #261
1334 NULL,                                                                   // #262
1335 NULL,                                                                   // #263
1336 NULL,                                                                   // #264
1337 NULL,                                                                   // #265
1338 NULL,                                                                   // #266
1339 NULL,                                                                   // #267
1340 NULL,                                                                   // #268
1341 NULL,                                                                   // #269
1342 NULL,                                                                   // #270
1343 NULL,                                                                   // #271
1344 NULL,                                                                   // #272
1345 NULL,                                                                   // #273
1346 NULL,                                                                   // #274
1347 NULL,                                                                   // #275
1348 NULL,                                                                   // #276
1349 NULL,                                                                   // #277
1350 NULL,                                                                   // #278
1351 NULL,                                                                   // #279
1352 NULL,                                                                   // #280
1353 NULL,                                                                   // #281
1354 NULL,                                                                   // #282
1355 NULL,                                                                   // #283
1356 NULL,                                                                   // #284
1357 NULL,                                                                   // #285
1358 NULL,                                                                   // #286
1359 NULL,                                                                   // #287
1360 NULL,                                                                   // #288
1361 NULL,                                                                   // #289
1362 NULL,                                                                   // #290
1363 NULL,                                                                   // #291
1364 NULL,                                                                   // #292
1365 NULL,                                                                   // #293
1366 NULL,                                                                   // #294
1367 NULL,                                                                   // #295
1368 NULL,                                                                   // #296
1369 NULL,                                                                   // #297
1370 NULL,                                                                   // #298
1371 NULL,                                                                   // #299
1372 // deactivate support for model rendering in the menu until someone has time to do it right [3/2/2008 Andreas]
1373 #if 0
1374 // CSQC range #300-#399
1375 VM_CL_R_ClearScene,                             // #300 void() clearscene (DP_QC_RENDER_SCENE)
1376 VM_CL_R_AddEntities,                    // #301 void(float mask) addentities (DP_QC_RENDER_SCENE)
1377 VM_CL_R_AddEntity,                              // #302 void(entity ent) addentity (DP_QC_RENDER_SCENE)
1378 VM_CL_R_SetView,                                // #303 float(float property, ...) setproperty (DP_QC_RENDER_SCENE)
1379 VM_CL_R_RenderScene,                    // #304 void() renderscene (DP_QC_RENDER_SCENE)
1380 VM_CL_R_AddDynamicLight,                // #305 void(vector org, float radius, vector lightcolours) adddynamiclight (DP_QC_RENDER_SCENE)
1381 VM_CL_R_PolygonBegin,                   // #306 void(string texturename, float flag[, float is2d, float lines]) R_BeginPolygon (DP_QC_RENDER_SCENE)
1382 VM_CL_R_PolygonVertex,                  // #307 void(vector org, vector texcoords, vector rgb, float alpha) R_PolygonVertex (DP_QC_RENDER_SCENE)
1383 VM_CL_R_PolygonEnd,                             // #308 void() R_EndPolygon
1384 NULL/*VM_CL_R_LoadWorldModel*/,                         // #309 void(string modelname) R_LoadWorldModel
1385 // TODO: rearrange and merge all builtin lists and share as many extensions as possible between all VM instances [1/27/2008 Andreas]
1386 VM_CL_setattachment,                            // #310 void(entity e, entity tagentity, string tagname) setattachment (DP_GFX_QUAKE3MODELTAGS) (DP_QC_RENDER_SCENE)
1387 VM_CL_gettagindex,                              // #311 float(entity ent, string tagname) gettagindex (DP_QC_GETTAGINFO) (DP_QC_RENDER_SCENE)
1388 VM_CL_gettaginfo,                                       // #312 vector(entity ent, float tagindex) gettaginfo (DP_QC_GETTAGINFO) (DP_QC_RENDER_SCENE)
1389 #else
1390 // CSQC range #300-#399
1391 NULL,           
1392 NULL,           
1393 NULL,           
1394 NULL,           
1395 NULL,           
1396 NULL,           
1397 NULL,           
1398 NULL,   
1399 NULL,   
1400 NULL,
1401 NULL,   
1402 NULL,   
1403 NULL,   
1404 #endif
1405 NULL,                                                                   // #313
1406 NULL,                                                                   // #314
1407 NULL,                                                                   // #315
1408 NULL,                                                                   // #316
1409 NULL,                                                                   // #317
1410 NULL,                                                                   // #318
1411 NULL,                                                                   // #319
1412 NULL,                                                                   // #320
1413 NULL,                                                                   // #321
1414 NULL,                                                                   // #322
1415 NULL,                                                                   // #323
1416 NULL,                                                                   // #324
1417 NULL,                                                                   // #325
1418 NULL,                                                                   // #326
1419 NULL,                                                                   // #327
1420 NULL,                                                                   // #328
1421 NULL,                                                                   // #329
1422 NULL,                                                                   // #330
1423 NULL,                                                                   // #331
1424 NULL,                                                                   // #332
1425 NULL,                                                                   // #333
1426 NULL,                                                                   // #334
1427 NULL,                                                                   // #335
1428 NULL,                                                                   // #336
1429 NULL,                                                                   // #337
1430 NULL,                                                                   // #338
1431 NULL,                                                                   // #339
1432 VM_keynumtostring,                              // #340 string keynumtostring(float keynum)
1433 VM_stringtokeynum,                              // #341 float stringtokeynum(string key)
1434 VM_getkeybind,                                                  // #342 string(float keynum[, float bindmap]) getkeybind (EXT_CSQC)
1435 NULL,                                                                   // #343
1436 NULL,                                                                   // #344
1437 NULL,                                                                   // #345
1438 NULL,                                                                   // #346
1439 NULL,                                                                   // #347
1440 NULL,                                                                   // #348
1441 VM_CL_isdemo,                                                   // #349
1442 NULL,                                                                   // #350
1443 NULL,                                                                   // #351
1444 VM_M_registercommand,                                   // #352 void(string cmdname)
1445 VM_wasfreed,                                                    // #353 float(entity ent) wasfreed
1446 NULL,                                                                   // #354
1447 VM_CL_videoplaying,                                             // #355
1448 VM_findfont,                                                    // #356 float(string fontname) loadfont (DP_GFX_FONTS)
1449 VM_loadfont,                                                    // #357 float(string fontname, string fontmaps, string sizes, float slot) loadfont (DP_GFX_FONTS)
1450 NULL,                                                                   // #358
1451 NULL,                                                                   // #359
1452 NULL,                                                                   // #360
1453 NULL,                                                                   // #361
1454 NULL,                                                                   // #362
1455 NULL,                                                                   // #363
1456 NULL,                                                                   // #364
1457 NULL,                                                                   // #365
1458 NULL,                                                                   // #366
1459 NULL,                                                                   // #367
1460 NULL,                                                                   // #368
1461 NULL,                                                                   // #369
1462 NULL,                                                                   // #370
1463 NULL,                                                                   // #371
1464 NULL,                                                                   // #372
1465 NULL,                                                                   // #373
1466 NULL,                                                                   // #374
1467 NULL,                                                                   // #375
1468 NULL,                                                                   // #376
1469 NULL,                                                                   // #377
1470 NULL,                                                                   // #378
1471 NULL,                                                                   // #379
1472 NULL,                                                                   // #380
1473 NULL,                                                                   // #381
1474 NULL,                                                                   // #382
1475 NULL,                                                                   // #383
1476 NULL,                                                                   // #384
1477 NULL,                                                                   // #385
1478 NULL,                                                                   // #386
1479 NULL,                                                                   // #387
1480 NULL,                                                                   // #388
1481 NULL,                                                                   // #389
1482 NULL,                                                                   // #390
1483 NULL,                                                                   // #391
1484 NULL,                                                                   // #392
1485 NULL,                                                                   // #393
1486 NULL,                                                                   // #394
1487 NULL,                                                                   // #395
1488 NULL,                                                                   // #396
1489 NULL,                                                                   // #397
1490 NULL,                                                                   // #398
1491 NULL,                                                                   // #399
1492 NULL,                                                                   // #400
1493 VM_M_WriteByte,                                 // #401
1494 VM_M_WriteChar,                                 // #402
1495 VM_M_WriteShort,                                        // #403
1496 VM_M_WriteLong,                                 // #404
1497 VM_M_WriteAngle,                                        // #405
1498 VM_M_WriteCoord,                                        // #406
1499 VM_M_WriteString,                                       // #407
1500 VM_M_WriteEntity,                                       // #408
1501 NULL,                                                                   // #409
1502 NULL,                                                                   // #410
1503 NULL,                                                                   // #411
1504 NULL,                                                                   // #412
1505 NULL,                                                                   // #413
1506 NULL,                                                                   // #414
1507 NULL,                                                                   // #415
1508 NULL,                                                                   // #416
1509 NULL,                                                                   // #417
1510 NULL,                                                                   // #418
1511 NULL,                                                                   // #419
1512 NULL,                                                                   // #420
1513 NULL,                                                                   // #421
1514 NULL,                                                                   // #422
1515 NULL,                                                                   // #423
1516 NULL,                                                                   // #424
1517 NULL,                                                                   // #425
1518 NULL,                                                                   // #426
1519 NULL,                                                                   // #427
1520 NULL,                                                                   // #428
1521 NULL,                                                                   // #429
1522 NULL,                                                                   // #430
1523 NULL,                                                                   // #431
1524 NULL,                                                                   // #432
1525 NULL,                                                                   // #433
1526 NULL,                                                                   // #434
1527 NULL,                                                                   // #435
1528 NULL,                                                                   // #436
1529 NULL,                                                                   // #437
1530 NULL,                                                                   // #438
1531 NULL,                                                                   // #439
1532 VM_buf_create,                                  // #440 float() buf_create (DP_QC_STRINGBUFFERS)
1533 VM_buf_del,                                             // #441 void(float bufhandle) buf_del (DP_QC_STRINGBUFFERS)
1534 VM_buf_getsize,                                 // #442 float(float bufhandle) buf_getsize (DP_QC_STRINGBUFFERS)
1535 VM_buf_copy,                                    // #443 void(float bufhandle_from, float bufhandle_to) buf_copy (DP_QC_STRINGBUFFERS)
1536 VM_buf_sort,                                    // #444 void(float bufhandle, float sortpower, float backward) buf_sort (DP_QC_STRINGBUFFERS)
1537 VM_buf_implode,                                 // #445 string(float bufhandle, string glue) buf_implode (DP_QC_STRINGBUFFERS)
1538 VM_bufstr_get,                                  // #446 string(float bufhandle, float string_index) bufstr_get (DP_QC_STRINGBUFFERS)
1539 VM_bufstr_set,                                  // #447 void(float bufhandle, float string_index, string str) bufstr_set (DP_QC_STRINGBUFFERS)
1540 VM_bufstr_add,                                  // #448 float(float bufhandle, string str, float order) bufstr_add (DP_QC_STRINGBUFFERS)
1541 VM_bufstr_free,                                 // #449 void(float bufhandle, float string_index) bufstr_free (DP_QC_STRINGBUFFERS)
1542 NULL,                                                                   // #450
1543 VM_iscachedpic,                                 // #451 draw functions...
1544 VM_precache_pic,                                        // #452
1545 VM_freepic,                                                     // #453
1546 VM_drawcharacter,                                       // #454
1547 VM_drawstring,                                          // #455
1548 VM_drawpic,                                                     // #456
1549 VM_drawfill,                                            // #457
1550 VM_drawsetcliparea,                             // #458
1551 VM_drawresetcliparea,                   // #459
1552 VM_getimagesize,                                        // #460
1553 VM_cin_open,                                            // #461
1554 VM_cin_close,                                           // #462
1555 VM_cin_setstate,                                        // #463
1556 VM_cin_getstate,                                        // #464
1557 VM_cin_restart,                                         // #465
1558 VM_drawline,                                            // #466
1559 VM_drawcolorcodedstring,                // #467
1560 VM_stringwidth,                                 // #468
1561 VM_drawsubpic,                                          // #469
1562 VM_drawrotpic,                                          // #470
1563 VM_asin,                                                                // #471 float(float s) VM_asin (DP_QC_ASINACOSATANATAN2TAN)
1564 VM_acos,                                                                // #472 float(float c) VM_acos (DP_QC_ASINACOSATANATAN2TAN)
1565 VM_atan,                                                                // #473 float(float t) VM_atan (DP_QC_ASINACOSATANATAN2TAN)
1566 VM_atan2,                                                       // #474 float(float c, float s) VM_atan2 (DP_QC_ASINACOSATANATAN2TAN)
1567 VM_tan,                                                         // #475 float(float a) VM_tan (DP_QC_ASINACOSATANATAN2TAN)
1568 VM_strlennocol,                                 // #476 float(string s) : DRESK - String Length (not counting color codes) (DP_QC_STRINGCOLORFUNCTIONS)
1569 VM_strdecolorize,                                       // #477 string(string s) : DRESK - Decolorized String (DP_QC_STRINGCOLORFUNCTIONS)
1570 VM_strftime,                                            // #478 string(float uselocaltime, string format, ...) (DP_QC_STRFTIME)
1571 VM_tokenizebyseparator,                 // #479 float(string s) tokenizebyseparator (DP_QC_TOKENIZEBYSEPARATOR)
1572 VM_strtolower,                                          // #480 string(string s) VM_strtolower : DRESK - Return string as lowercase
1573 VM_strtoupper,                                          // #481 string(string s) VM_strtoupper : DRESK - Return string as uppercase
1574 NULL,                                                                   // #482
1575 NULL,                                                                   // #483
1576 VM_strreplace,                                          // #484 string(string search, string replace, string subject) strreplace (DP_QC_STRREPLACE)
1577 VM_strireplace,                                 // #485 string(string search, string replace, string subject) strireplace (DP_QC_STRREPLACE)
1578 NULL,                                                                   // #486
1579 VM_gecko_create,                                        // #487 float gecko_create( string name )
1580 VM_gecko_destroy,                                       // #488 void gecko_destroy( string name )
1581 VM_gecko_navigate,                              // #489 void gecko_navigate( string name, string URI )
1582 VM_gecko_keyevent,                              // #490 float gecko_keyevent( string name, float key, float eventtype )
1583 VM_gecko_movemouse,                             // #491 void gecko_mousemove( string name, float x, float y )
1584 VM_gecko_resize,                                        // #492 void gecko_resize( string name, float w, float h )
1585 VM_gecko_get_texture_extent,    // #493 vector gecko_get_texture_extent( string name )
1586 VM_crc16,                                               // #494 float(float caseinsensitive, string s, ...) crc16 = #494 (DP_QC_CRC16)
1587 VM_cvar_type,                                   // #495 float(string name) cvar_type = #495; (DP_QC_CVAR_TYPE)
1588 VM_numentityfields,                             // #496 float() numentityfields = #496; (QP_QC_ENTITYDATA)
1589 VM_entityfieldname,                             // #497 string(float fieldnum) entityfieldname = #497; (DP_QC_ENTITYDATA)
1590 VM_entityfieldtype,                             // #498 float(float fieldnum) entityfieldtype = #498; (DP_QC_ENTITYDATA)
1591 VM_getentityfieldstring,                // #499 string(float fieldnum, entity ent) getentityfieldstring = #499; (DP_QC_ENTITYDATA)
1592 VM_putentityfieldstring,                // #500 float(float fieldnum, entity ent, string s) putentityfieldstring = #500; (DP_QC_ENTITYDATA)
1593 NULL,                                                                   // #501
1594 NULL,                                                                   // #502
1595 VM_whichpack,                                   // #503 string(string) whichpack = #503;
1596 NULL,                                                                   // #504
1597 NULL,                                                                   // #505
1598 NULL,                                                                   // #506
1599 NULL,                                                                   // #507
1600 NULL,                                                                   // #508
1601 NULL,                                                                   // #509
1602 VM_uri_escape,                                  // #510 string(string in) uri_escape = #510;
1603 VM_uri_unescape,                                // #511 string(string in) uri_unescape = #511;
1604 VM_etof,                                        // #512 float(entity ent) num_for_edict = #512 (DP_QC_NUM_FOR_EDICT)
1605 VM_uri_get,                                             // #513 float(string uri, float id, [string post_contenttype, string post_delim, [float buf]]) uri_get = #513; (DP_QC_URI_GET, DP_QC_URI_POST)
1606 VM_tokenize_console,                                    // #514 float(string str) tokenize_console = #514; (DP_QC_TOKENIZE_CONSOLE)
1607 VM_argv_start_index,                                    // #515 float(float idx) argv_start_index = #515; (DP_QC_TOKENIZE_CONSOLE)
1608 VM_argv_end_index,                                              // #516 float(float idx) argv_end_index = #516; (DP_QC_TOKENIZE_CONSOLE)
1609 VM_buf_cvarlist,                                                // #517 void(float buf, string prefix, string antiprefix) buf_cvarlist = #517; (DP_QC_STRINGBUFFERS_CVARLIST)
1610 VM_cvar_description,                                    // #518 float(string name) cvar_description = #518; (DP_QC_CVAR_DESCRIPTION)
1611 NULL,                                                                   // #519
1612 NULL,                                                                   // #520
1613 NULL,                                                                   // #521
1614 NULL,                                                                   // #522
1615 NULL,                                                                   // #523
1616 NULL,                                                                   // #524
1617 NULL,                                                                   // #525
1618 NULL,                                                                   // #526
1619 NULL,                                                                   // #527
1620 NULL,                                                                   // #528
1621 NULL,                                                                   // #529
1622 NULL,                                                                   // #530
1623 NULL,                                                                   // #531
1624 VM_log,                                                                 // #532
1625 VM_getsoundtime,                                                // #533 float(entity e, float channel) getsoundtime = #533; (DP_SND_GETSOUNDTIME)
1626 VM_soundlength,                                                 // #534 float(string sample) soundlength = #534; (DP_SND_GETSOUNDTIME)
1627 VM_buf_loadfile,                        // #535 float(string filename, float bufhandle) buf_loadfile (DP_QC_STRINGBUFFERS_EXT_WIP)
1628 VM_buf_writefile,                       // #536 float(float filehandle, float bufhandle, float startpos, float numstrings) buf_writefile (DP_QC_STRINGBUFFERS_EXT_WIP)
1629 VM_bufstr_find,                         // #537 float(float bufhandle, string match, float matchrule, float startpos) bufstr_find (DP_QC_STRINGBUFFERS_EXT_WIP)
1630 VM_matchpattern,                        // #538 float(string s, string pattern, float matchrule) matchpattern (DP_QC_STRINGBUFFERS_EXT_WIP)
1631 NULL,                                                                   // #539
1632 NULL,                                                                   // #540
1633 NULL,                                                                   // #541
1634 NULL,                                                                   // #542
1635 NULL,                                                                   // #543
1636 NULL,                                                                   // #544
1637 NULL,                                                                   // #545
1638 NULL,                                                                   // #546
1639 NULL,                                                                   // #547
1640 NULL,                                                                   // #548
1641 NULL,                                                                   // #549
1642 NULL,                                                                   // #550
1643 NULL,                                                                   // #551
1644 NULL,                                                                   // #552
1645 NULL,                                                                   // #553
1646 NULL,                                                                   // #554
1647 NULL,                                                                   // #555
1648 NULL,                                                                   // #556
1649 NULL,                                                                   // #557
1650 NULL,                                                                   // #558
1651 NULL,                                                                   // #559
1652 NULL,                                                                   // #560
1653 NULL,                                                                   // #561
1654 NULL,                                                                   // #562
1655 NULL,                                                                   // #563
1656 NULL,                                                                   // #564
1657 NULL,                                                                   // #565
1658 NULL,                                                                   // #566
1659 NULL,                                                                   // #567
1660 NULL,                                                                   // #568
1661 NULL,                                                                   // #569
1662 NULL,                                                                   // #570
1663 NULL,                                                                   // #571
1664 NULL,                                                                   // #572
1665 NULL,                                                                   // #573
1666 NULL,                                                                   // #574
1667 NULL,                                                                   // #575
1668 NULL,                                                                   // #576
1669 NULL,                                                                   // #577
1670 NULL,                                                                   // #578
1671 NULL,                                                                   // #579
1672 NULL,                                                                   // #580
1673 NULL,                                                                   // #581
1674 NULL,                                                                   // #582
1675 NULL,                                                                   // #583
1676 NULL,                                                                   // #584
1677 NULL,                                                                   // #585
1678 NULL,                                                                   // #586
1679 NULL,                                                                   // #587
1680 NULL,                                                                   // #588
1681 NULL,                                                                   // #589
1682 NULL,                                                                   // #590
1683 NULL,                                                                   // #591
1684 NULL,                                                                   // #592
1685 NULL,                                                                   // #593
1686 NULL,                                                                   // #594
1687 NULL,                                                                   // #595
1688 NULL,                                                                   // #596
1689 NULL,                                                                   // #597
1690 NULL,                                                                   // #598
1691 NULL,                                                                   // #599
1692 NULL,                                                                   // #600
1693 VM_M_setkeydest,                                        // #601 void setkeydest(float dest)
1694 VM_M_getkeydest,                                        // #602 float getkeydest(void)
1695 VM_M_setmousetarget,                            // #603 void setmousetarget(float trg)
1696 VM_M_getmousetarget,                            // #604 float getmousetarget(void)
1697 VM_callfunction,                                // #605 void callfunction(...)
1698 VM_writetofile,                                 // #606 void writetofile(float fhandle, entity ent)
1699 VM_isfunction,                                  // #607 float isfunction(string function_name)
1700 VM_M_getresolution,                             // #608 vector getresolution(float number, [float forfullscreen])
1701 VM_keynumtostring,                              // #609 string keynumtostring(float keynum)
1702 VM_findkeysforcommand,          // #610 string findkeysforcommand(string command[, float bindmap])
1703 VM_M_getserverliststat,                 // #611 float gethostcachevalue(float type)
1704 VM_M_getserverliststring,               // #612 string gethostcachestring(float type, float hostnr)
1705 VM_parseentitydata,                             // #613 void parseentitydata(entity ent, string data)
1706 VM_stringtokeynum,                              // #614 float stringtokeynum(string key)
1707 VM_M_resetserverlistmasks,              // #615 void resethostcachemasks(void)
1708 VM_M_setserverlistmaskstring,   // #616 void sethostcachemaskstring(float mask, float fld, string str, float op)
1709 VM_M_setserverlistmasknumber,   // #617 void sethostcachemasknumber(float mask, float fld, float num, float op)
1710 VM_M_resortserverlist,                  // #618 void resorthostcache(void)
1711 VM_M_setserverlistsort,                 // #619 void sethostcachesort(float fld, float descending)
1712 VM_M_refreshserverlist,                 // #620 void refreshhostcache(void)
1713 VM_M_getserverlistnumber,               // #621 float gethostcachenumber(float fld, float hostnr)
1714 VM_M_getserverlistindexforkey,// #622 float gethostcacheindexforkey(string key)
1715 VM_M_addwantedserverlistkey,    // #623 void addwantedhostcachekey(string key)
1716 VM_CL_getextresponse,                   // #624 string getextresponse(void)
1717 VM_netaddress_resolve,          // #625 string netaddress_resolve(string, float)
1718 VM_M_getgamedirinfo,            // #626 string getgamedirinfo(float n, float prop)
1719 VM_sprintf,                     // #627 string sprintf(string format, ...)
1720 NULL, // #628
1721 NULL, // #629
1722 VM_setkeybind,                                          // #630 float(float key, string bind[, float bindmap]) setkeybind
1723 VM_getbindmaps,                                         // #631 vector(void) getbindmap
1724 VM_setbindmaps,                                         // #632 float(vector bm) setbindmap
1725 VM_M_crypto_getkeyfp,                                   // #633 string(string addr) crypto_getkeyfp
1726 VM_M_crypto_getidfp,                                    // #634 string(string addr) crypto_getidfp
1727 VM_M_crypto_getencryptlevel,                            // #635 string(string addr) crypto_getencryptlevel
1728 VM_M_crypto_getmykeyfp,                                 // #636 string(float addr) crypto_getmykeyfp
1729 VM_M_crypto_getmyidfp,                                  // #637 string(float addr) crypto_getmyidfp
1730 NULL,                                                   // #638
1731 VM_digest_hex,                                          // #639
1732 NULL,                                                   // #640
1733 VM_M_crypto_getmyidstatus,                              // #641 float(float i) crypto_getmyidstatus
1734 VM_coverage,                                            // #642
1735 VM_M_crypto_getidstatus,                                // #643 float(string addr) crypto_getidstatus
1736 NULL
1737 };
1738
1739 const int vm_m_numbuiltins = sizeof(vm_m_builtins) / sizeof(prvm_builtin_t);
1740
1741 void MVM_init_cmd(prvm_prog_t *prog)
1742 {
1743         r_refdef_scene_t *scene;
1744
1745         VM_Cmd_Init(prog);
1746         prog->polygonbegin_model = NULL;
1747         prog->polygonbegin_guess2d = 0;
1748
1749         scene = R_GetScenePointer( RST_MENU );
1750
1751         memset (scene, 0, sizeof (*scene));
1752
1753         scene->maxtempentities = 128;
1754         scene->tempentities = (entity_render_t*) Mem_Alloc(prog->progs_mempool, sizeof(entity_render_t) * scene->maxtempentities);
1755
1756         scene->maxentities = MAX_EDICTS + 256 + 512;
1757         scene->entities = (entity_render_t **)Mem_Alloc(prog->progs_mempool, sizeof(entity_render_t *) * scene->maxentities);
1758
1759         // LadyHavoc: what is this for?
1760         scene->ambientintensity = 32.0f;
1761 }
1762
1763 void MVM_reset_cmd(prvm_prog_t *prog)
1764 {
1765         // note: the menu's render entities are automatically freed when the prog's pool is freed
1766
1767         //VM_Cmd_Init();
1768         VM_Cmd_Reset(prog);
1769         prog->polygonbegin_model = NULL;
1770         prog->polygonbegin_guess2d = 0;
1771 }