summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/message.cc
diff options
context:
space:
mode:
Diffstat (limited to 'crawl-ref/source/message.cc')
-rw-r--r--crawl-ref/source/message.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc
index 7bda843e10..30f4f8f341 100644
--- a/crawl-ref/source/message.cc
+++ b/crawl-ref/source/message.cc
@@ -1010,7 +1010,15 @@ std::string get_last_messages(int mcount)
bool full_buffer = (Store_Message[NUM_STORED_MESSAGES - 1].text.empty());
int initial = Next_Message - mcount;
if (initial < 0 || initial > NUM_STORED_MESSAGES)
- initial = full_buffer ? initial + NUM_STORED_MESSAGES : 0;
+ {
+ if (full_buffer)
+ {
+ initial = (initial + NUM_STORED_MESSAGES) % NUM_STORED_MESSAGES;
+ initial++;
+ }
+ else
+ initial = 0;
+ }
std::string text;
int count = 0;