]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Weapons: store switchingweapon as direct weapon reference
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 12 Dec 2015 09:10:23 +0000 (20:10 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 12 Dec 2015 09:10:23 +0000 (20:10 +1100)
qcsrc/common/state.qh
qcsrc/common/weapons/all.qh
qcsrc/server/cl_client.qc
qcsrc/server/weapons/weaponsystem.qc

index 84bb94686bcb6097885f70e6191b738b724e6992..6c0b327afb843c636d5f99d21d8d93793e16d66e 100644 (file)
@@ -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);
 }
 
index 4c8ede6dcc6286c6e8a583faf26280f1e0df5778..e84afe9402a5acc34a2a8d696d2f9b0a421ef480 100644 (file)
@@ -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
index fddaa09cbd422b87acb0258832f1f3bdcb89aaa8..6fc79fef2e0fc1c27eee554bf9c35221922a4f01 100644 (file)
@@ -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;
index 0124fa9f5cb08611376e57958fb7ebe573030093..678dd5096ec914702dfbd77f7f8463bb989cf052 100644 (file)
@@ -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