From 0eaaec01e120d39a564252ebc31a34d5ff114117 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 18 Jan 2020 02:07:37 +1000 Subject: [PATCH] Rename AmmoNameFromWeaponentity to GetAmmoName and move it out of miscfunctions --- qcsrc/common/weapons/all.qc | 14 ++++++++++++++ qcsrc/common/weapons/weapon.qh | 2 ++ qcsrc/server/miscfunctions.qc | 18 ++---------------- qcsrc/server/miscfunctions.qh | 2 -- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index f2fdf4407..ef7a38c4e 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -225,6 +225,20 @@ string GetAmmoPicture(int ammotype) } } +string GetAmmoName(int ammotype) +{ + switch (ammotype) + { + case RES_SHELLS: return ITEM_Shells.m_name; + case RES_BULLETS: return ITEM_Bullets.m_name; + case RES_ROCKETS: return ITEM_Rockets.m_name; + case RES_CELLS: return ITEM_Cells.m_name; + case RES_PLASMA: return ITEM_Plasma.m_name; + case RES_FUEL: return ITEM_JetpackFuel.m_name; + default: return "batteries"; + } +} + #ifdef CSQC int GetAmmoTypeFromNum(int i) { diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh index 3dd2a8048..02fbdb536 100644 --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@ -216,6 +216,8 @@ WepSet W_RandomWeapons(entity e, WepSet remaining, int n); string GetAmmoPicture(int ammotype); +string GetAmmoName(int ammotype); + #ifdef CSQC int GetAmmoTypeFromNum(int i); int GetAmmoStat(int ammotype); diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index dd14a049e..0cc8d7919 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -33,6 +33,7 @@ #include "../common/state.qh" #include "../common/effects/qc/globalsound.qh" #include "../common/wepent.qh" +#include #include "../lib/csqcmodel/sv_model.qh" #include "../lib/warpzone/anglestransform.qh" #include "../lib/warpzone/server.qh" @@ -214,21 +215,6 @@ string NearestLocation(vector p) return ret; } -string AmmoNameFromWeaponentity(Weapon wep) -{ - string ammoitems = "batteries"; - switch (wep.ammo_type) - { - case RES_SHELLS: ammoitems = ITEM_Shells.m_name; break; - case RES_BULLETS: ammoitems = ITEM_Bullets.m_name; break; - case RES_ROCKETS: ammoitems = ITEM_Rockets.m_name; break; - case RES_CELLS: ammoitems = ITEM_Cells.m_name; break; - case RES_PLASMA: ammoitems = ITEM_Plasma.m_name; break; - case RES_FUEL: ammoitems = ITEM_JetpackFuel.m_name; break; - } - return ammoitems; -} - string PlayerHealth(entity this) { float myhealth = floor(GetResource(this, RES_HEALTH)); @@ -311,7 +297,7 @@ string formatmessage(entity this, string msg) case "y": replacement = NearestLocation(cursor); break; case "d": replacement = NearestLocation(this.death_origin); break; case "w": replacement = WeaponNameFromWeaponentity(this, weaponentity); break; - case "W": replacement = AmmoNameFromWeaponentity(this.(weaponentity).m_weapon); break; + case "W": replacement = GetAmmoName(this.(weaponentity).m_weapon.ammo_type); break; case "x": replacement = ((cursor_ent.netname == "" || !cursor_ent) ? "nothing" : cursor_ent.netname); break; case "s": replacement = ftos(vlen(this.velocity - this.velocity_z * '0 0 1')); break; case "S": replacement = ftos(vlen(this.velocity)); break; diff --git a/qcsrc/server/miscfunctions.qh b/qcsrc/server/miscfunctions.qh index 2b85a0476..71affe5d7 100644 --- a/qcsrc/server/miscfunctions.qh +++ b/qcsrc/server/miscfunctions.qh @@ -96,8 +96,6 @@ float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, f string NearestLocation(vector p); -string AmmoNameFromWeaponentity(Weapon wep); - void play2(entity e, string filename); string playername(entity p, bool team_colorize); -- 2.39.2