summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-04-28 10:41:00 +0000
committertruelight <truelight@openttd.org>2007-04-28 10:41:00 +0000
commit0ac14b39afe239c0a9166247dca15033fdc0d024 (patch)
tree8002e297e6c4c3c50999d275f2ff3336e7f489b9 /src
parent1d05573950887ecaad8c586f512571d112dd1fd8 (diff)
downloadopenttd-0ac14b39afe239c0a9166247dca15033fdc0d024.tar.xz
(svn r9731) -Fix [FS#677]: in news history, newlines weren't replaced with spaces, making it look ugly from time to time
Diffstat (limited to 'src')
-rw-r--r--src/news_gui.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index 0bfb21b4c..bf9d13daf 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -620,15 +620,21 @@ static void DrawNewsString(int x, int y, uint16 color, const NewsItem *ni, uint
* from it such as big fonts, etc. */
ptr = buffer;
dest = buffer2;
+ WChar c_last = '\0';
for (;;) {
WChar c = Utf8Consume(&ptr);
if (c == 0) break;
- if (c == '\r') {
+ /* Make a space from a newline, but ignore multiple newlines */
+ if (c == '\n' && c_last != '\n') {
+ dest[0] = ' ';
+ dest++;
+ } else if (c == '\r') {
dest[0] = dest[1] = dest[2] = dest[3] = ' ';
dest += 4;
} else if (IsPrintable(c)) {
dest += Utf8Encode(dest, c);
}
+ c_last = c;
}
*dest = '\0';