summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/itemprop.cc
diff options
context:
space:
mode:
authorNicholas Feinberg <pleasingfung@gmail.com>2014-07-10 21:08:23 -0700
committerNicholas Feinberg <pleasingfung@gmail.com>2014-07-10 22:57:26 -0700
commit7eaa6eb283b06be6c1441215e634d4566c99257f (patch)
tree9ceafbfda2bc978f9fcacedb536a0cd1d8e2fc22 /crawl-ref/source/itemprop.cc
parent1cf06be6ea1471d9273a24fb7f95bde6938b7d3c (diff)
downloadcrawl-ref-7eaa6eb283b06be6c1441215e634d4566c99257f.tar.gz
crawl-ref-7eaa6eb283b06be6c1441215e634d4566c99257f.zip
Refactor
Make is_range_weapon and is_ranged_weapon_type use the same code.
Diffstat (limited to 'crawl-ref/source/itemprop.cc')
-rw-r--r--crawl-ref/source/itemprop.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc
index 2a6ea26d81..2657c4b002 100644
--- a/crawl-ref/source/itemprop.cc
+++ b/crawl-ref/source/itemprop.cc
@@ -1434,7 +1434,7 @@ bool is_giant_club_type(int wpn_type)
*/
bool is_ranged_weapon_type(int wpn_type)
{
- return Weapon_prop[wpn_type].dam_type == DAMV_NON_MELEE;
+ return Weapon_prop[Weapon_index[wpn_type]].ammo != MI_NONE;
}
/**
@@ -1473,6 +1473,12 @@ bool is_magic_weapon_type(int wpn_type)
return wpn_type == WPN_STAFF || wpn_type == WPN_ROD;
}
+
+bool is_melee_weapon(const item_def &weapon)
+{
+ return is_weapon(weapon) && !is_range_weapon(weapon);
+}
+
/**
* Is the provided item a demon weapon?
*
@@ -1756,7 +1762,7 @@ missile_type fires_ammo_type(const item_def &item)
bool is_range_weapon(const item_def &item)
{
- return fires_ammo_type(item) != MI_NONE;
+ return is_weapon(item) && is_ranged_weapon_type(item.sub_type);
}
const char *ammo_name(missile_type ammo)
@@ -1820,10 +1826,7 @@ launch_retval is_launched(const actor *actor, const item_def *launcher,
return is_throwable(actor, missile) ? LRET_THROWN : LRET_FUMBLED;
}
-bool is_melee_weapon(const item_def &weapon)
-{
- return is_weapon(weapon) && !is_range_weapon(weapon);
-}
+
//
// Reaching functions: