summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spells3.cc
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-16 16:04:57 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-16 16:04:57 +0000
commit53c0cf27ad353e288db928c911de1b3425131894 (patch)
tree159fad6203355309be7cc219eec48803b6c84773 /crawl-ref/source/spells3.cc
parent42acab0b7d5738062a3d4efc83002d9ad890381f (diff)
downloadcrawl-ref-53c0cf27ad353e288db928c911de1b3425131894.tar.gz
crawl-ref-53c0cf27ad353e288db928c911de1b3425131894.zip
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
Diffstat (limited to 'crawl-ref/source/spells3.cc')
-rw-r--r--crawl-ref/source/spells3.cc52
1 files changed, 19 insertions, 33 deletions
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;
}
}
}