From 53c0cf27ad353e288db928c911de1b3425131894 Mon Sep 17 00:00:00 2001 From: dolorous Date: Mon, 16 Jun 2008 16:04:57 +0000 Subject: Make animate_a_corpse() and animate_dead() use the new stack_iterator class. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5881 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/spells3.cc | 52 +++++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 33 deletions(-) (limited to 'crawl-ref/source/spells3.cc') diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index 14bd949813..94ee3c6755 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -876,20 +876,17 @@ bool animate_a_corpse(int x, int y, corpse_type class_allowed, { bool success = false; - int corps = igrd[x][y]; - - // This searches all the items on the ground for a corpse. - while (corps != NON_ITEM) + // Search all the items on the ground for a corpse. + for (stack_iterator si(igrd[x][y]); si; ++si) { - const item_def& item = mitm[corps]; - - if (_is_animatable_corpse(item) + if (_is_animatable_corpse(*si) && (class_allowed == CORPSE_BODY - || item.sub_type == CORPSE_SKELETON)) + || si->sub_type == CORPSE_SKELETON)) { - const bool was_butchering = is_being_butchered(item); + const bool was_butchering = is_being_butchered(*si); - success = _raise_corpse(x, y, corps, beha, hitting, god, actual); + success = _raise_corpse(x, y, si.link(), beha, hitting, god, + actual); if (actual && success) { @@ -907,8 +904,6 @@ bool animate_a_corpse(int x, int y, corpse_type class_allowed, } break; } - - corps = item.link; } return (success); @@ -963,31 +958,22 @@ int animate_dead(actor *caster, int pow, beh_type beha, unsigned short hitting, if (!in_bounds(a) || !see_grid(los, c, a)) continue; - int corps = igrd(a); - - if (corps != NON_ITEM) + // Search all the items on the ground for a corpse. Only + // one of a stack will be raised. + for (stack_iterator si(a); si; ++si) { - // This searches all the items on the ground for a - // corpse. Only one of a stack will be raised. - while (corps != NON_ITEM) - { - const item_def& item = mitm[corps]; - - if (is_being_butchered(item, false)) - was_butchering = true; + if (is_being_butchered(*si, false)) + was_butchering = true; - if (animate_a_corpse(a.x, a.y, CORPSE_BODY, beha, - hitting, god, actual, true)) - { - number_raised++; + if (animate_a_corpse(a.x, a.y, CORPSE_BODY, beha, + hitting, god, actual, true)) + { + number_raised++; - if (see_grid(env.show, you.pos(), a)) - number_seen++; + if (see_grid(env.show, you.pos(), a)) + number_seen++; - break; - } - - corps = item.link; + break; } } } -- cgit v1.2.3-54-g00ecf