From 3e7c799cf444d6891139555291d0bb5d730d104e Mon Sep 17 00:00:00 2001 From: zelgadis Date: Sun, 8 Jun 2008 03:19:47 +0000 Subject: Added option msg_condense_repeats (defaults to true) which causes message history to condense repeated messages into a single line, so that (for example) if you hear a Zot trap go off five times in a row while resting, message history will show: You hear a distant "Zot!" (x5) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5575 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/message.cc | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'crawl-ref/source/message.cc') diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc index 479899d853..159af003eb 100644 --- a/crawl-ref/source/message.cc +++ b/crawl-ref/source/message.cc @@ -577,6 +577,25 @@ static void mpr_store_messages(const std::string& message, { const int num_lines = crawl_view.msgsz.y; + bool was_repeat = false; + + if (Options.msg_condense_repeats) + { + int prev_message_num = Next_Message - 1; + + if (prev_message_num < 0) + prev_message_num = NUM_STORED_MESSAGES - 1; + + message_item &prev_message = Store_Message[prev_message_num]; + + if (prev_message.repeats > 0 && prev_message.channel == channel + && prev_message.param == param && prev_message.text == message) + { + prev_message.repeats++; + was_repeat = true; + } + } + // Prompt lines are presumably shown to / seen by the player accompanied // by a request for input, which should do the equivalent of a more(); to // save annoyance, don't bump New_Message_Count for prompts. @@ -590,12 +609,13 @@ static void mpr_store_messages(const std::string& message, textcolor(LIGHTGREY); // Equipment lists just waste space in the message recall. - if (channel_message_history(channel)) + if (!was_repeat && channel_message_history(channel)) { // Put the message into Store_Message, and move the '---' line forward Store_Message[ Next_Message ].text = message; Store_Message[ Next_Message ].channel = channel; Store_Message[ Next_Message ].param = param; + Store_Message[ Next_Message ].repeats = 1; Next_Message++; if (Next_Message >= NUM_STORED_MESSAGES) @@ -989,8 +1009,10 @@ void replay_messages(void) break; } } - cprintf(EOL); textcolor(LIGHTGREY); + if (Store_Message[ line ].repeats > 1) + cprintf(" (x%d)", Store_Message[ line ].repeats); + cprintf(EOL); } // print a footer -- note: relative co-ordinates start at 1 -- cgit v1.2.3-54-g00ecf