]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/view.qc
Clean up some slot 0 cases on client (fixes reticles)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / view.qc
index 98bd49dea30c35ee5577c1b929a76d1560255215..93c632e70fe250c34971c21f8d6fbad491becd41 100644 (file)
@@ -1154,10 +1154,6 @@ void HUD_Crosshair(entity this)
                                weapon_clipload = STAT(WEAPON_CLIPLOAD);
                                weapon_clipsize = STAT(WEAPON_CLIPSIZE);
 
-                               float ok_ammo_charge, ok_ammo_chargepool;
-                               ok_ammo_charge = STAT(OK_AMMO_CHARGE);
-                               ok_ammo_chargepool = STAT(OK_AMMO_CHARGEPOOL);
-
                                float vortex_charge, vortex_chargepool;
                                vortex_charge = STAT(VORTEX_CHARGE);
                                vortex_chargepool = STAT(VORTEX_CHARGEPOOL);
@@ -1204,13 +1200,6 @@ void HUD_Crosshair(entity this)
                                        ring_rgb = wcross_color;
                                        ring_image = "gfx/crosshair_ring.tga";
                                }
-                               else if (ok_ammo_charge)
-                               {
-                                       ring_value = ok_ammo_chargepool;
-                                       ring_alpha = autocvar_crosshair_ring_reload_alpha;
-                                       ring_rgb = wcross_color;
-                                       ring_image = "gfx/crosshair_ring.tga";
-                               }
                                else if(autocvar_crosshair_ring_reload && weapon_clipsize) // forces there to be only an ammo ring
                                {
                                        ring_value = bound(0, weapon_clipload / weapon_clipsize, 1);
@@ -1793,33 +1782,36 @@ void CSQC_UpdateView(entity this, float w, float h)
 
        ColorTranslateMode = autocvar_cl_stripcolorcodes;
 
-       entity wepent = viewmodels[0]; // TODO: unhardcode
-
-       if(last_switchweapon != wepent.switchweapon)
+       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
        {
-               weapontime = time;
-               last_switchweapon = wepent.switchweapon;
-               if(button_zoom && autocvar_cl_unpress_zoom_on_weapon_switch)
+               entity wepent = viewmodels[slot];
+
+               if(wepent.last_switchweapon != wepent.switchweapon)
                {
-                       localcmd("-zoom\n");
-                       button_zoom = false;
+                       weapontime = time;
+                       wepent.last_switchweapon = wepent.switchweapon;
+                       if(slot == 0 && button_zoom && autocvar_cl_unpress_zoom_on_weapon_switch)
+                       {
+                               localcmd("-zoom\n");
+                               button_zoom = false;
+                       }
+                       if(slot == 0 && autocvar_cl_unpress_attack_on_weapon_switch)
+                       {
+                               localcmd("-fire\n");
+                               localcmd("-fire2\n");
+                               button_attack2 = false;
+                       }
                }
-               if(autocvar_cl_unpress_attack_on_weapon_switch)
+               if(wepent.last_activeweapon != wepent.activeweapon)
                {
-                       localcmd("-fire\n");
-                       localcmd("-fire2\n");
-                       button_attack2 = false;
-               }
-       }
-       if(last_activeweapon != wepent.activeweapon)
-       {
-               last_activeweapon = wepent.activeweapon;
+                       wepent.last_activeweapon = wepent.activeweapon;
 
-               e = wepent.activeweapon;
-               if(e.netname != "")
-                       localcmd(strcat("\ncl_hook_activeweapon ", e.netname), "\n");
-               else
-                       localcmd("\ncl_hook_activeweapon none\n");
+                       e = wepent.activeweapon;
+                       if(e.netname != "")
+                               localcmd(strcat("\ncl_hook_activeweapon ", e.netname), "\n");
+                       else if(slot == 0)
+                               localcmd("\ncl_hook_activeweapon none\n");
+               }
        }
 
        // ALWAYS Clear Current Scene First
@@ -1947,7 +1939,7 @@ void CSQC_UpdateView(entity this, float w, float h)
 
        if(autocvar_cl_reticle)
        {
-               string reticle_image = wepent.activeweapon.w_reticle;
+               string reticle_image = "";
                bool wep_zoomed = false;
                for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {
@@ -1956,7 +1948,8 @@ void CSQC_UpdateView(entity this, float w, float h)
                        if(wep != WEP_Null && wep.wr_zoom)
                        {
                                bool do_zoom = wep.wr_zoom(wep, NULL);
-                               reticle_image = wep.w_reticle;
+                               if(wep.w_reticle && wep.w_reticle != "")
+                                       reticle_image = wep.w_reticle;
                                wep_zoomed += do_zoom;
                        }
                }