X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=mvm_cmds.c;h=29f4406b3ee5d481c290b9d778baa48168ffb53b;hp=4e909a3ba411468541783b6369c43dac505d09cb;hb=c0b8da8b7012a02ffd416d83840ad2bae7056191;hpb=66f008be9b269495cd15f0e0339b32820956a142 diff --git a/mvm_cmds.c b/mvm_cmds.c index 4e909a3b..29f4406b 100644 --- a/mvm_cmds.c +++ b/mvm_cmds.c @@ -4,6 +4,8 @@ #include "clvm_cmds.h" #include "menu.h" +// TODO check which strings really should be engine strings + //============================================================================ // Menu @@ -19,6 +21,7 @@ char *vm_m_extensions = "DP_QC_CVAR_TYPE " "DP_QC_CVAR_DESCRIPTION " "DP_QC_FINDCHAIN_TOFIELD " +"DP_QC_LOG " "DP_QC_RENDER_SCENE " "DP_QC_STRFTIME " "DP_QC_STRINGBUFFERS " @@ -144,93 +147,55 @@ void VM_M_getkeydest(void) } } + /* ========= -VM_M_callfunction +VM_M_getresolution - callfunction(...,string function_name) -Extension: pass +vector getresolution(float number) ========= */ -mfunction_t *PRVM_ED_FindFunction (const char *name); -void VM_M_callfunction(void) +void VM_M_getresolution(void) { - mfunction_t *func; - const char *s; - - VM_SAFEPARMCOUNTRANGE(1, 8, VM_M_callfunction); + int nr, fs; + VM_SAFEPARMCOUNTRANGE(1, 2, VM_getresolution); - s = PRVM_G_STRING(OFS_PARM0+(prog->argc - 1)*3); - - VM_CheckEmptyString(s); + nr = (int)PRVM_G_FLOAT(OFS_PARM0); - func = PRVM_ED_FindFunction(s); + fs = ((prog->argc <= 1) || ((int)PRVM_G_FLOAT(OFS_PARM1))); - if(!func) - PRVM_ERROR("VM_M_callfunciton: function %s not found !", s); - else if (func->first_statement < 0) + if(nr < 0 || nr >= (fs ? video_resolutions_count : video_resolutions_hardcoded_count)) { - // negative statements are built in functions - int builtinnumber = -func->first_statement; - prog->xfunction->builtinsprofile++; - if (builtinnumber < prog->numbuiltins && prog->builtins[builtinnumber]) - prog->builtins[builtinnumber](); - else - PRVM_ERROR("No such builtin #%i in %s; most likely cause: outdated engine build. Try updating!", builtinnumber, PRVM_NAME); + PRVM_G_VECTOR(OFS_RETURN)[0] = 0; + PRVM_G_VECTOR(OFS_RETURN)[1] = 0; + PRVM_G_VECTOR(OFS_RETURN)[2] = 0; } - else if(func - prog->functions > 0) + else { - prog->argc--; - PRVM_ExecuteProgram(func - prog->functions,""); - prog->argc++; + video_resolution_t *r = &((fs ? video_resolutions : video_resolutions_hardcoded)[nr]); + PRVM_G_VECTOR(OFS_RETURN)[0] = r->width; + PRVM_G_VECTOR(OFS_RETURN)[1] = r->height; + PRVM_G_VECTOR(OFS_RETURN)[2] = r->pixelheight; } } -/* -========= -VM_M_isfunction - -float isfunction(string function_name) -========= -*/ -mfunction_t *PRVM_ED_FindFunction (const char *name); -void VM_M_isfunction(void) -{ - mfunction_t *func; - const char *s; - - VM_SAFEPARMCOUNT(1, VM_M_isfunction); - - s = PRVM_G_STRING(OFS_PARM0); - - VM_CheckEmptyString(s); - - func = PRVM_ED_FindFunction(s); - - if(!func) - PRVM_G_FLOAT(OFS_RETURN) = false; - else - PRVM_G_FLOAT(OFS_RETURN) = true; -} - -/* -========= -VM_M_getresolution - -vector getresolution(float number) -========= -*/ -void VM_M_getresolution(void) +void VM_M_getgamedirinfo(void) { - int nr; - VM_SAFEPARMCOUNT(1, VM_getresolution); + int nr, item; + VM_SAFEPARMCOUNT(2, VM_getgamedirinfo); nr = (int)PRVM_G_FLOAT(OFS_PARM0); + item = (int)PRVM_G_FLOAT(OFS_PARM1); - // 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; + 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 ); + } } /* @@ -421,7 +386,7 @@ void VM_M_setserverlistmasknumber( void ) mask->info.freeslots = number; break; case SLIF_ISFAVORITE: - mask->info.isfavorite = number; + mask->info.isfavorite = number != 0; break; default: VM_Warning( "VM_M_setserverlistmasknumber: Bad field number %i passed!\n", field ); @@ -747,22 +712,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 @@ -794,6 +743,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 @@ -1171,7 +1127,7 @@ NULL, // #345 NULL, // #346 NULL, // #347 NULL, // #348 -NULL, // #349 +VM_M_isdemo, // #349 NULL, // #350 NULL, // #351 NULL, // #352 @@ -1354,7 +1310,7 @@ NULL, // #528 NULL, // #529 NULL, // #530 NULL, // #531 -NULL, // #532 +VM_log, // #532 NULL, // #533 NULL, // #534 NULL, // #535 @@ -1427,10 +1383,10 @@ VM_M_setkeydest, // #601 void setkeydest(float dest) VM_M_getkeydest, // #602 float getkeydest(void) VM_M_setmousetarget, // #603 void setmousetarget(float trg) VM_M_getmousetarget, // #604 float getmousetarget(void) -VM_M_callfunction, // #605 void callfunction(...) +VM_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_isfunction, // #607 float isfunction(string function_name) +VM_M_getresolution, // #608 vector getresolution(float number, [float forfullscreen]) VM_keynumtostring, // #609 string keynumtostring(float keynum) VM_findkeysforcommand, // #610 string findkeysforcommand(string command) VM_M_getserverliststat, // #611 float gethostcachevalue(float type) @@ -1446,8 +1402,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_netaddress_resolve // #625 string netaddress_resolve(string, float) +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);