]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Weapons: remove redundancies
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 12 Dec 2015 10:12:25 +0000 (21:12 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 12 Dec 2015 10:12:25 +0000 (21:12 +1100)
31 files changed:
qcsrc/client/hud/panel/weapons.qc
qcsrc/client/main.qc
qcsrc/client/scoreboard.qc
qcsrc/common/mutators/mutator/new_toys/new_toys.qc
qcsrc/common/mutators/mutator/nix/nix.qc
qcsrc/common/mutators/mutator/overkill/overkill.qc
qcsrc/common/mutators/mutator/overkill/rpc.qc
qcsrc/common/notifications.qh
qcsrc/common/weapons/all.qh
qcsrc/common/weapons/weapon.qh
qcsrc/common/weapons/weapon/arc.qc
qcsrc/common/weapons/weapon/crylink.qc
qcsrc/common/weapons/weapon/devastator.qc
qcsrc/common/weapons/weapon/electro.qc
qcsrc/common/weapons/weapon/hagar.qc
qcsrc/common/weapons/weapon/hlac.qc
qcsrc/common/weapons/weapon/machinegun.qc
qcsrc/common/weapons/weapon/minelayer.qc
qcsrc/common/weapons/weapon/mortar.qc
qcsrc/common/weapons/weapon/rifle.qc
qcsrc/common/weapons/weapon/seeker.qc
qcsrc/common/weapons/weapon/shotgun.qc
qcsrc/common/weapons/weapon/vaporizer.qc
qcsrc/common/weapons/weapon/vortex.qc
qcsrc/lib/stats.qh
qcsrc/server/bot/aim.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/mutator/gamemode_cts.qc
qcsrc/server/t_items.qc
qcsrc/server/weapons/selection.qc
qcsrc/server/weapons/weaponsystem.qc

index 8970332cd105def4f719790ddfabd38f217e44ec..9cfebb81e716c80f198f39a5235426cb25b93194 100644 (file)
@@ -11,9 +11,8 @@ void weaponorder_swap(int i, int j, entity pass)
 string weaponorder_cmp_str;
 int weaponorder_cmp(int i, int j, entity pass)
 {
-       int ai, aj;
-       ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].weapon), 0);
-       aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].weapon), 0);
+       int ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].m_id), 0);
+       int aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].m_id), 0);
        return aj - ai; // the string is in REVERSE order (higher prio at the right is what we want, but higher prio first is the string)
 }
 
@@ -118,7 +117,7 @@ void HUD_Weapons()
                // do we own this weapon?
                weapon_count = 0;
                for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
-                       if((weapons_stat & WepSet_FromWeapon(Weapons_from(weaponorder[i].weapon))) || (weaponorder[i].weapon == complain_weapon))
+                       if((weapons_stat & WepSet_FromWeapon(weaponorder[i])) || (weaponorder[i].m_id == complain_weapon))
                                ++weapon_count;
 
 
@@ -339,14 +338,14 @@ void HUD_Weapons()
                // retrieve information about the current weapon to be drawn
                setself(weaponorder[i]);
                weapon_id = self.impulse;
-               isCurrent = (self.weapon == switchweapon.m_id);
+               isCurrent = (self == switchweapon);
 
                // skip if this weapon doesn't exist
                if(!self || weapon_id < 0) { continue; }
 
                // skip this weapon if we don't own it (and onlyowned is enabled)-- or if weapons_complainbubble is showing for this weapon
                if(autocvar_hud_panel_weapons_onlyowned)
-               if (!((weapons_stat & WepSet_FromWeapon(Weapons_from(self.weapon))) || (self.weapon == complain_weapon)))
+               if (!((weapons_stat & WepSet_FromWeapon(self)) || (self.m_id == complain_weapon)))
                        continue;
 
                // figure out the drawing position of weapon
@@ -361,7 +360,7 @@ void HUD_Weapons()
                // draw the weapon accuracy
                if(autocvar_hud_panel_weapons_accuracy)
                {
-                       float panel_weapon_accuracy = weapon_accuracy[self.weapon-WEP_FIRST];
+                       float panel_weapon_accuracy = weapon_accuracy[self.m_id-WEP_FIRST];
                        if(panel_weapon_accuracy >= 0)
                        {
                                color = Accuracy_GetColor(panel_weapon_accuracy);
@@ -370,7 +369,7 @@ void HUD_Weapons()
                }
 
                // drawing all the weapon items
-               if(weapons_stat & WepSet_FromWeapon(Weapons_from(self.weapon)))
+               if(weapons_stat & WepSet_FromWeapon(self))
                {
                        // draw the weapon image
                        if(isCurrent)
@@ -442,7 +441,7 @@ void HUD_Weapons()
                }
 
                // draw the complain message
-               if(self.weapon == complain_weapon)
+               if(self.m_id == complain_weapon)
                {
                        if(fadetime)
                                a = ((complain_weapon_time + when > time) ? 1 : bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1));
index 79723cc3c2e3dd4b300c7ec14e734b3155a4ce79..3ee92bd6fe7f9d5859eb8fb364e6d5afc27d77d9 100644 (file)
@@ -1100,7 +1100,7 @@ NET_HANDLE(TE_CSQC_WEAPONCOMPLAIN, bool isNew)
 {
        complain_weapon = ReadByte();
        if (complain_weapon_name) strunzone(complain_weapon_name);
-       complain_weapon_name = strzone(WEP_NAME(complain_weapon));
+       complain_weapon_name = strzone(Weapons_from(complain_weapon).m_name);
        complain_weapon_type = ReadByte();
        return = true;
 
index 6ef89bf4d0343c92890e42676fb6cf0d15abc69b..9c86d9e4c63355a9c198aa84c9ed285c89d51a50 100644 (file)
@@ -1002,8 +1002,6 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        float initial_posx = pos.x;
        int disownedcnt = 0;
        FOREACH(Weapons, it != WEP_Null, LAMBDA(
-               if (!it.weapon) continue;
-
                int weapon_stats = weapon_accuracy[i - WEP_FIRST];
 
                WepSet set = it.m_wepset;
@@ -1064,7 +1062,6 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
 
        int column = 0;
        FOREACH(Weapons, it != WEP_Null, LAMBDA(
-               if (!it.weapon) continue;
                int weapon_stats = weapon_accuracy[i - WEP_FIRST];
 
                WepSet set = it.m_wepset;
index 2a0df8c642cce3b1157525e477675a64a833cb2e..20a9d94f5452c6c5d63885e2f6de5ced4baaa890 100644 (file)
@@ -169,8 +169,7 @@ MUTATOR_HOOKFUNCTION(nt, SetStartItems)
        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
        {
                entity e = Weapons_from(i);
-               if(!e.weapon)
-                       continue;
+               if(e == WEP_Null) continue;
 
                n = tokenize_console(nt_GetReplacement(e.netname, autocvar_g_new_toys_autoreplace));
 
index 9043a8399d407c5ce633e75cbf25bf1864ef881d..5995dcd8b670c8f617c6d226aee72686a145b4e6 100644 (file)
@@ -79,8 +79,7 @@ REGISTER_MUTATOR(nix, cvar("g_nix") && !cvar("g_instagib") && !cvar("g_overkill"
 bool NIX_CanChooseWeapon(int wpn)
 {
        entity e = Weapons_from(wpn);
-       if(!e.weapon) // skip dummies
-               return false;
+       if (e == WEP_Null) return false; // skip dummies
        if(g_weaponarena)
        {
                if(!(g_weaponarena_weapons & e.m_wepset))
index 952537e31f979bf5227847abe07d3cb3fdf7c9f0..789b2085d99b4701ec04283fc5a45f2b950ab378 100644 (file)
@@ -65,8 +65,7 @@ void ok_DecreaseCharge(entity ent, int wep)
 
        entity wepent = Weapons_from(wep);
 
-       if(wepent.weapon == 0)
-               return; // dummy
+       if (wepent == WEP_Null) return;  // dummy
 
        ent.ammo_charge[wep] -= max(0, cvar(sprintf("g_overkill_ammo_decharge_%s", wepent.netname)));
 }
@@ -75,8 +74,7 @@ void ok_IncreaseCharge(entity ent, int wep)
 {
        entity wepent = Weapons_from(wep);
 
-       if(wepent.weapon == 0)
-               return; // dummy
+       if (wepent == WEP_Null) return;  // dummy
 
        if(ent.ok_use_ammocharge)
        if(!ent.BUTTON_ATCK) // not while attacking?
@@ -89,8 +87,7 @@ float ok_CheckWeaponCharge(entity ent, int wep)
 
        entity wepent = Weapons_from(wep);
 
-       if(wepent.weapon == 0)
-               return 0; // dummy
+       if(wepent == WEP_Null) return 0;  // dummy
 
        return (ent.ammo_charge[wep] >= cvar(sprintf("g_overkill_ammo_decharge_%s", wepent.netname)));
 }
index 0b0a85a3ad4c8711061cb1d4e79fcdc8b851678e..638873d341bae18451655bb4532dd24e49ecace0 100644 (file)
@@ -177,7 +177,7 @@ void W_RocketPropelledChainsaw_Attack (Weapon thiswep)
                }
                METHOD(RocketPropelledChainsaw, wr_checkammo1, bool(entity thiswep))
                {
-                       float ammo_amount = self.WEP_AMMO(RPC) >= WEP_CVAR(rpc, ammo);
+                       float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(rpc, ammo);
                        ammo_amount += self.(weapon_load[WEP_RPC.m_id]) >= WEP_CVAR(rpc, ammo);
                        return ammo_amount;
                }
index 8586a16dc549d89164a4e5e300829cb82966c255..6619e7d7304aa89d1a5b2f446ce0ae998d027a91 100644 (file)
@@ -318,7 +318,7 @@ string BUFF_NAME(int i);
     ARG_CASE(ARG_CS_SV,     "spree_inf",     (autocvar_notification_show_sprees ? notif_arg_spree_inf(1, input, s2, f2) : "")) \
     ARG_CASE(ARG_CS_SV,     "spree_end",     (autocvar_notification_show_sprees ? notif_arg_spree_inf(-1, "", "", f1) : "")) \
     ARG_CASE(ARG_CS_SV,     "spree_lost",    (autocvar_notification_show_sprees ? notif_arg_spree_inf(-2, "", "", f1) : "")) \
-    ARG_CASE(ARG_CS_SV,     "item_wepname",  WEP_NAME(f1)) \
+    ARG_CASE(ARG_CS_SV,     "item_wepname",  Weapons_from(f1).m_name) \
     ARG_CASE(ARG_CS_SV,     "item_buffname", BUFF_NAME(f1)) \
     ARG_CASE(ARG_CS_SV,     "f3buffname",    BUFF_NAME(f3)) \
     ARG_CASE(ARG_CS_SV,     "item_wepammo",  (s1 != "" ? sprintf(_(" with %s"), s1) : "")) \
index e84afe9402a5acc34a2a8d696d2f9b0a421ef480..929564c3ef8504efa2f77a5b1916da72109a4829 100644 (file)
@@ -305,7 +305,6 @@ STATIC_INIT(register_weapons_done)
         WepSet set = it.m_wepset;
         WEPSET_ALL |= set;
         if ((it.spawnflags) & WEP_FLAG_SUPERWEAPON) WEPSET_SUPERWEAPONS |= set;
-        it.weapon = it.m_id;
         it.weapons = set;
         if (it == WEP_Null) continue;
         int imp = WEP_IMPULSE_BEGIN + it.m_id - 1;
index a0f9dd48a743fec4ea591d19f899c953fab281fd..ccb71154e5b3dd95d7d7a162dff8784b12880d68 100644 (file)
@@ -51,11 +51,6 @@ const int WS_READY  = 4;
 /** fields which are explicitly/manually set are marked with "M", fields set automatically are marked with "A" */
 CLASS(Weapon, Object)
        ATTRIB(Weapon, m_id, int, 0)
-    /**
-     * M: WEP_id    : WEP_...
-     * you can recognize dummies when this == 0
-     */
-    ATTRIB(Weapon, weapon, int, 0);
     /** A: WEPSET_id : WEPSET_... */
     ATTRIB(Weapon, weapons, WepSet, '0 0 0');
     /** M: ammotype  : main ammo field */
@@ -216,9 +211,4 @@ int GetAmmoStat(.int ammotype);
 string W_Sound(string w_snd);
 string W_Model(string w_mdl);
 
-
-// other useful macros
-#define WEP_AMMO(wpn) (WEP_##wpn.ammo_field) // only used inside weapon files/with direct name, don't duplicate prefix
-#define WEP_NAME(wpn) ((Weapons_from(wpn)).m_name)
-
 #endif
index 11d9115f0fadcf3a19db6690ca2afc69aeb113d6..959e0939d3b010806028f6c9b71dcaba5e6db497 100644 (file)
@@ -234,10 +234,12 @@ void W_Arc_Beam_Think()
                burst = ARC_BT_BURSTMASK;
        }
 
+       Weapon thiswep = WEP_ARC;
+
        if(
                !IS_PLAYER(self.owner)
                ||
-               (self.owner.WEP_AMMO(ARC) <= 0 && !(self.owner.items & IT_UNLIMITED_WEAPON_AMMO))
+               (self.owner.(thiswep.ammo_field) <= 0 && !(self.owner.items & IT_UNLIMITED_WEAPON_AMMO))
                ||
                self.owner.deadflag != DEAD_NO
                ||
@@ -302,8 +304,8 @@ void W_Arc_Beam_Think()
 
                if(rootammo)
                {
-                       coefficient = min(coefficient, self.owner.WEP_AMMO(ARC) / rootammo);
-                       self.owner.WEP_AMMO(ARC) = max(0, self.owner.WEP_AMMO(ARC) - (rootammo * frametime));
+                       coefficient = min(coefficient, self.owner.(thiswep.ammo_field) / rootammo);
+                       self.owner.(thiswep.ammo_field) = max(0, self.owner.(thiswep.ammo_field) - (rootammo * frametime));
                }
        }
        float heat_speed = burst ? WEP_CVAR(arc, burst_heat) : WEP_CVAR(arc, beam_heat);
@@ -727,13 +729,13 @@ void Arc_Smoke()
                METHOD(Arc, wr_checkammo1, bool(entity thiswep))
                {
                        SELFPARAM();
-                       return ((!WEP_CVAR(arc, beam_ammo)) || (self.WEP_AMMO(ARC) > 0));
+                       return ((!WEP_CVAR(arc, beam_ammo)) || (self.(thiswep.ammo_field) > 0));
                }
                METHOD(Arc, wr_checkammo2, bool(entity thiswep))
                {
                        SELFPARAM();
                        return WEP_CVAR(arc, overheat_max) > 0 &&
-                               ((!WEP_CVAR(arc, burst_ammo)) || (self.WEP_AMMO(ARC) > 0));
+                               ((!WEP_CVAR(arc, burst_ammo)) || (self.(thiswep.ammo_field) > 0));
                }
                METHOD(Arc, wr_killmessage, int(entity thiswep))
                {
index 56f9bba810335032411318d317b10a7be91fd6c2..7ef7cf64dfb0d26fe2d9fec069494821576548a7 100644 (file)
@@ -638,7 +638,7 @@ void W_Crylink_Attack2(Weapon thiswep)
                        if(self.crylink_lastgroup && self.crylink_waitrelease)
                                return true;
 
-                       float ammo_amount = self.WEP_AMMO(CRYLINK) >= WEP_CVAR_PRI(crylink, ammo);
+                       float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(crylink, ammo);
                        ammo_amount += self.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_PRI(crylink, ammo);
                        return ammo_amount;
                }
@@ -649,7 +649,7 @@ void W_Crylink_Attack2(Weapon thiswep)
                        if(self.crylink_lastgroup && self.crylink_waitrelease)
                                return true;
 
-                       float ammo_amount = self.WEP_AMMO(CRYLINK) >= WEP_CVAR_SEC(crylink, ammo);
+                       float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(crylink, ammo);
                        ammo_amount += self.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_SEC(crylink, ammo);
                        return ammo_amount;
                }
index 31701c3194bb75ae3419006beacff63c608ec3f1..a26d91c0c17d8dd915c53cbb1d51280bd977b49b 100644 (file)
@@ -108,9 +108,10 @@ void W_Devastator_Explode()
                other
        );
 
-       if(self.realowner.weapon == WEP_DEVASTATOR.m_id)
+       Weapon thiswep = WEP_DEVASTATOR;
+       if(self.realowner.weapon == thiswep.m_id)
        {
-               if(self.realowner.WEP_AMMO(DEVASTATOR) < WEP_CVAR(devastator, ammo))
+               if(self.realowner.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo))
                if(!(self.realowner.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        self.realowner.cnt = WEP_DEVASTATOR.m_id;
@@ -188,9 +189,10 @@ void W_Devastator_DoRemoteExplode(.entity weaponentity)
                world
        );
 
-       if(self.realowner.weapon == WEP_DEVASTATOR.m_id)
+       Weapon thiswep = WEP_DEVASTATOR;
+       if(self.realowner.weapon == thiswep.m_id)
        {
-               if(self.realowner.WEP_AMMO(DEVASTATOR) < WEP_CVAR(devastator, ammo))
+               if(self.realowner.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo))
                if(!(self.realowner.items & IT_UNLIMITED_WEAPON_AMMO))
                {
                        self.realowner.cnt = WEP_DEVASTATOR.m_id;
@@ -575,10 +577,10 @@ void W_Devastator_Attack(Weapon thiswep)
                                ammo_amount = false;
                                if(WEP_CVAR(devastator, reload_ammo))
                                {
-                                       if(self.WEP_AMMO(DEVASTATOR) < WEP_CVAR(devastator, ammo) && self.(weapon_load[WEP_DEVASTATOR.m_id]) < WEP_CVAR(devastator, ammo))
+                                       if(self.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo) && self.(weapon_load[WEP_DEVASTATOR.m_id]) < WEP_CVAR(devastator, ammo))
                                                ammo_amount = true;
                                }
-                               else if(self.WEP_AMMO(DEVASTATOR) < WEP_CVAR(devastator, ammo))
+                               else if(self.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo))
                                        ammo_amount = true;
                                return !ammo_amount;
                        }
@@ -586,18 +588,18 @@ void W_Devastator_Attack(Weapon thiswep)
                        #if 0
                        if(self.rl_release == 0)
                        {
-                               LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: TRUE\n", self.rl_release, self.WEP_AMMO(DEVASTATOR), WEP_CVAR(devastator, ammo));
+                               LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: TRUE\n", self.rl_release, self.(thiswep.ammo_field), WEP_CVAR(devastator, ammo));
                                return true;
                        }
                        else
                        {
-                               ammo_amount = self.WEP_AMMO(DEVASTATOR) >= WEP_CVAR(devastator, ammo);
+                               ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo);
                                ammo_amount += self.(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo);
-                               LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: %s\n", self.rl_release, self.WEP_AMMO(DEVASTATOR), WEP_CVAR(devastator, ammo), (ammo_amount ? "TRUE" : "FALSE"));
+                               LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: %s\n", self.rl_release, self.(thiswep.ammo_field), WEP_CVAR(devastator, ammo), (ammo_amount ? "TRUE" : "FALSE"));
                                return ammo_amount;
                        }
                        #else
-                       float ammo_amount = self.WEP_AMMO(DEVASTATOR) >= WEP_CVAR(devastator, ammo);
+                       float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo);
                        ammo_amount += self.(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo);
                        return ammo_amount;
                        #endif
index f43ce3bbd0558555969b164c523b33a051aa7252..44c5cf80d1f0ec9b9c582a865262ee48878baa05 100644 (file)
@@ -492,7 +492,7 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, i
                }
                METHOD(Electro, wr_checkammo1, bool(entity thiswep))
                {
-                       float ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_PRI(electro, ammo);
+                       float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(electro, ammo);
                        ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo);
                        return ammo_amount;
                }
@@ -501,12 +501,12 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, i
                        float ammo_amount;
                        if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
                        {
-                               ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
+                               ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
                                ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
                        }
                        else
                        {
-                               ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_SEC(electro, ammo);
+                               ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo);
                                ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo);
                        }
                        return ammo_amount;
index 17d0cee06d780da328d5b515bc289724463c2025..292e0361f32faafc86d92b0aa623cb121fd67686 100644 (file)
@@ -305,7 +305,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep, .entity weaponentity)
        else if(autocvar_g_balance_hagar_reload_ammo)
                enough_ammo = self.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_SEC(hagar, ammo);
        else
-               enough_ammo = self.WEP_AMMO(HAGAR) >= WEP_CVAR_SEC(hagar, ammo);
+               enough_ammo = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(hagar, ammo);
 
        bool stopped = loaded || !enough_ammo;
 
@@ -452,13 +452,13 @@ void W_Hagar_Attack2_Load(Weapon thiswep, .entity weaponentity)
                }
                METHOD(Hagar, wr_checkammo1, bool(entity thiswep))
                {
-                       float ammo_amount = self.WEP_AMMO(HAGAR) >= WEP_CVAR_PRI(hagar, ammo);
+                       float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(hagar, ammo);
                        ammo_amount += self.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_PRI(hagar, ammo);
                        return ammo_amount;
                }
                METHOD(Hagar, wr_checkammo2, bool(entity thiswep))
                {
-                       float ammo_amount = self.WEP_AMMO(HAGAR) >= WEP_CVAR_SEC(hagar, ammo);
+                       float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(hagar, ammo);
                        ammo_amount += self.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_SEC(hagar, ammo);
                        return ammo_amount;
                }
index 260f4b00406dcd9ed5eb62450046c0cc5d88709a..94c5d3e5ddedc059217947e1c48f6e92c88297e0 100644 (file)
@@ -236,13 +236,13 @@ void W_HLAC_Attack2_Frame(Weapon thiswep)
                }
                METHOD(HLAC, wr_checkammo1, bool(entity thiswep))
                {
-                       float ammo_amount = self.WEP_AMMO(HLAC) >= WEP_CVAR_PRI(hlac, ammo);
+                       float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(hlac, ammo);
                        ammo_amount += self.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_PRI(hlac, ammo);
                        return ammo_amount;
                }
                METHOD(HLAC, wr_checkammo2, bool(entity thiswep))
                {
-                       float ammo_amount = self.WEP_AMMO(HLAC) >= WEP_CVAR_SEC(hlac, ammo);
+                       float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(hlac, ammo);
                        ammo_amount += self.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_SEC(hlac, ammo);
                        return ammo_amount;
                }
index 8d49f8d7c2b4ec59e59158ef89dc50c1cc305acc..83c943fc0969245e93fbbc14e22a4fd29fc33a21 100644 (file)
@@ -304,9 +304,9 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentit
                {
                        float ammo_amount;
                        if(WEP_CVAR(machinegun, mode) == 1)
-                               ammo_amount = self.WEP_AMMO(MACHINEGUN) >= WEP_CVAR(machinegun, sustained_ammo);
+                               ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(machinegun, sustained_ammo);
                        else
-                               ammo_amount = self.WEP_AMMO(MACHINEGUN) >= WEP_CVAR(machinegun, first_ammo);
+                               ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(machinegun, first_ammo);
 
                        if(WEP_CVAR(machinegun, reload_ammo))
                        {
@@ -321,9 +321,9 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentit
                {
                        float ammo_amount;
                        if(WEP_CVAR(machinegun, mode) == 1)
-                               ammo_amount = self.WEP_AMMO(MACHINEGUN) >= WEP_CVAR(machinegun, burst_ammo);
+                               ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(machinegun, burst_ammo);
                        else
-                               ammo_amount = self.WEP_AMMO(MACHINEGUN) >= WEP_CVAR(machinegun, first_ammo);
+                               ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(machinegun, first_ammo);
 
                        if(WEP_CVAR(machinegun, reload_ammo))
                        {
index a9eee99faa89629d3a92a9807cd54131e43c4ada..1205b3d10820747189a4b5cb1601d8371fe817ca 100644 (file)
@@ -507,7 +507,7 @@ float W_MineLayer_PlacedMines(float detonate)
                        if(autocvar_g_balance_minelayer_reload_ammo && actor.clip_load < WEP_CVAR(minelayer, ammo)) // forced reload
                        {
                                // not if we're holding the minelayer without enough ammo, but can detonate existing mines
-                               if(!(W_MineLayer_PlacedMines(false) && actor.WEP_AMMO(MINE_LAYER) < WEP_CVAR(minelayer, ammo))) {
+                               if(!(W_MineLayer_PlacedMines(false) && actor.(thiswep.ammo_field) < WEP_CVAR(minelayer, ammo))) {
                                        thiswep.wr_reload(thiswep);
                                }
                        }
@@ -532,7 +532,7 @@ float W_MineLayer_PlacedMines(float detonate)
                        // don't switch while placing a mine
                        if(ATTACK_FINISHED(self, slot) <= time || self.weapon != WEP_MINE_LAYER.m_id)
                        {
-                               float ammo_amount = self.WEP_AMMO(MINE_LAYER) >= WEP_CVAR(minelayer, ammo);
+                               float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(minelayer, ammo);
                                ammo_amount += self.(weapon_load[WEP_MINE_LAYER.m_id]) >= WEP_CVAR(minelayer, ammo);
                                return ammo_amount;
                        }
index 6a479c20a82e119c3eef0a9e465206bbf1da4b7f..3271b2b253cdabba0439c5b1e674f4d829a2ea6b 100644 (file)
@@ -373,13 +373,13 @@ void W_Mortar_Attack2(Weapon thiswep)
                }
                METHOD(Mortar, wr_checkammo1, bool(entity thiswep))
                {
-                       float ammo_amount = self.WEP_AMMO(MORTAR) >= WEP_CVAR_PRI(mortar, ammo);
+                       float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(mortar, ammo);
                        ammo_amount += self.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_PRI(mortar, ammo);
                        return ammo_amount;
                }
                METHOD(Mortar, wr_checkammo2, bool(entity thiswep))
                {
-                       float ammo_amount = self.WEP_AMMO(MORTAR) >= WEP_CVAR_SEC(mortar, ammo);
+                       float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(mortar, ammo);
                        ammo_amount += self.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_SEC(mortar, ammo);
                        return ammo_amount;
                }
index 77f8cb5f23c5fd36d4d64652437248289c734314..e0ead086d06ab33aa03549c3b6885e7e205b78d3 100644 (file)
@@ -198,13 +198,13 @@ void W_Rifle_BulletHail(.entity weaponentity, float mode, void() AttackFunc, WFR
                }
                METHOD(Rifle, wr_checkammo1, bool(entity thiswep))
                {
-                       float ammo_amount = self.WEP_AMMO(RIFLE) >= WEP_CVAR_PRI(rifle, ammo);
+                       float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(rifle, ammo);
                        ammo_amount += self.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_PRI(rifle, ammo);
                        return ammo_amount;
                }
                METHOD(Rifle, wr_checkammo2, bool(entity thiswep))
                {
-                       float ammo_amount = self.WEP_AMMO(RIFLE) >= WEP_CVAR_SEC(rifle, ammo);
+                       float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(rifle, ammo);
                        ammo_amount += self.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_SEC(rifle, ammo);
                        return ammo_amount;
                }
index 039414c7b0909718b536dae613d3f75ad0a42054..55d6b4f7af125b411a0d6c528ac64890d6eb84cd 100644 (file)
@@ -420,7 +420,8 @@ void W_Seeker_Vollycontroller_Think() // TODO: Merge this with W_Seeker_Attack
        entity oldenemy;
        self.cnt = self.cnt - 1;
 
-       if((!(self.realowner.items & IT_UNLIMITED_AMMO) && self.realowner.WEP_AMMO(SEEKER) < WEP_CVAR(seeker, missile_ammo)) || (self.cnt <= -1) || (self.realowner.deadflag != DEAD_NO) || (PS(self.realowner).m_switchweapon != WEP_SEEKER))
+       Weapon thiswep = WEP_SEEKER;
+       if((!(self.realowner.items & IT_UNLIMITED_AMMO) && self.realowner.(thiswep.ammo_field) < WEP_CVAR(seeker, missile_ammo)) || (self.cnt <= -1) || (self.realowner.deadflag != DEAD_NO) || (PS(self.realowner).m_switchweapon != WEP_SEEKER))
        {
                remove(self);
                return;
@@ -656,12 +657,12 @@ void W_Seeker_Fire_Tag(Weapon thiswep)
                        float ammo_amount;
                        if(WEP_CVAR(seeker, type) == 1)
                        {
-                               ammo_amount = self.WEP_AMMO(SEEKER) >= WEP_CVAR(seeker, missile_ammo);
+                               ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(seeker, missile_ammo);
                                ammo_amount += self.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, missile_ammo);
                        }
                        else
                        {
-                               ammo_amount = self.WEP_AMMO(SEEKER) >= WEP_CVAR(seeker, tag_ammo);
+                               ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(seeker, tag_ammo);
                                ammo_amount += self.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo);
                        }
                        return ammo_amount;
@@ -671,12 +672,12 @@ void W_Seeker_Fire_Tag(Weapon thiswep)
                        float ammo_amount;
                        if(WEP_CVAR(seeker, type) == 1)
                        {
-                               ammo_amount = self.WEP_AMMO(SEEKER) >= WEP_CVAR(seeker, tag_ammo);
+                               ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(seeker, tag_ammo);
                                ammo_amount += self.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo);
                        }
                        else
                        {
-                               ammo_amount = self.WEP_AMMO(SEEKER) >= WEP_CVAR(seeker, flac_ammo);
+                               ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(seeker, flac_ammo);
                                ammo_amount += self.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, flac_ammo);
                        }
                        return ammo_amount;
index bdc592fed880cae56509ebbbaf2200f1e60c2cdf..9bc1a229e45a4469cc768712cf6f7c15f3d6e0e4 100644 (file)
@@ -273,7 +273,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity
                        if(actor.clip_load >= 0) // we are not currently reloading
                        if(!actor.crouch) // no crouchmelee please
                        if(WEP_CVAR(shotgun, secondary) == 1)
-                       if(((fire & 1) && actor.WEP_AMMO(SHOTGUN) <= 0 && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || (fire & 2))
+                       if(((fire & 1) && actor.(thiswep.ammo_field) <= 0 && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || (fire & 2))
                        if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(shotgun, refire)))
                        {
                                // attempt forcing playback of the anim by switching to another anim (that we never play) here...
@@ -286,7 +286,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity
                }
                METHOD(Shotgun, wr_checkammo1, bool(entity thiswep))
                {
-                       float ammo_amount = self.WEP_AMMO(SHOTGUN) >= WEP_CVAR_PRI(shotgun, ammo);
+                       float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo);
                        ammo_amount += self.(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo);
                        return ammo_amount;
                }
@@ -300,7 +300,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity
                                case 1: return true; // melee does not use ammo
                                case 2: // secondary triple shot
                                {
-                                       float ammo_amount = self.WEP_AMMO(SHOTGUN) >= WEP_CVAR_PRI(shotgun, ammo);
+                                       float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo);
                                        ammo_amount += self.(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo);
                                        return ammo_amount;
                                }
index 2905002d931622ec0ec68079206ab42c6da7fa6c..eb461380616ced1de1f5d070842977d03d23101c 100644 (file)
@@ -341,7 +341,7 @@ void W_RocketMinsta_Attack3 ()
 
                METHOD(Vaporizer, wr_aim, void(entity thiswep))
                {
-                       if(self.WEP_AMMO(VAPORIZER) > 0)
+                       if(self.(thiswep.ammo_field) > 0)
                                self.BUTTON_ATCK = bot_aim(1000000, 0, 1, false);
                        else
                                self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_SEC(vaporizer, speed), 0, WEP_CVAR_SEC(vaporizer, lifetime), false); // WEAPONTODO: replace with proper vaporizer cvars
@@ -422,13 +422,13 @@ void W_RocketMinsta_Attack3 ()
                }
                METHOD(Vaporizer, wr_setup, void(entity thiswep))
                {
-                       self.ammo_field = WEP_AMMO(VAPORIZER);
+                       self.ammo_field = (thiswep.ammo_field);
                        self.vaporizer_lasthit = 0;
                }
                METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep))
                {
                        float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
-                       float ammo_amount = self.WEP_AMMO(VAPORIZER) >= vaporizer_ammo;
+                       float ammo_amount = self.(thiswep.ammo_field) >= vaporizer_ammo;
                        ammo_amount += self.(weapon_load[WEP_VAPORIZER.m_id]) >= vaporizer_ammo;
                        return ammo_amount;
                }
@@ -436,7 +436,7 @@ void W_RocketMinsta_Attack3 ()
                {
                        if(!WEP_CVAR_SEC(vaporizer, ammo))
                                return true;
-                       float ammo_amount = self.WEP_AMMO(VAPORIZER) >= WEP_CVAR_SEC(vaporizer, ammo);
+                       float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(vaporizer, ammo);
                        ammo_amount += self.(weapon_load[WEP_VAPORIZER.m_id]) >= WEP_CVAR_SEC(vaporizer, ammo);
                        return ammo_amount;
                }
index 56f7a12aa378352817a6a81efcdbbd7b4617e776..d6204219048419ae569438a39f4983bd93eaffa5 100644 (file)
@@ -290,11 +290,11 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary)
                                                                                }
                                                                                else
                                                                                {
-                                                                                       dt = min(dt, (actor.WEP_AMMO(VORTEX) - WEP_CVAR_PRI(vortex, ammo)) / WEP_CVAR_SEC(vortex, ammo));
+                                                                                       dt = min(dt, (actor.(thiswep.ammo_field) - WEP_CVAR_PRI(vortex, ammo)) / WEP_CVAR_SEC(vortex, ammo));
                                                                                        dt = max(0, dt);
                                                                                        if(dt > 0)
                                                                                        {
-                                                                                               actor.WEP_AMMO(VORTEX) = max(WEP_CVAR_SEC(vortex, ammo), actor.WEP_AMMO(VORTEX) - WEP_CVAR_SEC(vortex, ammo) * dt);
+                                                                                               actor.(thiswep.ammo_field) = max(WEP_CVAR_SEC(vortex, ammo), actor.(thiswep.ammo_field) - WEP_CVAR_SEC(vortex, ammo) * dt);
                                                                                        }
                                                                                }
                                                                        }
@@ -326,7 +326,7 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary)
                }
                METHOD(Vortex, wr_checkammo1, bool(entity thiswep))
                {
-                       float ammo_amount = self.WEP_AMMO(VORTEX) >= WEP_CVAR_PRI(vortex, ammo);
+                       float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(vortex, ammo);
                        ammo_amount += (autocvar_g_balance_vortex_reload_ammo && self.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_PRI(vortex, ammo));
                        return ammo_amount;
                }
@@ -335,7 +335,7 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary)
                        if(WEP_CVAR(vortex, secondary))
                        {
                                // don't allow charging if we don't have enough ammo
-                               float ammo_amount = self.WEP_AMMO(VORTEX) >= WEP_CVAR_SEC(vortex, ammo);
+                               float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(vortex, ammo);
                                ammo_amount += self.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_SEC(vortex, ammo);
                                return ammo_amount;
                        }
index d1823a77d7d8078e5dbc0704f7996cce63e55a07..22aff1b63626d25348f132da602849f70656c5dc 100644 (file)
@@ -38,7 +38,8 @@ typedef vector vectori;
                [[accumulate]] void stats_get() \
                { \
                        T it = getstat_##T(STAT_##id.m_id); \
-                       if (it != CAT(_STAT(id), _prev)) _STAT(id) = it; \
+                       if (it != CAT(_STAT(id), _prev)) \
+                               CAT(_STAT(id), _prev) = _STAT(id) = it; \
                }
        #define REGISTER_STAT_3(x, T, expr) REGISTER_STAT(x, T)
 #elif defined(SVQC)
index 9541540298437b2a7526c326e8d5906e36b47030..d4614b84672902e555b57b9976fd1e07fedddfd8 100644 (file)
@@ -338,12 +338,12 @@ float bot_aim(float shotspeed, float shotspeedupward, float maxshottime, float a
        shotspeedupward *= W_WeaponSpeedFactor();
        if (!shotspeed)
        {
-               LOG_TRACE("bot_aim: WARNING: weapon ", WEP_NAME(self.weapon), " shotspeed is zero!\n");
+               LOG_TRACE("bot_aim: WARNING: weapon ", Weapons_from(self.weapon).m_name, " shotspeed is zero!\n");
                shotspeed = 1000000;
        }
        if (!maxshottime)
        {
-               LOG_TRACE("bot_aim: WARNING: weapon ", WEP_NAME(self.weapon), " maxshottime is zero!\n");
+               LOG_TRACE("bot_aim: WARNING: weapon ", Weapons_from(self.weapon).m_name, " maxshottime is zero!\n");
                maxshottime = 1;
        }
        makevectors(self.v_angle);
index bed49addd7c30dbf9d393b96a80370179b8a1444..012ac3997ac5eacf596a8d3ae1deb5bedda154e4 100644 (file)
@@ -262,7 +262,7 @@ string formatmessage(string msg)
                        case "l": replacement = NearestLocation(self.origin); break;
                        case "y": replacement = NearestLocation(cursor); break;
                        case "d": replacement = NearestLocation(self.death_origin); break;
-                       case "w": replacement = WEP_NAME(((!self.weapon) ? (!PS(self).m_switchweapon.m_id ? self.cnt : PS(self).m_switchweapon.m_id) : self.weapon)); break;
+                       case "w": replacement = ((!self.weapon) ? ((PS(self).m_switchweapon == WEP_Null) ? Weapons_from(self.cnt) : PS(self).m_switchweapon) : Weapons_from(self.weapon)).m_name; break;
                        case "W": replacement = ammoitems; break;
                        case "x": replacement = ((cursor_ent.netname == "" || !cursor_ent) ? "nothing" : cursor_ent.netname); break;
                        case "s": replacement = ftos(vlen(self.velocity - self.velocity_z * '0 0 1')); break;
@@ -448,7 +448,7 @@ string playername(entity p)
 
 float want_weapon(entity weaponinfo, float allguns) // WEAPONTODO: what still needs done?
 {
-       int i = weaponinfo.weapon;
+       int i = weaponinfo.m_id;
        int d = 0;
        bool allow_mutatorblocked = false;
 
index 5e509a9daa10164088643b869edd2ab4951d7fd9..9a3481ea7ba2553e189c371a3dd1bfd3d915739a 100644 (file)
@@ -421,7 +421,7 @@ MUTATOR_HOOKFUNCTION(cts, FixClientCvars)
 
 MUTATOR_HOOKFUNCTION(cts, WantWeapon)
 {
-       ret_float = (want_weaponinfo.weapon == WEP_SHOTGUN.m_id);
+       ret_float = (want_weaponinfo == WEP_SHOTGUN);
        want_mutatorblocked = true;
        return true;
 }
index 2511c69dcad69696cf46686ded6ac3692cdd1871..35fd8783205a9d2f017b263bcae1a04bf0d50302 100644 (file)
@@ -492,7 +492,7 @@ void Item_RespawnCountdown ()
                        do {
                                {
                                        entity wi = Weapons_from(self.weapon);
-                                       if (wi.m_id) {
+                                       if (wi != WEP_Null) {
                                                entity wp = WaypointSprite_Spawn(WP_Weapon, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Weapon);
                                                wp.wp_extra = wi.m_id;
                                                break;
@@ -500,7 +500,7 @@ void Item_RespawnCountdown ()
                                }
                                {
                                        entity ii = self.itemdef;
-                                       if (ii.m_id) {
+                                       if (ii != NULL) {
                                                entity wp = WaypointSprite_Spawn(WP_Item, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Item);
                                                wp.wp_extra = ii.m_id;
                                                break;
@@ -1448,8 +1448,7 @@ spawnfunc(target_items)
                                        {
                                                self.weapons |= (e.m_wepset);
                                                if(self.spawnflags == 0 || self.spawnflags == 2) {
-                                                       Weapon w = Weapons_from(e.weapon);
-                                                       w.wr_init(w);
+                                                       e.wr_init(e);
                                                }
                                                break;
                                        }
@@ -1505,8 +1504,8 @@ spawnfunc(target_items)
                for(j = WEP_FIRST; j <= WEP_LAST; ++j)
                {
                        e = Weapons_from(j);
-                       if(e.weapon)
-                               self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.weapons & (e.m_wepset)), e.netname);
+                       if(e == WEP_Null) continue;
+                       self.netname = sprintf("%s %s%d %s", self.netname, itemprefix, !!(self.weapons & (e.m_wepset)), e.netname);
                }
        }
        self.netname = strzone(self.netname);
@@ -1520,8 +1519,7 @@ spawnfunc(target_items)
                        e = Weapons_from(j);
                        if(argv(i) == e.netname)
                        {
-                               Weapon w = Weapons_from(e.weapon);
-                               w.wr_init(w);
+                               e.wr_init(e);
                                break;
                        }
                }
@@ -1689,9 +1687,9 @@ float GiveItems(entity e, float beginarg, float endarg)
                                for(j = WEP_FIRST; j <= WEP_LAST; ++j)
                                {
                                        wi = Weapons_from(j);
-                                       if(wi.weapon)
-                                               if (!(wi.spawnflags & WEP_FLAG_MUTATORBLOCKED))
-                                                       got += GiveWeapon(e, j, op, val);
+                                       if(wi == WEP_Null) continue;
+                                       if (!(wi.spawnflags & WEP_FLAG_MUTATORBLOCKED))
+                                               got += GiveWeapon(e, j, op, val);
                                }
                        case "allammo":
                                got += GiveValue(e, ammo_cells, op, val);
@@ -1775,15 +1773,12 @@ float GiveItems(entity e, float beginarg, float endarg)
        for(j = WEP_FIRST; j <= WEP_LAST; ++j)
        {
                wi = Weapons_from(j);
-               if(wi.weapon)
-               {
-                       POSTGIVE_WEAPON(e, Weapons_from(j), SND(WEAPONPICKUP), string_null);
-                       if (!(save_weapons & (wi.m_wepset)))
-                               if(e.weapons & (wi.m_wepset)) {
-                                       Weapon w = Weapons_from(wi.weapon);
-                                       w.wr_init(w);
-                               }
-               }
+               if (wi == WEP_Null) continue;
+               POSTGIVE_WEAPON(e, Weapons_from(j), SND(WEAPONPICKUP), string_null);
+               if (!(save_weapons & (wi.m_wepset)))
+                       if(e.weapons & (wi.m_wepset)) {
+                               wi.wr_init(wi);
+                       }
        }
        POSTGIVE_VALUE(e, strength_finished, 1, SND(POWERUP), SND(POWEROFF));
        POSTGIVE_VALUE(e, invincible_finished, 1, "misc/powerup_shield.wav", SND(POWEROFF));
index 9a2c9fd2bd7b08ab9077968e52d6512b820f45e1..b54cdf4b76a5c33c33d8e4dd610522a16d8b4ffd 100644 (file)
@@ -80,9 +80,7 @@ bool client_hasweapon(entity cl, Weapon wpn, float andammo, bool complain)
 
                        if(autocvar_g_showweaponspawns)
                        {
-                               entity e;
-
-                               for(e = world; (e = findfloat(e, weapon, wpn.m_id)); )
+                               for(entity e = world; (e = findfloat(e, weapon, wpn.m_id)); )
                                {
                                        if(e.classname == "droppedweapon" && autocvar_g_showweaponspawns < 2)
                                                continue;
index 678dd5096ec914702dfbd77f7f8463bb989cf052..3b0aed87b3627ca289d4b213c7fb776202845d6c 100644 (file)
@@ -718,7 +718,7 @@ void W_Reload(entity actor, float sent_ammo_min, string sent_sound)
                                if (IS_REAL_CLIENT(actor) && actor.reload_complain < time)
                                {
                                        play2(actor, SND(UNAVAILABLE));
-                                       sprint(actor, strcat("You don't have enough ammo to reload the ^2", WEP_NAME(actor.weapon), "\n"));
+                                       sprint(actor, strcat("You don't have enough ammo to reload the ^2", Weapons_from(actor.weapon).m_name, "\n"));
                                        actor.reload_complain = time + 1;
                                }
                                // switch away if the amount of ammo is not enough to keep using this weapon