Also relocated some functions declarations in a header that were properly misplaced.
#include <common/colors.qh>
#include <common/weapons/all.qh>
-string _Ammo_generate_description(entity ammo_type_ent, Resource ammo_res)
+METHOD(Ammo, describe, string(Ammo this))
{
- string s = sprintf(_("The %s ammo type is used by the:"), COLORED_NAME(ammo_type_ent));
- FOREACH(Weapons, true, {
- if (it.ammo_type == ammo_res)
- s = strcat(s, "\n", COLORED_NAME(it));
+ TC(Ammo, this);
+ entity ammo = GetAmmoResource(this);
+ string s = sprintf(_("The %s ammo type is used by the:"), COLORED_NAME(this));
+ FOREACH(Weapons, it.ammo_type == ammo, {
+ s = strcat(s, "\n", COLORED_NAME(it));
});
return s;
}
-
-METHOD(Shells, describe, string(Shells this))
-{
- TC(Shells, this);
- return _Ammo_generate_description(this, RES_SHELLS);
-}
-
-METHOD(Bullets, describe, string(Bullets this))
-{
- TC(Bullets, this);
- return _Ammo_generate_description(this, RES_BULLETS);
-}
-
-METHOD(Rockets, describe, string(Rockets this))
-{
- TC(Rockets, this);
- return _Ammo_generate_description(this, RES_ROCKETS);
-}
-
-METHOD(Cells, describe, string(Cells this))
-{
- TC(Cells, this);
- return _Ammo_generate_description(this, RES_CELLS);
-}
#endif
ATTRIB(Ammo, m_respawntimejitter, float(), GET(g_pickup_respawntimejitter_ammo));
ATTRIB(Ammo, m_pickupanyway, float(), GET(g_pickup_ammo_anyway));
#endif
-#ifdef MENUQC
- METHOD(Ammo, describe, string(Ammo this))
- {
- TC(Ammo, this);
- return SUPER(Pickup).describe(this);
- }
-#endif
ENDCLASS(Ammo)
return NULL;
}
+entity GetAmmoResource(Ammo ammotype)
+{
+ FOREACH(Resources, it.netname == ammotype.netname,
+ {
+ return it;
+ });
+ LOG_WARNF("Invalid ammo type %d ", ammotype.m_id);
+ return NULL;
+}
+
#ifdef CSQC
int GetAmmoStat(Resource ammotype)
{
#endif
#endif
+
+// functions:
+string W_FixWeaponOrder(string order, float complete);
+string W_NameWeaponOrder(string order);
+string W_NumberWeaponOrder(string order);
+string W_FixWeaponOrder_BuildImpulseList(string o);
+string W_FixWeaponOrder_AllowIncomplete(entity this, string order);
+string W_FixWeaponOrder_ForceComplete(string order);
+WepSet W_RandomWeapons(entity e, WepSet remaining, int n);
+
+entity GetAmmoItem(Resource ammotype);
+entity GetAmmoResource(Ammo ammotype);
+
+#ifdef CSQC
+int GetAmmoStat(Resource ammotype);
+#endif
+
+string W_Sound(string w_snd);
+string W_Model(string w_mdl);
// variables:
string weaponorder_byid;
-
-// functions:
-string W_FixWeaponOrder(string order, float complete);
-string W_NameWeaponOrder(string order);
-string W_NumberWeaponOrder(string order);
-string W_FixWeaponOrder_BuildImpulseList(string o);
-string W_FixWeaponOrder_AllowIncomplete(entity this, string order);
-string W_FixWeaponOrder_ForceComplete(string order);
-WepSet W_RandomWeapons(entity e, WepSet remaining, int n);
-
-entity GetAmmoItem(Resource ammotype);
-
-#ifdef CSQC
-int GetAmmoStat(Resource ammotype);
-#endif
-
-string W_Sound(string w_snd);
-string W_Model(string w_mdl);