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
This commit is contained in:
Christian Murphy 2017-02-20 00:11:03 +00:00 committed by Ted John
parent 6eb14aa90d
commit eab0dc7cdb
1 changed files with 6 additions and 1 deletions

View File

@ -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;
}