diff --git a/src/network/game_setup.cpp b/src/network/game_setup.cpp index 5481f83b2..800be8bd9 100644 --- a/src/network/game_setup.cpp +++ b/src/network/game_setup.cpp @@ -30,6 +30,7 @@ #include "utils/log.hpp" #include +#include //----------------------------------------------------------------------------- /** Update and see if any player disconnects. @@ -139,14 +140,23 @@ void GameSetup::addServerInfo(NetworkString* ns) //----------------------------------------------------------------------------- void GameSetup::sortPlayersForGrandPrix() { - if (!isGrandPrix() || m_tracks.size() == 1) + if (!isGrandPrix()) return; std::lock_guard lock(m_players_mutex); + + if (m_tracks.size() == 1) + { + std::random_device rd; + std::mt19937 g(rd()); + std::shuffle(m_players.begin(), m_players.end(), g); + return; + } + std::sort(m_players.begin(), m_players.end(), [](const std::weak_ptr& a, const std::weak_ptr& b) { - // They should never expired + // They should be never expired auto c = a.lock(); assert(c); auto d = b.lock();