]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - mvm_cmds.c
patch from esteel making the findkeysforcommand builtin available in
[xonotic/darkplaces.git] / mvm_cmds.c
index 7a5d41b8dd2807f2b7a399c79c600ae2927b7c98..d4c447b1909543010b486876b3b524b2e27746dc 100644 (file)
@@ -26,6 +26,8 @@ char *vm_m_extensions =
 "DP_QC_TOKENIZEBYSEPARATOR "
 "DP_QC_UNLIMITEDTEMPSTRINGS "
 "DP_QC_URI_ESCAPE "
+"DP_QC_URI_GET "
+"DP_QC_WHICHPACK "
 "FTE_STRINGS "
 ;
 
@@ -170,7 +172,7 @@ void VM_M_callfunction(void)
                if (builtinnumber < prog->numbuiltins && prog->builtins[builtinnumber])
                        prog->builtins[builtinnumber]();
                else
-                       PRVM_ERROR("No such builtin #%i in %s", builtinnumber, PRVM_NAME);
+                       PRVM_ERROR("No such builtin #%i in %s; most likely cause: outdated engine build. Try updating!", builtinnumber, PRVM_NAME);
        }
        else if(func - prog->functions > 0)
        {
@@ -227,40 +229,6 @@ void VM_M_getresolution(void)
        PRVM_G_VECTOR(OFS_RETURN)[2] = 0;
 }
 
-/*
-=========
-VM_M_findkeysforcommand
-
-string findkeysforcommand(string command)
-
-the returned string is an altstring
-=========
-*/
-#define NUMKEYS 5 // TODO: merge the constant in keys.c with this one somewhen
-
-void M_FindKeysForCommand(const char *command, int *keys);
-void VM_M_findkeysforcommand(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);
-
-       VM_CheckEmptyString(cmd);
-
-       M_FindKeysForCommand(cmd, keys);
-
-       ret[0] = 0;
-       for(i = 0; i < NUMKEYS; i++)
-               strlcat(ret, va(" \'%i\'", keys[i]), sizeof(ret));
-
-       PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(ret);
-}
-
 /*
 =========
 VM_M_getserverliststat
@@ -370,6 +338,12 @@ void VM_M_setserverlistmaskstring( void )
                case SLIF_NAME:
                        strlcpy( mask->info.name, PRVM_G_STRING( OFS_PARM2 ), sizeof(mask->info.name)  );
                        break;
+               case SLIF_QCSTATUS:
+                       strlcpy( mask->info.qcstatus, PRVM_G_STRING( OFS_PARM2 ), sizeof(mask->info.qcstatus)  );
+                       break;
+               case SLIF_PLAYERS:
+                       strlcpy( mask->info.players, PRVM_G_STRING( OFS_PARM2 ), sizeof(mask->info.players)  );
+                       break;
                case SLIF_MAP:
                        strlcpy( mask->info.map, PRVM_G_STRING( OFS_PARM2 ), sizeof(mask->info.map)  );
                        break;
@@ -496,6 +470,12 @@ void VM_M_getserverliststring(void)
                case SLIF_NAME:
                        PRVM_G_INT( OFS_RETURN ) = PRVM_SetEngineString( cache->info.name );
                        break;
+               case SLIF_QCSTATUS:
+                       PRVM_G_INT (OFS_RETURN ) = PRVM_SetEngineString (cache->info.qcstatus );
+                       break;
+               case SLIF_PLAYERS:
+                       PRVM_G_INT (OFS_RETURN ) = PRVM_SetEngineString (cache->info.players );
+                       break;
                case SLIF_GAME:
                        PRVM_G_INT( OFS_RETURN ) = PRVM_SetEngineString( cache->info.game );
                        break;
@@ -623,6 +603,10 @@ void VM_M_getserverlistindexforkey( void )
                PRVM_G_FLOAT( OFS_RETURN ) = SLIF_MAP;
        else if( !strcmp( key, "name" ) )
                PRVM_G_FLOAT( OFS_RETURN ) = SLIF_NAME;
+       else if( !strcmp( key, "qcstatus" ) )
+               PRVM_G_FLOAT( OFS_RETURN ) = SLIF_QCSTATUS;
+       else if( !strcmp( key, "players" ) )
+               PRVM_G_FLOAT( OFS_RETURN ) = SLIF_PLAYERS;
        else if( !strcmp( key, "maxplayers" ) )
                PRVM_G_FLOAT( OFS_RETURN ) = SLIF_MAXPLAYERS;
        else if( !strcmp( key, "numplayers" ) )
@@ -785,6 +769,19 @@ static void VM_M_copyentity (void)
        memcpy(out->fields.vp, in->fields.vp, prog->progs->entityfields * 4);
 }
 
+//#66 vector() getmousepos (EXT_CSQC)
+static void VM_M_getmousepos(void)
+{
+       VM_SAFEPARMCOUNT(0,VM_M_getmousepos);
+
+       if (key_consoleactive || (key_dest != key_menu && key_dest != key_menu_grabbed))
+               VectorSet(PRVM_G_VECTOR(OFS_RETURN), 0, 0, 0);
+       else if (in_client_mouse)
+               VectorSet(PRVM_G_VECTOR(OFS_RETURN), in_windowmouse_x * vid_conwidth.integer / vid.width, in_windowmouse_y * vid_conheight.integer / vid.height, 0);
+       else
+               VectorSet(PRVM_G_VECTOR(OFS_RETURN), in_mouse_x * vid_conwidth.integer / vid.width, in_mouse_y * vid_conheight.integer / vid.height, 0);
+}
+
 prvm_builtin_t vm_m_builtins[] = {
 NULL,                                                                  //   #0 NULL function (not callable)
 VM_checkextension,                             //   #1
@@ -852,7 +849,7 @@ VM_clientstate,                                     //  #62
 VM_clcommand,                                          //  #63
 VM_changelevel,                                        //  #64
 VM_localsound,                                         //  #65
-VM_getmousepos,                                        //  #66
+VM_M_getmousepos,                                      //  #66
 VM_gettime,                                                    //  #67
 VM_loadfromdata,                                       //  #68
 VM_loadfromfile,                                       //  #69
@@ -876,9 +873,16 @@ VM_altstr_ins,                                             //  #86
 VM_findflags,                                          //  #87
 VM_findchainflags,                             //  #88
 VM_cvar_defstring,                             //  #89
+// deactivate support for model rendering in the menu until someone has time to do it right [3/2/2008 Andreas]
+#if 0
 VM_CL_setmodel,                                        // #90 void(entity e, string m) setmodel (QUAKE)
 VM_CL_precache_model,                  // #91 void(string s) precache_model (QUAKE)
 VM_CL_setorigin,                               // #92 void(entity e, vector o) setorigin (QUAKE)
+#else
+NULL,
+NULL,
+NULL,
+#endif
 NULL,                                                                  //  #93
 NULL,                                                                  //  #94
 NULL,                                                                  //  #95
@@ -1086,6 +1090,8 @@ NULL,                                                                     // #296
 NULL,                                                                  // #297
 NULL,                                                                  // #298
 NULL,                                                                  // #299
+// deactivate support for model rendering in the menu until someone has time to do it right [3/2/2008 Andreas]
+#if 0
 // CSQC range #300-#399
 VM_CL_R_ClearScene,                            // #300 void() clearscene (DP_QC_RENDER_SCENE)
 VM_CL_R_AddEntities,                   // #301 void(float mask) addentities (DP_QC_RENDER_SCENE)
@@ -1101,6 +1107,22 @@ NULL/*VM_CL_R_LoadWorldModel*/,                          // #309 void(string modelname) R_LoadWorldMod
 VM_CL_setattachment,                           // #310 void(entity e, entity tagentity, string tagname) setattachment (DP_GFX_QUAKE3MODELTAGS) (DP_QC_RENDER_SCENE)
 VM_CL_gettagindex,                             // #311 float(entity ent, string tagname) gettagindex (DP_QC_GETTAGINFO) (DP_QC_RENDER_SCENE)
 VM_CL_gettaginfo,                                      // #312 vector(entity ent, float tagindex) gettaginfo (DP_QC_GETTAGINFO) (DP_QC_RENDER_SCENE)
+#else
+// CSQC range #300-#399
+NULL,          
+NULL,          
+NULL,          
+NULL,          
+NULL,          
+NULL,          
+NULL,          
+NULL,  
+NULL,  
+NULL,
+NULL,  
+NULL,  
+NULL,  
+#endif
 NULL,                                                                  // #313
 NULL,                                                                  // #314
 NULL,                                                                  // #315
@@ -1291,7 +1313,7 @@ NULL,                                                                     // #499
 NULL,                                                                  // #500
 NULL,                                                                  // #501
 NULL,                                                                  // #502
-NULL,                                                                  // #503
+VM_whichpack,                                  // #503 string(string) whichpack = #503;
 NULL,                                                                  // #504
 NULL,                                                                  // #505
 NULL,                                                                  // #506
@@ -1301,7 +1323,7 @@ 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
+VM_uri_get,                                            // #513 float(string uril, float id) uri_get = #513; (DP_QC_URI_GET)
 NULL,                                                                  // #514
 NULL,                                                                  // #515
 NULL,                                                                  // #516
@@ -1398,7 +1420,7 @@ 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_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)