8 // TODO check which strings really should be engine strings
10 //============================================================================
13 const char *vm_m_extensions =
19 "DP_GFX_FONTS_FREETYPE "
21 "DP_FONT_VARIABLEWIDTH "
22 "DP_MENU_EXTRESPONSEPACKET "
23 "DP_QC_ASINACOSATANATAN2TAN "
28 "DP_QC_CVAR_DESCRIPTION "
30 "DP_QC_DIGEST_SHA256 "
31 "DP_QC_FINDCHAIN_TOFIELD "
37 "DP_QC_STRINGBUFFERS "
38 "DP_QC_STRINGBUFFERS_CVARLIST "
39 "DP_QC_STRINGCOLORFUNCTIONS "
40 "DP_QC_STRING_CASE_FUNCTIONS "
42 "DP_QC_TOKENIZEBYSEPARATOR "
43 "DP_QC_TOKENIZE_CONSOLE "
44 "DP_QC_UNLIMITEDTEMPSTRINGS "
56 setmousetarget(float target)
59 static void VM_M_setmousetarget(prvm_prog_t *prog)
61 VM_SAFEPARMCOUNT(1, VM_M_setmousetarget);
63 switch((int)PRVM_G_FLOAT(OFS_PARM0))
66 in_client_mouse = false;
69 in_client_mouse = true;
72 prog->error_cmd("VM_M_setmousetarget: wrong destination %f !",PRVM_G_FLOAT(OFS_PARM0));
83 static void VM_M_getmousetarget(prvm_prog_t *prog)
85 VM_SAFEPARMCOUNT(0,VM_M_getmousetarget);
88 PRVM_G_FLOAT(OFS_RETURN) = 2;
90 PRVM_G_FLOAT(OFS_RETURN) = 1;
99 setkeydest(float dest)
102 static void VM_M_setkeydest(prvm_prog_t *prog)
104 VM_SAFEPARMCOUNT(1,VM_M_setkeydest);
106 switch((int)PRVM_G_FLOAT(OFS_PARM0))
118 key_dest = key_menu_grabbed;
122 // key_dest = key_message
125 prog->error_cmd("VM_M_setkeydest: wrong destination %f !", PRVM_G_FLOAT(OFS_PARM0));
136 static void VM_M_getkeydest(prvm_prog_t *prog)
138 VM_SAFEPARMCOUNT(0,VM_M_getkeydest);
140 // key_game = 0, key_message = 1, key_menu = 2, key_menu_grabbed = 3, unknown = -1
144 PRVM_G_FLOAT(OFS_RETURN) = 0;
147 PRVM_G_FLOAT(OFS_RETURN) = 2;
149 case key_menu_grabbed:
150 PRVM_G_FLOAT(OFS_RETURN) = 3;
154 // PRVM_G_FLOAT(OFS_RETURN) = 1;
157 PRVM_G_FLOAT(OFS_RETURN) = -1;
166 vector getresolution(float number)
169 static void VM_M_getresolution(prvm_prog_t *prog)
172 VM_SAFEPARMCOUNTRANGE(1, 2, VM_getresolution);
174 nr = (int)PRVM_G_FLOAT(OFS_PARM0);
176 fs = ((prog->argc <= 1) || ((int)PRVM_G_FLOAT(OFS_PARM1)));
178 if(nr < 0 || nr >= (fs ? video_resolutions_count : video_resolutions_hardcoded_count))
180 PRVM_G_VECTOR(OFS_RETURN)[0] = 0;
181 PRVM_G_VECTOR(OFS_RETURN)[1] = 0;
182 PRVM_G_VECTOR(OFS_RETURN)[2] = 0;
186 video_resolution_t *r = &((fs ? video_resolutions : video_resolutions_hardcoded)[nr]);
187 PRVM_G_VECTOR(OFS_RETURN)[0] = r->width;
188 PRVM_G_VECTOR(OFS_RETURN)[1] = r->height;
189 PRVM_G_VECTOR(OFS_RETURN)[2] = r->pixelheight;
193 static void VM_M_getgamedirinfo(prvm_prog_t *prog)
196 VM_SAFEPARMCOUNT(2, VM_getgamedirinfo);
198 nr = (int)PRVM_G_FLOAT(OFS_PARM0);
199 item = (int)PRVM_G_FLOAT(OFS_PARM1);
201 PRVM_G_INT( OFS_RETURN ) = OFS_NULL;
203 if(nr >= 0 && nr < fs_all_gamedirs_count)
206 PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString( prog, fs_all_gamedirs[nr].name );
208 PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString( prog, fs_all_gamedirs[nr].description );
214 VM_M_getserverliststat
216 float getserverliststat(float type)
221 0 serverlist_viewcount
222 1 serverlist_totalcount
230 static void VM_M_getserverliststat(prvm_prog_t *prog)
233 VM_SAFEPARMCOUNT ( 1, VM_M_getserverliststat );
235 PRVM_G_FLOAT( OFS_RETURN ) = 0;
237 type = (int)PRVM_G_FLOAT( OFS_PARM0 );
241 PRVM_G_FLOAT ( OFS_RETURN ) = serverlist_viewcount;
244 PRVM_G_FLOAT ( OFS_RETURN ) = serverlist_cachecount;
247 PRVM_G_FLOAT ( OFS_RETURN ) = masterquerycount;
250 PRVM_G_FLOAT ( OFS_RETURN ) = masterreplycount;
253 PRVM_G_FLOAT ( OFS_RETURN ) = serverquerycount;
256 PRVM_G_FLOAT ( OFS_RETURN ) = serverreplycount;
259 PRVM_G_FLOAT ( OFS_RETURN ) = serverlist_sortbyfield;
262 PRVM_G_FLOAT ( OFS_RETURN ) = serverlist_sortflags;
265 VM_Warning(prog, "VM_M_getserverliststat: bad type %i!\n", type );
270 ========================
271 VM_M_resetserverlistmasks
273 resetserverlistmasks()
274 ========================
276 static void VM_M_resetserverlistmasks(prvm_prog_t *prog)
278 VM_SAFEPARMCOUNT(0, VM_M_resetserverlistmasks);
279 ServerList_ResetMasks();
284 ========================
285 VM_M_setserverlistmaskstring
287 setserverlistmaskstring(float mask, float fld, string str, float op)
290 ========================
292 static void VM_M_setserverlistmaskstring(prvm_prog_t *prog)
296 serverlist_mask_t *mask;
299 VM_SAFEPARMCOUNT( 4, VM_M_setserverlistmaskstring );
300 str = PRVM_G_STRING( OFS_PARM2 );
302 masknr = (int)PRVM_G_FLOAT( OFS_PARM0 );
303 if( masknr >= 0 && masknr <= SERVERLIST_ANDMASKCOUNT )
304 mask = &serverlist_andmasks[masknr];
305 else if( masknr >= 512 && masknr - 512 <= SERVERLIST_ORMASKCOUNT )
306 mask = &serverlist_ormasks[masknr - 512 ];
309 VM_Warning(prog, "VM_M_setserverlistmaskstring: invalid mask number %i\n", masknr );
313 field = (int) PRVM_G_FLOAT( OFS_PARM1 );
317 strlcpy( mask->info.cname, str, sizeof(mask->info.cname) );
320 strlcpy( mask->info.name, str, sizeof(mask->info.name) );
323 strlcpy( mask->info.qcstatus, str, sizeof(mask->info.qcstatus) );
326 strlcpy( mask->info.players, str, sizeof(mask->info.players) );
329 strlcpy( mask->info.map, str, sizeof(mask->info.map) );
332 strlcpy( mask->info.mod, str, sizeof(mask->info.mod) );
335 strlcpy( mask->info.game, str, sizeof(mask->info.game) );
338 VM_Warning(prog, "VM_M_setserverlistmaskstring: Bad field number %i passed!\n", field );
343 mask->tests[field] = (serverlist_maskop_t)((int)PRVM_G_FLOAT( OFS_PARM3 ));
347 ========================
348 VM_M_setserverlistmasknumber
350 setserverlistmasknumber(float mask, float fld, float num, float op)
354 ========================
356 static void VM_M_setserverlistmasknumber(prvm_prog_t *prog)
359 serverlist_mask_t *mask;
362 VM_SAFEPARMCOUNT( 4, VM_M_setserverlistmasknumber );
364 masknr = (int)PRVM_G_FLOAT( OFS_PARM0 );
365 if( masknr >= 0 && masknr <= SERVERLIST_ANDMASKCOUNT )
366 mask = &serverlist_andmasks[masknr];
367 else if( masknr >= 512 && masknr - 512 <= SERVERLIST_ORMASKCOUNT )
368 mask = &serverlist_ormasks[masknr - 512 ];
371 VM_Warning(prog, "VM_M_setserverlistmasknumber: invalid mask number %i\n", masknr );
375 number = (int)PRVM_G_FLOAT( OFS_PARM2 );
376 field = (int) PRVM_G_FLOAT( OFS_PARM1 );
379 case SLIF_MAXPLAYERS:
380 mask->info.maxplayers = number;
382 case SLIF_NUMPLAYERS:
383 mask->info.numplayers = number;
386 mask->info.numbots = number;
389 mask->info.numhumans = number;
392 mask->info.ping = number;
395 mask->info.protocol = number;
398 mask->info.freeslots = number;
400 case SLIF_ISFAVORITE:
401 mask->info.isfavorite = number != 0;
404 VM_Warning(prog, "VM_M_setserverlistmasknumber: Bad field number %i passed!\n", field );
409 mask->tests[field] = (serverlist_maskop_t)((int)PRVM_G_FLOAT( OFS_PARM3 ));
414 ========================
415 VM_M_resortserverlist
418 ========================
420 static void VM_M_resortserverlist(prvm_prog_t *prog)
422 VM_SAFEPARMCOUNT(0, VM_M_resortserverlist);
423 ServerList_RebuildViewList();
428 VM_M_getserverliststring
430 string getserverliststring(float field, float hostnr)
433 static void VM_M_getserverliststring(prvm_prog_t *prog)
435 serverlist_entry_t *cache;
438 VM_SAFEPARMCOUNT(2, VM_M_getserverliststring);
440 PRVM_G_INT(OFS_RETURN) = OFS_NULL;
442 hostnr = (int)PRVM_G_FLOAT(OFS_PARM1);
444 if(hostnr < 0 || hostnr >= serverlist_viewcount)
446 Con_Print("VM_M_getserverliststring: bad hostnr passed!\n");
449 cache = ServerList_GetViewEntry(hostnr);
450 switch( (int) PRVM_G_FLOAT(OFS_PARM0) ) {
452 PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString( prog, cache->info.cname );
455 PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString( prog, cache->info.name );
458 PRVM_G_INT (OFS_RETURN ) = PRVM_SetTempString( prog, cache->info.qcstatus );
461 PRVM_G_INT (OFS_RETURN ) = PRVM_SetTempString( prog, cache->info.players );
464 PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString( prog, cache->info.game );
467 PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString( prog, cache->info.mod );
470 PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString( prog, cache->info.map );
472 // TODO remove this again
474 PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString( prog, cache->line1 );
477 PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString( prog, cache->line2 );
480 Con_Print("VM_M_getserverliststring: bad field number passed!\n");
486 VM_M_getserverlistnumber
488 float getserverlistnumber(float field, float hostnr)
491 static void VM_M_getserverlistnumber(prvm_prog_t *prog)
493 serverlist_entry_t *cache;
496 VM_SAFEPARMCOUNT(2, VM_M_getserverliststring);
498 PRVM_G_INT(OFS_RETURN) = OFS_NULL;
500 hostnr = (int)PRVM_G_FLOAT(OFS_PARM1);
502 if(hostnr < 0 || hostnr >= serverlist_viewcount)
504 Con_Print("VM_M_getserverliststring: bad hostnr passed!\n");
507 cache = ServerList_GetViewEntry(hostnr);
508 switch( (int) PRVM_G_FLOAT(OFS_PARM0) ) {
509 case SLIF_MAXPLAYERS:
510 PRVM_G_FLOAT( OFS_RETURN ) = cache->info.maxplayers;
512 case SLIF_NUMPLAYERS:
513 PRVM_G_FLOAT( OFS_RETURN ) = cache->info.numplayers;
516 PRVM_G_FLOAT( OFS_RETURN ) = cache->info.numbots;
519 PRVM_G_FLOAT( OFS_RETURN ) = cache->info.numhumans;
522 PRVM_G_FLOAT( OFS_RETURN ) = cache->info.freeslots;
525 PRVM_G_FLOAT( OFS_RETURN ) = cache->info.ping;
528 PRVM_G_FLOAT( OFS_RETURN ) = cache->info.protocol;
530 case SLIF_ISFAVORITE:
531 PRVM_G_FLOAT( OFS_RETURN ) = cache->info.isfavorite;
534 Con_Print("VM_M_getserverlistnumber: bad field number passed!\n");
539 ========================
540 VM_M_setserverlistsort
542 setserverlistsort(float field, float flags)
543 ========================
545 static void VM_M_setserverlistsort(prvm_prog_t *prog)
547 VM_SAFEPARMCOUNT( 2, VM_M_setserverlistsort );
549 serverlist_sortbyfield = (serverlist_infofield_t)((int)PRVM_G_FLOAT( OFS_PARM0 ));
550 serverlist_sortflags = (int) PRVM_G_FLOAT( OFS_PARM1 );
554 ========================
555 VM_M_refreshserverlist
558 ========================
560 static void VM_M_refreshserverlist(prvm_prog_t *prog)
562 VM_SAFEPARMCOUNT( 0, VM_M_refreshserverlist );
563 ServerList_QueryList(false, true, false, false);
567 ========================
568 VM_M_getserverlistindexforkey
570 float getserverlistindexforkey(string key)
571 ========================
573 static void VM_M_getserverlistindexforkey(prvm_prog_t *prog)
576 VM_SAFEPARMCOUNT( 1, VM_M_getserverlistindexforkey );
578 key = PRVM_G_STRING( OFS_PARM0 );
579 VM_CheckEmptyString( prog, key );
581 if( !strcmp( key, "cname" ) )
582 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_CNAME;
583 else if( !strcmp( key, "ping" ) )
584 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_PING;
585 else if( !strcmp( key, "game" ) )
586 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_GAME;
587 else if( !strcmp( key, "mod" ) )
588 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_MOD;
589 else if( !strcmp( key, "map" ) )
590 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_MAP;
591 else if( !strcmp( key, "name" ) )
592 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_NAME;
593 else if( !strcmp( key, "qcstatus" ) )
594 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_QCSTATUS;
595 else if( !strcmp( key, "players" ) )
596 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_PLAYERS;
597 else if( !strcmp( key, "maxplayers" ) )
598 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_MAXPLAYERS;
599 else if( !strcmp( key, "numplayers" ) )
600 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_NUMPLAYERS;
601 else if( !strcmp( key, "numbots" ) )
602 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_NUMBOTS;
603 else if( !strcmp( key, "numhumans" ) )
604 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_NUMHUMANS;
605 else if( !strcmp( key, "freeslots" ) )
606 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_FREESLOTS;
607 else if( !strcmp( key, "protocol" ) )
608 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_PROTOCOL;
609 else if( !strcmp( key, "isfavorite" ) )
610 PRVM_G_FLOAT( OFS_RETURN ) = SLIF_ISFAVORITE;
612 PRVM_G_FLOAT( OFS_RETURN ) = -1;
616 ========================
617 VM_M_addwantedserverlistkey
619 addwantedserverlistkey(string key)
620 ========================
622 static void VM_M_addwantedserverlistkey(prvm_prog_t *prog)
624 VM_SAFEPARMCOUNT( 1, VM_M_addwantedserverlistkey );
628 ===============================================================================
631 used only for client and menu
632 server uses VM_SV_...
634 Write*(* data, float type, float to)
636 ===============================================================================
639 #define MSG_BROADCAST 0 // unreliable to all
640 #define MSG_ONE 1 // reliable to one (msg_entity)
641 #define MSG_ALL 2 // reliable to all
642 #define MSG_INIT 3 // write to the init string
644 static sizebuf_t *VM_M_WriteDest (prvm_prog_t *prog)
650 prog->error_cmd("VM_M_WriteDest: game is not server (%s)", prog->name);
652 dest = (int)PRVM_G_FLOAT(OFS_PARM1);
659 destclient = (int) PRVM_G_FLOAT(OFS_PARM2);
660 if (destclient < 0 || destclient >= svs.maxclients || !svs.clients[destclient].active || !svs.clients[destclient].netconnection)
661 prog->error_cmd("VM_clientcommand: %s: invalid client !", prog->name);
663 return &svs.clients[destclient].netconnection->message;
666 return &sv.reliable_datagram;
672 prog->error_cmd("WriteDest: bad destination");
679 static void VM_M_WriteByte (prvm_prog_t *prog)
681 VM_SAFEPARMCOUNT(1, VM_M_WriteByte);
682 MSG_WriteByte (VM_M_WriteDest(prog), (int)PRVM_G_FLOAT(OFS_PARM0));
685 static void VM_M_WriteChar (prvm_prog_t *prog)
687 VM_SAFEPARMCOUNT(1, VM_M_WriteChar);
688 MSG_WriteChar (VM_M_WriteDest(prog), (int)PRVM_G_FLOAT(OFS_PARM0));
691 static void VM_M_WriteShort (prvm_prog_t *prog)
693 VM_SAFEPARMCOUNT(1, VM_M_WriteShort);
694 MSG_WriteShort (VM_M_WriteDest(prog), (int)PRVM_G_FLOAT(OFS_PARM0));
697 static void VM_M_WriteLong (prvm_prog_t *prog)
699 VM_SAFEPARMCOUNT(1, VM_M_WriteLong);
700 MSG_WriteLong (VM_M_WriteDest(prog), (int)PRVM_G_FLOAT(OFS_PARM0));
703 static void VM_M_WriteAngle (prvm_prog_t *prog)
705 VM_SAFEPARMCOUNT(1, VM_M_WriteAngle);
706 MSG_WriteAngle (VM_M_WriteDest(prog), PRVM_G_FLOAT(OFS_PARM0), sv.protocol);
709 static void VM_M_WriteCoord (prvm_prog_t *prog)
711 VM_SAFEPARMCOUNT(1, VM_M_WriteCoord);
712 MSG_WriteCoord (VM_M_WriteDest(prog), PRVM_G_FLOAT(OFS_PARM0), sv.protocol);
715 static void VM_M_WriteString (prvm_prog_t *prog)
717 VM_SAFEPARMCOUNT(1, VM_M_WriteString);
718 MSG_WriteString (VM_M_WriteDest(prog), PRVM_G_STRING(OFS_PARM0));
721 static void VM_M_WriteEntity (prvm_prog_t *prog)
723 VM_SAFEPARMCOUNT(1, VM_M_WriteEntity);
724 MSG_WriteShort (VM_M_WriteDest(prog), PRVM_G_EDICTNUM(OFS_PARM0));
731 copies data from one entity to another
733 copyentity(entity src, entity dst)
736 static void VM_M_copyentity (prvm_prog_t *prog)
738 prvm_edict_t *in, *out;
739 VM_SAFEPARMCOUNT(2,VM_M_copyentity);
740 in = PRVM_G_EDICT(OFS_PARM0);
741 out = PRVM_G_EDICT(OFS_PARM1);
742 memcpy(out->fields.vp, in->fields.vp, prog->entityfields * 4);
745 //#66 vector() getmousepos (EXT_CSQC)
746 static void VM_M_getmousepos(prvm_prog_t *prog)
748 VM_SAFEPARMCOUNT(0,VM_M_getmousepos);
750 if (key_consoleactive || (key_dest != key_menu && key_dest != key_menu_grabbed))
751 VectorSet(PRVM_G_VECTOR(OFS_RETURN), 0, 0, 0);
752 else if (in_client_mouse)
753 VectorSet(PRVM_G_VECTOR(OFS_RETURN), in_windowmouse_x * vid_conwidth.integer / vid.width, in_windowmouse_y * vid_conheight.integer / vid.height, 0);
755 VectorSet(PRVM_G_VECTOR(OFS_RETURN), in_mouse_x * vid_conwidth.integer / vid.width, in_mouse_y * vid_conheight.integer / vid.height, 0);
758 static void VM_M_crypto_getkeyfp(prvm_prog_t *prog)
762 char keyfp[FP64_SIZE + 1];
764 VM_SAFEPARMCOUNT(1,VM_M_crypto_getkeyfp);
766 s = PRVM_G_STRING( OFS_PARM0 );
767 VM_CheckEmptyString( prog, s );
769 if(LHNETADDRESS_FromString(&addr, s, 26000) && Crypto_RetrieveHostKey(&addr, NULL, keyfp, sizeof(keyfp), NULL, 0, NULL))
770 PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString( prog, keyfp );
772 PRVM_G_INT( OFS_RETURN ) = OFS_NULL;
774 static void VM_M_crypto_getidfp(prvm_prog_t *prog)
778 char idfp[FP64_SIZE + 1];
780 VM_SAFEPARMCOUNT(1,VM_M_crypto_getidfp);
782 s = PRVM_G_STRING( OFS_PARM0 );
783 VM_CheckEmptyString( prog, s );
785 if(LHNETADDRESS_FromString(&addr, s, 26000) && Crypto_RetrieveHostKey(&addr, NULL, NULL, 0, idfp, sizeof(idfp), NULL))
786 PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString( prog, idfp );
788 PRVM_G_INT( OFS_RETURN ) = OFS_NULL;
790 static void VM_M_crypto_getencryptlevel(prvm_prog_t *prog)
797 VM_SAFEPARMCOUNT(1,VM_M_crypto_getencryptlevel);
799 s = PRVM_G_STRING( OFS_PARM0 );
800 VM_CheckEmptyString( prog, s );
802 if(LHNETADDRESS_FromString(&addr, s, 26000) && Crypto_RetrieveHostKey(&addr, NULL, NULL, 0, NULL, 0, &aeslevel))
803 PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString(prog, aeslevel ? va(vabuf, sizeof(vabuf), "%d AES128", aeslevel) : "0");
805 PRVM_G_INT( OFS_RETURN ) = OFS_NULL;
807 static void VM_M_crypto_getmykeyfp(prvm_prog_t *prog)
810 char keyfp[FP64_SIZE + 1];
812 VM_SAFEPARMCOUNT(1,VM_M_crypto_getmykey);
814 i = PRVM_G_FLOAT( OFS_PARM0 );
815 switch(Crypto_RetrieveLocalKey(i, keyfp, sizeof(keyfp), NULL, 0, NULL))
818 PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString(prog, "");
821 PRVM_G_INT( OFS_RETURN ) = OFS_NULL;
825 PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString(prog, keyfp);
829 static void VM_M_crypto_getmyidfp(prvm_prog_t *prog)
832 char idfp[FP64_SIZE + 1];
834 VM_SAFEPARMCOUNT(1,VM_M_crypto_getmykey);
836 i = PRVM_G_FLOAT( OFS_PARM0 );
837 switch(Crypto_RetrieveLocalKey(i, NULL, 0, idfp, sizeof(idfp), NULL))
840 PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString(prog, "");
843 PRVM_G_INT( OFS_RETURN ) = OFS_NULL;
847 PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString(prog, idfp);
851 static void VM_M_crypto_getmyidstatus(prvm_prog_t *prog)
856 VM_SAFEPARMCOUNT(1,VM_M_crypto_getmykey);
858 i = PRVM_G_FLOAT( OFS_PARM0 );
859 switch(Crypto_RetrieveLocalKey(i, NULL, 0, NULL, 0, &issigned))
862 PRVM_G_FLOAT( OFS_RETURN ) = 0; // have no ID there
865 PRVM_G_FLOAT( OFS_RETURN ) = -1; // out of range
869 PRVM_G_FLOAT( OFS_RETURN ) = issigned ? 2 : 1;
874 prvm_builtin_t vm_m_builtins[] = {
875 NULL, // #0 NULL function (not callable)
876 VM_checkextension, // #1
882 VM_centerprint, // #7
886 VM_vectoangles, // #11
902 VM_findchainfloat, // #27
903 VM_precache_file, // #28
904 VM_precache_sound, // #29
917 VM_registercvar, // #42
922 VM_M_copyentity, // #47
936 VM_clientcount, // #61
937 VM_clientstate, // #62
939 VM_changelevel, // #64
940 VM_localsound, // #65
941 VM_M_getmousepos, // #66
943 VM_loadfromdata, // #68
944 VM_loadfromfile, // #69
946 VM_cvar_string, // #71
949 VM_search_begin, // #74
950 VM_search_end, // #75
951 VM_search_getsize, // #76
952 VM_search_getfilename, // #77
956 VM_itof, // #81 isString
957 VM_altstr_count, // #82
958 VM_altstr_prepare, // #83
959 VM_altstr_get, // #84
960 VM_altstr_set, // #85
961 VM_altstr_ins, // #86
963 VM_findchainflags, // #88
964 VM_cvar_defstring, // #89
965 // deactivate support for model rendering in the menu until someone has time to do it right [3/2/2008 Andreas]
967 VM_CL_setmodel, // #90 void(entity e, string m) setmodel (QUAKE)
968 VM_CL_precache_model, // #91 void(string s) precache_model (QUAKE)
969 VM_CL_setorigin, // #92 void(entity e, vector o) setorigin (QUAKE)
1103 VM_strstrofs, // #221 float(string str, string sub[, float startpos]) strstrofs (FTE_STRINGS)
1104 VM_str2chr, // #222 float(string str, float ofs) str2chr (FTE_STRINGS)
1105 VM_chr2str, // #223 string(float c, ...) chr2str (FTE_STRINGS)
1106 VM_strconv, // #224 string(float ccase, float calpha, float cnum, string s, ...) strconv (FTE_STRINGS)
1107 VM_strpad, // #225 string(float chars, string s, ...) strpad (FTE_STRINGS)
1108 VM_infoadd, // #226 string(string info, string key, string value, ...) infoadd (FTE_STRINGS)
1109 VM_infoget, // #227 string(string info, string key) infoget (FTE_STRINGS)
1110 VM_strncmp, // #228 float(string s1, string s2, float len) strncmp (FTE_STRINGS)
1111 VM_strncasecmp, // #229 float(string s1, string s2) strcasecmp (FTE_STRINGS)
1112 VM_strncasecmp, // #230 float(string s1, string s2, float len) strncasecmp (FTE_STRINGS)
1182 // deactivate support for model rendering in the menu until someone has time to do it right [3/2/2008 Andreas]
1184 // CSQC range #300-#399
1185 VM_CL_R_ClearScene, // #300 void() clearscene (DP_QC_RENDER_SCENE)
1186 VM_CL_R_AddEntities, // #301 void(float mask) addentities (DP_QC_RENDER_SCENE)
1187 VM_CL_R_AddEntity, // #302 void(entity ent) addentity (DP_QC_RENDER_SCENE)
1188 VM_CL_R_SetView, // #303 float(float property, ...) setproperty (DP_QC_RENDER_SCENE)
1189 VM_CL_R_RenderScene, // #304 void() renderscene (DP_QC_RENDER_SCENE)
1190 VM_CL_R_AddDynamicLight, // #305 void(vector org, float radius, vector lightcolours) adddynamiclight (DP_QC_RENDER_SCENE)
1191 VM_CL_R_PolygonBegin, // #306 void(string texturename, float flag[, float is2d, float lines]) R_BeginPolygon (DP_QC_RENDER_SCENE)
1192 VM_CL_R_PolygonVertex, // #307 void(vector org, vector texcoords, vector rgb, float alpha) R_PolygonVertex (DP_QC_RENDER_SCENE)
1193 VM_CL_R_PolygonEnd, // #308 void() R_EndPolygon
1194 NULL/*VM_CL_R_LoadWorldModel*/, // #309 void(string modelname) R_LoadWorldModel
1195 // TODO: rearrange and merge all builtin lists and share as many extensions as possible between all VM instances [1/27/2008 Andreas]
1196 VM_CL_setattachment, // #310 void(entity e, entity tagentity, string tagname) setattachment (DP_GFX_QUAKE3MODELTAGS) (DP_QC_RENDER_SCENE)
1197 VM_CL_gettagindex, // #311 float(entity ent, string tagname) gettagindex (DP_QC_GETTAGINFO) (DP_QC_RENDER_SCENE)
1198 VM_CL_gettaginfo, // #312 vector(entity ent, float tagindex) gettaginfo (DP_QC_GETTAGINFO) (DP_QC_RENDER_SCENE)
1200 // CSQC range #300-#399
1242 VM_keynumtostring, // #340 string keynumtostring(float keynum)
1243 VM_stringtokeynum, // #341 float stringtokeynum(string key)
1244 VM_getkeybind, // #342 string(float keynum[, float bindmap]) getkeybind (EXT_CSQC)
1251 VM_CL_isdemo, // #349
1255 VM_wasfreed, // #353 float(entity ent) wasfreed
1257 VM_CL_videoplaying, // #355
1258 VM_findfont, // #356 float(string fontname) loadfont (DP_GFX_FONTS)
1259 VM_loadfont, // #357 float(string fontname, string fontmaps, string sizes, float slot) loadfont (DP_GFX_FONTS)
1303 VM_M_WriteByte, // #401
1304 VM_M_WriteChar, // #402
1305 VM_M_WriteShort, // #403
1306 VM_M_WriteLong, // #404
1307 VM_M_WriteAngle, // #405
1308 VM_M_WriteCoord, // #406
1309 VM_M_WriteString, // #407
1310 VM_M_WriteEntity, // #408
1342 VM_buf_create, // #440 float() buf_create (DP_QC_STRINGBUFFERS)
1343 VM_buf_del, // #441 void(float bufhandle) buf_del (DP_QC_STRINGBUFFERS)
1344 VM_buf_getsize, // #442 float(float bufhandle) buf_getsize (DP_QC_STRINGBUFFERS)
1345 VM_buf_copy, // #443 void(float bufhandle_from, float bufhandle_to) buf_copy (DP_QC_STRINGBUFFERS)
1346 VM_buf_sort, // #444 void(float bufhandle, float sortpower, float backward) buf_sort (DP_QC_STRINGBUFFERS)
1347 VM_buf_implode, // #445 string(float bufhandle, string glue) buf_implode (DP_QC_STRINGBUFFERS)
1348 VM_bufstr_get, // #446 string(float bufhandle, float string_index) bufstr_get (DP_QC_STRINGBUFFERS)
1349 VM_bufstr_set, // #447 void(float bufhandle, float string_index, string str) bufstr_set (DP_QC_STRINGBUFFERS)
1350 VM_bufstr_add, // #448 float(float bufhandle, string str, float order) bufstr_add (DP_QC_STRINGBUFFERS)
1351 VM_bufstr_free, // #449 void(float bufhandle, float string_index) bufstr_free (DP_QC_STRINGBUFFERS)
1353 VM_iscachedpic, // #451 draw functions...
1354 VM_precache_pic, // #452
1356 VM_drawcharacter, // #454
1357 VM_drawstring, // #455
1359 VM_drawfill, // #457
1360 VM_drawsetcliparea, // #458
1361 VM_drawresetcliparea, // #459
1362 VM_getimagesize, // #460
1363 VM_cin_open, // #461
1364 VM_cin_close, // #462
1365 VM_cin_setstate, // #463
1366 VM_cin_getstate, // #464
1367 VM_cin_restart, // #465
1368 VM_drawline, // #466
1369 VM_drawcolorcodedstring, // #467
1370 VM_stringwidth, // #468
1371 VM_drawsubpic, // #469
1372 VM_drawrotpic, // #470
1373 VM_asin, // #471 float(float s) VM_asin (DP_QC_ASINACOSATANATAN2TAN)
1374 VM_acos, // #472 float(float c) VM_acos (DP_QC_ASINACOSATANATAN2TAN)
1375 VM_atan, // #473 float(float t) VM_atan (DP_QC_ASINACOSATANATAN2TAN)
1376 VM_atan2, // #474 float(float c, float s) VM_atan2 (DP_QC_ASINACOSATANATAN2TAN)
1377 VM_tan, // #475 float(float a) VM_tan (DP_QC_ASINACOSATANATAN2TAN)
1378 VM_strlennocol, // #476 float(string s) : DRESK - String Length (not counting color codes) (DP_QC_STRINGCOLORFUNCTIONS)
1379 VM_strdecolorize, // #477 string(string s) : DRESK - Decolorized String (DP_QC_STRINGCOLORFUNCTIONS)
1380 VM_strftime, // #478 string(float uselocaltime, string format, ...) (DP_QC_STRFTIME)
1381 VM_tokenizebyseparator, // #479 float(string s) tokenizebyseparator (DP_QC_TOKENIZEBYSEPARATOR)
1382 VM_strtolower, // #480 string(string s) VM_strtolower : DRESK - Return string as lowercase
1383 VM_strtoupper, // #481 string(string s) VM_strtoupper : DRESK - Return string as uppercase
1386 VM_strreplace, // #484 string(string search, string replace, string subject) strreplace (DP_QC_STRREPLACE)
1387 VM_strireplace, // #485 string(string search, string replace, string subject) strireplace (DP_QC_STRREPLACE)
1389 VM_gecko_create, // #487 float gecko_create( string name )
1390 VM_gecko_destroy, // #488 void gecko_destroy( string name )
1391 VM_gecko_navigate, // #489 void gecko_navigate( string name, string URI )
1392 VM_gecko_keyevent, // #490 float gecko_keyevent( string name, float key, float eventtype )
1393 VM_gecko_movemouse, // #491 void gecko_mousemove( string name, float x, float y )
1394 VM_gecko_resize, // #492 void gecko_resize( string name, float w, float h )
1395 VM_gecko_get_texture_extent, // #493 vector gecko_get_texture_extent( string name )
1396 VM_crc16, // #494 float(float caseinsensitive, string s, ...) crc16 = #494 (DP_QC_CRC16)
1397 VM_cvar_type, // #495 float(string name) cvar_type = #495; (DP_QC_CVAR_TYPE)
1405 VM_whichpack, // #503 string(string) whichpack = #503;
1412 VM_uri_escape, // #510 string(string in) uri_escape = #510;
1413 VM_uri_unescape, // #511 string(string in) uri_unescape = #511;
1414 VM_etof, // #512 float(entity ent) num_for_edict = #512 (DP_QC_NUM_FOR_EDICT)
1415 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)
1416 VM_tokenize_console, // #514 float(string str) tokenize_console = #514; (DP_QC_TOKENIZE_CONSOLE)
1417 VM_argv_start_index, // #515 float(float idx) argv_start_index = #515; (DP_QC_TOKENIZE_CONSOLE)
1418 VM_argv_end_index, // #516 float(float idx) argv_end_index = #516; (DP_QC_TOKENIZE_CONSOLE)
1419 VM_buf_cvarlist, // #517 void(float buf, string prefix, string antiprefix) buf_cvarlist = #517; (DP_QC_STRINGBUFFERS_CVARLIST)
1420 VM_cvar_description, // #518 float(string name) cvar_description = #518; (DP_QC_CVAR_DESCRIPTION)
1435 VM_getsoundtime, // #533 float(entity e, float channel) getsoundtime = #533; (DP_SND_GETSOUNDTIME)
1436 VM_soundlength, // #534 float(string sample) soundlength = #534; (DP_SND_GETSOUNDTIME)
1503 VM_M_setkeydest, // #601 void setkeydest(float dest)
1504 VM_M_getkeydest, // #602 float getkeydest(void)
1505 VM_M_setmousetarget, // #603 void setmousetarget(float trg)
1506 VM_M_getmousetarget, // #604 float getmousetarget(void)
1507 VM_callfunction, // #605 void callfunction(...)
1508 VM_writetofile, // #606 void writetofile(float fhandle, entity ent)
1509 VM_isfunction, // #607 float isfunction(string function_name)
1510 VM_M_getresolution, // #608 vector getresolution(float number, [float forfullscreen])
1511 VM_keynumtostring, // #609 string keynumtostring(float keynum)
1512 VM_findkeysforcommand, // #610 string findkeysforcommand(string command[, float bindmap])
1513 VM_M_getserverliststat, // #611 float gethostcachevalue(float type)
1514 VM_M_getserverliststring, // #612 string gethostcachestring(float type, float hostnr)
1515 VM_parseentitydata, // #613 void parseentitydata(entity ent, string data)
1516 VM_stringtokeynum, // #614 float stringtokeynum(string key)
1517 VM_M_resetserverlistmasks, // #615 void resethostcachemasks(void)
1518 VM_M_setserverlistmaskstring, // #616 void sethostcachemaskstring(float mask, float fld, string str, float op)
1519 VM_M_setserverlistmasknumber, // #617 void sethostcachemasknumber(float mask, float fld, float num, float op)
1520 VM_M_resortserverlist, // #618 void resorthostcache(void)
1521 VM_M_setserverlistsort, // #619 void sethostcachesort(float fld, float descending)
1522 VM_M_refreshserverlist, // #620 void refreshhostcache(void)
1523 VM_M_getserverlistnumber, // #621 float gethostcachenumber(float fld, float hostnr)
1524 VM_M_getserverlistindexforkey,// #622 float gethostcacheindexforkey(string key)
1525 VM_M_addwantedserverlistkey, // #623 void addwantedhostcachekey(string key)
1526 VM_CL_getextresponse, // #624 string getextresponse(void)
1527 VM_netaddress_resolve, // #625 string netaddress_resolve(string, float)
1528 VM_M_getgamedirinfo, // #626 string getgamedirinfo(float n, float prop)
1529 VM_sprintf, // #627 string sprintf(string format, ...)
1532 VM_setkeybind, // #630 float(float key, string bind[, float bindmap]) setkeybind
1533 VM_getbindmaps, // #631 vector(void) getbindmap
1534 VM_setbindmaps, // #632 float(vector bm) setbindmap
1535 VM_M_crypto_getkeyfp, // #633 string(string addr) crypto_getkeyfp
1536 VM_M_crypto_getidfp, // #634 string(string addr) crypto_getidfp
1537 VM_M_crypto_getencryptlevel, // #635 string(string addr) crypto_getencryptlevel
1538 VM_M_crypto_getmykeyfp, // #636 string(float addr) crypto_getmykeyfp
1539 VM_M_crypto_getmyidfp, // #637 string(float addr) crypto_getmyidfp
1541 VM_digest_hex, // #639
1543 VM_M_crypto_getmyidstatus, // #641 float(float i) crypto_getmyidstatus
1547 const int vm_m_numbuiltins = sizeof(vm_m_builtins) / sizeof(prvm_builtin_t);
1549 void MVM_init_cmd(prvm_prog_t *prog)
1551 r_refdef_scene_t *scene;
1554 VM_Polygons_Reset(prog);
1556 scene = R_GetScenePointer( RST_MENU );
1558 memset (scene, 0, sizeof (*scene));
1560 scene->maxtempentities = 128;
1561 scene->tempentities = (entity_render_t*) Mem_Alloc(prog->progs_mempool, sizeof(entity_render_t) * scene->maxtempentities);
1563 scene->maxentities = MAX_EDICTS + 256 + 512;
1564 scene->entities = (entity_render_t **)Mem_Alloc(prog->progs_mempool, sizeof(entity_render_t *) * scene->maxentities);
1566 scene->ambient = 32.0f;
1569 void MVM_reset_cmd(prvm_prog_t *prog)
1571 // note: the menu's render entities are automatically freed when the prog's pool is freed
1575 VM_Polygons_Reset(prog);