]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/client/View.qc
Fix uservec*_enable cvars getting set dynamically, causing hiccups. They will now...
[voretournament/voretournament.git] / data / qcsrc / client / View.qc
index 4d445a3500c329ea92fe67baeef9a78fb1f5fb19..ef62afcbad2f315832e975313f07328a0946f140 100644 (file)
@@ -256,6 +256,7 @@ float artwork_fade;
 float pickup_crosshair_time, pickup_crosshair_size;\r
 float myhealth, myhealth_prev, myhealth_flash;\r
 float contentavgalpha, liquidalpha_prev;\r
+float old_blurradius, old_bluralpha, old_sharpen_intensity;\r
 float stomachsplash_alpha, stomachsplash_remove_at_respawn;\r
 float volume_modify_1, volume_modify_2, volume_modify_default_1, volume_modify_default_2;\r
 float volume_modify_changed_1, volume_modify_changed_2;\r
@@ -563,7 +564,7 @@ void CSQC_UpdateView(float w, float h)
 \r
                if(cvar("hud_postprocessing"))\r
                {\r
-                       if(cvar("hud_contents_liquid_blur"))\r
+                       if(cvar("hud_contents_liquid_blur") && contentavgalpha)\r
                        {\r
                                // when inside the stomach, we use different blur settings than when we're inside other fluids\r
                                content_blurpostprocess_x = 1;\r
@@ -649,7 +650,7 @@ void CSQC_UpdateView(float w, float h)
 \r
                if(cvar("hud_postprocessing"))\r
                {\r
-                       if(cvar("hud_damage_blur"))\r
+                       if(cvar("hud_damage_blur") && myhealth_flash_temp)\r
                        {\r
                                damage_blurpostprocess_x = 1;\r
                                damage_blurpostprocess_y = bound(0, myhealth_flash_temp, 1) * cvar("hud_damage_blur");\r
@@ -694,49 +695,65 @@ void CSQC_UpdateView(float w, float h)
 \r
        if(cvar("hud_postprocessing"))\r
        {\r
+               // all of this should be done in the engine eventually\r
+\r
+               // enable or disable rendering types if they are used or not\r
+               if(cvar("r_glsl_postprocess_uservec1_enable") != (cvar("hud_postprocessing_maxbluralpha") != 0))\r
+                       cvar_set("r_glsl_postprocess_uservec1_enable", ftos(cvar("hud_postprocessing_maxbluralpha") != 0));\r
+               if(cvar("r_glsl_postprocess_uservec2_enable") != (cvar("hud_powerup") != 0))\r
+                       cvar_set("r_glsl_postprocess_uservec2_enable", ftos(cvar("hud_powerup") != 0));\r
+\r
                // lets apply the postprocess effects from the previous two functions if needed\r
                if(damage_blurpostprocess_x || content_blurpostprocess_x)\r
                {\r
                        float blurradius = bound(0, damage_blurpostprocess_y + content_blurpostprocess_y, cvar("hud_postprocessing_maxblurradius"));\r
                        float bluralpha = bound(0, damage_blurpostprocess_z + content_blurpostprocess_z, cvar("hud_postprocessing_maxbluralpha"));\r
-                       cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(blurradius), " ", ftos(bluralpha), " 0 0"));\r
-                       cvar_set("r_glsl_postprocess_uservec1_enable", "1");\r
+                       if(blurradius != old_blurradius || bluralpha != old_bluralpha) // reduce cvar_set spam as much as possible\r
+                       {\r
+                               cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(blurradius), " ", ftos(bluralpha), " 0 0"));\r
+                               old_blurradius = blurradius;\r
+                               old_bluralpha = bluralpha;\r
+                       }\r
                }\r
-               else\r
+               else if(cvar_string("r_glsl_postprocess_uservec1") != "0 0 0 0") // reduce cvar_set spam as much as possible\r
                {\r
                        cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0");\r
-                       cvar_set("r_glsl_postprocess_uservec1_enable", "0");\r
+                       old_blurradius = 0;\r
+                       old_bluralpha = 0;\r
                }\r
 \r
-               if(cvar("hud_powerup"))\r
+               float sharpen_intensity;\r
+               if (getstatf(STAT_STRENGTH_FINISHED) - time > 0)\r
+                       sharpen_intensity += (getstatf(STAT_STRENGTH_FINISHED) - time);\r
+               if (getstatf(STAT_INVINCIBLE_FINISHED) - time > 0)\r
+                       sharpen_intensity += (getstatf(STAT_INVINCIBLE_FINISHED) - time);\r
+\r
+               if(cvar("hud_powerup") && sharpen_intensity > 0)\r
                {\r
-                       float sharpen_intensity;\r
-                       if (getstatf(STAT_STRENGTH_FINISHED) - time > 0)\r
-                               sharpen_intensity += (getstatf(STAT_STRENGTH_FINISHED) - time);\r
-                       if (getstatf(STAT_INVINCIBLE_FINISHED) - time > 0)\r
-                               sharpen_intensity += (getstatf(STAT_INVINCIBLE_FINISHED) - time);\r
                        sharpen_intensity = bound(0, sharpen_intensity, 5); // powerup warning time is 5 seconds, so fade the effect from there\r
 \r
-                       if(sharpen_intensity > 0)\r
+                       if(sharpen_intensity != old_sharpen_intensity) // reduce cvar_set spam as much as possible\r
                        {\r
                                cvar_set("r_glsl_postprocess_uservec2", strcat("0 ", ftos(-sharpen_intensity * cvar("hud_powerup")), " 0 0"));\r
-                               cvar_set("r_glsl_postprocess_uservec2_enable", "1");\r
-                       }\r
-                       else\r
-                       {\r
-                               cvar_set("r_glsl_postprocess_uservec2", "0 0 0 0");\r
-                               cvar_set("r_glsl_postprocess_uservec2_enable", "0");\r
+                               old_sharpen_intensity = sharpen_intensity;\r
                        }\r
                }\r
+               else if(cvar_string("r_glsl_postprocess_uservec2") != "0 0 0 0") // reduce cvar_set spam as much as possible\r
+               {\r
+                       cvar_set("r_glsl_postprocess_uservec2", "0 0 0 0");\r
+                       old_sharpen_intensity = 0;\r
+               }\r
        }\r
 \r
-       if not(cvar("hud_damage") && cvar("hud_postprocessing"))\r
+       if(cvar("hud_postprocessing") && !cvar("hud_postprocessing_maxbluralpha"))\r
+       if(cvar("r_glsl_postprocess_uservec1_enable"))\r
        {\r
                // don't allow blur to get stuck on if we disable the cvar while damaged\r
                cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0");\r
                cvar_set("r_glsl_postprocess_uservec1_enable", "0");\r
        }\r
-       if not(cvar("hud_powerup") && cvar("hud_postprocessing"))\r
+       if(cvar("hud_postprocessing") && !cvar("hud_powerup"))\r
+       if(cvar("r_glsl_postprocess_uservec2_enable"))\r
        {\r
                // don't allow sharpen to get stuck on if we disable the cvar while powered up\r
                cvar_set("r_glsl_postprocess_uservec2", "0 0 0 0");\r
@@ -992,7 +1009,7 @@ void CSQC_UpdateView(float w, float h)
                                string wcross_name;\r
                                float wcross_alpha, wcross_scale, wcross_blur, wcross_resolution;\r
 \r
-                               if(swallow_indicator)\r
+                               if(swallow_indicator && (cvar("crosshair_swallowindicator_color_red") || cvar("crosshair_swallowindicator_color_green") || cvar("crosshair_swallowindicator_color_blue")))\r
                                {\r
                                        wcross_color_x = cvar("crosshair_swallowindicator_color_red");\r
                                        wcross_color_y = cvar("crosshair_swallowindicator_color_green");\r
@@ -1051,6 +1068,15 @@ void CSQC_UpdateView(float w, float h)
                                wcross_alpha = cvar("crosshair_color_alpha");\r
                                wcross_resolution = cvar("crosshair_size");\r
 \r
+                               if(!activeweapon)\r
+                               if(!swallow_indicator)\r
+                               {\r
+                                       if(cvar("crosshair_unarmed_dim_color"))\r
+                                               wcross_color *= cvar("crosshair_unarmed_dim_color");\r
+                                       if(cvar("crosshair_unarmed_dim_alpha"))\r
+                                               wcross_alpha *= cvar("crosshair_unarmed_dim_alpha");\r
+                               }\r
+\r
                                wcross_name = strcat("gfx/crosshair", wcross_style);\r
 \r
                                if(cvar("crosshair_effect_scalefade"))\r