diff --git a/src/chat.cpp b/src/chat.cpp index c62471e194..a69af36864 100644 --- a/src/chat.cpp +++ b/src/chat.cpp @@ -31,7 +31,7 @@ ChatBuffer::ChatBuffer(u32 scrollback): } } -void ChatBuffer::addLine(const std::wstring &name, const std::wstring &text) +void ChatBuffer::addLine(const EnrichedString &name, const EnrichedString &text) { m_lines_modified = true; @@ -774,13 +774,15 @@ ChatBackend::ChatBackend(): void ChatBackend::addMessage(const std::wstring &name, std::wstring text) { // Note: A message may consist of multiple lines, for example the MOTD. - text = translate_string(text); - WStrfnd fnd(text); - while (!fnd.at_end()) - { - std::wstring line = fnd.next(L"\n"); - m_console_buffer.addLine(name, line); - m_recent_buffer.addLine(name, line); + EnrichedString ename(name); + EnrichedString etext(text); + + size_t str_pos = 0; + while (str_pos < etext.size()) { + EnrichedString line = etext.getNextLine(&str_pos); + + m_console_buffer.addLine(ename, line); + m_recent_buffer.addLine(ename, line); } } diff --git a/src/chat.h b/src/chat.h index 87a348a4ad..38e32c1e06 100644 --- a/src/chat.h +++ b/src/chat.h @@ -64,7 +64,7 @@ public: // Append chat line // Removes oldest chat line if scrollback size is reached - void addLine(const std::wstring &name, const std::wstring &text); + void addLine(const EnrichedString &name, const EnrichedString &text); // Remove all chat lines void clear();