diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-11-22 03:48:27 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-11-22 03:48:27 +0000 |
commit | f119c29736878ef93deed692013d3c974831b038 (patch) | |
tree | a977f1bbd15465bbfeeed866dfc3b83078a0792a /crawl-ref/source/items.cc | |
parent | 21243c536b155025edacec7fb43b563c724cbd0a (diff) | |
download | crawl-ref-f119c29736878ef93deed692013d3c974831b038.tar.gz crawl-ref-f119c29736878ef93deed692013d3c974831b038.zip |
Fix bug 2298697: for dealing with weapons of returning which fail to return,
mons_throw() should have been using the mslot of the weapon, not weapon's
mitm index.
Introduces the new functions get_mon_equip_slot() and item_to_mslot().
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7530 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/items.cc')
-rw-r--r-- | crawl-ref/source/items.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 1675ec0c9b..498722a4a4 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -2019,6 +2019,24 @@ int get_equip_slot(const item_def *item) return worn; } +mon_inv_type get_mon_equip_slot(const monsters* mon, const item_def &item) +{ + ASSERT(mon->alive()); + + mon_inv_type slot = item_to_mslot(item); + + if (slot == NUM_MONSTER_SLOTS) + return NUM_MONSTER_SLOTS; + + if (mon->mslot_item(slot) == &item) + return slot; + + if (slot == MSLOT_WEAPON && mon->mslot_item(MSLOT_ALT_WEAPON) == &item) + return MSLOT_ALT_WEAPON; + + return NUM_MONSTER_SLOTS; +} + static std::string _drop_selitem_text( const std::vector<MenuEntry*> *s ) { char buf[130]; |