diff --git a/source/game/StarUniverseServer.cpp b/source/game/StarUniverseServer.cpp index 690f1c6..28f7862 100644 --- a/source/game/StarUniverseServer.cpp +++ b/source/game/StarUniverseServer.cpp @@ -1782,8 +1782,12 @@ void UniverseServer::acceptConnection(UniverseConnection connection, MaybeshipCoordinate().location(), clientContext->shipLocation()); Logger::info("UniverseServer: Client {} connected", clientContext->descriptiveName()); + ReadLocker m_clientsReadLocker(m_clientsLock); auto players = static_cast(m_clients.size()); - for (auto clientId : m_clients.keys()) { + auto clients = m_clients.keys(); + m_clientsReadLocker.unlock(); + + for (auto clientId : clients) { m_connectionServer->sendPackets(clientId, { make_shared(players, static_cast(m_maxPlayers)) });