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_admin.cpp | |
parent | dc7ba33b515c83ec0ebd9cb1789fd20294dee4ec (diff) | |
download | openttd-53c28a8ec9845a90f0c9e1ed83a87dbb7959d14d.tar.xz |
Codechange: [Network] replace _realtime_tick with std::chrono
Diffstat (limited to 'src/network/network_admin.cpp')
-rw-r--r-- | src/network/network_admin.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/network/network_admin.cpp b/src/network/network_admin.cpp index 20bd25f8f..aa2859ef8 100644 --- a/src/network/network_admin.cpp +++ b/src/network/network_admin.cpp @@ -37,7 +37,7 @@ NetworkAdminSocketPool _networkadminsocket_pool("NetworkAdminSocket"); INSTANTIATE_POOL_METHODS(NetworkAdminSocket) /** The timeout for authorisation of the client. */ -static const int ADMIN_AUTHORISATION_TIMEOUT = 10000; +static const std::chrono::seconds ADMIN_AUTHORISATION_TIMEOUT(10); /** Frequencies, which may be registered for a certain update type. */ @@ -64,7 +64,7 @@ ServerNetworkAdminSocketHandler::ServerNetworkAdminSocketHandler(SOCKET s) : Net { _network_admins_connected++; this->status = ADMIN_STATUS_INACTIVE; - this->realtime_connect = _realtime_tick; + this->connect_time = std::chrono::steady_clock::now(); } /** @@ -95,8 +95,8 @@ ServerNetworkAdminSocketHandler::~ServerNetworkAdminSocketHandler() /* static */ void ServerNetworkAdminSocketHandler::Send() { for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::Iterate()) { - if (as->status == ADMIN_STATUS_INACTIVE && as->realtime_connect + ADMIN_AUTHORISATION_TIMEOUT < _realtime_tick) { - DEBUG(net, 1, "[admin] Admin did not send its authorisation within %d seconds", ADMIN_AUTHORISATION_TIMEOUT / 1000); + if (as->status == ADMIN_STATUS_INACTIVE && std::chrono::steady_clock::now() > as->connect_time + ADMIN_AUTHORISATION_TIMEOUT) { + DEBUG(net, 1, "[admin] Admin did not send its authorisation within %d seconds", (uint32)std::chrono::duration_cast<std::chrono::seconds>(ADMIN_AUTHORISATION_TIMEOUT).count()); as->CloseConnection(true); continue; } |