From: TimePath Date: Sat, 19 Dec 2015 05:24:31 +0000 (+1100) Subject: weapons: fix being able to switch to no weapon X-Git-Tag: xonotic-v0.8.2~1475 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0d626c1759ca9320467b44c0522dd884a6d9678a;p=xonotic%2Fxonotic-data.pk3dir.git weapons: fix being able to switch to no weapon --- diff --git a/qcsrc/common/weapons/weapon/blaster.qc b/qcsrc/common/weapons/weapon/blaster.qc index 5ae4dd4b9..1d76279f3 100644 --- a/qcsrc/common/weapons/weapon/blaster.qc +++ b/qcsrc/common/weapons/weapon/blaster.qc @@ -192,7 +192,7 @@ void W_Blaster_Attack( case 0: // switch to last used weapon { if(PS(actor).m_switchweapon == WEP_BLASTER) // don't do this if already switching - W_LastWeapon(); + W_LastWeapon(actor); break; } diff --git a/qcsrc/server/cl_impulse.qc b/qcsrc/server/cl_impulse.qc index 59fc183aa..ecd4ae07e 100644 --- a/qcsrc/server/cl_impulse.qc +++ b/qcsrc/server/cl_impulse.qc @@ -195,7 +195,7 @@ IMPULSE(weapon_last) { if (this.vehicle) return; if (this.deadflag != DEAD_NO) return; - W_LastWeapon(); + W_LastWeapon(this); } IMPULSE(weapon_best) diff --git a/qcsrc/server/weapons/selection.qc b/qcsrc/server/weapons/selection.qc index 1c286829f..049577422 100644 --- a/qcsrc/server/weapons/selection.qc +++ b/qcsrc/server/weapons/selection.qc @@ -234,16 +234,18 @@ void W_SwitchToOtherWeapon(entity pl) // hack to ensure it switches to an OTHER weapon (in case the other fire mode still has ammo, we want that anyway) Weapon ww; WepSet set = WepSet_FromWeapon(PS(pl).m_weapon); - if(pl.weapons & set) + if (pl.weapons & set) { pl.weapons &= ~set; ww = w_getbestweapon(pl); pl.weapons |= set; } else + { ww = w_getbestweapon(pl); - if(ww) - W_SwitchWeapon_Force(pl, ww); + } + if (ww == WEP_Null) return; + W_SwitchWeapon_Force(pl, ww); } void W_SwitchWeapon(Weapon w) @@ -299,11 +301,11 @@ void W_PreviousWeapon(float list) } // previously used if exists and has ammo, (second) best otherwise -void W_LastWeapon() -{SELFPARAM(); - Weapon wep = Weapons_from(self.cnt); - if(client_hasweapon(self, wep, true, false)) +void W_LastWeapon(entity this) +{ + Weapon wep = Weapons_from(this.cnt); + if (client_hasweapon(this, wep, true, false)) W_SwitchWeapon(wep); else - W_SwitchToOtherWeapon(self); + W_SwitchToOtherWeapon(this); } diff --git a/qcsrc/server/weapons/selection.qh b/qcsrc/server/weapons/selection.qh index 18e3f5a1c..b4e2fb81c 100644 --- a/qcsrc/server/weapons/selection.qh +++ b/qcsrc/server/weapons/selection.qh @@ -29,5 +29,5 @@ void W_NextWeapon(float list); void W_PreviousWeapon(float list); // previously used if exists and has ammo, (second) best otherwise -void W_LastWeapon(); +void W_LastWeapon(entity this); #endif