diff options
author | Neil Moore <neil@s-z.org> | 2013-12-01 15:08:40 -0500 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2013-12-01 15:30:12 -0500 |
commit | 6f3e6ea69b53e199ddc582ec6d6ab745cd9285ef (patch) | |
tree | 6f6e0b3406ecaa152a1ebc4a30ea067cf0b4d283 /crawl-ref/source/behold.cc | |
parent | 62c0bb93461756a7ef6574948f2970053acf9812 (diff) | |
download | crawl-ref-6f3e6ea69b53e199ddc582ec6d6ab745cd9285ef.tar.gz crawl-ref-6f3e6ea69b53e199ddc582ec6d6ab745cd9285ef.zip |
Avoid a beholder/fearmonger crash (#6547)
When removing the last beholder or fearmonger, we could print a message
before setting DUR_MESMERISED|AFRAID to zero. If that triggered a
redraw of the status area, the inconsistent state would trigger an
assertion.
Now quietly remove the status before messaging about losing the
beholder.
Diffstat (limited to 'crawl-ref/source/behold.cc')
-rw-r--r-- | crawl-ref/source/behold.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/crawl-ref/source/behold.cc b/crawl-ref/source/behold.cc index bf3db22e2c..403f560aed 100644 --- a/crawl-ref/source/behold.cc +++ b/crawl-ref/source/behold.cc @@ -211,6 +211,11 @@ void player::update_beholders() { beholders.erase(beholders.begin() + i); removed = true; + + // If that was the last one, clear the duration before + // printing any subsequent messages, or a --more-- can + // crash (#6547). + _removed_beholder(true); _removed_beholder_msg(mon); } } @@ -235,14 +240,17 @@ void player::update_beholder(const monster* mon) // Helper function that resets the duration and messages if the player // is no longer mesmerised. -void player::_removed_beholder() +void player::_removed_beholder(bool quiet) { if (beholders.empty()) { duration[DUR_MESMERISED] = 0; - mprf(MSGCH_DURATION, - coinflip() ? "You break out of your daze!" - : "You are no longer entranced."); + if (!quiet) + { + mprf(MSGCH_DURATION, + coinflip() ? "You break out of your daze!" + : "You are no longer entranced."); + } } } |