summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/fineff.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2012-10-16 12:00:20 +0200
committerAdam Borowski <kilobyte@angband.pl>2012-10-16 23:59:13 +0200
commit2ee5dd9bf5074d0a33e969f6e71310d33f339d58 (patch)
tree123e5407aab5526b7453274930709b87d7b8f691 /crawl-ref/source/fineff.cc
parente6c5af89b6be5e5d53cae6256d8b2356028f8423 (diff)
downloadcrawl-ref-2ee5dd9bf5074d0a33e969f6e71310d33f339d58.tar.gz
crawl-ref-2ee5dd9bf5074d0a33e969f6e71310d33f339d58.zip
Properly handle new final effects that spawn when previoud ones fire.
If one would merge with an existing one, the extra would be ignored.
Diffstat (limited to 'crawl-ref/source/fineff.cc')
-rw-r--r--crawl-ref/source/fineff.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/crawl-ref/source/fineff.cc b/crawl-ref/source/fineff.cc
index 3692af70c4..28796bdaf9 100644
--- a/crawl-ref/source/fineff.cc
+++ b/crawl-ref/source/fineff.cc
@@ -240,13 +240,14 @@ void blood_fineff::fire()
// to deal with only one creature at a time, so that's handled last.
void fire_final_effects()
{
- for (unsigned int i = 0; i < env.final_effects.size(); ++i)
- env.final_effects[i]->fire();
-
- // Delete the allocated final_effects in a separate pass; otherwise,
- // if one fineff schedules another, we would dereference a deleted object
- // when checking mergeability in final_effect::schedule().
- for (unsigned int i = 0; i < env.final_effects.size(); ++i)
- delete env.final_effects[i];
- env.final_effects.clear();
+ while (!env.final_effects.empty())
+ {
+ // Remove it first so nothing can merge with it.
+ final_effect *eff = env.final_effects.back();
+ env.final_effects.pop_back();
+
+ eff->fire();
+
+ delete eff;
+ }
}