diff options
author | Adam Borowski <kilobyte@angband.pl> | 2011-11-11 19:52:53 +0100 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2011-11-11 20:23:29 +0100 |
commit | e6ed42f4c8cfce3e881bdda511e040563a88e320 (patch) | |
tree | 0ecbf5b1bfa7d58b4432eaa4769a141229efd0d1 /crawl-ref/source/mon-speak.cc | |
parent | bb81648a5f5d433d4465aeaca525c0eaa18e5b5e (diff) | |
download | crawl-ref-e6ed42f4c8cfce3e881bdda511e040563a88e320.tar.gz crawl-ref-e6ed42f4c8cfce3e881bdda511e040563a88e320.zip |
Let CHANNEL: prefixes use all types in both current uses.
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 9a823e8d12..48ad0aa626 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; |