]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_screen.c
fix segfault with long aliases
[xonotic/darkplaces.git] / cl_screen.c
index 0534d3336d01f9ff90b306546bd66211956e7857..48fb04131bbb2abb50460a98e6716c79b1129555 100644 (file)
@@ -118,6 +118,9 @@ void SCR_DrawCenterString (void)
                if(sb_showscores) // make TAB hide the finale message (sb_showscores overrides finale in sbar.c)
                        return;
 
+       if(scr_centertime.value <= 0 && !cl.intermission)
+               return;
+
 // the finale prints the characters one at a time, except if printspeed is an absurdly high value
        if (cl.intermission && scr_printspeed.value > 0 && scr_printspeed.value < 1000000)
                remaining = (int)(scr_printspeed.value * (cl.time - scr_centertime_start));
@@ -334,7 +337,7 @@ void SCR_DrawTurtle (void)
        if (count < 3)
                return;
 
-       DrawQ_Pic (0, 0, Draw_CachePic("gfx/turtle", true), 0, 0, 1, 1, 1, 1, 0);
+       DrawQ_Pic (0, 0, Draw_CachePic ("gfx/turtle"), 0, 0, 1, 1, 1, 1, 0);
 }
 
 /*
@@ -351,7 +354,7 @@ void SCR_DrawNet (void)
        if (cls.demoplayback)
                return;
 
-       DrawQ_Pic (64, 0, Draw_CachePic("gfx/net", true), 0, 0, 1, 1, 1, 1, 0);
+       DrawQ_Pic (64, 0, Draw_CachePic ("gfx/net"), 0, 0, 1, 1, 1, 1, 0);
 }
 
 /*
@@ -372,7 +375,7 @@ void SCR_DrawPause (void)
        if (!cl.paused)
                return;
 
-       pic = Draw_CachePic ("gfx/pause", true);
+       pic = Draw_CachePic ("gfx/pause");
        DrawQ_Pic ((vid_conwidth.integer - pic->width)/2, (vid_conheight.integer - pic->height)/2, pic, 0, 0, 1, 1, 1, 1, 0);
 }
 
@@ -389,7 +392,7 @@ void SCR_DrawBrand (void)
        if (!scr_showbrand.value)
                return;
 
-       pic = Draw_CachePic ("gfx/brand", true);
+       pic = Draw_CachePic ("gfx/brand");
 
        switch ((int)scr_showbrand.value)
        {
@@ -698,7 +701,7 @@ void R_TimeReport_EndFrame(void)
                        sprintf(string + strlen(string), "Location: %s\n", loc->name);
                sprintf(string + strlen(string), "%3i renders org:'%+8.2f %+8.2f %+8.2f' dir:'%+2.3f %+2.3f %+2.3f'\n", r_refdef.stats.renders, r_refdef.view.origin[0], r_refdef.view.origin[1], r_refdef.view.origin[2], r_refdef.view.forward[0], r_refdef.view.forward[1], r_refdef.view.forward[2]);
                sprintf(string + strlen(string), "%7i surfaces%7i triangles %5i entities (%7i surfaces%7i triangles)\n", r_refdef.stats.world_surfaces, r_refdef.stats.world_triangles, r_refdef.stats.entities, r_refdef.stats.entities_surfaces, r_refdef.stats.entities_triangles);
-               sprintf(string + strlen(string), "%5i leafs%5i portals%6i/%6i particles%6i/%6i decals %3i%% quality\n", r_refdef.stats.world_leafs, r_refdef.stats.world_portals, r_refdef.stats.particles, cl.num_particles, r_refdef.stats.decals, cl.num_decals, 100 / (1 << r_refdef.view.qualityreduction));
+               sprintf(string + strlen(string), "%5i leafs%5i portals%6i/%6i particles%6i/%6i decals %3i%% quality\n", r_refdef.stats.world_leafs, r_refdef.stats.world_portals, r_refdef.stats.particles, cl.num_particles, r_refdef.stats.decals, cl.num_decals, (int)(100 * r_refdef.view.quality));
                sprintf(string + strlen(string), "%7i lightmap updates (%7i pixels)\n", r_refdef.stats.lightmapupdates, r_refdef.stats.lightmapupdatepixels);
                sprintf(string + strlen(string), "%4i lights%4i clears%4i scissored%7i light%7i shadow%7i dynamic\n", r_refdef.stats.lights, r_refdef.stats.lights_clears, r_refdef.stats.lights_scissored, r_refdef.stats.lights_lighttriangles, r_refdef.stats.lights_shadowtriangles, r_refdef.stats.lights_dynamicshadowtriangles);
                if (r_refdef.stats.bloom)
@@ -1731,7 +1734,7 @@ static void R_Envmap_f (void)
        {
                sprintf(filename, "env/%s%s.tga", basename, envmapinfo[j].name);
                Matrix4x4_CreateFromQuakeEntity(&r_refdef.view.matrix, r_refdef.view.origin[0], r_refdef.view.origin[1], r_refdef.view.origin[2], envmapinfo[j].angles[0], envmapinfo[j].angles[1], envmapinfo[j].angles[2], 1);
-               r_refdef.view.qualityreduction = 0;
+               r_refdef.view.quality = 1;
                r_refdef.view.clear = true;
                R_Mesh_Start();
                R_RenderView();
@@ -1808,7 +1811,7 @@ void SHOWLMP_drawall(void)
        int i;
        for (i = 0;i < cl.num_showlmps;i++)
                if (cl.showlmps[i].isactive)
-                       DrawQ_Pic(cl.showlmps[i].x, cl.showlmps[i].y, Draw_CachePic(cl.showlmps[i].pic, true), 0, 0, 1, 1, 1, 1, 0);
+                       DrawQ_Pic(cl.showlmps[i].x, cl.showlmps[i].y, Draw_CachePic (cl.showlmps[i].pic), 0, 0, 1, 1, 1, 1, 0);
 }
 
 /*
@@ -2051,7 +2054,7 @@ void SCR_UpdateLoadingScreen (qboolean clear)
        R_Mesh_Start();
        R_Mesh_Matrix(&identitymatrix);
        // draw the loading plaque
-       pic = Draw_CachePic("gfx/loading", true);
+       pic = Draw_CachePic ("gfx/loading");
        x = (vid_conwidth.integer - pic->width)/2;
        y = (vid_conheight.integer - pic->height)/2;
        GL_Color(1,1,1,1);
@@ -2064,6 +2067,7 @@ void SCR_UpdateLoadingScreen (qboolean clear)
        R_Mesh_ResetTextureState();
        R_Mesh_TexBind(0, R_GetTexture(pic->tex));
        R_Mesh_TexCoordPointer(0, 2, texcoord2f, 0, 0);
+       R_SetupGenericShader(true);
        vertex3f[2] = vertex3f[5] = vertex3f[8] = vertex3f[11] = 0;
        vertex3f[0] = vertex3f[9] = x;
        vertex3f[1] = vertex3f[4] = y;
@@ -2094,16 +2098,28 @@ void SCR_UpdateLoadingScreen (qboolean clear)
 }
 
 extern cvar_t cl_minfps;
-extern cvar_t cl_minfps_expbase;
 extern cvar_t cl_minfps_fade;
-extern cvar_t cl_minfps_maxqualityreduction;
+extern cvar_t cl_minfps_qualitymax;
+extern cvar_t cl_minfps_qualitymin;
+extern cvar_t cl_minfps_qualitypower;
+extern cvar_t cl_minfps_qualityscale;
 static double cl_updatescreen_rendertime = 0;
-static double cl_updatescreen_qualityreduction = 0;
+static double cl_updatescreen_quality = 1;
 void CL_UpdateScreen(void)
 {
        double rendertime1;
        float conwidth, conheight;
 
+       // play a bit with the palette
+       palette_rgb_pantscolormap[15][0] = 128 + 127 * sin(cl.time / exp(1) + 0*M_PI/3);
+       palette_rgb_pantscolormap[15][1] = 128 + 127 * sin(cl.time / exp(1) + 2*M_PI/3);
+       palette_rgb_pantscolormap[15][2] = 128 + 127 * sin(cl.time / exp(1) + 4*M_PI/3);
+       palette_rgb_shirtcolormap[15][0] = 128 + 127 * sin(cl.time /  M_PI  + 5*M_PI/3);
+       palette_rgb_shirtcolormap[15][1] = 128 + 127 * sin(cl.time /  M_PI  + 3*M_PI/3);
+       palette_rgb_shirtcolormap[15][2] = 128 + 127 * sin(cl.time /  M_PI  + 1*M_PI/3);
+       memcpy(palette_rgb_pantsscoreboard[15], palette_rgb_pantscolormap[15], sizeof(*palette_rgb_pantscolormap));
+       memcpy(palette_rgb_shirtscoreboard[15], palette_rgb_shirtcolormap[15], sizeof(*palette_rgb_shirtcolormap));
+
        if (vid_hidden || !scr_refresh.integer)
                return;
 
@@ -2169,7 +2185,7 @@ void CL_UpdateScreen(void)
        qglClearColor(0,0,0,0);CHECKGLERROR
        R_ClearScreen(false);
        r_refdef.view.clear = false;
-       r_refdef.view.qualityreduction = (int)floor(cl_updatescreen_qualityreduction + 0.5);
+       r_refdef.view.quality = bound(cl_minfps_qualitymin.value, pow(cl_updatescreen_quality, cl_minfps_qualitypower.value) * cl_minfps_qualityscale.value, cl_minfps_qualitymax.value);
 
        if(scr_stipple.integer)
        {
@@ -2242,12 +2258,11 @@ void CL_UpdateScreen(void)
 
        // quality adjustment according to render time
        qglFlush();
-       cl_updatescreen_rendertime += ((Sys_DoubleTime() - rendertime1) - cl_updatescreen_rendertime) * bound(0.01, cl_minfps_fade.value, 1);
-       if (cl_minfps.value > 0 && !cls.timedemo && (!cls.capturevideo.active || !cls.capturevideo.realtime))
-               cl_updatescreen_qualityreduction = invpow(cl_minfps_expbase.value, cl_minfps.value * cl_updatescreen_rendertime);
+       cl_updatescreen_rendertime += ((Sys_DoubleTime() - rendertime1) - cl_updatescreen_rendertime) * bound(0, cl_minfps_fade.value, 1);
+       if (cl_minfps.value > 0 && cl_updatescreen_rendertime > 0 && !cls.timedemo && (!cls.capturevideo.active || !cls.capturevideo.realtime))
+               cl_updatescreen_quality = 1 / (cl_updatescreen_rendertime * cl_minfps.value);
        else
-               cl_updatescreen_qualityreduction = 0;
-       cl_updatescreen_qualityreduction = bound(0, cl_updatescreen_qualityreduction, bound(0, cl_minfps_maxqualityreduction.value, 30));
+               cl_updatescreen_quality = 1;
 
        VID_Finish(true);
 }