From 824dde5a5388816a57e8a9897b3b612a380a482c Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Sun, 18 Oct 2020 20:52:41 +1000 Subject: [PATCH] Rename GetAmmoConsumptionPrimary to GetAmmoConsumptionQ3 and move to quake3.qc --- qcsrc/common/weapons/all.qc | 17 ----------------- qcsrc/common/weapons/weapon.qh | 4 ---- qcsrc/server/compat/quake3.qc | 16 ++++++++++++++++ qcsrc/server/compat/quake3.qh | 3 ++- qcsrc/server/weapons/spawning.qc | 4 ++-- 5 files changed, 20 insertions(+), 24 deletions(-) diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index 5de760d48..d6e7cdbe7 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -251,23 +251,6 @@ entity GetAmmoItem(int ammotype) // GetAmmoPicture GetAmmoName notif_arg_item_wepammo ammo_pickupevalfunc ? } -#ifdef SVQC -int GetAmmoConsumptionPrimary(string netname) -// Returns ammo consumed per shot by the primary/default fire mode -// Returns 0 if the netname has no ammo cvar -{ - switch (netname) - { - case "arc": return autocvar_g_balance_arc_beam_ammo; - case "devastator": return autocvar_g_balance_devastator_ammo; - case "machinegun": return autocvar_g_balance_machinegun_sustained_ammo; - case "minelayer": return autocvar_g_balance_minelayer_ammo; - case "seeker": return autocvar_g_balance_seeker_tag_ammo; - default: return cvar(strcat("g_balance_", netname, "_primary_ammo")); - } -} -#endif - #ifdef CSQC int GetAmmoTypeFromNum(int i) { diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh index cf266b8d6..83f3f4a0f 100644 --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@ -229,10 +229,6 @@ string GetAmmoName(int ammotype); entity GetAmmoItem(int ammotype); -#ifdef SVQC -int GetAmmoConsumptionPrimary(string netname); -#endif - #ifdef CSQC int GetAmmoTypeFromNum(int i); int GetAmmoStat(int ammotype); diff --git a/qcsrc/server/compat/quake3.qc b/qcsrc/server/compat/quake3.qc index fec250558..4c50ea51f 100644 --- a/qcsrc/server/compat/quake3.qc +++ b/qcsrc/server/compat/quake3.qc @@ -333,3 +333,19 @@ bool DoesQ3ARemoveThisEntity(entity this) return false; } + +int GetAmmoConsumptionQ3(string netname) +// Returns ammo consumed per shot by the primary/default fire mode +// Returns 0 if the netname has no ammo cvar +{ + switch (netname) + { + case "arc": return autocvar_g_balance_arc_beam_ammo; + case "devastator": return autocvar_g_balance_devastator_ammo; + case "machinegun": return autocvar_g_balance_machinegun_sustained_ammo; + case "minelayer": return autocvar_g_balance_minelayer_ammo; + case "seeker": return autocvar_g_balance_seeker_tag_ammo; + default: return cvar(strcat("g_balance_", netname, "_primary_ammo")); + } +} + diff --git a/qcsrc/server/compat/quake3.qh b/qcsrc/server/compat/quake3.qh index 321c6fb4f..029485ab0 100644 --- a/qcsrc/server/compat/quake3.qh +++ b/qcsrc/server/compat/quake3.qh @@ -5,6 +5,7 @@ int q3compat = 0; #define Q3COMPAT_DEFI BIT(1) bool DoesQ3ARemoveThisEntity(entity this); +int GetAmmoConsumptionQ3(string netname); .int fragsfilter_cnt; @@ -17,7 +18,7 @@ bool DoesQ3ARemoveThisEntity(entity this); spawnfunc(ammo_classname) \ { \ if(this.count && xonwep.ammo_type) \ - SetResource(this, xonwep.ammo_type, this.count * GetAmmoConsumptionPrimary(xonwep.netname)); \ + SetResource(this, xonwep.ammo_type, this.count * GetAmmoConsumptionQ3(xonwep.netname)); \ SPAWNFUNC_BODY(GetAmmoItem(xonwep.ammo_type)) \ } diff --git a/qcsrc/server/weapons/spawning.qc b/qcsrc/server/weapons/spawning.qc index dd664986d..730a73796 100644 --- a/qcsrc/server/weapons/spawning.qc +++ b/qcsrc/server/weapons/spawning.qc @@ -111,8 +111,8 @@ void weapon_defaultspawnfunc(entity this, Weapon wpn) if ((wpn.ammo_type != RES_NONE) && !GetResource(this, wpn.ammo_type)) { int ammo = 0; - if (this.count > 0) - ammo = this.count * GetAmmoConsumptionPrimary(wpn.netname); + if (q3compat && this.count > 0) + ammo = this.count * GetAmmoConsumptionQ3(wpn.netname); // WEAPONTODO: magazines of MG, rifle and OK weapons are unaccounted for else { -- 2.39.2