]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
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 28b10da9ed4b5a9e4a0fe39f6fb7da941303fcff..2c10ae9ff281b327480095f096b67d2b5d9c110c 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 b5f542928f3fc4d869999c8b379a414143eb2a8e..0ed34006cbb43307fb8e021fc0ad90b0599fb55f 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 0e49171122634db1b0aaecce386dd1ccc984914d..afd02f57407f06825643b38aa49aa9f3b1465662 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 60557cbf8d42211602f985a6ba32da1c22551fa1..39433dd6fd7272217981c3c7bea49826784ca44c 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