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