]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - mvm_cmds.c
s/QPATH/OSPATH/g in libcurl
[xonotic/darkplaces.git] / mvm_cmds.c
index 7c1c97d011fdb633e2c4022aca9bc2b8b42bb726..b2fbaaf0c6dc9cdfad7ad9edbc84a1eec239cbe8 100644 (file)
@@ -4,6 +4,8 @@
 #include "clvm_cmds.h"
 #include "menu.h"
 
+// TODO check which strings really should be engine strings
+
 //============================================================================
 // Menu
 
@@ -227,10 +229,37 @@ void VM_M_getresolution(void)
 
        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;
+       if(nr < 0 || nr >= video_resolutions_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] = video_resolutions[nr].width;
+               PRVM_G_VECTOR(OFS_RETURN)[1] = video_resolutions[nr].height;
+               PRVM_G_VECTOR(OFS_RETURN)[2] = 0;
+       }
+}
+
+void VM_M_getgamedirinfo(void)
+{
+       int nr, item;
+       VM_SAFEPARMCOUNT(2, VM_getgamedirinfo);
+
+       nr = (int)PRVM_G_FLOAT(OFS_PARM0);
+       item = (int)PRVM_G_FLOAT(OFS_PARM1);
+
+       PRVM_G_INT( OFS_RETURN ) = OFS_NULL;
+
+       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 );
+       }
 }
 
 /*
@@ -778,6 +807,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
@@ -1155,7 +1191,7 @@ NULL,                                                                     // #345
 NULL,                                                                  // #346
 NULL,                                                                  // #347
 NULL,                                                                  // #348
-NULL,                                                                  // #349
+VM_M_isdemo,                                                           // #349
 NULL,                                                                  // #350
 NULL,                                                                  // #351
 NULL,                                                                  // #352
@@ -1431,7 +1467,9 @@ VM_M_getserverlistnumber,         // #621 float gethostcachenumber(float fld, float hos
 VM_M_getserverlistindexforkey,// #622 float gethostcacheindexforkey(string key)
 VM_M_addwantedserverlistkey,   // #623 void addwantedhostcachekey(string key)
 VM_getextresponse,                             // #624 string getextresponse(void)
-VM_netaddress_resolve           // #625 string netaddress_resolve(string, float)
+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);