]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - clvm_cmds.c
curl: change how failure/success is decided to prevent "black screen" problems if...
[xonotic/darkplaces.git] / clvm_cmds.c
index 9856f21cce4a161addfc5c1b4d1c4a4cde7101d6..67c8b70b964229522519ac75d5be5912fdad17b6 100644 (file)
@@ -23,6 +23,8 @@
 extern cvar_t v_flipped;
 extern cvar_t r_equalize_entities_fullbright;
 
+r_refdef_view_t csqc_original_r_refdef_view;
+
 sfx_t *S_FindName(const char *name);
 int Sbar_GetSortedPlayerIndex (int index);
 void Sbar_SortFrags (void);
@@ -205,7 +207,7 @@ static void VM_CL_sound (void)
        }
 
        CL_VM_GetEntitySoundOrigin(MAX_EDICTS + PRVM_NUM_FOR_EDICT(entity), org);
-       S_StartSound(MAX_EDICTS + PRVM_NUM_FOR_EDICT(entity), channel, S_FindName(sample), org, volume, attenuation);
+       S_StartSound_StartPosition_Flags(MAX_EDICTS + PRVM_NUM_FOR_EDICT(entity), channel, S_FindName(sample), org, volume, attenuation, 0, flags, pitchchange > 0.0f ? pitchchange * 0.01f : 1.0f);
 }
 
 // #483 void(vector origin, string sample, float volume, float attenuation) pointsound
@@ -681,7 +683,7 @@ static void VM_CL_getlight (void)
        vec3_t ambientcolor, diffusecolor, diffusenormal;
        vec_t *p;
 
-       VM_SAFEPARMCOUNTRANGE(1, 2, VM_CL_getlight);
+       VM_SAFEPARMCOUNTRANGE(1, 3, VM_CL_getlight);
 
        p = PRVM_G_VECTOR(OFS_PARM0);
        VectorClear(ambientcolor);
@@ -692,6 +694,12 @@ static void VM_CL_getlight (void)
        else if (cl.worldmodel && cl.worldmodel->brush.LightPoint)
                cl.worldmodel->brush.LightPoint(cl.worldmodel, p, ambientcolor, diffusecolor, diffusenormal);
        VectorMA(ambientcolor, 0.5, diffusecolor, PRVM_G_VECTOR(OFS_RETURN));
+       if (PRVM_clientglobalvector(getlight_ambient))
+               VectorCopy(ambientcolor, PRVM_clientglobalvector(getlight_ambient));
+       if (PRVM_clientglobalvector(getlight_diffuse))
+               VectorCopy(diffusecolor, PRVM_clientglobalvector(getlight_diffuse));
+       if (PRVM_clientglobalvector(getlight_dir))
+               VectorCopy(diffusenormal, PRVM_clientglobalvector(getlight_dir));
 }
 
 //============================================================================
@@ -716,23 +724,8 @@ void VM_CL_R_ClearScene (void)
        // clear renderable entity and light lists
        r_refdef.scene.numentities = 0;
        r_refdef.scene.numlights = 0;
-       // FIXME: restore these to the values from VM_CL_UpdateView
-       r_refdef.view.x = 0;
-       r_refdef.view.y = 0;
-       r_refdef.view.z = 0;
-       r_refdef.view.width = vid.width;
-       r_refdef.view.height = vid.height;
-       r_refdef.view.depth = 1;
-       // FIXME: restore frustum_x/frustum_y
-       r_refdef.view.useperspective = true;
-       r_refdef.view.frustum_y = tan(scr_fov.value * M_PI / 360.0) * (3.0/4.0) * cl.viewzoom;
-       r_refdef.view.frustum_x = r_refdef.view.frustum_y * (float)r_refdef.view.width / (float)r_refdef.view.height / vid_pixelheight.value;
-       r_refdef.view.frustum_x *= r_refdef.frustumscale_x;
-       r_refdef.view.frustum_y *= r_refdef.frustumscale_y;
-       r_refdef.view.ortho_x = scr_fov.value * (3.0 / 4.0) * (float)r_refdef.view.width / (float)r_refdef.view.height / vid_pixelheight.value;
-       r_refdef.view.ortho_y = scr_fov.value * (3.0 / 4.0);
-       r_refdef.view.clear = true;
-       r_refdef.view.isoverlay = false;
+       // restore the view settings to the values that VM_CL_UpdateView received from the client code
+       r_refdef.view = csqc_original_r_refdef_view;
        VectorCopy(cl.csqc_vieworiginfromengine, cl.csqc_vieworigin);
        VectorCopy(cl.csqc_viewanglesfromengine, cl.csqc_viewangles);
        cl.csqc_vidvars.drawworld = r_drawworld.integer != 0;
@@ -790,6 +783,8 @@ void VM_CL_R_AddEntity (void)
 //#303 float(float property, ...) setproperty (EXT_CSQC)
 //#303 float(float property) getproperty
 //#303 vector(float property) getpropertyvec
+//#309 float(float property) getproperty
+//#309 vector(float property) getpropertyvec
 // VorteX: make this function be able to return previously set property if new value is not given
 void VM_CL_R_SetView (void)
 {
@@ -887,6 +882,38 @@ void VM_CL_R_SetView (void)
                case VF_CLEARSCREEN:
                        PRVM_G_FLOAT(OFS_RETURN) = r_refdef.view.isoverlay;
                        break;
+               case VF_FOG_DENSITY:
+                       PRVM_G_FLOAT(OFS_RETURN) = r_refdef.fog_density;
+                       break;
+               case VF_FOG_COLOR:
+                       PRVM_G_VECTOR(OFS_RETURN)[0] = r_refdef.fog_red;
+                       PRVM_G_VECTOR(OFS_RETURN)[1] = r_refdef.fog_green;
+                       PRVM_G_VECTOR(OFS_RETURN)[2] = r_refdef.fog_blue;
+                       break;
+               case VF_FOG_COLOR_R:
+                       PRVM_G_VECTOR(OFS_RETURN)[0] = r_refdef.fog_red;
+                       break;
+               case VF_FOG_COLOR_G:
+                       PRVM_G_VECTOR(OFS_RETURN)[1] = r_refdef.fog_green;
+                       break;
+               case VF_FOG_COLOR_B:
+                       PRVM_G_VECTOR(OFS_RETURN)[2] = r_refdef.fog_blue;
+                       break;
+               case VF_FOG_ALPHA:
+                       PRVM_G_FLOAT(OFS_RETURN) = r_refdef.fog_alpha;
+                       break;
+               case VF_FOG_START:
+                       PRVM_G_FLOAT(OFS_RETURN) = r_refdef.fog_start;
+                       break;
+               case VF_FOG_END:
+                       PRVM_G_FLOAT(OFS_RETURN) = r_refdef.fog_end;
+                       break;
+               case VF_FOG_HEIGHT:
+                       PRVM_G_FLOAT(OFS_RETURN) = r_refdef.fog_height;
+                       break;
+               case VF_FOG_FADEDEPTH:
+                       PRVM_G_FLOAT(OFS_RETURN) = r_refdef.fog_fadedepth;
+                       break;
                default:
                        PRVM_G_FLOAT(OFS_RETURN) = 0;
                        VM_Warning("VM_CL_R_GetView : unknown parm %i\n", c);
@@ -1002,6 +1029,38 @@ void VM_CL_R_SetView (void)
        case VF_CLEARSCREEN:
                r_refdef.view.isoverlay = !k;
                break;
+       case VF_FOG_DENSITY:
+               r_refdef.fog_density = k;
+               break;
+       case VF_FOG_COLOR:
+               r_refdef.fog_red = f[0];
+               r_refdef.fog_green = f[1];
+               r_refdef.fog_blue = f[2];
+               break;
+       case VF_FOG_COLOR_R:
+               r_refdef.fog_red = k;
+               break;
+       case VF_FOG_COLOR_G:
+               r_refdef.fog_green = k;
+               break;
+       case VF_FOG_COLOR_B:
+               r_refdef.fog_blue = k;
+               break;
+       case VF_FOG_ALPHA:
+               r_refdef.fog_alpha = k;
+               break;
+       case VF_FOG_START:
+               r_refdef.fog_start = k;
+               break;
+       case VF_FOG_END:
+               r_refdef.fog_end = k;
+               break;
+       case VF_FOG_HEIGHT:
+               r_refdef.fog_height = k;
+               break;
+       case VF_FOG_FADEDEPTH:
+               r_refdef.fog_fadedepth = k;
+               break;
        default:
                PRVM_G_FLOAT(OFS_RETURN) = 0;
                VM_Warning("VM_CL_R_SetView : unknown parm %i\n", c);
@@ -3032,6 +3091,7 @@ void VM_CL_R_RenderScene (void)
        // we need to update any RENDER_VIEWMODEL entities at this point because
        // csqc supplies its own view matrix
        CL_UpdateViewEntities();
+
        // now draw stuff!
        R_RenderView();
 
@@ -4375,7 +4435,7 @@ VM_CL_R_AddDynamicLight,          // #305 void(vector org, float radius, vector lightcol
 VM_CL_R_PolygonBegin,                  // #306 void(string texturename, float flag, float is2d[NYI: , float lines]) R_BeginPolygon
 VM_CL_R_PolygonVertex,                 // #307 void(vector org, vector texcoords, vector rgb, float alpha) R_PolygonVertex
 VM_CL_R_PolygonEnd,                            // #308 void() R_EndPolygon
-NULL /* R_LoadWorldModel in menu VM, should stay unassigned in client*/, // #309
+VM_CL_R_SetView,                               // #309 float(float property) getproperty (EXT_CSQC)
 VM_CL_unproject,                               // #310 vector (vector v) cs_unproject (EXT_CSQC)
 VM_CL_project,                                 // #311 vector (vector v) cs_project (EXT_CSQC)
 NULL,                                                  // #312
@@ -4387,8 +4447,8 @@ VM_precache_pic,                          // #317 string(string name, float trywad) precache_pic (EXT_
 VM_getimagesize,                               // #318 vector(string picname) draw_getimagesize (EXT_CSQC)
 VM_freepic,                                            // #319 void(string name) freepic (EXT_CSQC)
 VM_drawcharacter,                              // #320 float(vector position, float character, vector scale, vector rgb, float alpha, float flag) drawcharacter (EXT_CSQC)
-VM_drawstring,                                 // #321 float(vector position, string text, vector scale, vector rgb, float alpha, float flag) drawstring (EXT_CSQC)
-VM_drawpic,                                            // #322 float(vector position, string pic, vector size, vector rgb, float alpha, float flag) drawpic (EXT_CSQC)
+VM_drawstring,                                 // #321 float(vector position, string text, vector scale, vector rgb, float alpha[, float flag]) drawstring (EXT_CSQC, DP_CSQC)
+VM_drawpic,                                            // #322 float(vector position, string pic, vector size, vector rgb, float alpha[, float flag]) drawpic (EXT_CSQC)
 VM_drawfill,                                   // #323 float(vector position, vector size, vector rgb, float alpha, float flag) drawfill (EXT_CSQC)
 VM_drawsetcliparea,                            // #324 void(float x, float y, float width, float height) drawsetcliparea
 VM_drawresetcliparea,                  // #325 void(void) drawresetcliparea
@@ -4706,7 +4766,8 @@ NULL,                                                     // #635
 NULL,                                                  // #636
 NULL,                                                  // #637
 VM_CL_RotateMoves,                                     // #638
-NULL,                                                  // #639
+VM_digest_hex,                                         // #639
+NULL,                                                  // #640
 };
 
 const int vm_cl_numbuiltins = sizeof(vm_cl_builtins) / sizeof(prvm_builtin_t);