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