]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - mvm_cmds.c
new tokenizer tokenize_console that matches the console tokenizing
[xonotic/darkplaces.git] / mvm_cmds.c
index 07cd69e181e3c4a60af35f1bbd1f52c75cf9c44a..28fa492db74f44cbadbf759ea036ed8c0454703b 100644 (file)
 char *vm_m_extensions =
 "BX_WAL_SUPPORT "
 "DP_CINEMATIC_DPV "
+"DP_FONT_VARIABLEWIDTH "
+"DP_GECKO_SUPPORT "
 "DP_MENU_EXTRESPONSEPACKET "
 "DP_QC_ASINACOSATANATAN2TAN "
+"DP_QC_CMD "
+"DP_QC_CRC16 "
+"DP_QC_CVAR_TYPE "
+"DP_QC_RENDER_SCENE "
 "DP_QC_STRFTIME "
-"DP_QC_STRING_CASE_FUNCTIONS "
+"DP_QC_STRINGBUFFERS "
 "DP_QC_STRINGCOLORFUNCTIONS "
+"DP_QC_STRING_CASE_FUNCTIONS "
+"DP_QC_STRREPLACE "
 "DP_QC_TOKENIZEBYSEPARATOR "
+"DP_QC_TOKENIZE_CONSOLE "
 "DP_QC_UNLIMITEDTEMPSTRINGS "
-"DP_QC_CMD "
-"DP_QC_STRREPLACE "
-"DP_FONT_VARIABLEWIDTH "
-"DP_GECKO_SUPPORT "
-"DP_QC_RENDER_SCENE "
-"DP_QC_STRINGBUFFERS "
-"DP_QC_CRC16 "
+"DP_QC_URI_ESCAPE "
+"DP_QC_URI_GET "
+"DP_QC_WHICHPACK "
 "FTE_STRINGS "
 ;
 
@@ -168,7 +173,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)
        {
@@ -225,40 +230,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
@@ -275,7 +246,7 @@ float       getserverliststat(float type)
 4      serverquerycount
 5      serverreplycount
 6      sortfield
-7      sortdescending
+7      sortflags
 */
 void VM_M_getserverliststat( void )
 {
@@ -308,7 +279,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 );
@@ -368,6 +339,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;
@@ -440,6 +417,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;
@@ -494,6 +474,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;
@@ -561,6 +547,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");
        }
@@ -570,7 +559,7 @@ void VM_M_getserverlistnumber(void)
 ========================
 VM_M_setserverlistsort
 
-setserverlistsort(float field, float descending)
+setserverlistsort(float field, float flags)
 ========================
 */
 void VM_M_setserverlistsort( void )
@@ -578,7 +567,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 = (qboolean) PRVM_G_FLOAT( OFS_PARM1 );
 }
 
 /*
@@ -621,6 +610,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" ) )
@@ -633,6 +626,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;
 }
@@ -783,6 +778,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
@@ -850,7 +858,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
@@ -874,9 +882,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
@@ -1084,6 +1099,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)
@@ -1099,6 +1116,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
@@ -1281,7 +1314,7 @@ VM_gecko_movemouse,                               // #491 void gecko_mousemove( string name, float x, float
 VM_gecko_resize,                                       // #492 void gecko_resize( string name, float w, float h )
 VM_gecko_get_texture_extent,   // #493 vector gecko_get_texture_extent( string name )
 VM_crc16,                                              // #494 float(float caseinsensitive, string s, ...) crc16 = #494 (DP_QC_CRC16)
-NULL,                                                                  // #495
+VM_cvar_type,                                  // #495 float(string name) cvar_type = #495; (DP_QC_CVAR_TYPE)
 NULL,                                                                  // #496
 NULL,                                                                  // #497
 NULL,                                                                  // #498
@@ -1289,20 +1322,20 @@ NULL,                                                                   // #499
 NULL,                                                                  // #500
 NULL,                                                                  // #501
 NULL,                                                                  // #502
-NULL,                                                                  // #503
+VM_whichpack,                                  // #503 string(string) whichpack = #503;
 NULL,                                                                  // #504
 NULL,                                                                  // #505
 NULL,                                                                  // #506
 NULL,                                                                  // #507
 NULL,                                                                  // #508
 NULL,                                                                  // #509
-NULL,                                                                  // #510
-NULL,                                                                  // #511
-NULL,                                                                  // #512
-NULL,                                                                  // #513
-NULL,                                                                  // #514
-NULL,                                                                  // #515
-NULL,                                                                  // #516
+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)
+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)
 NULL,                                                                  // #517
 NULL,                                                                  // #518
 NULL,                                                                  // #519
@@ -1396,7 +1429,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)
@@ -1410,7 +1443,8 @@ 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_M_getextresponse,                   // #624 string getextresponse(void)
+VM_netaddress_resolve           // #625 string netaddress_resolve(string, float)
 };
 
 const int vm_m_numbuiltins = sizeof(vm_m_builtins) / sizeof(prvm_builtin_t);
@@ -1431,6 +1465,8 @@ void VM_M_Cmd_Init(void)
 
        scene->maxentities = MAX_EDICTS + 256 + 512;
        scene->entities = (entity_render_t **)Mem_Alloc(prog->progs_mempool, sizeof(entity_render_t *) * scene->maxentities);
+
+       scene->ambient = 32.0f;
 }
 
 void VM_M_Cmd_Reset(void)