summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/monster.cc
diff options
context:
space:
mode:
authorStefan O'Rear <stefanor@cox.net>2009-12-29 22:43:19 -0800
committerStefan O'Rear <stefanor@cox.net>2009-12-29 22:44:54 -0800
commit8a504d20b9992fea2daac06faa6ca5559ca63ae0 (patch)
tree2e809b12b5e1020ebe4ee3237025081d5cd22816 /crawl-ref/source/monster.cc
parent75c0968931bf47f6f718b91ce3f589cd9f815298 (diff)
downloadcrawl-ref-8a504d20b9992fea2daac06faa6ca5559ca63ae0.tar.gz
crawl-ref-8a504d20b9992fea2daac06faa6ca5559ca63ae0.zip
Give move/copy_item_to_grid responsibility for hazardous terrain
We now have much less duplication of logic, yay.
Diffstat (limited to 'crawl-ref/source/monster.cc')
-rw-r--r--crawl-ref/source/monster.cc42
1 files changed, 15 insertions, 27 deletions
diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc
index 2f83c01d6f..de3af6b0a9 100644
--- a/crawl-ref/source/monster.cc
+++ b/crawl-ref/source/monster.cc
@@ -1154,12 +1154,8 @@ bool monsters::drop_item(int eslot, int near)
was_unequipped = true;
}
- bool on_floor = true;
-
if (pitem->flags & ISFLAG_SUMMONED)
{
- on_floor = false;
-
if (need_message(near))
mprf("%s %s as %s drops %s!",
pitem->name(DESC_CAP_THE).c_str(),
@@ -1170,38 +1166,30 @@ bool monsters::drop_item(int eslot, int near)
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(*pitem, eslot, near);
-
- return (false);
- }
-
- // move_item_to_grid could change item_index, so
- // update pitem.
- pitem = &mitm[item_index];
-
- if (on_floor)
+ else
{
- if (friendly())
- pitem->flags |= ISFLAG_DROPPED_BY_ALLY;
-
if (need_message(near))
{
mprf("%s drops %s.", name(DESC_CAP_THE).c_str(),
pitem->name(DESC_NOCAP_A).c_str());
}
- dungeon_feature_type feat = grd(pos());
- if (feat_destroys_items(feat))
+ if (!move_item_to_grid(&item_index, pos()))
{
- if ( player_can_hear(pos()) )
- mprf(MSGCH_SOUND, feat_item_destruction_message(feat));
+ // Re-equip item if we somehow failed to drop it.
+ if (was_unequipped)
+ equip(*pitem, eslot, near);
- item_was_destroyed(*pitem, mindex());
- unlink_item(item_index);
+ return (false);
+ }
+
+ if (friendly() && item_index != NON_ITEM)
+ {
+ // move_item_to_grid could change item_index, so
+ // update pitem.
+ pitem = &mitm[item_index];
+
+ pitem->flags |= ISFLAG_DROPPED_BY_ALLY;
}
}