]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud/panel/modicons.qc
Avoid a division by 0 (it happened playing DOM on a map that doesn't support DOM)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / panel / modicons.qc
index 2c99485731ebbf1acef68f063a4c4867bb5bb8b5..a4d84cf9e8694eea15eb467b8b7c1a6e5b71ec4c 100644 (file)
@@ -4,7 +4,7 @@
 #include <common/ent_cs.qh>
 #include <server/mutators/mutator/gamemode_ctf.qh> // TODO: remove
 
-// Mod icons panel (#10)
+// Mod icons (#10)
 
 bool mod_active; // is there any active mod icon?
 
@@ -676,7 +676,9 @@ void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, int layout, in
                        color = '1 0 1';
                        break;
        }
-       float pps_ratio = stat / STAT(DOM_TOTAL_PPS);
+       float pps_ratio = 0;
+       if(STAT(DOM_TOTAL_PPS))
+               pps_ratio = stat / STAT(DOM_TOTAL_PPS);
 
        if(mySize.x/mySize.y > aspect_ratio)
        {
@@ -758,9 +760,6 @@ void HUD_ModIcons()
                if(!HUD_ModIcons_GameType) return;
        }
 
-       HUD_Panel_UpdateCvars();
-
-       draw_beginBoldFont();
 
        if(mod_active != mod_prev) {
                mod_change = time;
@@ -772,12 +771,19 @@ void HUD_ModIcons()
        else
                mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
 
+       //if(mod_alpha <= 0)
+       //      return;
+       panel_fade_alpha *= mod_alpha;
+       HUD_Panel_LoadCvars();
+
+       draw_beginBoldFont();
+
        if (autocvar_hud_panel_modicons_dynamichud)
                HUD_Scale_Enable();
        else
                HUD_Scale_Disable();
-       if(mod_alpha)
-               HUD_Panel_DrawBg(mod_alpha);
+
+       HUD_Panel_DrawBg();
 
        if(panel_bg_padding)
        {