Fix sign of time with mono clock

This commit is contained in:
Benau 2019-05-06 16:41:29 +08:00
parent ebf95ee958
commit 6f8d0892a2
4 changed files with 11 additions and 8 deletions

View File

@ -41,7 +41,7 @@
# include <ifaddrs.h>
#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::map<irr::core::stringw,
*/
bool ServersManager::refresh(bool full_refresh)
{
if (StkTime::getMonoTimeMs() - m_last_load_time.load()
if ((int64_t)StkTime::getMonoTimeMs() - m_last_load_time.load()
< SERVER_REFRESH_INTERVAL)
{
// Avoid too frequent refreshing

View File

@ -45,7 +45,7 @@ private:
/** List of broadcast addresses to use. */
std::vector<TransportAddress> m_broadcast_address;
std::atomic<uint64_t> m_last_load_time;
std::atomic<int64_t> 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

View File

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

View File

@ -151,7 +151,7 @@ private:
std::atomic<uint32_t> m_total_players;
std::atomic<uint64_t> m_network_timer;
std::atomic<int64_t> m_network_timer;
std::unique_ptr<NetworkTimerSynchronizer> 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<int, int> getAllPlayersTeamInfo() const;
// ------------------------------------------------------------------------