Add a high ping workaround in server

This will allow around ping with 400ms to have a playable game with
the default values of max-ping and jitter-tolerance, as long as the
internet connection is stable (no packet loss)
This commit is contained in:
Benau 2019-10-31 11:36:03 +08:00
parent 2f93ef9c6d
commit a8fdd98a0e
4 changed files with 17 additions and 2 deletions

View File

@ -144,6 +144,9 @@ The current server configuration xml looks like this:
<!-- Kick players whose ping is above max-ping. -->
<kick-high-ping-players value="false" />
<!-- Allow players exceeding max-ping to have a playable game, if enabled kick-high-ping-players will be disabled, please also use a default value for max-ping and jitter-tolerance with it. -->
<high-ping-workaround value="true" />
<!-- Kick idle player which has no network activity to server for more than some seconds during game, unless he has finished the race. Negative value to disable, and this option will always be disabled for LAN server. -->
<kick-idle-player-seconds value="60" />

View File

@ -4033,6 +4033,7 @@ void ServerLobby::configPeersStartTime()
{
uint32_t max_ping = 0;
const unsigned max_ping_from_peers = ServerConfig::m_max_ping;
bool peer_exceeded_max_ping = false;
for (auto p : m_peers_ready)
{
auto peer = p.first.lock();
@ -4043,14 +4044,16 @@ void ServerLobby::configPeersStartTime()
Log::warn("ServerLobby",
"Peer %s cannot catch up with max ping %d.",
peer->getRealAddress().c_str(), max_ping);
peer_exceeded_max_ping = true;
continue;
}
max_ping = std::max(peer->getAveragePing(), max_ping);
}
if (ServerConfig::m_live_players && race_manager->supportsLiveJoining())
if ((ServerConfig::m_high_ping_workaround && peer_exceeded_max_ping) ||
(ServerConfig::m_live_players && race_manager->supportsLiveJoining()))
{
Log::info("ServerLobby", "Max ping to ServerConfig::m_max_ping for "
"live joining.");
"live joining or high ping workaround.");
max_ping = ServerConfig::m_max_ping;
}
// Start up time will be after 2500ms, so even if this packet is sent late

View File

@ -330,6 +330,8 @@ void loadServerLobbyFromConfig()
if (m_live_players)
m_official_karts_threshold = 1.0f;
if (m_high_ping_workaround)
m_kick_high_ping_players = false;
auto modes = getLocalGameModeFromConfig();
race_manager->setMinorMode(modes.first);
race_manager->setMajorMode(modes.second);

View File

@ -311,6 +311,13 @@ namespace ServerConfig
"kick-high-ping-players",
"Kick players whose ping is above max-ping."));
SERVER_CFG_PREFIX BoolServerConfigParam m_high_ping_workaround
SERVER_CFG_DEFAULT(BoolServerConfigParam(true,
"high-ping-workaround",
"Allow players exceeding max-ping to have a playable game, if enabled "
"kick-high-ping-players will be disabled, please also use a default "
"value for max-ping and jitter-tolerance with it."));
SERVER_CFG_PREFIX IntServerConfigParam m_kick_idle_player_seconds
SERVER_CFG_DEFAULT(IntServerConfigParam(60,
"kick-idle-player-seconds",