summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-03 17:08:47 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-03 17:08:47 +0000
commit81af4f86540998fcfe758e757ddb2098ac0733b8 (patch)
treef83b17c8cb3b7d19c47281573d017655aa2c2071 /crawl-ref
parent8a7f4ec404cbbb329622a85c56886749af1b7af4 (diff)
downloadcrawl-ref-81af4f86540998fcfe758e757ddb2098ac0733b8.tar.gz
crawl-ref-81af4f86540998fcfe758e757ddb2098ac0733b8.zip
Fix bad messaging when monsters drop an item which stacks with something
on the floor. Fixes [2514315]. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8881 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/mon-util.cc26
1 files changed, 15 insertions, 11 deletions
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 8597846cc1..a80d4affca 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -4376,7 +4376,7 @@ bool monsters::drop_item(int eslot, int near)
if (item_index == NON_ITEM)
return (true);
- item_def &item(mitm[item_index]);
+ item_def* pitem = &mitm[item_index];
// Unequip equipped items before dropping them; unequip() prevents
// cursed items from being removed.
@@ -4384,44 +4384,48 @@ bool monsters::drop_item(int eslot, int near)
if (eslot == MSLOT_WEAPON || eslot == MSLOT_ARMOUR
|| eslot == MSLOT_ALT_WEAPON && mons_wields_two_weapons(this))
{
- if (!unequip(item, eslot, near))
+ if (!unequip(*pitem, eslot, near))
return (false);
was_unequipped = true;
}
bool on_floor = true;
- if (item.flags & ISFLAG_SUMMONED)
+ if (pitem->flags & ISFLAG_SUMMONED)
{
on_floor = false;
if (need_message(near))
mprf("%s %s as %s drops %s!",
- item.name(DESC_CAP_THE).c_str(),
- summoned_poof_msg(this, item).c_str(),
+ pitem->name(DESC_CAP_THE).c_str(),
+ summoned_poof_msg(this, *pitem).c_str(),
name(DESC_NOCAP_THE).c_str(),
- item.quantity > 1 ? "them" : "it");
+ pitem->quantity > 1 ? "them" : "it");
- item_was_destroyed(item, mindex());
+ item_was_destroyed(*pitem, mindex());
destroy_item(item_index);
}
else if (!move_item_to_grid(&item_index, pos()))
{
// Re-equip item if we somehow failed to drop it.
if (was_unequipped)
- equip(item, eslot, near);
+ equip(*pitem, eslot, near);
return (false);
}
+ // move_item_to_grid could change item_index, so
+ // update pitem.
+ pitem = &mitm[item_index];
+
if (on_floor)
{
if (mons_friendly(this))
- item.flags |= ISFLAG_DROPPED_BY_ALLY;
+ pitem->flags |= ISFLAG_DROPPED_BY_ALLY;
if (need_message(near))
mprf("%s drops %s.", name(DESC_CAP_THE).c_str(),
- item.name(DESC_NOCAP_A).c_str());
+ pitem->name(DESC_NOCAP_A).c_str());
dungeon_feature_type feat = grd(pos());
if (grid_destroys_items(feat))
@@ -4429,7 +4433,7 @@ bool monsters::drop_item(int eslot, int near)
if ( player_can_hear(pos()) )
mprf(MSGCH_SOUND, grid_item_destruction_message(feat));
- item_was_destroyed(item, mindex());
+ item_was_destroyed(*pitem, mindex());
unlink_item(item_index);
}
}