X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=clvm_cmds.c;h=268222d127c9f647a715fb93c002b78f1c7418f5;hb=6427b8f454267692d70e561e5d3ae62deff2633e;hp=431ec3d985c3a94bb9a89d6b9ab4b189d1a56381;hpb=148c1ff5b07d30c1faffbc8d71afc8849eafdbe6;p=xonotic%2Fdarkplaces.git diff --git a/clvm_cmds.c b/clvm_cmds.c index 431ec3d9..268222d1 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -404,7 +404,7 @@ static void VM_CL_findradius (void) eorg[2] -= bound(ent->fields.client->mins[2], eorg[2], ent->fields.client->maxs[2]); } else - VectorMAMAM(1, eorg, 0.5f, ent->fields.client->mins, 0.5f, ent->fields.client->maxs, eorg); + VectorMAMAM(1, eorg, -0.5f, ent->fields.client->mins, -0.5f, ent->fields.client->maxs, eorg); if (DotProduct(eorg, eorg) < radius2) { ent->fields.client->chain = PRVM_EDICT_TO_PROG(chain); @@ -618,6 +618,26 @@ static void VM_CL_R_ClearScene (void) // clear renderable entity and light lists r_refdef.numentities = 0; r_refdef.numlights = 0; + // FIXME: restore these to the values from VM_CL_UpdateView + r_view.x = 0; + r_view.y = 0; + r_view.z = 0; + r_view.width = vid.width; + r_view.height = vid.height; + r_view.depth = 1; + // FIXME: restore frustum_x/frustum_y + r_view.useperspective = true; + r_view.frustum_y = tan(scr_fov.value * M_PI / 360.0) * (3.0/4.0) * cl.viewzoom; + r_view.frustum_x = r_view.frustum_y * (float)r_view.width / (float)r_view.height / vid_pixelheight.value; + r_view.frustum_x *= r_refdef.frustumscale_x; + r_view.frustum_y *= r_refdef.frustumscale_y; + r_view.ortho_x = scr_fov.value * (3.0 / 4.0) * (float)r_view.width / (float)r_view.height / vid_pixelheight.value; + r_view.ortho_y = scr_fov.value * (3.0 / 4.0); + // FIXME: restore cl.csqc_origin + // FIXME: restore cl.csqc_angles + cl.csqc_vidvars.drawworld = true; + cl.csqc_vidvars.drawenginesbar = false; + cl.csqc_vidvars.drawcrosshair = false; } //#301 void(float mask) addentities (EXT_CSQC) @@ -673,35 +693,32 @@ static void VM_CL_R_SetView (void) switch(c) { - case VF_MIN: r_view.x = (int)f[0]; - r_view.y = (int)f[1]; + case VF_MIN: r_view.x = (int)(f[0] * vid.width / vid_conwidth.value); + r_view.y = (int)(f[1] * vid.height / vid_conheight.value); break; - case VF_MIN_X: r_view.x = (int)k; + case VF_MIN_X: r_view.x = (int)(k * vid.width / vid_conwidth.value); break; - case VF_MIN_Y: r_view.y = (int)k; + case VF_MIN_Y: r_view.y = (int)(k * vid.height / vid_conheight.value); break; - case VF_SIZE: r_view.width = (int)f[0]; - r_view.height = (int)f[1]; + case VF_SIZE: r_view.width = (int)(f[0] * vid.width / vid_conwidth.value); + r_view.height = (int)(f[1] * vid.height / vid_conheight.value); break; - case VF_SIZE_Y: r_view.width = (int)k; + case VF_SIZE_Y: r_view.width = (int)(k * vid.width / vid_conwidth.value); break; - case VF_SIZE_X: r_view.height = (int)k; + case VF_SIZE_X: r_view.height = (int)(k * vid.height / vid_conheight.value); break; - case VF_VIEWPORT: r_view.x = (int)f[0]; - r_view.y = (int)f[1]; - r_view.z = 0; - // TODO: make sure that view_z and view_depth are set properly even if csqc does not set them! + case VF_VIEWPORT: r_view.x = (int)(f[0] * vid.width / vid_conwidth.value); + r_view.y = (int)(f[1] * vid.height / vid_conheight.value); f = PRVM_G_VECTOR(OFS_PARM2); - r_view.width = (int)f[0]; - r_view.height = (int)f[1]; - r_view.depth = 1; + r_view.width = (int)(f[0] * vid.width / vid_conwidth.value); + r_view.height = (int)(f[1] * vid.height / vid_conheight.value); break; - case VF_FOV: //r_refdef.fov_x = f[0]; // FIXME! - //r_refdef.fov_y = f[1]; // FIXME! + case VF_FOV: r_view.frustum_x = tan(f[0] * M_PI / 360.0);r_view.ortho_x = f[0]; + r_view.frustum_y = tan(f[1] * M_PI / 360.0);r_view.ortho_y = f[1]; break; - case VF_FOVX: //r_refdef.fov_x = k; // FIXME! + case VF_FOVX: r_view.frustum_x = tan(k * M_PI / 360.0);r_view.ortho_x = k; break; - case VF_FOVY: //r_refdef.fov_y = k; // FIXME! + case VF_FOVY: r_view.frustum_y = tan(k * M_PI / 360.0);r_view.ortho_y = k; break; case VF_ORIGIN: VectorCopy(f, cl.csqc_origin); CSQC_R_RecalcView(); @@ -743,6 +760,9 @@ static void VM_CL_R_SetView (void) case VF_CL_VIEWANGLES_Z:cl.viewangles[2] = k; break; + case VF_PERSPECTIVE: r_view.useperspective = k != 0; + break; + default: PRVM_G_FLOAT(OFS_RETURN) = 0; VM_Warning("VM_CL_R_SetView : unknown parm %i\n", c); return; @@ -830,8 +850,24 @@ static void VM_CL_getstatf (void) static void VM_CL_getstati (void) { int i, index; - VM_SAFEPARMCOUNT(1, VM_CL_getstati); + int firstbit, bitcount; + + VM_SAFEPARMCOUNTRANGE(1, 3, VM_CL_getstati); + index = (int)PRVM_G_FLOAT(OFS_PARM0); + if (prog->argc > 1) + { + firstbit = (int)PRVM_G_FLOAT(OFS_PARM1); + if (prog->argc > 2) + bitcount = (int)PRVM_G_FLOAT(OFS_PARM2); + else + bitcount = 1; + } + else + { + firstbit = 0; + bitcount = 32; + } if(index < 0 || index >= MAX_CL_STATS) { @@ -839,6 +875,8 @@ static void VM_CL_getstati (void) return; } i = cl.stats[index]; + if (bitcount != 32) //32 causes the mask to overflow, so there's nothing to subtract from. + i = (((unsigned int)i)&(((1<>firstbit; PRVM_G_FLOAT(OFS_RETURN) = i; } @@ -1159,7 +1197,7 @@ static void VM_CL_makestatic (void) // copy it to the current state staticent->render.model = CL_GetModelByIndex((int)ent->fields.client->modelindex); - staticent->render.frame = staticent->render.frame1 = staticent->render.frame2 = (int)ent->fields.client->frame; + staticent->render.frame1 = staticent->render.frame2 = (int)ent->fields.client->frame; staticent->render.framelerp = 0; // make torchs play out of sync staticent->render.frame1time = staticent->render.frame2time = lhrandom(-10, -1); @@ -2897,16 +2935,16 @@ NULL, // #217 VM_bitshift, // #218 float(float number, float quantity) bitshift (EXT_BITSHIFT) NULL, // #219 NULL, // #220 -NULL, // #221 +VM_strstrofs, // #221 float(string str, string sub[, float startpos]) strstrofs (FTE_STRINGS) VM_str2chr, // #222 float(string str, float ofs) str2chr (FTE_STRINGS) VM_chr2str, // #223 string(float c, ...) chr2str (FTE_STRINGS) -NULL, // #224 -NULL, // #225 -NULL, // #226 -NULL, // #227 +VM_strconv, // #224 string(float ccase, float calpha, float cnum, string s, ...) strconv (FTE_STRINGS) +VM_strpad, // #225 string(float chars, string s, ...) strpad (FTE_STRINGS) +VM_infoadd, // #226 string(string info, string key, string value, ...) infoadd (FTE_STRINGS) +VM_infoget, // #227 string(string info, string key) infoget (FTE_STRINGS) VM_strncmp, // #228 float(string s1, string s2, float len) strncmp (FTE_STRINGS) -NULL, // #229 -NULL, // #230 +VM_strncasecmp, // #229 float(string s1, string s2) strcasecmp (FTE_STRINGS) +VM_strncasecmp, // #230 float(string s1, string s2, float len) strncasecmp (FTE_STRINGS) NULL, // #231 NULL, // #232 void(float index, float type, .void field) SV_AddStat (EXT_CSQC) NULL, // #233 @@ -3122,10 +3160,10 @@ NULL, // #440 void(entity e, string s) clientcommand (KRIMZON_SV_PARSECLIE VM_tokenize, // #441 float(string s) tokenize (KRIMZON_SV_PARSECLIENTCOMMAND) VM_argv, // #442 string(float n) argv (KRIMZON_SV_PARSECLIENTCOMMAND) VM_CL_setattachment, // #443 void(entity e, entity tagentity, string tagname) setattachment (DP_GFX_QUAKE3MODELTAGS) -VM_search_begin, // #444 float(string pattern, float caseinsensitive, float quiet) search_begin (DP_FS_SEARCH) -VM_search_end, // #445 void(float handle) search_end (DP_FS_SEARCH) -VM_search_getsize, // #446 float(float handle) search_getsize (DP_FS_SEARCH) -VM_search_getfilename, // #447 string(float handle, float num) search_getfilename (DP_FS_SEARCH) +VM_search_begin, // #444 float(string pattern, float caseinsensitive, float quiet) search_begin (DP_QC_FS_SEARCH) +VM_search_end, // #445 void(float handle) search_end (DP_QC_FS_SEARCH) +VM_search_getsize, // #446 float(float handle) search_getsize (DP_QC_FS_SEARCH) +VM_search_getfilename, // #447 string(float handle, float num) search_getfilename (DP_QC_FS_SEARCH) VM_cvar_string, // #448 string(string s) cvar_string (DP_QC_CVAR_STRING) VM_findflags, // #449 entity(entity start, .float fld, float match) findflags (DP_QC_FINDFLAGS) VM_findchainflags, // #450 entity(.float fld, float match) findchainflags (DP_QC_FINDCHAINFLAGS) @@ -3158,9 +3196,9 @@ VM_strlennocol, // #476 float(string s) : DRESK - String Length (not countin VM_strdecolorize, // #477 string(string s) : DRESK - Decolorized String (DP_QC_STRINGCOLORFUNCTIONS) VM_strftime, // #478 string(float uselocaltime, string format, ...) (DP_QC_STRFTIME) VM_tokenizebyseparator, // #479 float(string s) tokenizebyseparator (DP_QC_TOKENIZEBYSEPARATOR) -VM_strtolower, // #480 string(string s) VM_strtolower : DRESK - Return string as lowercase -VM_strtoupper, // #481 string(string s) VM_strtoupper : DRESK - Return string as uppercase -NULL, // #482 +VM_strtolower, // #480 string(string s) VM_strtolower (DP_QC_STRING_CASE_FUNCTIONS) +VM_strtoupper, // #481 string(string s) VM_strtoupper (DP_QC_STRING_CASE_FUNCTIONS) +VM_cvar_defstring, // #482 string(string s) cvar_defstring (DP_QC_CVAR_DEFSTRING) NULL, // #483 NULL, // #484 NULL, // #485