]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/view.qc
Add an alpha check to avoid a drawpic call every frame
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / view.qc
index defec0708fb3d643f51162b0597c9bad04983233..124a677535cdc83eb997a8ca988631d891df2c6f 100644 (file)
@@ -1,4 +1,3 @@
-#include "_all.qh"
 
 #include "announcer.qh"
 #include "hook.qh"
@@ -7,23 +6,28 @@
 #include "mapvoting.qh"
 #include "scoreboard.qh"
 #include "shownames.qh"
+#include "quickmenu.qh"
 
 #include "mutators/events.qh"
 
 #include "../common/constants.qh"
 #include "../common/mapinfo.qh"
+#include "../common/gamemodes/all.qh"
 #include "../common/nades/all.qh"
 #include "../common/stats.qh"
 #include "../common/triggers/target/music.qh"
 #include "../common/teams.qh"
-#include "../common/util.qh"
 
+#include "../common/vehicles/all.qh"
 #include "../common/weapons/all.qh"
+#include "../common/viewloc.qh"
+#include "../common/minigames/cl_minigames.qh"
+#include "../common/minigames/cl_minigames_hud.qh"
 
-#include "../csqcmodellib/cl_player.qh"
+#include "../lib/csqcmodel/cl_player.qh"
 
-#include "../warpzonelib/client.qh"
-#include "../warpzonelib/common.qh"
+#include "../lib/warpzone/client.qh"
+#include "../lib/warpzone/common.qh"
 
 entity porto;
 vector polyline[16];
@@ -394,8 +398,6 @@ float TrueAimCheck()
        return SHOTTYPE_HITWORLD;
 }
 
-void CSQC_common_hud(void);
-
 void PostInit(void);
 void CSQC_Demo_Camera();
 float HUD_WouldDrawScoreboard();
@@ -457,24 +459,8 @@ bool WantEventchase()
        return false;
 }
 
-void HUD_Vehicle()
-{
-       if(!hud || intermission)
-               return;
-
-       if(hud == HUD_BUMBLEBEE_GUN)
-               CSQC_BUMBLE_GUN_HUD();
-       else {
-               Vehicle info = get_vehicleinfo(hud);
-               info.vr_hud(info);
-       }
-}
-
 void HUD_Crosshair_Vehicle()
 {
-       if(!hud || intermission)
-               return;
-
        if(hud != HUD_BUMBLEBEE_GUN)
        {
                Vehicle info = get_vehicleinfo(hud);
@@ -561,17 +547,23 @@ void HitSound()
 void HUD_Crosshair()
 {SELFPARAM();
        static float rainbow_last_flicker;
-    static vector rainbow_prev_color;
+       static vector rainbow_prev_color;
        entity e = self;
        float f, i, j;
        vector v;
        if(!scoreboard_active && !camera_active && intermission != 2 &&
-               spectatee_status != -1 && hud == HUD_NORMAL && !csqcplayer.viewloc &&
+               spectatee_status != -1 && !csqcplayer.viewloc &&
                !HUD_MinigameMenu_IsOpened() )
        {
                if (!autocvar_crosshair_enabled) // main toggle for crosshair rendering
                        return;
 
+               if (hud != HUD_NORMAL)
+               {
+                       HUD_Crosshair_Vehicle();
+                       return;
+               }
+
                string wcross_style;
                float wcross_alpha, wcross_resolution;
                wcross_style = autocvar_crosshair;
@@ -1031,12 +1023,17 @@ void HUD_Draw()
 
        if(autocvar_r_letterbox == 0)
                if(autocvar_viewsize < 120)
-                       CSQC_common_hud();
+               {
+                       if(!(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS))
+                               Accuracy_LoadLevels();
+
+                       HUD_Main();
+                       HUD_DrawScoreboard();
+               }
 
        // crosshair goes VERY LAST
        UpdateDamage();
        HUD_Crosshair();
-       HUD_Crosshair_Vehicle();
        HitSound();
 }
 
@@ -1753,7 +1750,7 @@ void CSQC_UpdateView(float w, float h)
 
                        drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, myhealth_gentlergb, autocvar_hud_damage_gentle_alpha_multiplier * bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage, DRAWFLAG_NORMAL);
                }
-               else
+               else if(myhealth_flash_temp > 0)
                        drawpic(splash_pos, "gfx/blood", splash_size, stov(autocvar_hud_damage_color), bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage, DRAWFLAG_NORMAL);
 
                if(autocvar_hud_postprocessing) // we still need to set this anyway even when chase_active is set, this way it doesn't get stuck on.
@@ -1894,20 +1891,6 @@ void CSQC_UpdateView(float w, float h)
        setproperty(VF_SIZE, '1 0 0' * w + '0 1 0' * h);
 }
 
-void CSQC_common_hud(void)
-{
-       if(!(gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS))
-               Accuracy_LoadLevels();
-
-       HUD_Main(); // always run these functions for alpha checks
-       HUD_Vehicle();
-       HUD_DrawScoreboard();
-
-       // scoreboard/accuracy, map/gametype voting screen
-       if (scoreboard_active || intermission == 2)
-               HUD_Reset();
-}
-
 
 // following vectors must be global to allow seamless switching between camera modes
 vector camera_offset, current_camera_offset, mouse_angles, current_angles, current_origin, current_position;