Don't show timer warning if voting timeout is not default

This commit is contained in:
Benau 2018-08-27 13:49:52 +08:00
parent 0f39add432
commit 732fd7a4c9
3 changed files with 13 additions and 6 deletions

View File

@ -216,11 +216,14 @@ void ClientLobby::addAllPlayers(Event* event)
// time
if (!STKHost::get()->getNetworkTimerSynchronizer()->isSynchronised())
{
core::stringw msg = _("Bad network connection is detected.");
MessageQueue::add(MessageQueue::MT_ERROR, msg);
Log::warn("ClientLobby", "Failed to synchronize timer before game "
"start, maybe you enter the game too quick? (at least 5 seconds "
"are required for synchronization.");
if (UserConfigParams::m_voting_timeout >= 10.0f)
{
core::stringw msg = _("Bad network connection is detected.");
MessageQueue::add(MessageQueue::MT_ERROR, msg);
Log::warn("ClientLobby", "Failed to synchronize timer before game "
"start, maybe you enter the game too quick? (at least 5 "
"seconds are required for synchronization.");
}
STKHost::get()->getNetworkTimerSynchronizer()->enableForceSetTimer();
}

View File

@ -759,7 +759,8 @@ void STKHost::mainLoop()
const unsigned ap = p.second->getAveragePing();
const unsigned max_ping = UserConfigParams::m_max_ping;
if (UserConfigParams::m_kick_high_ping_players &&
p.second->isValidated() && ap > max_ping)
p.second->isValidated() &&
p.second->getConnectedTime() > 5.0f && ap > max_ping)
{
Log::info("STKHost", "%s with ping %d is higher than"
" %d ms, kick.",

View File

@ -156,7 +156,10 @@ bool STKPeer::isSamePeer(const ENetPeer* peer) const
uint32_t STKPeer::getPing()
{
if (getConnectedTime() < 3.0f)
{
m_average_ping.store(m_enet_peer->roundTripTime);
return 0;
}
if (NetworkConfig::get()->isServer())
{
// Average ping in 5 seconds