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