From e9a58044e36966a261704a21681e1240f985ea45 Mon Sep 17 00:00:00 2001 From: dolorous Date: Mon, 1 Jun 2009 17:58:23 +0000 Subject: Fix [2794986]: Special damage descriptions weren't being displayed for weapons with multiple damage types. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9876 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/itemprop.cc | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'crawl-ref/source/itemprop.cc') diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc index 1cf82700c3..387fd72b18 100644 --- a/crawl-ref/source/itemprop.cc +++ b/crawl-ref/source/itemprop.cc @@ -1537,31 +1537,51 @@ int weapon_rarity( int w_type ) return (0); } -int get_vorpal_type( const item_def &item ) +int get_vorpal_type(const item_def &item) { int ret = DVORP_NONE; if (item.base_type == OBJ_WEAPONS) - ret = (Weapon_prop[ Weapon_index[item.sub_type] ].dam_type & DAMV_MASK); + ret = (Weapon_prop[Weapon_index[item.sub_type]].dam_type & DAMV_MASK); return (ret); } -int get_damage_type( const item_def &item ) +int get_damage_type(const item_def &item) { int ret = DAM_BASH; if (item.base_type == OBJ_WEAPONS) - ret = (Weapon_prop[ Weapon_index[item.sub_type] ].dam_type & DAM_MASK); + ret = (Weapon_prop[Weapon_index[item.sub_type]].dam_type & DAM_MASK); return (ret); } -bool does_damage_type( const item_def &item, int dam_type ) +bool does_damage_type(const item_def &item, int dam_type) { - return (get_damage_type( item ) & dam_type); + return (get_damage_type(item) & dam_type); } +int single_damage_type(const item_def &item) +{ + int ret = get_damage_type(item); + + if (ret > 0) + { + int count = 0; + + for (int i = 1; i <= DAM_MAX_TYPE; i <<= 1) + { + if (!does_damage_type(item, i)) + continue; + + if (one_chance_in(++count)) + ret = i; + } + } + + return (ret); +} hands_reqd_type hands_reqd(object_class_type base_type, int sub_type, size_type size) -- cgit v1.2.3-54-g00ecf