From 8c70ee719410a075c4a59a3e73ad8bd3fa2bf6f3 Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Wed, 28 May 2014 02:44:17 -0400 Subject: [PATCH] Make sure netplay player IDs are actually unique. Fixes issue 7329. --- Source/Core/Core/NetPlayServer.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/NetPlayServer.cpp b/Source/Core/Core/NetPlayServer.cpp index 731f3b1093..c7145079bf 100644 --- a/Source/Core/Core/NetPlayServer.cpp +++ b/Source/Core/Core/NetPlayServer.cpp @@ -153,7 +153,16 @@ unsigned int NetPlayServer::OnConnect(sf::SocketTCP& socket) rpac >> player.name; // give new client first available id - player.pid = (PlayerId)(m_players.size() + 1); + PlayerId pid = 1; + for (auto i = m_players.begin(); i != m_players.end(); ++i) + { + if (i->second.pid == pid) + { + pid++; + i = m_players.begin(); + } + } + player.pid = pid; // try to automatically assign new user a pad for (PadMapping& mapping : m_pad_map)