diff options
author | Neil Moore <neil@s-z.org> | 2012-07-07 18:32:33 -0400 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2012-07-07 18:51:33 -0400 |
commit | 5d609a866ab48ddc5852645ebdae470470fc6c7e (patch) | |
tree | 7c5426d1de4943425f84f5777462f0a19d0d70e3 /crawl-ref/source/teleport.cc | |
parent | e19d01d2b54c118901e342facef0e81cbcad0d1b (diff) | |
download | crawl-ref-5d609a866ab48ddc5852645ebdae470470fc6c7e.tar.gz crawl-ref-5d609a866ab48ddc5852645ebdae470470fc6c7e.zip |
Do not crash when a constricted monster fails to blink.
Also, add messages for this case, and tweak the message when it does
manage to escape by blinking.
Diffstat (limited to 'crawl-ref/source/teleport.cc')
-rw-r--r-- | crawl-ref/source/teleport.cc | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/crawl-ref/source/teleport.cc b/crawl-ref/source/teleport.cc index db6582a585..f4fe422ae9 100644 --- a/crawl-ref/source/teleport.cc +++ b/crawl-ref/source/teleport.cc @@ -57,13 +57,32 @@ bool monster::blink_to(const coord_def& dest, bool quiet) if (dest == pos()) return false; - if (!attempt_escape(2)) - return false; - + bool was_constricted = false; const bool jump = type == MONS_JUMPING_SPIDER; + const std::string verb = (jump ? "leap" : "blink"); + + if (is_constricted()) + { + was_constricted = true; + + if (!attempt_escape(2)) + { + if (!quiet) + { + std::string message = " struggles to " + verb + + " free from constriction."; + simple_monster_message(this, message.c_str()); + } + return false; + } + } if (!quiet) - simple_monster_message(this, jump ? " leaps!" : " blinks!"); + { + std::string message = " " + conj_verb(verb) + + (was_constricted ? " free!" : "!"); + simple_monster_message(this, message.c_str()); + } if (!(flags & MF_WAS_IN_VIEW)) seen_context = SC_TELEPORT_IN; @@ -146,7 +165,7 @@ bool blink_away(monster* mon) if (dest.origin()) return false; bool success = mon->blink_to(dest); - ASSERT(success); + ASSERT(success || mon->is_constricted()); return success; } @@ -160,7 +179,7 @@ void blink_range(monster* mon) if (dest.origin()) return; bool success = mon->blink_to(dest); - ASSERT(success); + ASSERT(success || mon->is_constricted()); #ifndef DEBUG UNUSED(success); #endif @@ -176,7 +195,7 @@ void blink_close(monster* mon) if (dest.origin()) return; bool success = mon->blink_to(dest); - ASSERT(success); + ASSERT(success || mon->is_constricted()); #ifndef DEBUG UNUSED(success); #endif |