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