From e07f8e3787ae9a76d3914063daf9a1ea19a5d471 Mon Sep 17 00:00:00 2001 From: Chris Beck Date: Mon, 14 Jul 2014 12:14:37 -0400 Subject: [PATCH] fixup chat history synopsis system It was truncating all of the history because of some unexpected behavior with find and npos. --- src/game_display.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/game_display.cpp b/src/game_display.cpp index 704ea995405b..4704dc250f13 100644 --- a/src/game_display.cpp +++ b/src/game_display.cpp @@ -924,9 +924,14 @@ void game_display::send_notification(const std::string& /*owner*/, const std::st if (i != i_end) { i->message = message + "\n" + i->message; - int endl_pos = -1; - for (int ctr = 0; ctr < 5; ctr++) + + size_t endl_pos = i->message.find('\n'); + size_t ctr = 1; + + while(ctr < 5 && endl_pos != std::string::npos) { endl_pos = i->message.find('\n', endl_pos+1); + ctr++; + } i->message = i->message.substr(0,endl_pos);