From 55d6cdf0e206d34974eaa086ac4a6ed3bde6ef3c Mon Sep 17 00:00:00 2001 From: zelgadis Date: Wed, 7 Jan 2009 09:21:27 +0000 Subject: 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 --- crawl-ref/source/monstuff.cc | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'crawl-ref/source/monstuff.cc') 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. -- cgit v1.2.3-54-g00ecf