From 85d1187251eae197d44f2b39a4a0e6fe96b56f9d Mon Sep 17 00:00:00 2001 From: TimePath Date: Sat, 12 Dec 2015 20:10:23 +1100 Subject: [PATCH] Weapons: store switchingweapon as direct weapon reference --- qcsrc/common/state.qh | 2 +- qcsrc/common/weapons/all.qh | 3 --- qcsrc/server/cl_client.qc | 6 +++--- qcsrc/server/weapons/weaponsystem.qc | 10 +++++----- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/qcsrc/common/state.qh b/qcsrc/common/state.qh index 84bb94686..6c0b327af 100644 --- a/qcsrc/common/state.qh +++ b/qcsrc/common/state.qh @@ -50,6 +50,7 @@ CLASS(PlayerState, Object) ATTRIB(PlayerState, m_weapon, Weapon, Weapons_from(-1)) METHOD(PlayerState, ps_push, void(PlayerState this)) { + STAT(SWITCHINGWEAPON, this.m_client) = this.m_switchingweapon.m_id; STAT(SWITCHWEAPON, this.m_client) = this.m_switchweapon.m_id; } ENDCLASS(PlayerState) @@ -63,7 +64,6 @@ PlayerState PS(entity this) { assert(IS_CLIENT(this)); return this._ps; } void PlayerState_attach(entity this) { - LOG_INFO("Attached\n"); this._ps = NEW(PlayerState, this); } diff --git a/qcsrc/common/weapons/all.qh b/qcsrc/common/weapons/all.qh index 4c8ede6dc..e84afe940 100644 --- a/qcsrc/common/weapons/all.qh +++ b/qcsrc/common/weapons/all.qh @@ -331,9 +331,6 @@ STATIC_INIT(register_weapons_done) .vector weaponentity_glowmod; //.int weapon; // current weapon -#ifdef SVQC -.int switchingweapon = _STAT(SWITCHINGWEAPON); -#endif .string weaponname; // name of .weapon .vector spawnorigin; // for casings diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index fddaa09cb..6fc79fef2 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -306,7 +306,7 @@ void PutObserverInServer() self.weapon = 0; self.weaponname = ""; - self.switchingweapon = 0; + PS(self).m_switchingweapon = WEP_Null; self.weaponmodel = ""; for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { @@ -627,7 +627,7 @@ void PutClientInServer() this.cnt = -1; // W_LastWeapon will not complain this.weapon = 0; this.weaponname = ""; - this.switchingweapon = 0; + PS(this).m_switchingweapon = WEP_Null; if (!warmup_stage && !this.alivetime) this.alivetime = time; @@ -1681,7 +1681,7 @@ void SpectateCopy(entity this, entity spectatee) self.pressedkeys = spectatee.pressedkeys; self.weapons = spectatee.weapons; PS(self).m_switchweapon = PS(spectatee).m_switchweapon; - self.switchingweapon = spectatee.switchingweapon; + PS(self).m_switchingweapon = PS(spectatee).m_switchingweapon; self.weapon = spectatee.weapon; self.vortex_charge = spectatee.vortex_charge; self.vortex_chargepool_ammo = spectatee.vortex_chargepool_ammo; diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 0124fa9f5..678dd5096 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -188,7 +188,7 @@ void w_clear(Weapon thiswep, entity actor, .entity weaponentity, int fire) if (actor.weapon != -1) { actor.weapon = 0; - actor.switchingweapon = 0; + PS(actor).m_switchingweapon = WEP_Null; } entity this = actor.(weaponentity); if (this) @@ -432,7 +432,7 @@ void W_WeaponFrame(entity actor) if (PS(actor).m_switchweapon.m_id == 0) { actor.weapon = 0; - actor.switchingweapon = 0; + PS(actor).m_switchingweapon = WEP_Null; this.state = WS_CLEAR; actor.weaponname = ""; // actor.items &= ~IT_AMMO; @@ -459,7 +459,7 @@ void W_WeaponFrame(entity actor) { // end switching! Weapon newwep = PS(actor).m_switchweapon; - actor.switchingweapon = newwep.m_id; + PS(actor).m_switchingweapon = newwep; // the two weapon entities will notice this has changed and update their models actor.weapon = newwep.m_id; @@ -486,13 +486,13 @@ void W_WeaponFrame(entity actor) case WS_DROP: { // in dropping phase we can switch at any time - actor.switchingweapon = PS(actor).m_switchweapon.m_id; + PS(actor).m_switchingweapon = PS(actor).m_switchweapon; break; } case WS_READY: { // start switching! - actor.switchingweapon = PS(actor).m_switchweapon.m_id; + PS(actor).m_switchingweapon = PS(actor).m_switchweapon; entity oldwep = Weapons_from(actor.weapon); // set up weapon switch think in the future, and start drop anim -- 2.39.2