From eab0dc7cdbfca7f1610aa2063dfc691553f41ad6 Mon Sep 17 00:00:00 2001 From: Christian Murphy Date: Mon, 20 Feb 2017 00:11:03 +0000 Subject: [PATCH] Add timestamps to chat messages Squashed commit from: - a908a4c Added config parameter "timestamp_chat" to network config section to allow chat messages to be timestamped - 820fcd7 make timestamps on by default - e6ecad2 timestamp chat messages, removed config option - 3b4439d Replace strftime temp buffer with directly using strftime into lineCh - add20d3 Move time --- src/openrct2/network/network.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/openrct2/network/network.cpp b/src/openrct2/network/network.cpp index bb98b15f3f..7d2791c642 100644 --- a/src/openrct2/network/network.cpp +++ b/src/openrct2/network/network.cpp @@ -574,9 +574,13 @@ const char* Network::FormatChat(NetworkPlayer* fromplayer, const char* text) char* lineCh = formatted; formatted[0] = 0; if (fromplayer) { + time_t timer; + time(&timer); + auto tmInfo = localtime(&timer); lineCh = utf8_write_codepoint(lineCh, FORMAT_OUTLINE); lineCh = utf8_write_codepoint(lineCh, FORMAT_BABYBLUE); - safe_strcpy(lineCh, (const char *) fromplayer->Name.c_str(), sizeof(formatted) - (lineCh - formatted)); + lineCh += strftime(lineCh, sizeof(formatted) - (lineCh - formatted), "[%H:%M] ", tmInfo); + safe_strcat(lineCh, (const char *) fromplayer->Name.c_str(), sizeof(formatted) - (lineCh - formatted)); safe_strcat(lineCh, ": ", sizeof(formatted) - (lineCh - formatted)); lineCh = strchr(lineCh, '\0'); } @@ -584,6 +588,7 @@ const char* Network::FormatChat(NetworkPlayer* fromplayer, const char* text) lineCh = utf8_write_codepoint(lineCh, FORMAT_WHITE); char* ptrtext = lineCh; safe_strcpy(lineCh, text, 800); + utf8_remove_format_codes((utf8*)ptrtext, true); return formatted; }