From 6f8d0892a2798b0792471a6ee1d5f57ddee0b9d3 Mon Sep 17 00:00:00 2001 From: Benau Date: Mon, 6 May 2019 16:41:29 +0800 Subject: [PATCH] Fix sign of time with mono clock --- src/network/servers_manager.cpp | 6 +++--- src/network/servers_manager.hpp | 4 ++-- src/network/stk_host.cpp | 2 +- src/network/stk_host.hpp | 7 +++++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/network/servers_manager.cpp b/src/network/servers_manager.cpp index 2e21e8648..a354207a0 100644 --- a/src/network/servers_manager.cpp +++ b/src/network/servers_manager.cpp @@ -41,7 +41,7 @@ # include #endif -const uint64_t SERVER_REFRESH_INTERVAL = 5000; +const int64_t SERVER_REFRESH_INTERVAL = 5000; static ServersManager* g_manager_singleton(NULL); @@ -246,7 +246,7 @@ void ServersManager::setLanServers(const std::mapisWAN()) { Online::RequestManager::get()->addRequest(getWANRefreshRequest()); diff --git a/src/network/servers_manager.hpp b/src/network/servers_manager.hpp index b1b3ea3fd..b3c932532 100644 --- a/src/network/servers_manager.hpp +++ b/src/network/servers_manager.hpp @@ -45,7 +45,7 @@ private: /** List of broadcast addresses to use. */ std::vector m_broadcast_address; - std::atomic m_last_load_time; + std::atomic m_last_load_time; std::atomic_bool m_list_updated; // ------------------------------------------------------------------------ @@ -84,7 +84,7 @@ public: // ------------------------------------------------------------------------ void reset() { - m_last_load_time.store(0); + m_last_load_time.store(-5000); m_list_updated = false; } }; // class ServersManager diff --git a/src/network/stk_host.cpp b/src/network/stk_host.cpp index e3055bd8c..d8bc16aca 100644 --- a/src/network/stk_host.cpp +++ b/src/network/stk_host.cpp @@ -297,7 +297,7 @@ void STKHost::init() m_players_in_game.store(0); m_players_waiting.store(0); m_total_players.store(0); - m_network_timer.store(StkTime::getMonoTimeMs()); + m_network_timer.store((int64_t)StkTime::getMonoTimeMs()); m_shutdown = false; m_authorised = false; m_network = NULL; diff --git a/src/network/stk_host.hpp b/src/network/stk_host.hpp index 7d5df62ac..a0908c50d 100644 --- a/src/network/stk_host.hpp +++ b/src/network/stk_host.hpp @@ -151,7 +151,7 @@ private: std::atomic m_total_players; - std::atomic m_network_timer; + std::atomic m_network_timer; std::unique_ptr m_nts; @@ -351,7 +351,10 @@ public: { return StkTime::getMonoTimeMs() - m_network_timer.load(); } // ------------------------------------------------------------------------ void setNetworkTimer(uint64_t ticks) - { m_network_timer.store(StkTime::getMonoTimeMs() - ticks); } + { + m_network_timer.store( + (int64_t)StkTime::getMonoTimeMs() - (int64_t)ticks); + } // ------------------------------------------------------------------------ std::pair getAllPlayersTeamInfo() const; // ------------------------------------------------------------------------