]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - mvm_cmds.c
also check ticrate movevar
[xonotic/darkplaces.git] / mvm_cmds.c
index 0581a1c8446ea25c17696016c0e98c530472b2fe..9b832d7c91baf4afcfddd5de3373c174fc7705bd 100644 (file)
@@ -4,6 +4,8 @@
 #include "clvm_cmds.h"
 #include "menu.h"
 
+// TODO check which strings really should be engine strings
+
 //============================================================================
 // Menu
 
@@ -17,15 +19,20 @@ char *vm_m_extensions =
 "DP_QC_CMD "
 "DP_QC_CRC16 "
 "DP_QC_CVAR_TYPE "
+"DP_QC_CVAR_DESCRIPTION "
+"DP_QC_FINDCHAIN_TOFIELD "
 "DP_QC_RENDER_SCENE "
 "DP_QC_STRFTIME "
 "DP_QC_STRINGBUFFERS "
+"DP_QC_STRINGBUFFERS_CVARLIST "
 "DP_QC_STRINGCOLORFUNCTIONS "
 "DP_QC_STRING_CASE_FUNCTIONS "
 "DP_QC_STRREPLACE "
 "DP_QC_TOKENIZEBYSEPARATOR "
+"DP_QC_TOKENIZE_CONSOLE "
 "DP_QC_UNLIMITEDTEMPSTRINGS "
 "DP_QC_URI_ESCAPE "
+"DP_QC_URI_GET "
 "DP_QC_WHICHPACK "
 "FTE_STRINGS "
 ;
@@ -217,49 +224,44 @@ vector    getresolution(float number)
 */
 void VM_M_getresolution(void)
 {
-       int nr;
-       VM_SAFEPARMCOUNT(1, VM_getresolution);
+       int nr, fs;
+       VM_SAFEPARMCOUNTRANGE(1, 2, VM_getresolution);
 
        nr = (int)PRVM_G_FLOAT(OFS_PARM0);
 
-       // FIXME bounds check
-       PRVM_G_VECTOR(OFS_RETURN)[0] = video_resolutions[nr].width;
-       PRVM_G_VECTOR(OFS_RETURN)[1] = video_resolutions[nr].height;
-       PRVM_G_VECTOR(OFS_RETURN)[2] = 0;
-}
-
-/*
-=========
-VM_M_findkeysforcommand
-
-string findkeysforcommand(string command)
+       fs = ((prog->argc <= 1) || ((int)PRVM_G_FLOAT(OFS_PARM1)));
 
-the returned string is an altstring
-=========
-*/
-#define NUMKEYS 5 // TODO: merge the constant in keys.c with this one somewhen
+       if(nr < 0 || nr >= (fs ? video_resolutions_count : video_resolutions_hardcoded_count))
+       {
+               PRVM_G_VECTOR(OFS_RETURN)[0] = 0;
+               PRVM_G_VECTOR(OFS_RETURN)[1] = 0;
+               PRVM_G_VECTOR(OFS_RETURN)[2] = 0;
+       }
+       else
+       {
+               PRVM_G_VECTOR(OFS_RETURN)[0] = (fs ? video_resolutions : video_resolutions_hardcoded)[nr].width;
+               PRVM_G_VECTOR(OFS_RETURN)[1] = (fs ? video_resolutions : video_resolutions_hardcoded)[nr].height;
+               PRVM_G_VECTOR(OFS_RETURN)[2] = 0;
+       }
+}
 
-void M_FindKeysForCommand(const char *command, int *keys);
-void VM_M_findkeysforcommand(void)
+void VM_M_getgamedirinfo(void)
 {
-       const char *cmd;
-       char ret[VM_STRINGTEMP_LENGTH];
-       int keys[NUMKEYS];
-       int i;
-
-       VM_SAFEPARMCOUNT(1, VM_M_findkeysforcommand);
-
-       cmd = PRVM_G_STRING(OFS_PARM0);
+       int nr, item;
+       VM_SAFEPARMCOUNT(2, VM_getgamedirinfo);
 
-       VM_CheckEmptyString(cmd);
-
-       M_FindKeysForCommand(cmd, keys);
+       nr = (int)PRVM_G_FLOAT(OFS_PARM0);
+       item = (int)PRVM_G_FLOAT(OFS_PARM1);
 
-       ret[0] = 0;
-       for(i = 0; i < NUMKEYS; i++)
-               strlcat(ret, va(" \'%i\'", keys[i]), sizeof(ret));
+       PRVM_G_INT( OFS_RETURN ) = OFS_NULL;
 
-       PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(ret);
+       if(nr >= 0 && nr < fs_all_gamedirs_count)
+       {
+               if(item == 0)
+                       PRVM_G_INT( OFS_RETURN ) = PRVM_SetEngineString( fs_all_gamedirs[nr].name );
+               else if(item == 1)
+                       PRVM_G_INT( OFS_RETURN ) = PRVM_SetEngineString( fs_all_gamedirs[nr].description );
+       }
 }
 
 /*
@@ -278,7 +280,7 @@ float       getserverliststat(float type)
 4      serverquerycount
 5      serverreplycount
 6      sortfield
-7      sortdescending
+7      sortflags
 */
 void VM_M_getserverliststat( void )
 {
@@ -311,7 +313,7 @@ void VM_M_getserverliststat( void )
                PRVM_G_FLOAT ( OFS_RETURN ) = serverlist_sortbyfield;
                return;
        case 7:
-               PRVM_G_FLOAT ( OFS_RETURN ) = serverlist_sortdescending;
+               PRVM_G_FLOAT ( OFS_RETURN ) = serverlist_sortflags;
                return;
        default:
                VM_Warning( "VM_M_getserverliststat: bad type %i!\n", type );
@@ -449,6 +451,9 @@ void VM_M_setserverlistmasknumber( void )
                case SLIF_FREESLOTS:
                        mask->info.freeslots = number;
                        break;
+               case SLIF_ISFAVORITE:
+                       mask->info.isfavorite = number;
+                       break;
                default:
                        VM_Warning( "VM_M_setserverlistmasknumber: Bad field number %i passed!\n", field );
                        return;
@@ -576,6 +581,9 @@ void VM_M_getserverlistnumber(void)
                case SLIF_PROTOCOL:
                        PRVM_G_FLOAT( OFS_RETURN ) = cache->info.protocol;
                        break;
+               case SLIF_ISFAVORITE:
+                       PRVM_G_FLOAT( OFS_RETURN ) = cache->info.isfavorite;
+                       break;
                default:
                        Con_Print("VM_M_getserverlistnumber: bad field number passed!\n");
        }
@@ -585,7 +593,7 @@ void VM_M_getserverlistnumber(void)
 ========================
 VM_M_setserverlistsort
 
-setserverlistsort(float field, float descending)
+setserverlistsort(float field, float flags)
 ========================
 */
 void VM_M_setserverlistsort( void )
@@ -593,7 +601,7 @@ void VM_M_setserverlistsort( void )
        VM_SAFEPARMCOUNT( 2, VM_M_setserverlistsort );
 
        serverlist_sortbyfield = (serverlist_infofield_t)((int)PRVM_G_FLOAT( OFS_PARM0 ));
-       serverlist_sortdescending = (qboolean) PRVM_G_FLOAT( OFS_PARM1 );
+       serverlist_sortflags = (int) PRVM_G_FLOAT( OFS_PARM1 );
 }
 
 /*
@@ -652,6 +660,8 @@ void VM_M_getserverlistindexforkey( void )
                PRVM_G_FLOAT( OFS_RETURN ) = SLIF_FREESLOTS;
        else if( !strcmp( key, "protocol" ) )
                PRVM_G_FLOAT( OFS_RETURN ) = SLIF_PROTOCOL;
+       else if( !strcmp( key, "isfavorite" ) )
+               PRVM_G_FLOAT( OFS_RETURN ) = SLIF_ISFAVORITE;
        else
                PRVM_G_FLOAT( OFS_RETURN ) = -1;
 }
@@ -768,22 +778,6 @@ void VM_M_WriteEntity (void)
        MSG_WriteShort (VM_M_WriteDest(), PRVM_G_EDICTNUM(OFS_PARM0));
 }
 
-//string(void) getextresponse = #624; // returns the next extResponse packet that was sent to this client
-void VM_M_getextresponse (void)
-{
-       VM_SAFEPARMCOUNT(0,VM_argv);
-
-       if (net_extresponse_count <= 0)
-               PRVM_G_INT(OFS_RETURN) = OFS_NULL;
-       else
-       {
-               int first;
-               --net_extresponse_count;
-               first = (net_extresponse_last + NET_EXTRESPONSE_MAX - net_extresponse_count) % NET_EXTRESPONSE_MAX;
-               PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(net_extresponse[first]);
-       }
-}
-
 /*
 =================
 VM_M_copyentity
@@ -815,6 +809,13 @@ static void VM_M_getmousepos(void)
                VectorSet(PRVM_G_VECTOR(OFS_RETURN), in_mouse_x * vid_conwidth.integer / vid.width, in_mouse_y * vid_conheight.integer / vid.height, 0);
 }
 
+//#349 float() isdemo (EXT_CSQC)
+static void VM_M_isdemo (void)
+{
+       VM_SAFEPARMCOUNT(0, VM_M_isdemo);
+       PRVM_G_FLOAT(OFS_RETURN) = cls.demoplayback;
+}
+
 prvm_builtin_t vm_m_builtins[] = {
 NULL,                                                                  //   #0 NULL function (not callable)
 VM_checkextension,                             //   #1
@@ -1192,7 +1193,7 @@ NULL,                                                                     // #345
 NULL,                                                                  // #346
 NULL,                                                                  // #347
 NULL,                                                                  // #348
-NULL,                                                                  // #349
+VM_M_isdemo,                                                           // #349
 NULL,                                                                  // #350
 NULL,                                                                  // #351
 NULL,                                                                  // #352
@@ -1313,7 +1314,7 @@ VM_drawline,                                              // #466
 VM_drawcolorcodedstring,               // #467
 VM_stringwidth,                                        // #468
 VM_drawsubpic,                                         // #469
-NULL,                                                                  // #470
+VM_drawrotpic,                                         // #470
 VM_asin,                                                               // #471 float(float s) VM_asin (DP_QC_ASINACOSATANATAN2TAN)
 VM_acos,                                                               // #472 float(float c) VM_acos (DP_QC_ASINACOSATANATAN2TAN)
 VM_atan,                                                               // #473 float(float t) VM_atan (DP_QC_ASINACOSATANATAN2TAN)
@@ -1356,12 +1357,12 @@ NULL,                                                                   // #509
 VM_uri_escape,                                 // #510 string(string in) uri_escape = #510;
 VM_uri_unescape,                               // #511 string(string in) uri_unescape = #511;
 VM_etof,                                       // #512 float(entity ent) num_for_edict = #512 (DP_QC_NUM_FOR_EDICT)
-NULL,                                                                  // #513
-NULL,                                                                  // #514
-NULL,                                                                  // #515
-NULL,                                                                  // #516
-NULL,                                                                  // #517
-NULL,                                                                  // #518
+VM_uri_get,                                            // #513 float(string uril, float id) uri_get = #513; (DP_QC_URI_GET)
+VM_tokenize_console,                                   // #514 float(string str) tokenize_console = #514; (DP_QC_TOKENIZE_CONSOLE)
+VM_argv_start_index,                                   // #515 float(float idx) argv_start_index = #515; (DP_QC_TOKENIZE_CONSOLE)
+VM_argv_end_index,                                             // #516 float(float idx) argv_end_index = #516; (DP_QC_TOKENIZE_CONSOLE)
+VM_buf_cvarlist,                                               // #517 void(float buf, string prefix, string antiprefix) buf_cvarlist = #517; (DP_QC_STRINGBUFFERS_CVARLIST)
+VM_cvar_description,                                   // #518 float(string name) cvar_description = #518; (DP_QC_CVAR_DESCRIPTION)
 NULL,                                                                  // #519
 NULL,                                                                  // #520
 NULL,                                                                  // #521
@@ -1451,9 +1452,9 @@ VM_M_getmousetarget,                              // #604 float getmousetarget(void)
 VM_M_callfunction,                             // #605 void callfunction(...)
 VM_writetofile,                                        // #606 void writetofile(float fhandle, entity ent)
 VM_M_isfunction,                                       // #607 float isfunction(string function_name)
-VM_M_getresolution,                            // #608 vector getresolution(float number)
+VM_M_getresolution,                            // #608 vector getresolution(float number, [float forfullscreen])
 VM_keynumtostring,                             // #609 string keynumtostring(float keynum)
-VM_M_findkeysforcommand,               // #610 string findkeysforcommand(string command)
+VM_findkeysforcommand,         // #610 string findkeysforcommand(string command)
 VM_M_getserverliststat,                        // #611 float gethostcachevalue(float type)
 VM_M_getserverliststring,              // #612 string gethostcachestring(float type, float hostnr)
 VM_parseentitydata,                            // #613 void parseentitydata(entity ent, string data)
@@ -1467,7 +1468,10 @@ VM_M_refreshserverlist,                  // #620 void refreshhostcache(void)
 VM_M_getserverlistnumber,              // #621 float gethostcachenumber(float fld, float hostnr)
 VM_M_getserverlistindexforkey,// #622 float gethostcacheindexforkey(string key)
 VM_M_addwantedserverlistkey,   // #623 void addwantedhostcachekey(string key)
-VM_M_getextresponse                            // #624 string getextresponse(void)
+VM_getextresponse,                             // #624 string getextresponse(void)
+VM_netaddress_resolve,          // #625 string netaddress_resolve(string, float)
+VM_M_getgamedirinfo,            // #626 string getgamedirinfo(float n, float prop)
+NULL
 };
 
 const int vm_m_numbuiltins = sizeof(vm_m_builtins) / sizeof(prvm_builtin_t);