]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - mvm_cmds.c
fixed a bug with "time" command in effectinfo.txt to use float parsing
[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
7 //============================================================================
8 // Menu
9
10 char *vm_m_extensions =
11 "BX_WAL_SUPPORT "
12 "DP_CINEMATIC_DPV "
13 "DP_FONT_VARIABLEWIDTH "
14 "DP_GECKO_SUPPORT "
15 "DP_MENU_EXTRESPONSEPACKET "
16 "DP_QC_ASINACOSATANATAN2TAN "
17 "DP_QC_CMD "
18 "DP_QC_CRC16 "
19 "DP_QC_CVAR_TYPE "
20 "DP_QC_RENDER_SCENE "
21 "DP_QC_STRFTIME "
22 "DP_QC_STRINGBUFFERS "
23 "DP_QC_STRINGCOLORFUNCTIONS "
24 "DP_QC_STRING_CASE_FUNCTIONS "
25 "DP_QC_STRREPLACE "
26 "DP_QC_TOKENIZEBYSEPARATOR "
27 "DP_QC_UNLIMITEDTEMPSTRINGS "
28 "DP_QC_URI_ESCAPE "
29 "DP_QC_URI_GET "
30 "DP_QC_WHICHPACK "
31 "FTE_STRINGS "
32 ;
33
34 /*
35 =========
36 VM_M_setmousetarget
37
38 setmousetarget(float target)
39 =========
40 */
41 void VM_M_setmousetarget(void)
42 {
43         VM_SAFEPARMCOUNT(1, VM_M_setmousetarget);
44
45         switch((int)PRVM_G_FLOAT(OFS_PARM0))
46         {
47         case 1:
48                 in_client_mouse = false;
49                 break;
50         case 2:
51                 in_client_mouse = true;
52                 break;
53         default:
54                 PRVM_ERROR("VM_M_setmousetarget: wrong destination %f !",PRVM_G_FLOAT(OFS_PARM0));
55         }
56 }
57
58 /*
59 =========
60 VM_M_getmousetarget
61
62 float   getmousetarget
63 =========
64 */
65 void VM_M_getmousetarget(void)
66 {
67         VM_SAFEPARMCOUNT(0,VM_M_getmousetarget);
68
69         if(in_client_mouse)
70                 PRVM_G_FLOAT(OFS_RETURN) = 2;
71         else
72                 PRVM_G_FLOAT(OFS_RETURN) = 1;
73 }
74
75
76
77 /*
78 =========
79 VM_M_setkeydest
80
81 setkeydest(float dest)
82 =========
83 */
84 void VM_M_setkeydest(void)
85 {
86         VM_SAFEPARMCOUNT(1,VM_M_setkeydest);
87
88         switch((int)PRVM_G_FLOAT(OFS_PARM0))
89         {
90         case 0:
91                 // key_game
92                 key_dest = key_game;
93                 break;
94         case 2:
95                 // key_menu
96                 key_dest = key_menu;
97                 break;
98         case 3:
99                 // key_menu_grabbed
100                 key_dest = key_menu_grabbed;
101                 break;
102         case 1:
103                 // key_message
104                 // key_dest = key_message
105                 // break;
106         default:
107                 PRVM_ERROR("VM_M_setkeydest: wrong destination %f !", PRVM_G_FLOAT(OFS_PARM0));
108         }
109 }
110
111 /*
112 =========
113 VM_M_getkeydest
114
115 float   getkeydest
116 =========
117 */
118 void VM_M_getkeydest(void)
119 {
120         VM_SAFEPARMCOUNT(0,VM_M_getkeydest);
121
122         // key_game = 0, key_message = 1, key_menu = 2, key_menu_grabbed = 3, unknown = -1
123         switch(key_dest)
124         {
125         case key_game:
126                 PRVM_G_FLOAT(OFS_RETURN) = 0;
127                 break;
128         case key_menu:
129                 PRVM_G_FLOAT(OFS_RETURN) = 2;
130                 break;
131         case key_menu_grabbed:
132                 PRVM_G_FLOAT(OFS_RETURN) = 3;
133                 break;
134         case key_message:
135                 // not supported
136                 // PRVM_G_FLOAT(OFS_RETURN) = 1;
137                 // break;
138         default:
139                 PRVM_G_FLOAT(OFS_RETURN) = -1;
140         }
141 }
142
143 /*
144 =========
145 VM_M_callfunction
146
147         callfunction(...,string function_name)
148 Extension: pass
149 =========
150 */
151 mfunction_t *PRVM_ED_FindFunction (const char *name);
152 void VM_M_callfunction(void)
153 {
154         mfunction_t *func;
155         const char *s;
156
157         VM_SAFEPARMCOUNTRANGE(1, 8, VM_M_callfunction);
158
159         s = PRVM_G_STRING(OFS_PARM0+(prog->argc - 1)*3);
160
161         VM_CheckEmptyString(s);
162
163         func = PRVM_ED_FindFunction(s);
164
165         if(!func)
166                 PRVM_ERROR("VM_M_callfunciton: function %s not found !", s);
167         else if (func->first_statement < 0)
168         {
169                 // negative statements are built in functions
170                 int builtinnumber = -func->first_statement;
171                 prog->xfunction->builtinsprofile++;
172                 if (builtinnumber < prog->numbuiltins && prog->builtins[builtinnumber])
173                         prog->builtins[builtinnumber]();
174                 else
175                         PRVM_ERROR("No such builtin #%i in %s; most likely cause: outdated engine build. Try updating!", builtinnumber, PRVM_NAME);
176         }
177         else if(func - prog->functions > 0)
178         {
179                 prog->argc--;
180                 PRVM_ExecuteProgram(func - prog->functions,"");
181                 prog->argc++;
182         }
183 }
184
185 /*
186 =========
187 VM_M_isfunction
188
189 float   isfunction(string function_name)
190 =========
191 */
192 mfunction_t *PRVM_ED_FindFunction (const char *name);
193 void VM_M_isfunction(void)
194 {
195         mfunction_t *func;
196         const char *s;
197
198         VM_SAFEPARMCOUNT(1, VM_M_isfunction);
199
200         s = PRVM_G_STRING(OFS_PARM0);
201
202         VM_CheckEmptyString(s);
203
204         func = PRVM_ED_FindFunction(s);
205
206         if(!func)
207                 PRVM_G_FLOAT(OFS_RETURN) = false;
208         else
209                 PRVM_G_FLOAT(OFS_RETURN) = true;
210 }
211
212 /*
213 =========
214 VM_M_getresolution
215
216 vector  getresolution(float number)
217 =========
218 */
219 void VM_M_getresolution(void)
220 {
221         int nr;
222         VM_SAFEPARMCOUNT(1, VM_getresolution);
223
224         nr = (int)PRVM_G_FLOAT(OFS_PARM0);
225
226         // FIXME bounds check
227         PRVM_G_VECTOR(OFS_RETURN)[0] = video_resolutions[nr].width;
228         PRVM_G_VECTOR(OFS_RETURN)[1] = video_resolutions[nr].height;
229         PRVM_G_VECTOR(OFS_RETURN)[2] = 0;
230 }
231
232 /*
233 =========
234 VM_M_getserverliststat
235
236 float   getserverliststat(float type)
237 =========
238 */
239 /*
240         type:
241 0       serverlist_viewcount
242 1   serverlist_totalcount
243 2       masterquerycount
244 3       masterreplycount
245 4       serverquerycount
246 5       serverreplycount
247 6       sortfield
248 7       sortflags
249 */
250 void VM_M_getserverliststat( void )
251 {
252         int type;
253         VM_SAFEPARMCOUNT ( 1, VM_M_getserverliststat );
254
255         PRVM_G_FLOAT( OFS_RETURN ) = 0;
256
257         type = (int)PRVM_G_FLOAT( OFS_PARM0 );
258         switch(type)
259         {
260         case 0:
261                 PRVM_G_FLOAT ( OFS_RETURN ) = serverlist_viewcount;
262                 return;
263         case 1:
264                 PRVM_G_FLOAT ( OFS_RETURN ) = serverlist_cachecount;
265         case 2:
266                 PRVM_G_FLOAT ( OFS_RETURN ) = masterquerycount;
267                 return;
268         case 3:
269                 PRVM_G_FLOAT ( OFS_RETURN ) = masterreplycount;
270                 return;
271         case 4:
272                 PRVM_G_FLOAT ( OFS_RETURN ) = serverquerycount;
273                 return;
274         case 5:
275                 PRVM_G_FLOAT ( OFS_RETURN ) = serverreplycount;
276                 return;
277         case 6:
278                 PRVM_G_FLOAT ( OFS_RETURN ) = serverlist_sortbyfield;
279                 return;
280         case 7:
281                 PRVM_G_FLOAT ( OFS_RETURN ) = serverlist_sortflags;
282                 return;
283         default:
284                 VM_Warning( "VM_M_getserverliststat: bad type %i!\n", type );
285         }
286 }
287
288 /*
289 ========================
290 VM_M_resetserverlistmasks
291
292 resetserverlistmasks()
293 ========================
294 */
295 void VM_M_resetserverlistmasks( void )
296 {
297         VM_SAFEPARMCOUNT(0, VM_M_resetserverlistmasks);
298         ServerList_ResetMasks();
299 }
300
301
302 /*
303 ========================
304 VM_M_setserverlistmaskstring
305
306 setserverlistmaskstring(float mask, float fld, string str, float op)
307 0-511           and
308 512 - 1024      or
309 ========================
310 */
311 void VM_M_setserverlistmaskstring( void )
312 {
313         const char *str;
314         int masknr;
315         serverlist_mask_t *mask;
316         int field;
317
318         VM_SAFEPARMCOUNT( 4, VM_M_setserverlistmaskstring );
319         str = PRVM_G_STRING( OFS_PARM2 );
320
321         masknr = (int)PRVM_G_FLOAT( OFS_PARM0 );
322         if( masknr >= 0 && masknr <= SERVERLIST_ANDMASKCOUNT )
323                 mask = &serverlist_andmasks[masknr];
324         else if( masknr >= 512 && masknr - 512 <= SERVERLIST_ORMASKCOUNT )
325                 mask = &serverlist_ormasks[masknr - 512 ];
326         else
327         {
328                 VM_Warning( "VM_M_setserverlistmaskstring: invalid mask number %i\n", masknr );
329                 return;
330         }
331
332         field = (int) PRVM_G_FLOAT( OFS_PARM1 );
333
334         switch( field ) {
335                 case SLIF_CNAME:
336                         strlcpy( mask->info.cname, PRVM_G_STRING( OFS_PARM2 ), sizeof(mask->info.cname) );
337                         break;
338                 case SLIF_NAME:
339                         strlcpy( mask->info.name, PRVM_G_STRING( OFS_PARM2 ), sizeof(mask->info.name)  );
340                         break;
341                 case SLIF_QCSTATUS:
342                         strlcpy( mask->info.qcstatus, PRVM_G_STRING( OFS_PARM2 ), sizeof(mask->info.qcstatus)  );
343                         break;
344                 case SLIF_PLAYERS:
345                         strlcpy( mask->info.players, PRVM_G_STRING( OFS_PARM2 ), sizeof(mask->info.players)  );
346                         break;
347                 case SLIF_MAP:
348                         strlcpy( mask->info.map, PRVM_G_STRING( OFS_PARM2 ), sizeof(mask->info.map)  );
349                         break;
350                 case SLIF_MOD:
351                         strlcpy( mask->info.mod, PRVM_G_STRING( OFS_PARM2 ), sizeof(mask->info.mod)  );
352                         break;
353                 case SLIF_GAME:
354                         strlcpy( mask->info.game, PRVM_G_STRING( OFS_PARM2 ), sizeof(mask->info.game)  );
355                         break;
356                 default:
357                         VM_Warning( "VM_M_setserverlistmaskstring: Bad field number %i passed!\n", field );
358                         return;
359         }
360
361         mask->active = true;
362         mask->tests[field] = (serverlist_maskop_t)((int)PRVM_G_FLOAT( OFS_PARM3 ));
363 }
364
365 /*
366 ========================
367 VM_M_setserverlistmasknumber
368
369 setserverlistmasknumber(float mask, float fld, float num, float op)
370
371 0-511           and
372 512 - 1024      or
373 ========================
374 */
375 void VM_M_setserverlistmasknumber( void )
376 {
377         int number;
378         serverlist_mask_t *mask;
379         int     masknr;
380         int field;
381         VM_SAFEPARMCOUNT( 4, VM_M_setserverlistmasknumber );
382
383         masknr = (int)PRVM_G_FLOAT( OFS_PARM0 );
384         if( masknr >= 0 && masknr <= SERVERLIST_ANDMASKCOUNT )
385                 mask = &serverlist_andmasks[masknr];
386         else if( masknr >= 512 && masknr - 512 <= SERVERLIST_ORMASKCOUNT )
387                 mask = &serverlist_ormasks[masknr - 512 ];
388         else
389         {
390                 VM_Warning( "VM_M_setserverlistmasknumber: invalid mask number %i\n", masknr );
391                 return;
392         }
393
394         number = (int)PRVM_G_FLOAT( OFS_PARM2 );
395         field = (int) PRVM_G_FLOAT( OFS_PARM1 );
396
397         switch( field ) {
398                 case SLIF_MAXPLAYERS:
399                         mask->info.maxplayers = number;
400                         break;
401                 case SLIF_NUMPLAYERS:
402                         mask->info.numplayers = number;
403                         break;
404                 case SLIF_NUMBOTS:
405                         mask->info.numbots = number;
406                         break;
407                 case SLIF_NUMHUMANS:
408                         mask->info.numhumans = number;
409                         break;
410                 case SLIF_PING:
411                         mask->info.ping = number;
412                         break;
413                 case SLIF_PROTOCOL:
414                         mask->info.protocol = number;
415                         break;
416                 case SLIF_FREESLOTS:
417                         mask->info.freeslots = number;
418                         break;
419                 case SLIF_ISFAVORITE:
420                         mask->info.isfavorite = number;
421                         break;
422                 default:
423                         VM_Warning( "VM_M_setserverlistmasknumber: Bad field number %i passed!\n", field );
424                         return;
425         }
426
427         mask->active = true;
428         mask->tests[field] = (serverlist_maskop_t)((int)PRVM_G_FLOAT( OFS_PARM3 ));
429 }
430
431
432 /*
433 ========================
434 VM_M_resortserverlist
435
436 resortserverlist
437 ========================
438 */
439 void VM_M_resortserverlist( void )
440 {
441         VM_SAFEPARMCOUNT(0, VM_M_resortserverlist);
442         ServerList_RebuildViewList();
443 }
444
445 /*
446 =========
447 VM_M_getserverliststring
448
449 string  getserverliststring(float field, float hostnr)
450 =========
451 */
452 void VM_M_getserverliststring(void)
453 {
454         serverlist_entry_t *cache;
455         int hostnr;
456
457         VM_SAFEPARMCOUNT(2, VM_M_getserverliststring);
458
459         PRVM_G_INT(OFS_RETURN) = OFS_NULL;
460
461         hostnr = (int)PRVM_G_FLOAT(OFS_PARM1);
462
463         if(hostnr < 0 || hostnr >= serverlist_viewcount)
464         {
465                 Con_Print("VM_M_getserverliststring: bad hostnr passed!\n");
466                 return;
467         }
468         cache = serverlist_viewlist[hostnr];
469         switch( (int) PRVM_G_FLOAT(OFS_PARM0) ) {
470                 case SLIF_CNAME:
471                         PRVM_G_INT( OFS_RETURN ) = PRVM_SetEngineString( cache->info.cname );
472                         break;
473                 case SLIF_NAME:
474                         PRVM_G_INT( OFS_RETURN ) = PRVM_SetEngineString( cache->info.name );
475                         break;
476                 case SLIF_QCSTATUS:
477                         PRVM_G_INT (OFS_RETURN ) = PRVM_SetEngineString (cache->info.qcstatus );
478                         break;
479                 case SLIF_PLAYERS:
480                         PRVM_G_INT (OFS_RETURN ) = PRVM_SetEngineString (cache->info.players );
481                         break;
482                 case SLIF_GAME:
483                         PRVM_G_INT( OFS_RETURN ) = PRVM_SetEngineString( cache->info.game );
484                         break;
485                 case SLIF_MOD:
486                         PRVM_G_INT( OFS_RETURN ) = PRVM_SetEngineString( cache->info.mod );
487                         break;
488                 case SLIF_MAP:
489                         PRVM_G_INT( OFS_RETURN ) = PRVM_SetEngineString( cache->info.map );
490                         break;
491                 // TODO remove this again
492                 case 1024:
493                         PRVM_G_INT( OFS_RETURN ) = PRVM_SetEngineString( cache->line1 );
494                         break;
495                 case 1025:
496                         PRVM_G_INT( OFS_RETURN ) = PRVM_SetEngineString( cache->line2 );
497                         break;
498                 default:
499                         Con_Print("VM_M_getserverliststring: bad field number passed!\n");
500         }
501 }
502
503 /*
504 =========
505 VM_M_getserverlistnumber
506
507 float   getserverlistnumber(float field, float hostnr)
508 =========
509 */
510 void VM_M_getserverlistnumber(void)
511 {
512         serverlist_entry_t *cache;
513         int hostnr;
514
515         VM_SAFEPARMCOUNT(2, VM_M_getserverliststring);
516
517         PRVM_G_INT(OFS_RETURN) = OFS_NULL;
518
519         hostnr = (int)PRVM_G_FLOAT(OFS_PARM1);
520
521         if(hostnr < 0 || hostnr >= serverlist_viewcount)
522         {
523                 Con_Print("VM_M_getserverliststring: bad hostnr passed!\n");
524                 return;
525         }
526         cache = serverlist_viewlist[hostnr];
527         switch( (int) PRVM_G_FLOAT(OFS_PARM0) ) {
528                 case SLIF_MAXPLAYERS:
529                         PRVM_G_FLOAT( OFS_RETURN ) = cache->info.maxplayers;
530                         break;
531                 case SLIF_NUMPLAYERS:
532                         PRVM_G_FLOAT( OFS_RETURN ) = cache->info.numplayers;
533                         break;
534                 case SLIF_NUMBOTS:
535                         PRVM_G_FLOAT( OFS_RETURN ) = cache->info.numbots;
536                         break;
537                 case SLIF_NUMHUMANS:
538                         PRVM_G_FLOAT( OFS_RETURN ) = cache->info.numhumans;
539                         break;
540                 case SLIF_FREESLOTS:
541                         PRVM_G_FLOAT( OFS_RETURN ) = cache->info.freeslots;
542                         break;
543                 case SLIF_PING:
544                         PRVM_G_FLOAT( OFS_RETURN ) = cache->info.ping;
545                         break;
546                 case SLIF_PROTOCOL:
547                         PRVM_G_FLOAT( OFS_RETURN ) = cache->info.protocol;
548                         break;
549                 case SLIF_ISFAVORITE:
550                         PRVM_G_FLOAT( OFS_RETURN ) = cache->info.isfavorite;
551                         break;
552                 default:
553                         Con_Print("VM_M_getserverlistnumber: bad field number passed!\n");
554         }
555 }
556
557 /*
558 ========================
559 VM_M_setserverlistsort
560
561 setserverlistsort(float field, float flags)
562 ========================
563 */
564 void VM_M_setserverlistsort( void )
565 {
566         VM_SAFEPARMCOUNT( 2, VM_M_setserverlistsort );
567
568         serverlist_sortbyfield = (serverlist_infofield_t)((int)PRVM_G_FLOAT( OFS_PARM0 ));
569         serverlist_sortflags = (qboolean) PRVM_G_FLOAT( OFS_PARM1 );
570 }
571
572 /*
573 ========================
574 VM_M_refreshserverlist
575
576 refreshserverlist()
577 ========================
578 */
579 void VM_M_refreshserverlist( void )
580 {
581         VM_SAFEPARMCOUNT( 0, VM_M_refreshserverlist );
582         ServerList_QueryList(false, true, false, false);
583 }
584
585 /*
586 ========================
587 VM_M_getserverlistindexforkey
588
589 float getserverlistindexforkey(string key)
590 ========================
591 */
592 void VM_M_getserverlistindexforkey( void )
593 {
594         const char *key;
595         VM_SAFEPARMCOUNT( 1, VM_M_getserverlistindexforkey );
596
597         key = PRVM_G_STRING( OFS_PARM0 );
598         VM_CheckEmptyString( key );
599
600         if( !strcmp( key, "cname" ) )
601                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_CNAME;
602         else if( !strcmp( key, "ping" ) )
603                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_PING;
604         else if( !strcmp( key, "game" ) )
605                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_GAME;
606         else if( !strcmp( key, "mod" ) )
607                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_MOD;
608         else if( !strcmp( key, "map" ) )
609                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_MAP;
610         else if( !strcmp( key, "name" ) )
611                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_NAME;
612         else if( !strcmp( key, "qcstatus" ) )
613                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_QCSTATUS;
614         else if( !strcmp( key, "players" ) )
615                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_PLAYERS;
616         else if( !strcmp( key, "maxplayers" ) )
617                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_MAXPLAYERS;
618         else if( !strcmp( key, "numplayers" ) )
619                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_NUMPLAYERS;
620         else if( !strcmp( key, "numbots" ) )
621                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_NUMBOTS;
622         else if( !strcmp( key, "numhumans" ) )
623                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_NUMHUMANS;
624         else if( !strcmp( key, "freeslots" ) )
625                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_FREESLOTS;
626         else if( !strcmp( key, "protocol" ) )
627                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_PROTOCOL;
628         else if( !strcmp( key, "isfavorite" ) )
629                 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_ISFAVORITE;
630         else
631                 PRVM_G_FLOAT( OFS_RETURN ) = -1;
632 }
633
634 /*
635 ========================
636 VM_M_addwantedserverlistkey
637
638 addwantedserverlistkey(string key)
639 ========================
640 */
641 void VM_M_addwantedserverlistkey( void )
642 {
643         VM_SAFEPARMCOUNT( 1, VM_M_addwantedserverlistkey );
644 }
645
646 /*
647 ===============================================================================
648 MESSAGE WRITING
649
650 used only for client and menu
651 server uses VM_SV_...
652
653 Write*(* data, float type, float to)
654
655 ===============================================================================
656 */
657
658 #define MSG_BROADCAST   0               // unreliable to all
659 #define MSG_ONE                 1               // reliable to one (msg_entity)
660 #define MSG_ALL                 2               // reliable to all
661 #define MSG_INIT                3               // write to the init string
662
663 sizebuf_t *VM_M_WriteDest (void)
664 {
665         int             dest;
666         int             destclient;
667
668         if(!sv.active)
669                 PRVM_ERROR("VM_M_WriteDest: game is not server (%s)", PRVM_NAME);
670
671         dest = (int)PRVM_G_FLOAT(OFS_PARM1);
672         switch (dest)
673         {
674         case MSG_BROADCAST:
675                 return &sv.datagram;
676
677         case MSG_ONE:
678                 destclient = (int) PRVM_G_FLOAT(OFS_PARM2);
679                 if (destclient < 0 || destclient >= svs.maxclients || !svs.clients[destclient].active || !svs.clients[destclient].netconnection)
680                         PRVM_ERROR("VM_clientcommand: %s: invalid client !", PRVM_NAME);
681
682                 return &svs.clients[destclient].netconnection->message;
683
684         case MSG_ALL:
685                 return &sv.reliable_datagram;
686
687         case MSG_INIT:
688                 return &sv.signon;
689
690         default:
691                 PRVM_ERROR ("WriteDest: bad destination");
692                 break;
693         }
694
695         return NULL;
696 }
697
698 void VM_M_WriteByte (void)
699 {
700         VM_SAFEPARMCOUNT(1, VM_M_WriteByte);
701         MSG_WriteByte (VM_M_WriteDest(), (int)PRVM_G_FLOAT(OFS_PARM0));
702 }
703
704 void VM_M_WriteChar (void)
705 {
706         VM_SAFEPARMCOUNT(1, VM_M_WriteChar);
707         MSG_WriteChar (VM_M_WriteDest(), (int)PRVM_G_FLOAT(OFS_PARM0));
708 }
709
710 void VM_M_WriteShort (void)
711 {
712         VM_SAFEPARMCOUNT(1, VM_M_WriteShort);
713         MSG_WriteShort (VM_M_WriteDest(), (int)PRVM_G_FLOAT(OFS_PARM0));
714 }
715
716 void VM_M_WriteLong (void)
717 {
718         VM_SAFEPARMCOUNT(1, VM_M_WriteLong);
719         MSG_WriteLong (VM_M_WriteDest(), (int)PRVM_G_FLOAT(OFS_PARM0));
720 }
721
722 void VM_M_WriteAngle (void)
723 {
724         VM_SAFEPARMCOUNT(1, VM_M_WriteAngle);
725         MSG_WriteAngle (VM_M_WriteDest(), PRVM_G_FLOAT(OFS_PARM0), sv.protocol);
726 }
727
728 void VM_M_WriteCoord (void)
729 {
730         VM_SAFEPARMCOUNT(1, VM_M_WriteCoord);
731         MSG_WriteCoord (VM_M_WriteDest(), PRVM_G_FLOAT(OFS_PARM0), sv.protocol);
732 }
733
734 void VM_M_WriteString (void)
735 {
736         VM_SAFEPARMCOUNT(1, VM_M_WriteString);
737         MSG_WriteString (VM_M_WriteDest(), PRVM_G_STRING(OFS_PARM0));
738 }
739
740 void VM_M_WriteEntity (void)
741 {
742         VM_SAFEPARMCOUNT(1, VM_M_WriteEntity);
743         MSG_WriteShort (VM_M_WriteDest(), PRVM_G_EDICTNUM(OFS_PARM0));
744 }
745
746 //string(void) getextresponse = #624; // returns the next extResponse packet that was sent to this client
747 void VM_M_getextresponse (void)
748 {
749         VM_SAFEPARMCOUNT(0,VM_argv);
750
751         if (net_extresponse_count <= 0)
752                 PRVM_G_INT(OFS_RETURN) = OFS_NULL;
753         else
754         {
755                 int first;
756                 --net_extresponse_count;
757                 first = (net_extresponse_last + NET_EXTRESPONSE_MAX - net_extresponse_count) % NET_EXTRESPONSE_MAX;
758                 PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(net_extresponse[first]);
759         }
760 }
761
762 /*
763 =================
764 VM_M_copyentity
765
766 copies data from one entity to another
767
768 copyentity(entity src, entity dst)
769 =================
770 */
771 static void VM_M_copyentity (void)
772 {
773         prvm_edict_t *in, *out;
774         VM_SAFEPARMCOUNT(2,VM_M_copyentity);
775         in = PRVM_G_EDICT(OFS_PARM0);
776         out = PRVM_G_EDICT(OFS_PARM1);
777         memcpy(out->fields.vp, in->fields.vp, prog->progs->entityfields * 4);
778 }
779
780 //#66 vector() getmousepos (EXT_CSQC)
781 static void VM_M_getmousepos(void)
782 {
783         VM_SAFEPARMCOUNT(0,VM_M_getmousepos);
784
785         if (key_consoleactive || (key_dest != key_menu && key_dest != key_menu_grabbed))
786                 VectorSet(PRVM_G_VECTOR(OFS_RETURN), 0, 0, 0);
787         else if (in_client_mouse)
788                 VectorSet(PRVM_G_VECTOR(OFS_RETURN), in_windowmouse_x * vid_conwidth.integer / vid.width, in_windowmouse_y * vid_conheight.integer / vid.height, 0);
789         else
790                 VectorSet(PRVM_G_VECTOR(OFS_RETURN), in_mouse_x * vid_conwidth.integer / vid.width, in_mouse_y * vid_conheight.integer / vid.height, 0);
791 }
792
793 prvm_builtin_t vm_m_builtins[] = {
794 NULL,                                                                   //   #0 NULL function (not callable)
795 VM_checkextension,                              //   #1
796 VM_error,                                                       //   #2
797 VM_objerror,                                            //   #3
798 VM_print,                                                       //   #4
799 VM_bprint,                                                      //   #5
800 VM_sprint,                                                      //   #6
801 VM_centerprint,                                 //   #7
802 VM_normalize,                                           //   #8
803 VM_vlen,                                                                //   #9
804 VM_vectoyaw,                                            //  #10
805 VM_vectoangles,                                 //  #11
806 VM_random,                                                      //  #12
807 VM_localcmd,                                            //  #13
808 VM_cvar,                                                                //  #14
809 VM_cvar_set,                                            //  #15
810 VM_dprint,                                                      //  #16
811 VM_ftos,                                                                //  #17
812 VM_fabs,                                                                //  #18
813 VM_vtos,                                                                //  #19
814 VM_etos,                                                                //  #20
815 VM_stof,                                                                //  #21
816 VM_spawn,                                                       //  #22
817 VM_remove,                                                      //  #23
818 VM_find,                                                                //  #24
819 VM_findfloat,                                           //  #25
820 VM_findchain,                                           //  #26
821 VM_findchainfloat,                              //  #27
822 VM_precache_file,                                       //  #28
823 VM_precache_sound,                              //  #29
824 VM_coredump,                                            //  #30
825 VM_traceon,                                                     //  #31
826 VM_traceoff,                                            //  #32
827 VM_eprint,                                                      //  #33
828 VM_rint,                                                                //  #34
829 VM_floor,                                                       //  #35
830 VM_ceil,                                                                //  #36
831 VM_nextent,                                                     //  #37
832 VM_sin,                                                         //  #38
833 VM_cos,                                                         //  #39
834 VM_sqrt,                                                                //  #40
835 VM_randomvec,                                           //  #41
836 VM_registercvar,                                        //  #42
837 VM_min,                                                         //  #43
838 VM_max,                                                         //  #44
839 VM_bound,                                                       //  #45
840 VM_pow,                                                         //  #46
841 VM_M_copyentity,                                        //  #47
842 VM_fopen,                                                       //  #48
843 VM_fclose,                                                      //  #49
844 VM_fgets,                                                       //  #50
845 VM_fputs,                                                       //  #51
846 VM_strlen,                                                      //  #52
847 VM_strcat,                                                      //  #53
848 VM_substring,                                           //  #54
849 VM_stov,                                                                //  #55
850 VM_strzone,                                                     //  #56
851 VM_strunzone,                                           //  #57
852 VM_tokenize,                                            //  #58
853 VM_argv,                                                                //  #59
854 VM_isserver,                                            //  #60
855 VM_clientcount,                                 //  #61
856 VM_clientstate,                                 //  #62
857 VM_clcommand,                                           //  #63
858 VM_changelevel,                                 //  #64
859 VM_localsound,                                          //  #65
860 VM_M_getmousepos,                                       //  #66
861 VM_gettime,                                                     //  #67
862 VM_loadfromdata,                                        //  #68
863 VM_loadfromfile,                                        //  #69
864 VM_modulo,                                                      //  #70
865 VM_cvar_string,                                 //  #71
866 VM_crash,                                                       //  #72
867 VM_stackdump,                                           //  #73
868 VM_search_begin,                                        //  #74
869 VM_search_end,                                          //  #75
870 VM_search_getsize,                              //  #76
871 VM_search_getfilename,                  //  #77
872 VM_chr,                                                         //  #78
873 VM_itof,                                                                //  #79
874 VM_ftoe,                                                                //  #80
875 VM_itof,                                                                //  #81 isString
876 VM_altstr_count,                                        //  #82
877 VM_altstr_prepare,                              //  #83
878 VM_altstr_get,                                          //  #84
879 VM_altstr_set,                                          //  #85
880 VM_altstr_ins,                                          //  #86
881 VM_findflags,                                           //  #87
882 VM_findchainflags,                              //  #88
883 VM_cvar_defstring,                              //  #89
884 // deactivate support for model rendering in the menu until someone has time to do it right [3/2/2008 Andreas]
885 #if 0
886 VM_CL_setmodel,                                 // #90 void(entity e, string m) setmodel (QUAKE)
887 VM_CL_precache_model,                   // #91 void(string s) precache_model (QUAKE)
888 VM_CL_setorigin,                                // #92 void(entity e, vector o) setorigin (QUAKE)
889 #else
890 NULL,
891 NULL,
892 NULL,
893 #endif
894 NULL,                                                                   //  #93
895 NULL,                                                                   //  #94
896 NULL,                                                                   //  #95
897 NULL,                                                                   //  #96
898 NULL,                                                                   //  #97
899 NULL,                                                                   //  #98
900 NULL,                                                                   //  #99
901 NULL,                                                                   // #100
902 NULL,                                                                   // #101
903 NULL,                                                                   // #102
904 NULL,                                                                   // #103
905 NULL,                                                                   // #104
906 NULL,                                                                   // #105
907 NULL,                                                                   // #106
908 NULL,                                                                   // #107
909 NULL,                                                                   // #108
910 NULL,                                                                   // #109
911 NULL,                                                                   // #110
912 NULL,                                                                   // #111
913 NULL,                                                                   // #112
914 NULL,                                                                   // #113
915 NULL,                                                                   // #114
916 NULL,                                                                   // #115
917 NULL,                                                                   // #116
918 NULL,                                                                   // #117
919 NULL,                                                                   // #118
920 NULL,                                                                   // #119
921 NULL,                                                                   // #120
922 NULL,                                                                   // #121
923 NULL,                                                                   // #122
924 NULL,                                                                   // #123
925 NULL,                                                                   // #124
926 NULL,                                                                   // #125
927 NULL,                                                                   // #126
928 NULL,                                                                   // #127
929 NULL,                                                                   // #128
930 NULL,                                                                   // #129
931 NULL,                                                                   // #130
932 NULL,                                                                   // #131
933 NULL,                                                                   // #132
934 NULL,                                                                   // #133
935 NULL,                                                                   // #134
936 NULL,                                                                   // #135
937 NULL,                                                                   // #136
938 NULL,                                                                   // #137
939 NULL,                                                                   // #138
940 NULL,                                                                   // #139
941 NULL,                                                                   // #140
942 NULL,                                                                   // #141
943 NULL,                                                                   // #142
944 NULL,                                                                   // #143
945 NULL,                                                                   // #144
946 NULL,                                                                   // #145
947 NULL,                                                                   // #146
948 NULL,                                                                   // #147
949 NULL,                                                                   // #148
950 NULL,                                                                   // #149
951 NULL,                                                                   // #150
952 NULL,                                                                   // #151
953 NULL,                                                                   // #152
954 NULL,                                                                   // #153
955 NULL,                                                                   // #154
956 NULL,                                                                   // #155
957 NULL,                                                                   // #156
958 NULL,                                                                   // #157
959 NULL,                                                                   // #158
960 NULL,                                                                   // #159
961 NULL,                                                                   // #160
962 NULL,                                                                   // #161
963 NULL,                                                                   // #162
964 NULL,                                                                   // #163
965 NULL,                                                                   // #164
966 NULL,                                                                   // #165
967 NULL,                                                                   // #166
968 NULL,                                                                   // #167
969 NULL,                                                                   // #168
970 NULL,                                                                   // #169
971 NULL,                                                                   // #170
972 NULL,                                                                   // #171
973 NULL,                                                                   // #172
974 NULL,                                                                   // #173
975 NULL,                                                                   // #174
976 NULL,                                                                   // #175
977 NULL,                                                                   // #176
978 NULL,                                                                   // #177
979 NULL,                                                                   // #178
980 NULL,                                                                   // #179
981 NULL,                                                                   // #180
982 NULL,                                                                   // #181
983 NULL,                                                                   // #182
984 NULL,                                                                   // #183
985 NULL,                                                                   // #184
986 NULL,                                                                   // #185
987 NULL,                                                                   // #186
988 NULL,                                                                   // #187
989 NULL,                                                                   // #188
990 NULL,                                                                   // #189
991 NULL,                                                                   // #190
992 NULL,                                                                   // #191
993 NULL,                                                                   // #192
994 NULL,                                                                   // #193
995 NULL,                                                                   // #194
996 NULL,                                                                   // #195
997 NULL,                                                                   // #196
998 NULL,                                                                   // #197
999 NULL,                                                                   // #198
1000 NULL,                                                                   // #199
1001 NULL,                                                                   // #200
1002 NULL,                                                                   // #201
1003 NULL,                                                                   // #202
1004 NULL,                                                                   // #203
1005 NULL,                                                                   // #204
1006 NULL,                                                                   // #205
1007 NULL,                                                                   // #206
1008 NULL,                                                                   // #207
1009 NULL,                                                                   // #208
1010 NULL,                                                                   // #209
1011 NULL,                                                                   // #210
1012 NULL,                                                                   // #211
1013 NULL,                                                                   // #212
1014 NULL,                                                                   // #213
1015 NULL,                                                                   // #214
1016 NULL,                                                                   // #215
1017 NULL,                                                                   // #216
1018 NULL,                                                                   // #217
1019 NULL,                                                                   // #218
1020 NULL,                                                                   // #219
1021 NULL,                                                                   // #220
1022 VM_strstrofs,                                           // #221 float(string str, string sub[, float startpos]) strstrofs (FTE_STRINGS)
1023 VM_str2chr,                                             // #222 float(string str, float ofs) str2chr (FTE_STRINGS)
1024 VM_chr2str,                                             // #223 string(float c, ...) chr2str (FTE_STRINGS)
1025 VM_strconv,                                             // #224 string(float ccase, float calpha, float cnum, string s, ...) strconv (FTE_STRINGS)
1026 VM_strpad,                                              // #225 string(float chars, string s, ...) strpad (FTE_STRINGS)
1027 VM_infoadd,                                             // #226 string(string info, string key, string value, ...) infoadd (FTE_STRINGS)
1028 VM_infoget,                                             // #227 string(string info, string key) infoget (FTE_STRINGS)
1029 VM_strncmp,                                                     // #228 float(string s1, string s2, float len) strncmp (FTE_STRINGS)
1030 VM_strncasecmp,                                 // #229 float(string s1, string s2) strcasecmp (FTE_STRINGS)
1031 VM_strncasecmp,                                 // #230 float(string s1, string s2, float len) strncasecmp (FTE_STRINGS)
1032 NULL,                                                                   // #231
1033 NULL,                                                                   // #232
1034 NULL,                                                                   // #233
1035 NULL,                                                                   // #234
1036 NULL,                                                                   // #235
1037 NULL,                                                                   // #236
1038 NULL,                                                                   // #237
1039 NULL,                                                                   // #238
1040 NULL,                                                                   // #239
1041 NULL,                                                                   // #240
1042 NULL,                                                                   // #241
1043 NULL,                                                                   // #242
1044 NULL,                                                                   // #243
1045 NULL,                                                                   // #244
1046 NULL,                                                                   // #245
1047 NULL,                                                                   // #246
1048 NULL,                                                                   // #247
1049 NULL,                                                                   // #248
1050 NULL,                                                                   // #249
1051 NULL,                                                                   // #250
1052 NULL,                                                                   // #251
1053 NULL,                                                                   // #252
1054 NULL,                                                                   // #253
1055 NULL,                                                                   // #254
1056 NULL,                                                                   // #255
1057 NULL,                                                                   // #256
1058 NULL,                                                                   // #257
1059 NULL,                                                                   // #258
1060 NULL,                                                                   // #259
1061 NULL,                                                                   // #260
1062 NULL,                                                                   // #261
1063 NULL,                                                                   // #262
1064 NULL,                                                                   // #263
1065 NULL,                                                                   // #264
1066 NULL,                                                                   // #265
1067 NULL,                                                                   // #266
1068 NULL,                                                                   // #267
1069 NULL,                                                                   // #268
1070 NULL,                                                                   // #269
1071 NULL,                                                                   // #270
1072 NULL,                                                                   // #271
1073 NULL,                                                                   // #272
1074 NULL,                                                                   // #273
1075 NULL,                                                                   // #274
1076 NULL,                                                                   // #275
1077 NULL,                                                                   // #276
1078 NULL,                                                                   // #277
1079 NULL,                                                                   // #278
1080 NULL,                                                                   // #279
1081 NULL,                                                                   // #280
1082 NULL,                                                                   // #281
1083 NULL,                                                                   // #282
1084 NULL,                                                                   // #283
1085 NULL,                                                                   // #284
1086 NULL,                                                                   // #285
1087 NULL,                                                                   // #286
1088 NULL,                                                                   // #287
1089 NULL,                                                                   // #288
1090 NULL,                                                                   // #289
1091 NULL,                                                                   // #290
1092 NULL,                                                                   // #291
1093 NULL,                                                                   // #292
1094 NULL,                                                                   // #293
1095 NULL,                                                                   // #294
1096 NULL,                                                                   // #295
1097 NULL,                                                                   // #296
1098 NULL,                                                                   // #297
1099 NULL,                                                                   // #298
1100 NULL,                                                                   // #299
1101 // deactivate support for model rendering in the menu until someone has time to do it right [3/2/2008 Andreas]
1102 #if 0
1103 // CSQC range #300-#399
1104 VM_CL_R_ClearScene,                             // #300 void() clearscene (DP_QC_RENDER_SCENE)
1105 VM_CL_R_AddEntities,                    // #301 void(float mask) addentities (DP_QC_RENDER_SCENE)
1106 VM_CL_R_AddEntity,                              // #302 void(entity ent) addentity (DP_QC_RENDER_SCENE)
1107 VM_CL_R_SetView,                                // #303 float(float property, ...) setproperty (DP_QC_RENDER_SCENE)
1108 VM_CL_R_RenderScene,                    // #304 void() renderscene (DP_QC_RENDER_SCENE)
1109 VM_CL_R_AddDynamicLight,                // #305 void(vector org, float radius, vector lightcolours) adddynamiclight (DP_QC_RENDER_SCENE)
1110 VM_CL_R_PolygonBegin,                   // #306 void(string texturename, float flag[, float is2d, float lines]) R_BeginPolygon (DP_QC_RENDER_SCENE)
1111 VM_CL_R_PolygonVertex,                  // #307 void(vector org, vector texcoords, vector rgb, float alpha) R_PolygonVertex (DP_QC_RENDER_SCENE)
1112 VM_CL_R_PolygonEnd,                             // #308 void() R_EndPolygon
1113 NULL/*VM_CL_R_LoadWorldModel*/,                         // #309 void(string modelname) R_LoadWorldModel
1114 // TODO: rearrange and merge all builtin lists and share as many extensions as possible between all VM instances [1/27/2008 Andreas]
1115 VM_CL_setattachment,                            // #310 void(entity e, entity tagentity, string tagname) setattachment (DP_GFX_QUAKE3MODELTAGS) (DP_QC_RENDER_SCENE)
1116 VM_CL_gettagindex,                              // #311 float(entity ent, string tagname) gettagindex (DP_QC_GETTAGINFO) (DP_QC_RENDER_SCENE)
1117 VM_CL_gettaginfo,                                       // #312 vector(entity ent, float tagindex) gettaginfo (DP_QC_GETTAGINFO) (DP_QC_RENDER_SCENE)
1118 #else
1119 // CSQC range #300-#399
1120 NULL,           
1121 NULL,           
1122 NULL,           
1123 NULL,           
1124 NULL,           
1125 NULL,           
1126 NULL,           
1127 NULL,   
1128 NULL,   
1129 NULL,
1130 NULL,   
1131 NULL,   
1132 NULL,   
1133 #endif
1134 NULL,                                                                   // #313
1135 NULL,                                                                   // #314
1136 NULL,                                                                   // #315
1137 NULL,                                                                   // #316
1138 NULL,                                                                   // #317
1139 NULL,                                                                   // #318
1140 NULL,                                                                   // #319
1141 NULL,                                                                   // #320
1142 NULL,                                                                   // #321
1143 NULL,                                                                   // #322
1144 NULL,                                                                   // #323
1145 NULL,                                                                   // #324
1146 NULL,                                                                   // #325
1147 NULL,                                                                   // #326
1148 NULL,                                                                   // #327
1149 NULL,                                                                   // #328
1150 NULL,                                                                   // #329
1151 NULL,                                                                   // #330
1152 NULL,                                                                   // #331
1153 NULL,                                                                   // #332
1154 NULL,                                                                   // #333
1155 NULL,                                                                   // #334
1156 NULL,                                                                   // #335
1157 NULL,                                                                   // #336
1158 NULL,                                                                   // #337
1159 NULL,                                                                   // #338
1160 NULL,                                                                   // #339
1161 NULL,                                                                   // #340
1162 NULL,                                                                   // #341
1163 NULL,                                                                   // #342
1164 NULL,                                                                   // #343
1165 NULL,                                                                   // #344
1166 NULL,                                                                   // #345
1167 NULL,                                                                   // #346
1168 NULL,                                                                   // #347
1169 NULL,                                                                   // #348
1170 NULL,                                                                   // #349
1171 NULL,                                                                   // #350
1172 NULL,                                                                   // #351
1173 NULL,                                                                   // #352
1174 NULL,                                                                   // #353
1175 NULL,                                                                   // #354
1176 NULL,                                                                   // #355
1177 NULL,                                                                   // #356
1178 NULL,                                                                   // #357
1179 NULL,                                                                   // #358
1180 NULL,                                                                   // #359
1181 NULL,                                                                   // #360
1182 NULL,                                                                   // #361
1183 NULL,                                                                   // #362
1184 NULL,                                                                   // #363
1185 NULL,                                                                   // #364
1186 NULL,                                                                   // #365
1187 NULL,                                                                   // #366
1188 NULL,                                                                   // #367
1189 NULL,                                                                   // #368
1190 NULL,                                                                   // #369
1191 NULL,                                                                   // #370
1192 NULL,                                                                   // #371
1193 NULL,                                                                   // #372
1194 NULL,                                                                   // #373
1195 NULL,                                                                   // #374
1196 NULL,                                                                   // #375
1197 NULL,                                                                   // #376
1198 NULL,                                                                   // #377
1199 NULL,                                                                   // #378
1200 NULL,                                                                   // #379
1201 NULL,                                                                   // #380
1202 NULL,                                                                   // #381
1203 NULL,                                                                   // #382
1204 NULL,                                                                   // #383
1205 NULL,                                                                   // #384
1206 NULL,                                                                   // #385
1207 NULL,                                                                   // #386
1208 NULL,                                                                   // #387
1209 NULL,                                                                   // #388
1210 NULL,                                                                   // #389
1211 NULL,                                                                   // #390
1212 NULL,                                                                   // #391
1213 NULL,                                                                   // #392
1214 NULL,                                                                   // #393
1215 NULL,                                                                   // #394
1216 NULL,                                                                   // #395
1217 NULL,                                                                   // #396
1218 NULL,                                                                   // #397
1219 NULL,                                                                   // #398
1220 NULL,                                                                   // #399
1221 NULL,                                                                   // #400
1222 VM_M_WriteByte,                                 // #401
1223 VM_M_WriteChar,                                 // #402
1224 VM_M_WriteShort,                                        // #403
1225 VM_M_WriteLong,                                 // #404
1226 VM_M_WriteAngle,                                        // #405
1227 VM_M_WriteCoord,                                        // #406
1228 VM_M_WriteString,                                       // #407
1229 VM_M_WriteEntity,                                       // #408
1230 NULL,                                                                   // #409
1231 NULL,                                                                   // #410
1232 NULL,                                                                   // #411
1233 NULL,                                                                   // #412
1234 NULL,                                                                   // #413
1235 NULL,                                                                   // #414
1236 NULL,                                                                   // #415
1237 NULL,                                                                   // #416
1238 NULL,                                                                   // #417
1239 NULL,                                                                   // #418
1240 NULL,                                                                   // #419
1241 NULL,                                                                   // #420
1242 NULL,                                                                   // #421
1243 NULL,                                                                   // #422
1244 NULL,                                                                   // #423
1245 NULL,                                                                   // #424
1246 NULL,                                                                   // #425
1247 NULL,                                                                   // #426
1248 NULL,                                                                   // #427
1249 NULL,                                                                   // #428
1250 NULL,                                                                   // #429
1251 NULL,                                                                   // #430
1252 NULL,                                                                   // #431
1253 NULL,                                                                   // #432
1254 NULL,                                                                   // #433
1255 NULL,                                                                   // #434
1256 NULL,                                                                   // #435
1257 NULL,                                                                   // #436
1258 NULL,                                                                   // #437
1259 NULL,                                                                   // #438
1260 NULL,                                                                   // #439
1261 VM_buf_create,                                  // #440 float() buf_create (DP_QC_STRINGBUFFERS)
1262 VM_buf_del,                                             // #441 void(float bufhandle) buf_del (DP_QC_STRINGBUFFERS)
1263 VM_buf_getsize,                                 // #442 float(float bufhandle) buf_getsize (DP_QC_STRINGBUFFERS)
1264 VM_buf_copy,                                    // #443 void(float bufhandle_from, float bufhandle_to) buf_copy (DP_QC_STRINGBUFFERS)
1265 VM_buf_sort,                                    // #444 void(float bufhandle, float sortpower, float backward) buf_sort (DP_QC_STRINGBUFFERS)
1266 VM_buf_implode,                                 // #445 string(float bufhandle, string glue) buf_implode (DP_QC_STRINGBUFFERS)
1267 VM_bufstr_get,                                  // #446 string(float bufhandle, float string_index) bufstr_get (DP_QC_STRINGBUFFERS)
1268 VM_bufstr_set,                                  // #447 void(float bufhandle, float string_index, string str) bufstr_set (DP_QC_STRINGBUFFERS)
1269 VM_bufstr_add,                                  // #448 float(float bufhandle, string str, float order) bufstr_add (DP_QC_STRINGBUFFERS)
1270 VM_bufstr_free,                                 // #449 void(float bufhandle, float string_index) bufstr_free (DP_QC_STRINGBUFFERS)
1271 NULL,                                                                   // #450
1272 VM_iscachedpic,                                 // #451 draw functions...
1273 VM_precache_pic,                                        // #452
1274 VM_freepic,                                                     // #453
1275 VM_drawcharacter,                                       // #454
1276 VM_drawstring,                                          // #455
1277 VM_drawpic,                                                     // #456
1278 VM_drawfill,                                            // #457
1279 VM_drawsetcliparea,                             // #458
1280 VM_drawresetcliparea,                   // #459
1281 VM_getimagesize,                                        // #460
1282 VM_cin_open,                                            // #461
1283 VM_cin_close,                                           // #462
1284 VM_cin_setstate,                                        // #463
1285 VM_cin_getstate,                                        // #464
1286 VM_cin_restart,                                         // #465
1287 VM_drawline,                                            // #466
1288 VM_drawcolorcodedstring,                // #467
1289 VM_stringwidth,                                 // #468
1290 VM_drawsubpic,                                          // #469
1291 NULL,                                                                   // #470
1292 VM_asin,                                                                // #471 float(float s) VM_asin (DP_QC_ASINACOSATANATAN2TAN)
1293 VM_acos,                                                                // #472 float(float c) VM_acos (DP_QC_ASINACOSATANATAN2TAN)
1294 VM_atan,                                                                // #473 float(float t) VM_atan (DP_QC_ASINACOSATANATAN2TAN)
1295 VM_atan2,                                                       // #474 float(float c, float s) VM_atan2 (DP_QC_ASINACOSATANATAN2TAN)
1296 VM_tan,                                                         // #475 float(float a) VM_tan (DP_QC_ASINACOSATANATAN2TAN)
1297 VM_strlennocol,                                 // #476 float(string s) : DRESK - String Length (not counting color codes) (DP_QC_STRINGCOLORFUNCTIONS)
1298 VM_strdecolorize,                                       // #477 string(string s) : DRESK - Decolorized String (DP_QC_STRINGCOLORFUNCTIONS)
1299 VM_strftime,                                            // #478 string(float uselocaltime, string format, ...) (DP_QC_STRFTIME)
1300 VM_tokenizebyseparator,                 // #479 float(string s) tokenizebyseparator (DP_QC_TOKENIZEBYSEPARATOR)
1301 VM_strtolower,                                          // #480 string(string s) VM_strtolower : DRESK - Return string as lowercase
1302 VM_strtoupper,                                          // #481 string(string s) VM_strtoupper : DRESK - Return string as uppercase
1303 NULL,                                                                   // #482
1304 NULL,                                                                   // #483
1305 VM_strreplace,                                          // #484 string(string search, string replace, string subject) strreplace (DP_QC_STRREPLACE)
1306 VM_strireplace,                                 // #485 string(string search, string replace, string subject) strireplace (DP_QC_STRREPLACE)
1307 NULL,                                                                   // #486
1308 VM_gecko_create,                                        // #487 float gecko_create( string name )
1309 VM_gecko_destroy,                                       // #488 void gecko_destroy( string name )
1310 VM_gecko_navigate,                              // #489 void gecko_navigate( string name, string URI )
1311 VM_gecko_keyevent,                              // #490 float gecko_keyevent( string name, float key, float eventtype )
1312 VM_gecko_movemouse,                             // #491 void gecko_mousemove( string name, float x, float y )
1313 VM_gecko_resize,                                        // #492 void gecko_resize( string name, float w, float h )
1314 VM_gecko_get_texture_extent,    // #493 vector gecko_get_texture_extent( string name )
1315 VM_crc16,                                               // #494 float(float caseinsensitive, string s, ...) crc16 = #494 (DP_QC_CRC16)
1316 VM_cvar_type,                                   // #495 float(string name) cvar_type = #495; (DP_QC_CVAR_TYPE)
1317 NULL,                                                                   // #496
1318 NULL,                                                                   // #497
1319 NULL,                                                                   // #498
1320 NULL,                                                                   // #499
1321 NULL,                                                                   // #500
1322 NULL,                                                                   // #501
1323 NULL,                                                                   // #502
1324 VM_whichpack,                                   // #503 string(string) whichpack = #503;
1325 NULL,                                                                   // #504
1326 NULL,                                                                   // #505
1327 NULL,                                                                   // #506
1328 NULL,                                                                   // #507
1329 NULL,                                                                   // #508
1330 NULL,                                                                   // #509
1331 VM_uri_escape,                                  // #510 string(string in) uri_escape = #510;
1332 VM_uri_unescape,                                // #511 string(string in) uri_unescape = #511;
1333 VM_etof,                                        // #512 float(entity ent) num_for_edict = #512 (DP_QC_NUM_FOR_EDICT)
1334 VM_uri_get,                                             // #513 float(string uril, float id) uri_get = #513; (DP_QC_URI_GET)
1335 NULL,                                                                   // #514
1336 NULL,                                                                   // #515
1337 NULL,                                                                   // #516
1338 NULL,                                                                   // #517
1339 NULL,                                                                   // #518
1340 NULL,                                                                   // #519
1341 NULL,                                                                   // #520
1342 NULL,                                                                   // #521
1343 NULL,                                                                   // #522
1344 NULL,                                                                   // #523
1345 NULL,                                                                   // #524
1346 NULL,                                                                   // #525
1347 NULL,                                                                   // #526
1348 NULL,                                                                   // #527
1349 NULL,                                                                   // #528
1350 NULL,                                                                   // #529
1351 NULL,                                                                   // #530
1352 NULL,                                                                   // #531
1353 NULL,                                                                   // #532
1354 NULL,                                                                   // #533
1355 NULL,                                                                   // #534
1356 NULL,                                                                   // #535
1357 NULL,                                                                   // #536
1358 NULL,                                                                   // #537
1359 NULL,                                                                   // #538
1360 NULL,                                                                   // #539
1361 NULL,                                                                   // #540
1362 NULL,                                                                   // #541
1363 NULL,                                                                   // #542
1364 NULL,                                                                   // #543
1365 NULL,                                                                   // #544
1366 NULL,                                                                   // #545
1367 NULL,                                                                   // #546
1368 NULL,                                                                   // #547
1369 NULL,                                                                   // #548
1370 NULL,                                                                   // #549
1371 NULL,                                                                   // #550
1372 NULL,                                                                   // #551
1373 NULL,                                                                   // #552
1374 NULL,                                                                   // #553
1375 NULL,                                                                   // #554
1376 NULL,                                                                   // #555
1377 NULL,                                                                   // #556
1378 NULL,                                                                   // #557
1379 NULL,                                                                   // #558
1380 NULL,                                                                   // #559
1381 NULL,                                                                   // #560
1382 NULL,                                                                   // #561
1383 NULL,                                                                   // #562
1384 NULL,                                                                   // #563
1385 NULL,                                                                   // #564
1386 NULL,                                                                   // #565
1387 NULL,                                                                   // #566
1388 NULL,                                                                   // #567
1389 NULL,                                                                   // #568
1390 NULL,                                                                   // #569
1391 NULL,                                                                   // #570
1392 NULL,                                                                   // #571
1393 NULL,                                                                   // #572
1394 NULL,                                                                   // #573
1395 NULL,                                                                   // #574
1396 NULL,                                                                   // #575
1397 NULL,                                                                   // #576
1398 NULL,                                                                   // #577
1399 NULL,                                                                   // #578
1400 NULL,                                                                   // #579
1401 NULL,                                                                   // #580
1402 NULL,                                                                   // #581
1403 NULL,                                                                   // #582
1404 NULL,                                                                   // #583
1405 NULL,                                                                   // #584
1406 NULL,                                                                   // #585
1407 NULL,                                                                   // #586
1408 NULL,                                                                   // #587
1409 NULL,                                                                   // #588
1410 NULL,                                                                   // #589
1411 NULL,                                                                   // #590
1412 NULL,                                                                   // #591
1413 NULL,                                                                   // #592
1414 NULL,                                                                   // #593
1415 NULL,                                                                   // #594
1416 NULL,                                                                   // #595
1417 NULL,                                                                   // #596
1418 NULL,                                                                   // #597
1419 NULL,                                                                   // #598
1420 NULL,                                                                   // #599
1421 NULL,                                                                   // #600
1422 VM_M_setkeydest,                                        // #601 void setkeydest(float dest)
1423 VM_M_getkeydest,                                        // #602 float getkeydest(void)
1424 VM_M_setmousetarget,                            // #603 void setmousetarget(float trg)
1425 VM_M_getmousetarget,                            // #604 float getmousetarget(void)
1426 VM_M_callfunction,                              // #605 void callfunction(...)
1427 VM_writetofile,                                 // #606 void writetofile(float fhandle, entity ent)
1428 VM_M_isfunction,                                        // #607 float isfunction(string function_name)
1429 VM_M_getresolution,                             // #608 vector getresolution(float number)
1430 VM_keynumtostring,                              // #609 string keynumtostring(float keynum)
1431 VM_findkeysforcommand,          // #610 string findkeysforcommand(string command)
1432 VM_M_getserverliststat,                 // #611 float gethostcachevalue(float type)
1433 VM_M_getserverliststring,               // #612 string gethostcachestring(float type, float hostnr)
1434 VM_parseentitydata,                             // #613 void parseentitydata(entity ent, string data)
1435 VM_stringtokeynum,                              // #614 float stringtokeynum(string key)
1436 VM_M_resetserverlistmasks,              // #615 void resethostcachemasks(void)
1437 VM_M_setserverlistmaskstring,   // #616 void sethostcachemaskstring(float mask, float fld, string str, float op)
1438 VM_M_setserverlistmasknumber,   // #617 void sethostcachemasknumber(float mask, float fld, float num, float op)
1439 VM_M_resortserverlist,                  // #618 void resorthostcache(void)
1440 VM_M_setserverlistsort,                 // #619 void sethostcachesort(float fld, float descending)
1441 VM_M_refreshserverlist,                 // #620 void refreshhostcache(void)
1442 VM_M_getserverlistnumber,               // #621 float gethostcachenumber(float fld, float hostnr)
1443 VM_M_getserverlistindexforkey,// #622 float gethostcacheindexforkey(string key)
1444 VM_M_addwantedserverlistkey,    // #623 void addwantedhostcachekey(string key)
1445 VM_M_getextresponse,                    // #624 string getextresponse(void)
1446 VM_netaddress_resolve           // #625 string netaddress_resolve(string, float)
1447 };
1448
1449 const int vm_m_numbuiltins = sizeof(vm_m_builtins) / sizeof(prvm_builtin_t);
1450
1451 void VM_M_Cmd_Init(void)
1452 {
1453         r_refdef_scene_t *scene;
1454
1455         VM_Cmd_Init();
1456         VM_Polygons_Reset();
1457
1458         scene = R_GetScenePointer( RST_MENU );
1459
1460         memset (scene, 0, sizeof (*scene));
1461
1462         scene->maxtempentities = 128;
1463         scene->tempentities = (entity_render_t*) Mem_Alloc(prog->progs_mempool, sizeof(entity_render_t) * scene->maxtempentities);
1464
1465         scene->maxentities = MAX_EDICTS + 256 + 512;
1466         scene->entities = (entity_render_t **)Mem_Alloc(prog->progs_mempool, sizeof(entity_render_t *) * scene->maxentities);
1467
1468         scene->ambient = 32.0f;
1469 }
1470
1471 void VM_M_Cmd_Reset(void)
1472 {
1473         // note: the menu's render entities are automatically freed when the prog's pool is freed
1474
1475         //VM_Cmd_Init();
1476         VM_Cmd_Reset();
1477         VM_Polygons_Reset();
1478 }