Add wr_zoomdir (cleans out another weapon specific function in the main codebase)
authorMario <mario@smbclan.net>
Mon, 12 Feb 2018 15:04:46 +0000 (01:04 +1000)
committerMario <mario@smbclan.net>
Mon, 12 Feb 2018 15:04:46 +0000 (01:04 +1000)
qcsrc/client/view.qc
qcsrc/common/weapons/weapon.qh
qcsrc/common/weapons/weapon/rifle.qc
qcsrc/common/weapons/weapon/vortex.qc

index 28b10da..2c10ae9 100644 (file)
@@ -471,9 +471,14 @@ vector GetCurrentFov(float fov)
                for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {
                        entity wepent = viewmodels[slot];
-                       if(wepent.switchweapon == wepent.activeweapon)
-                       if((wepent.activeweapon == WEP_VORTEX && !WEP_CVAR(vortex, secondary)) || (wepent.activeweapon == WEP_RIFLE && !WEP_CVAR(rifle, secondary))) // do NOT use switchweapon here
-                               zoomdir += button_attack2;
+                       if(wepent.switchweapon != wepent.activeweapon)
+                               continue;
+                       Weapon wep = wepent.activeweapon;
+                       if(wep != WEP_Null && wep.wr_zoomdir)
+                       {
+                               bool do_zoom = wep.wr_zoomdir(wep); // TODO: merge this with wr_zoom?
+                               zoomdir += do_zoom;
+                       }
                }
        }
        if(spectatee_status > 0 || isdemo())
index b5f5429..0ed3400 100644 (file)
@@ -108,6 +108,8 @@ CLASS(Weapon, Object)
         // no weapon specific image for this weapon
         return false;
     }
+    /** (CLIENT) check whether the weapon should zoom (special handling) */
+    METHOD(Weapon, wr_zoomdir, bool(Weapon this)) {return false;}
     /** (CLIENT) weapon specific view model */
     METHOD(Weapon, wr_viewmodel, string(Weapon this, entity wep)) { return string_null; }
     /** (CLIENT) weapon specific glow */
index 0e49171..afd02f5 100644 (file)
@@ -223,5 +223,9 @@ METHOD(Rifle, wr_zoom, bool(entity thiswep, entity actor))
         return false;
     }
 }
+METHOD(Rifle, wr_zoomdir, bool(entity thiswep))
+{
+    return button_attack2 && !WEP_CVAR(rifle, secondary);
+}
 
 #endif
index 60557cb..39433dd 100644 (file)
@@ -358,5 +358,9 @@ METHOD(Vortex, wr_zoom, bool(entity thiswep, entity actor))
         return false;
     }
 }
+METHOD(Vortex, wr_zoomdir, bool(entity thiswep))
+{
+    return button_attack2 && !WEP_CVAR(vortex, secondary);
+}
 
 #endif