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