From: TimePath Date: Sat, 12 Dec 2015 10:12:25 +0000 (+1100) Subject: Weapons: remove redundancies X-Git-Tag: xonotic-v0.8.2~1500 X-Git-Url: https://de.git.xonotic.org/?a=commitdiff_plain;h=c2d50c76c59b481a0b0e29a205f5e0dfc9f95630;hp=85d1187251eae197d44f2b39a4a0e6fe96b56f9d;p=xonotic%2Fxonotic-data.pk3dir.git Weapons: remove redundancies --- diff --git a/qcsrc/client/hud/panel/weapons.qc b/qcsrc/client/hud/panel/weapons.qc index 8970332cd..9cfebb81e 100644 --- a/qcsrc/client/hud/panel/weapons.qc +++ b/qcsrc/client/hud/panel/weapons.qc @@ -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)); diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 79723cc3c..3ee92bd6f 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -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; diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc index 6ef89bf4d..9c86d9e4c 100644 --- a/qcsrc/client/scoreboard.qc +++ b/qcsrc/client/scoreboard.qc @@ -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; diff --git a/qcsrc/common/mutators/mutator/new_toys/new_toys.qc b/qcsrc/common/mutators/mutator/new_toys/new_toys.qc index 2a0df8c64..20a9d94f5 100644 --- a/qcsrc/common/mutators/mutator/new_toys/new_toys.qc +++ b/qcsrc/common/mutators/mutator/new_toys/new_toys.qc @@ -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)); diff --git a/qcsrc/common/mutators/mutator/nix/nix.qc b/qcsrc/common/mutators/mutator/nix/nix.qc index 9043a8399..5995dcd8b 100644 --- a/qcsrc/common/mutators/mutator/nix/nix.qc +++ b/qcsrc/common/mutators/mutator/nix/nix.qc @@ -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)) diff --git a/qcsrc/common/mutators/mutator/overkill/overkill.qc b/qcsrc/common/mutators/mutator/overkill/overkill.qc index 952537e31..789b2085d 100644 --- a/qcsrc/common/mutators/mutator/overkill/overkill.qc +++ b/qcsrc/common/mutators/mutator/overkill/overkill.qc @@ -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))); } diff --git a/qcsrc/common/mutators/mutator/overkill/rpc.qc b/qcsrc/common/mutators/mutator/overkill/rpc.qc index 0b0a85a3a..638873d34 100644 --- a/qcsrc/common/mutators/mutator/overkill/rpc.qc +++ b/qcsrc/common/mutators/mutator/overkill/rpc.qc @@ -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; } diff --git a/qcsrc/common/notifications.qh b/qcsrc/common/notifications.qh index 8586a16dc..6619e7d73 100644 --- a/qcsrc/common/notifications.qh +++ b/qcsrc/common/notifications.qh @@ -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) : "")) \ diff --git a/qcsrc/common/weapons/all.qh b/qcsrc/common/weapons/all.qh index e84afe940..929564c3e 100644 --- a/qcsrc/common/weapons/all.qh +++ b/qcsrc/common/weapons/all.qh @@ -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; diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh index a0f9dd48a..ccb71154e 100644 --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@ -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 diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 11d9115f0..959e0939d 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -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)) { diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index 56f9bba81..7ef7cf64d 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -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; } diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index 31701c319..a26d91c0c 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -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 diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index f43ce3bbd..44c5cf80d 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -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; diff --git a/qcsrc/common/weapons/weapon/hagar.qc b/qcsrc/common/weapons/weapon/hagar.qc index 17d0cee06..292e0361f 100644 --- a/qcsrc/common/weapons/weapon/hagar.qc +++ b/qcsrc/common/weapons/weapon/hagar.qc @@ -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; } diff --git a/qcsrc/common/weapons/weapon/hlac.qc b/qcsrc/common/weapons/weapon/hlac.qc index 260f4b004..94c5d3e5d 100644 --- a/qcsrc/common/weapons/weapon/hlac.qc +++ b/qcsrc/common/weapons/weapon/hlac.qc @@ -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; } diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index 8d49f8d7c..83c943fc0 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -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)) { diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index a9eee99fa..1205b3d10 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -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; } diff --git a/qcsrc/common/weapons/weapon/mortar.qc b/qcsrc/common/weapons/weapon/mortar.qc index 6a479c20a..3271b2b25 100644 --- a/qcsrc/common/weapons/weapon/mortar.qc +++ b/qcsrc/common/weapons/weapon/mortar.qc @@ -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; } diff --git a/qcsrc/common/weapons/weapon/rifle.qc b/qcsrc/common/weapons/weapon/rifle.qc index 77f8cb5f2..e0ead086d 100644 --- a/qcsrc/common/weapons/weapon/rifle.qc +++ b/qcsrc/common/weapons/weapon/rifle.qc @@ -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; } diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index 039414c7b..55d6b4f7a 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -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; diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index bdc592fed..9bc1a229e 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -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; } diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index 2905002d9..eb4613806 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -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; } diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index 56f7a12aa..d62042190 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -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; } diff --git a/qcsrc/lib/stats.qh b/qcsrc/lib/stats.qh index d1823a77d..22aff1b63 100644 --- a/qcsrc/lib/stats.qh +++ b/qcsrc/lib/stats.qh @@ -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) diff --git a/qcsrc/server/bot/aim.qc b/qcsrc/server/bot/aim.qc index 954154029..d4614b846 100644 --- a/qcsrc/server/bot/aim.qc +++ b/qcsrc/server/bot/aim.qc @@ -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); diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index bed49addd..012ac3997 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -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; diff --git a/qcsrc/server/mutators/mutator/gamemode_cts.qc b/qcsrc/server/mutators/mutator/gamemode_cts.qc index 5e509a9da..9a3481ea7 100644 --- a/qcsrc/server/mutators/mutator/gamemode_cts.qc +++ b/qcsrc/server/mutators/mutator/gamemode_cts.qc @@ -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; } diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc index 2511c69dc..35fd87832 100644 --- a/qcsrc/server/t_items.qc +++ b/qcsrc/server/t_items.qc @@ -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)); diff --git a/qcsrc/server/weapons/selection.qc b/qcsrc/server/weapons/selection.qc index 9a2c9fd2b..b54cdf4b7 100644 --- a/qcsrc/server/weapons/selection.qc +++ b/qcsrc/server/weapons/selection.qc @@ -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; diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 678dd5096..3b0aed87b 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -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