From 4edcb7a00a4d9b606182011b9351460baf5f6bbd Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 13 Feb 2018 01:04:46 +1000 Subject: [PATCH] Add wr_zoomdir (cleans out another weapon specific function in the main codebase) --- qcsrc/client/view.qc | 11 ++++++++--- qcsrc/common/weapons/weapon.qh | 2 ++ qcsrc/common/weapons/weapon/rifle.qc | 4 ++++ qcsrc/common/weapons/weapon/vortex.qc | 4 ++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 28b10da9e..2c10ae9ff 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -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()) diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh index b5f542928..0ed34006c 100644 --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@ -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 */ diff --git a/qcsrc/common/weapons/weapon/rifle.qc b/qcsrc/common/weapons/weapon/rifle.qc index 0e4917112..afd02f574 100644 --- a/qcsrc/common/weapons/weapon/rifle.qc +++ b/qcsrc/common/weapons/weapon/rifle.qc @@ -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 diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index 60557cbf8..39433dd6f 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -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 -- 2.39.2