]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix another hardcoded slot 0
authorMario <mario@smbclan.net>
Thu, 29 Sep 2016 15:23:30 +0000 (01:23 +1000)
committerMario <mario@smbclan.net>
Thu, 29 Sep 2016 15:23:30 +0000 (01:23 +1000)
21 files changed:
qcsrc/common/mutators/mutator/nix/sv_nix.qc
qcsrc/common/mutators/mutator/overkill/hmg.qc
qcsrc/common/t_items.qc
qcsrc/common/weapons/weapon/crylink.qc
qcsrc/common/weapons/weapon/devastator.qc
qcsrc/common/weapons/weapon/hagar.qc
qcsrc/common/weapons/weapon/hlac.qc
qcsrc/common/weapons/weapon/hook.qc
qcsrc/common/weapons/weapon/machinegun.qc
qcsrc/common/weapons/weapon/minelayer.qc
qcsrc/common/weapons/weapon/shotgun.qc
qcsrc/server/client.qc
qcsrc/server/g_damage.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/weapons/hitplot.qc
qcsrc/server/weapons/hitplot.qh
qcsrc/server/weapons/selection.qc
qcsrc/server/weapons/selection.qh
qcsrc/server/weapons/throwing.qc
qcsrc/server/weapons/tracing.qc
qcsrc/server/weapons/weaponsystem.qc

index 0a2bc818161775c3660ce9786b18624c6346f952..7804c073298d004df7052047b366a7911b90f36e 100644 (file)
@@ -65,7 +65,7 @@ REGISTER_MUTATOR(nix, cvar("g_nix") && !cvar("g_instagib") && !cvar("g_overkill"
                        it.weapons = start_weapons;
                        .entity weaponentity = weaponentities[0]; // TODO: unhardcode
                        if(!client_hasweapon(it, it.(weaponentity).m_weapon, weaponentity, true, false))
-                               it.(weaponentity).m_switchweapon = w_getbestweapon(it);
+                               it.(weaponentity).m_switchweapon = w_getbestweapon(it, weaponentity);
                });
        }
 
index c04607e99c3c80c74da7dd096dce1124da579868..8a1de98ada5cbb2f1fd3ec8a11dc8bf6333e88ea 100644 (file)
@@ -22,7 +22,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weapone
 
        if((!thiswep.wr_checkammo1(thiswep, actor, weaponentity) && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || (!(actor.items & IT_SUPERWEAPON) && !(actor.items & IT_UNLIMITED_SUPERWEAPONS)))
        {
-               W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
+               W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
                w_ready(thiswep, actor, weaponentity, fire);
                return;
        }
index 1753f9d1f033ff47d86f26501cef0e38cd6dfba3..3c80ae01b9ba3156c04c6128b8a2e78469e737f3 100644 (file)
@@ -684,7 +684,7 @@ float Item_GiveTo(entity item, entity player)
        // if the player is using their best weapon before items are given, they
        // probably want to switch to an even better weapon after items are given
        if (player.autoswitch)
-       if (player.(weaponentity).m_switchweapon == w_getbestweapon(player))
+       if (player.(weaponentity).m_switchweapon == w_getbestweapon(player, weaponentity))
                _switchweapon = true;
 
        if (!(player.weapons & WepSet_FromWeapon(player.(weaponentity).m_switchweapon)))
@@ -767,8 +767,8 @@ LABEL(skip)
        }
 
        if (_switchweapon)
-               if (player.(weaponentity).m_switchweapon != w_getbestweapon(player))
-                       W_SwitchWeapon_Force(player, w_getbestweapon(player), weaponentity);
+               if (player.(weaponentity).m_switchweapon != w_getbestweapon(player, weaponentity))
+                       W_SwitchWeapon_Force(player, w_getbestweapon(player, weaponentity), weaponentity);
 
        return 1;
 }
@@ -1659,7 +1659,7 @@ float GiveItems(entity e, float beginarg, float endarg)
 
        _switchweapon = false;
        if (e.autoswitch)
-               if (e.(weaponentity).m_switchweapon == w_getbestweapon(e))
+               if (e.(weaponentity).m_switchweapon == w_getbestweapon(e, weaponentity))
                        _switchweapon = true;
 
        e.strength_finished = max(0, e.strength_finished - time);
@@ -1828,7 +1828,7 @@ float GiveItems(entity e, float beginarg, float endarg)
        if (!(e.weapons & WepSet_FromWeapon(e.(weaponentity).m_switchweapon)))
                _switchweapon = true;
        if(_switchweapon)
-               W_SwitchWeapon_Force(e, w_getbestweapon(e), weaponentity);
+               W_SwitchWeapon_Force(e, w_getbestweapon(e, weaponentity), weaponentity);
 
        return got;
 }
index 570e14fbbfa852f69c8159c5ecf4027132b70fb6..8b09240b6089ea8f75e48ca733aa0f4a9b610e93 100644 (file)
@@ -638,7 +638,7 @@ METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentit
             {
                 // ran out of ammo!
                 actor.cnt = WEP_CRYLINK.m_id;
-                actor.(weaponentity).m_switchweapon = w_getbestweapon(actor);
+                actor.(weaponentity).m_switchweapon = w_getbestweapon(actor, weaponentity);
             }
         }
     }
index 6ca5fa101cf9ddef4d3773b0e4e7b0909965fab1..13a13927f611f28d3596bb22eda582f95856cc8a 100644 (file)
@@ -124,7 +124,7 @@ void W_Devastator_Explode(entity this, entity directhitentity)
                        this.realowner.cnt = WEP_DEVASTATOR.m_id;
                        int slot = weaponslot(weaponentity);
                        ATTACK_FINISHED(this.realowner, slot) = time;
-                       this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner);
+                       this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner, weaponentity);
                }
        }
        delete(this);
@@ -210,7 +210,7 @@ void W_Devastator_DoRemoteExplode(entity this, .entity weaponentity)
                        this.realowner.cnt = WEP_DEVASTATOR.m_id;
                        int slot = weaponslot(weaponentity);
                        ATTACK_FINISHED(this.realowner, slot) = time;
-                       this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner);
+                       this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner, weaponentity);
                }
        }
        delete(this);
index f74de39b0d8cea0652e24ee99b32d5e430a3f1a7..e6c1f8d2617dbdeaa068fe1c6f92d30bf8fb0eac 100644 (file)
@@ -430,7 +430,7 @@ void W_Hagar_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int
        if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity))
        if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
-               W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
+               W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
                w_ready(thiswep, actor, weaponentity, fire);
                return;
        }
index 3fe8e8c042b1867c3937badd58dda32221cb52e4..161f402be02833b4d4117bf5f9098dc8d2f91bc7 100644 (file)
@@ -179,7 +179,7 @@ void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentity, int
                if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity))
                if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
                {
-                       W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
+                       W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
                        w_ready(thiswep, actor, weaponentity, fire);
                        return;
                }
index 2c4edd13df0738b97668c5754beaea0a9e3b24b0..db2ac45d6eed9461d3ee7c5da750013f7c95ddde 100644 (file)
@@ -251,7 +251,7 @@ METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity,
                     {
                         actor.ammo_fuel = 0;
                         actor.(weaponentity).hook_state |= HOOK_REMOVING;
-                        W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
+                        W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
                     }
                 }
             }
index c2b5667302821b78e2d325cb3d5f54a9f1b3f167..0116e7d39bc5beeac839d588867f231853d52e51 100644 (file)
@@ -157,7 +157,7 @@ void W_MachineGun_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentit
                if(!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
                if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
                {
-                       W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
+                       W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
                        w_ready(thiswep, actor, weaponentity, fire);
                        return;
                }
@@ -183,7 +183,7 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity
        if(!thiswep.wr_checkammo1(thiswep, actor, weaponentity))
        if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
-               W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
+               W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
                w_ready(thiswep, actor, weaponentity, fire);
                return;
        }
@@ -281,7 +281,7 @@ METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponen
             if(!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
             if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
             {
-                W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
+                W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
                 w_ready(thiswep, actor, weaponentity, fire);
                 return;
             }
index dd75963661def50405df14d1fa5771f7b1c7b06a..cff18ef705eb500ca216a7bbf06173dc5272a191 100644 (file)
@@ -137,7 +137,7 @@ void W_MineLayer_Explode(entity this, entity directhitentity)
                        own.cnt = WEP_MINE_LAYER.m_id;
                        int slot = weaponslot(weaponentity);
                        ATTACK_FINISHED(own, slot) = time;
-                       own.(weaponentity).m_switchweapon = w_getbestweapon(own);
+                       own.(weaponentity).m_switchweapon = w_getbestweapon(own, weaponentity);
                }
        }
        this.realowner.minelayer_mines -= 1;
@@ -169,7 +169,7 @@ void W_MineLayer_DoRemoteExplode(entity this)
                        own.cnt = WEP_MINE_LAYER.m_id;
                        int slot = weaponslot(weaponentity);
                        ATTACK_FINISHED(own, slot) = time;
-                       own.(weaponentity).m_switchweapon = w_getbestweapon(own);
+                       own.(weaponentity).m_switchweapon = w_getbestweapon(own, weaponentity);
                }
        }
        this.realowner.minelayer_mines -= 1;
index 80d485e4b804b29c482bc81fb9023ab0b700c93f..6a30a92f982216ec5e72384a2ef176caa5c2ce24 100644 (file)
@@ -202,7 +202,7 @@ void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, .entity weaponentity
        if (!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
        if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
-               W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
+               W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
                w_ready(thiswep, actor, weaponentity, fire);
                return;
        }
@@ -216,7 +216,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity
        if (!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
        if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
        {
-               W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
+               W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
                w_ready(thiswep, actor, weaponentity, fire);
                return;
        }
index 61b0c779ab7f4fa861f9f926f71e7af5eb0d2f96..205eb0cb396dd0bfc55e0002006b4c4330a09a86 100644 (file)
@@ -696,7 +696,7 @@ void PutClientInServer(entity this)
                {
                        .entity weaponentity = weaponentities[slot];
                        if(slot == 0)
-                               this.(weaponentity).m_switchweapon = w_getbestweapon(this);
+                               this.(weaponentity).m_switchweapon = w_getbestweapon(this, weaponentity);
                        else
                                this.(weaponentity).m_switchweapon = WEP_Null;
                        this.(weaponentity).weaponname = "";
index fd8e89c9f71bff9cf035ecbe13960e56a64fe100..531ad6f530642d5218076c1d243d309f1ff5aacf 100644 (file)
@@ -100,7 +100,7 @@ void GiveFrags (entity attacker, entity targ, float f, int deathtype)
 
                // after a frag, choose another random weapon set
                if (!(attacker.weapons & WepSet_FromWeapon(attacker.(weaponentity).m_weapon)))
-                       W_SwitchWeapon_Force(attacker, w_getbestweapon(attacker), weaponentity);
+                       W_SwitchWeapon_Force(attacker, w_getbestweapon(attacker, weaponentity), weaponentity);
        }
 
        // FIXME fix the mess this is (we have REAL points now!)
index 2914ca2deee09cb6430f8222f51344afa9b4e2db..e8b32c8049692830571eae42d73e7e9cd1698cee 100644 (file)
@@ -450,7 +450,7 @@ void GetCvars(entity this, int f)
        {
                .entity weaponentity = weaponentities[0]; // TODO: unhardcode
                if (s == "cl_weaponpriority")
-                       if (this.(weaponentity)) this.(weaponentity).m_switchweapon = w_getbestweapon(this);
+                       if (this.(weaponentity)) this.(weaponentity).m_switchweapon = w_getbestweapon(this, weaponentity);
                if (s == "cl_allow_uidtracking")
                        PlayerStats_GameReport_AddPlayer(this);
        }
index 2e1c4058dff45293ec32a8c2256021a0d9c005da..0173c6d9d6623291c3acf4f25f78d063afc097b7 100644 (file)
@@ -51,7 +51,7 @@ vector W_HitPlotNormalizedUntransform(vector org, entity targ, vector screenforw
        return ret;
 }
 
-void W_HitPlotAnalysis(entity player, vector screenforward, vector screenright, vector screenup)
+void W_HitPlotAnalysis(entity player, .entity weaponentity, vector screenforward, vector screenright, vector screenup)
 {
        vector hitplot;
        vector org;
@@ -73,7 +73,6 @@ void W_HitPlotAnalysis(entity player, vector screenforward, vector screenright,
                        antilag_takeback(trace_ent, store, time - lag);
                        hitplot = W_HitPlotNormalizedUntransform(org, trace_ent, screenforward, screenright, screenup, trace_endpos);
                        antilag_restore(trace_ent, store);
-                       .entity weaponentity = weaponentities[0]; // TODO: unhardcode
                        fputs(player.hitplotfh, strcat(ftos(hitplot.x), " ", ftos(hitplot.y), " ", ftos(hitplot.z), " ", ftos(player.(weaponentity).m_switchweapon.m_id), "\n"));
                        //print(strcat(ftos(hitplot_x), " ", ftos(hitplot_y), " ", ftos(hitplot_z), "\n"));
                }
index 8aa15a61b4f37222725bc539f51d4e7682545766..89f7f50504d580c04f354fd971d61d56fddb7824 100644 (file)
@@ -2,6 +2,6 @@
 
 .float hitplotfh;
 
-void W_HitPlotAnalysis(entity player, vector screenforward, vector screenright, vector screenup);
+void W_HitPlotAnalysis(entity player, .entity weaponentity, vector screenforward, vector screenright, vector screenup);
 void W_HitPlotOpen(entity player);
 void W_HitPlotClose(entity player);
index f8ce9e750cd91091d8e3e54fae0f0857d6108afa..f7a061acad826fafbb010dade6e2c250b6c70cff 100644 (file)
@@ -248,12 +248,12 @@ void W_SwitchToOtherWeapon(entity this, .entity weaponentity)
        if (this.weapons & set)
        {
                this.weapons &= ~set;
-               ww = w_getbestweapon(this);
+               ww = w_getbestweapon(this, weaponentity);
                this.weapons |= set;
        }
        else
        {
-               ww = w_getbestweapon(this);
+               ww = w_getbestweapon(this, weaponentity);
        }
        if (ww == WEP_Null) return;
        W_SwitchWeapon_Force(this, ww, weaponentity);
index 68c15139ea7dee762d87bf8a593f377f8c70d118..071a0fea8bcb73fb1b2ebad279b7d26cbdcf3f83 100644 (file)
@@ -9,8 +9,7 @@ bool client_hasweapon(entity this, Weapon wpn, .entity weaponentity, float andam
 .int weaponcomplainindex;
 float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, float complain, float skipmissing, .entity weaponentity);
 
-// TODO: unhardcode
-#define w_getbestweapon(ent) Weapons_from(W_GetCycleWeapon(ent, ent.cvar_cl_weaponpriority, 0, -1, false, true, weaponentities[0]))
+#define w_getbestweapon(ent,wepent) Weapons_from(W_GetCycleWeapon(ent, ent.cvar_cl_weaponpriority, 0, -1, false, true, wepent))
 
 void W_SwitchWeapon_Force(Player this, Weapon w, .entity weaponentity);
 
index f36a0eebfad18a3a9e89cfb3d83f068677930f48..e0e1e9db669cc39dc4864eabe57cf7b14fd7dace 100644 (file)
@@ -183,7 +183,7 @@ void W_ThrowWeapon(entity this, .entity weaponentity, vector velo, vector delta,
        if(!(this.weapons & set)) return;
        this.weapons &= ~set;
 
-       W_SwitchWeapon_Force(this, w_getbestweapon(this), weaponentity);
+       W_SwitchWeapon_Force(this, w_getbestweapon(this, weaponentity), weaponentity);
        string a = W_ThrowNewWeapon(this, w.m_id, doreduce, this.origin + delta, velo, weaponentity);
 
        if(!a) return;
index 1f7f5946757dac215ca0621bb682cb0f97aeca51..8e6d2eabf1e2aca1ba608bcc198cce4be5d1b712 100644 (file)
@@ -56,7 +56,7 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, .entity weaponentity, vect
                accuracy_add(ent, ent.(weaponentity).m_weapon.m_id, maxdamage, 0);
 
        if(IS_PLAYER(ent))
-               W_HitPlotAnalysis(ent, v_forward, v_right, v_up);
+               W_HitPlotAnalysis(ent, weaponentity, v_forward, v_right, v_up);
 
        vector md = ent.(weaponentity).movedir;
        if(md.x > 0)
index a37462eae8ed1d40de3365e2785680422d882625..c68c452b9cb48d250cae21acee102bcf6418d13a 100644 (file)
@@ -180,7 +180,7 @@ void CL_SpawnWeaponentity(entity actor, .entity weaponentity)
 
        wepent_link(view);
 
-       if (weaponentity == weaponentities[0])
+       if (weaponentity == weaponentities[0]) // only one exterior model, thank you very much
        {
                entity exterior = actor.exteriorweaponentity = new(exteriorweaponentity);
                exterior.solid = SOLID_NOT;
@@ -539,7 +539,7 @@ void W_WeaponFrame(Player actor, .entity weaponentity)
        {
                if (w != WEP_Null && !(actor.weapons & WepSet_FromWeapon(w)))
                {
-                       if (this.m_weapon == this.m_switchweapon) W_SwitchWeapon_Force(actor, w_getbestweapon(actor), weaponentity);
+                       if (this.m_weapon == this.m_switchweapon) W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
                        w = WEP_Null;
                }