From dbd629e54ce8f55d4f681f595502093c49f6dc4b Mon Sep 17 00:00:00 2001 From: Nikhil Narayana Date: Sun, 29 May 2022 23:34:10 -0700 Subject: [PATCH] pull in project-slippi/Ishiiruka/commit/90b87df414a1e4b833139da9f8d3d5a1e36f62ff --- Source/Core/Core/Slippi/SlippiMatchmaking.cpp | 4 ++- Source/Core/Core/Slippi/SlippiNetplay.cpp | 32 +++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/Slippi/SlippiMatchmaking.cpp b/Source/Core/Core/Slippi/SlippiMatchmaking.cpp index 147231fe18..8d6d2b3bfe 100644 --- a/Source/Core/Core/Slippi/SlippiMatchmaking.cpp +++ b/Source/Core/Core/Slippi/SlippiMatchmaking.cpp @@ -658,7 +658,9 @@ void SlippiMatchmaking::handleConnecting() if (p >= m_localPlayerIndex) p++; - err << m_playerInfo[p].display_name << " "; + err << m_playerInfo[p].display_name; + if (i < failedConns.size() - 1) + err << ", "; } m_errorMsg = err.str(); } diff --git a/Source/Core/Core/Slippi/SlippiNetplay.cpp b/Source/Core/Core/Slippi/SlippiNetplay.cpp index 7197e7f76c..6266cc6291 100644 --- a/Source/Core/Core/Slippi/SlippiNetplay.cpp +++ b/Source/Core/Core/Slippi/SlippiNetplay.cpp @@ -529,6 +529,7 @@ void SlippiNetplayClient::ThreadFunc() int net = enet_host_service(m_client, &netEvent, 500); if (net > 0) { + sf::Packet rpac; switch (netEvent.type) { case ENET_EVENT_TYPE_RECEIVE: @@ -537,8 +538,13 @@ void SlippiNetplayClient::ThreadFunc() INFO_LOG(SLIPPI_ONLINE, "[Netplay] got receive event with nil peer"); continue; } - INFO_LOG(SLIPPI_ONLINE, "[Netplay] got receive event with peer addr %x:%d", + ERROR_LOG_FMT(SLIPPI_ONLINE, "[Netplay] got receive event with peer addr {}:{}", netEvent.peer->address.host, netEvent.peer->address.port); + rpac.append(netEvent.packet->data, netEvent.packet->dataLength); + + OnData(rpac, netEvent.peer); + + enet_packet_destroy(netEvent.packet); break; case ENET_EVENT_TYPE_DISCONNECT: @@ -559,8 +565,30 @@ void SlippiNetplayClient::ThreadFunc() continue; } - INFO_LOG(SLIPPI_ONLINE, "[Netplay] got connect event with peer addr %x:%d", + INFO_LOG_FMT(SLIPPI_ONLINE, "[Netplay] got connect event with peer addr {}:{}", netEvent.peer->address.host, netEvent.peer->address.port); + + auto isAlreadyConnected = false; + for (int i = 0; i < m_server.size(); i++) + { + if (connections[i] && netEvent.peer->address.host == m_server[i]->address.host && + netEvent.peer->address.port == m_server[i]->address.port) + { + m_server[i] = netEvent.peer; + isAlreadyConnected = true; + break; + } + } + + if (isAlreadyConnected) + { + // Don't add this person again if they are already connected. Not doing this can cause one + // person to take up 2 or more spots, denying one or more players from connecting and thus + // getting stuck on the "Waiting" step + ERROR_LOG(SLIPPI_ONLINE, "Already connected!"); + break; // Breaks out of case + } + for (int i = 0; i < m_server.size(); i++) { // This check used to check for port as well as host. The problem was that for some