summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/monstuff.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-07 09:21:27 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-07 09:21:27 +0000
commit55d6cdf0e206d34974eaa086ac4a6ed3bde6ef3c (patch)
treeb7a33d056fe0dbd3bce287fb660a79584c0d9560 /crawl-ref/source/monstuff.cc
parent4eaf99959d1a57bc95b7f8acc046e9c5af7fa6b9 (diff)
downloadcrawl-ref-55d6cdf0e206d34974eaa086ac4a6ed3bde6ef3c.tar.gz
crawl-ref-55d6cdf0e206d34974eaa086ac4a6ed3bde6ef3c.zip
When MF_HARD_RESET monsters die/reset/etc, destroy the items they hold so they
don't hang around cluttering up mitm[] Don't set the values of a cell from mitm[] unless it's sure to be used; using it as a scratch object or partially setting it up and then bailing clutters up mitm[] with valid but unused items, preventing those slots from being used. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8295 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/monstuff.cc')
-rw-r--r--crawl-ref/source/monstuff.cc31
1 files changed, 24 insertions, 7 deletions
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 6eeea59214..633e517986 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -366,11 +366,8 @@ int fill_out_corpse(const monsters* monster, item_def& corpse,
static void _place_monster_corpse(const monsters *monster, bool silent)
{
- int o = get_item_slot();
- if (o == NON_ITEM)
- return;
-
- const int corpse_class = fill_out_corpse(monster, mitm[o]);
+ item_def corpse;
+ const int corpse_class = fill_out_corpse(monster, corpse);
// Don't place a corpse? If a zombified monster is somehow capable
// of leaving a corpse then always place it.
@@ -380,10 +377,15 @@ static void _place_monster_corpse(const monsters *monster, bool silent)
if (grid_destroys_items(grd(monster->pos())))
{
- item_was_destroyed(mitm[o]);
- mitm[o].base_type = OBJ_UNASSIGNED;
+ item_was_destroyed(corpse);
return;
}
+
+ int o = get_item_slot();
+ if (o == NON_ITEM)
+ return;
+ mitm[o] = corpse;
+
origin_set_monster(mitm[o], monster);
// Don't care if 'o' is changed, and it shouldn't be (corpses don't stack).
@@ -1632,6 +1634,21 @@ void monster_die(monsters *monster, killer_type killer,
const coord_def mwhere = monster->pos();
if (drop_items)
monster_drop_ething(monster, YOU_KILL(killer) || pet_kill);
+ else
+ {
+ // Destroy the items belonging to MF_HARD_RESET monsters so they
+ // don't clutter up mitm[]
+ for (int i = 0; i < NUM_MONSTER_SLOTS; i++)
+ {
+ int item = monster->inv[i];
+
+ if (item != NON_ITEM)
+ {
+ destroy_item(item);
+ monster->inv[i] = NON_ITEM;
+ }
+ }
+ }
monster_cleanup(monster);
// Force redraw for monsters that die.