diff options
author | Patric Stout <truebrain@openttd.org> | 2021-02-25 20:30:16 +0100 |
---|---|---|
committer | Patric Stout <github@truebrain.nl> | 2021-02-27 00:36:14 +0100 |
commit | 53c28a8ec9845a90f0c9e1ed83a87dbb7959d14d (patch) | |
tree | ec8b01761fd3c819d4e1317c86e7da37070b1152 /src/network/network_chat_gui.cpp | |
parent | dc7ba33b515c83ec0ebd9cb1789fd20294dee4ec (diff) | |
download | openttd-53c28a8ec9845a90f0c9e1ed83a87dbb7959d14d.tar.xz |
Codechange: [Network] replace _realtime_tick with std::chrono
Diffstat (limited to 'src/network/network_chat_gui.cpp')
-rw-r--r-- | src/network/network_chat_gui.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index 83824e126..80a0b7869 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -40,7 +40,7 @@ static const uint NETWORK_CHAT_LINE_SPACING = 3; struct ChatMessage { char message[DRAW_STRING_BUFFER]; ///< The action message. TextColour colour; ///< The colour of the message. - uint32 remove_time; ///< The time to remove the message. + std::chrono::steady_clock::time_point remove_time; ///< The time to remove the message. }; /* used for chat window */ @@ -97,7 +97,7 @@ void CDECL NetworkAddChatMessage(TextColour colour, uint duration, const char *m ChatMessage *cmsg = &_chatmsg_list[msg_count++]; strecpy(cmsg->message, buf, lastof(cmsg->message)); cmsg->colour = (colour & TC_IS_PALETTE_COLOUR) ? colour : TC_WHITE; - cmsg->remove_time = _realtime_tick + duration * 1000; + cmsg->remove_time = std::chrono::steady_clock::now() + std::chrono::seconds(duration); _chatmessage_dirty = true; } @@ -180,7 +180,7 @@ void NetworkChatMessageLoop() if (cmsg->message[0] == '\0') continue; /* Message has expired, remove from the list */ - if (cmsg->remove_time < _realtime_tick) { + if (std::chrono::steady_clock::now() > cmsg->remove_time) { /* Move the remaining messages over the current message */ if (i != MAX_CHAT_MESSAGES - 1) memmove(cmsg, cmsg + 1, sizeof(*cmsg) * (MAX_CHAT_MESSAGES - i - 1)); |