diff options
author | Adam Borowski <kilobyte@angband.pl> | 2011-11-19 21:01:34 +0100 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2011-11-19 21:01:34 +0100 |
commit | 5b6b80ccc3ae539ac05cb868fa9d00451299da59 (patch) | |
tree | e514ebd695abb2c90c269b85efbd64ac37db24a0 /crawl-ref/source/mon-speak.cc | |
parent | b63d4227075ae3fb862f26c022360ef384ad4110 (diff) | |
parent | 0534696989ccbd75f8352bef1b464b794cee8389 (diff) | |
download | crawl-ref-5b6b80ccc3ae539ac05cb868fa9d00451299da59.tar.gz crawl-ref-5b6b80ccc3ae539ac05cb868fa9d00451299da59.zip |
Merge branch 'master' into portal_branches
Diffstat (limited to 'crawl-ref/source/mon-speak.cc')
-rw-r--r-- | crawl-ref/source/mon-speak.cc | 52 |
1 files changed, 13 insertions, 39 deletions
diff --git a/crawl-ref/source/mon-speak.cc b/crawl-ref/source/mon-speak.cc index b8003c40f6..6a0a548658 100644 --- a/crawl-ref/source/mon-speak.cc +++ b/crawl-ref/source/mon-speak.cc @@ -838,7 +838,7 @@ bool mons_speaks(monster* mons) } bool mons_speaks_msg(monster* mons, const std::string &msg, - const msg_channel_type def_chan, const bool silence) + const msg_channel_type def_chan, bool silence) { if (!mons_near(mons)) return (false); @@ -864,53 +864,27 @@ bool mons_speaks_msg(monster* mons, const std::string &msg, // [jpeg] Added MSGCH_TALK_VISUAL for silent "chatter". msg_channel_type msg_type = def_chan; - std::string param = ""; - std::string::size_type pos = line.find(":"); - - if (pos != std::string::npos) - param = line.substr(0, pos); - - if (!param.empty()) + if (strip_channel_prefix(line, msg_type, silence)) { - bool match = true; - - if (param == "DANGER") - msg_type = MSGCH_DANGER; - else if (param == "WARN" && !silence || param == "VISUAL WARN") - msg_type = MSGCH_WARN; - else if (param == "SOUND") - msg_type = MSGCH_SOUND; - else if (param == "VISUAL") - msg_type = MSGCH_TALK_VISUAL; - else if (param == "SPELL" && !silence || param == "VISUAL SPELL") - { - msg_type = mons->friendly() ? MSGCH_FRIEND_SPELL - : MSGCH_MONSTER_SPELL; - } - else if (param == "ENCHANT" && !silence - || param == "VISUAL ENCHANT") - { - msg_type = mons->friendly() ? MSGCH_FRIEND_ENCHANT - : MSGCH_MONSTER_ENCHANT; - } - else if (param == "PLAIN") - msg_type = MSGCH_PLAIN; - else - match = false; - - if (match) - line = line.substr(pos + 1); + if (msg_type == MSGCH_MONSTER_SPELL && mons->friendly()) + msg_type = MSGCH_FRIEND_SPELL; + if (msg_type == MSGCH_MONSTER_ENCHANT && mons->friendly()) + msg_type = MSGCH_FRIEND_ENCHANT; + if (line == "") + continue; } const bool old_noticed = noticed; noticed = true; // Only one case is different. // Except for VISUAL, none of the above influence these. - if (line == "__YOU_RESIST" && (!silence || param == "VISUAL")) + if (msg_type == MSGCH_TALK_VISUAL) + silence = false; + if (line == "__YOU_RESIST" && !silence) canned_msg(MSG_YOU_RESIST); - else if (line == "__NOTHING_HAPPENS" && (!silence || param == "VISUAL")) + else if (line == "__NOTHING_HAPPENS" && !silence) canned_msg(MSG_NOTHING_HAPPENS); - else if (line == "__MORE" && (!silence || param == "VISUAL")) + else if (line == "__MORE" && !silence) more(); else if (msg_type == MSGCH_TALK_VISUAL && !you.can_see(mons)) noticed = old_noticed; |