From: Mario Date: Mon, 12 Feb 2018 15:04:46 +0000 (+1000) Subject: Add wr_zoomdir (cleans out another weapon specific function in the main codebase) X-Git-Tag: xonotic-v0.8.5~2323 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4edcb7a00a4d9b606182011b9351460baf5f6bbd;p=xonotic%2Fxonotic-data.pk3dir.git Add wr_zoomdir (cleans out another weapon specific function in the main codebase) --- 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