aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/PendingConnection.cpp
diff options
context:
space:
mode:
authorMrTheShy <49885496+MrTheShy@users.noreply.github.com>2026-03-09 05:10:00 +0100
committerGitHub <noreply@github.com>2026-03-08 23:10:00 -0500
commit7a4f57e3e692c621c20e58bc658d321842872de5 (patch)
treed4b5d12b934bd3639e2bcdafeacac7eb7c38d10e /Minecraft.Client/PendingConnection.cpp
parente2adaa082c219c4c5f2025ae4898d3711000cab9 (diff)
Reject duplicate UIDs on login and remove noisy gdraw debug log (#1013)
Players joining a server with a UID already in use are now disconnected instead of the existing player being force-kicked. The previous behaviour introduced in #767 allowed two clients with the same UID to coexist, causing invisible players and undefined behaviour. Also removes a per-frame debug printf in gdraw_SetViewSizeAndWorldScale that was left in from earlier resolution-fix work.
Diffstat (limited to 'Minecraft.Client/PendingConnection.cpp')
-rw-r--r--Minecraft.Client/PendingConnection.cpp33
1 files changed, 5 insertions, 28 deletions
diff --git a/Minecraft.Client/PendingConnection.cpp b/Minecraft.Client/PendingConnection.cpp
index 0a0f3c44..6d5497f0 100644
--- a/Minecraft.Client/PendingConnection.cpp
+++ b/Minecraft.Client/PendingConnection.cpp
@@ -190,34 +190,11 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet)
}
else if (duplicateXuid)
{
- // The old player is still in PlayerList (disconnect hasn't been
- // processed yet). Force-close the stale connection so the
- // reconnecting client isn't rejected.
- app.DebugPrintf("RECONNECT: Duplicate xuid for name: %ls, forcing old connection closed\n", name.c_str());
- shared_ptr<ServerPlayer> stalePlayer = server->getPlayers()->getPlayer(loginXuid);
- if (stalePlayer == nullptr && packet->m_onlineXuid != INVALID_XUID)
- stalePlayer = server->getPlayers()->getPlayer(packet->m_onlineXuid);
-
- if (stalePlayer != nullptr && stalePlayer->connection != nullptr)
- {
- BYTE oldSmallId = 0;
- if (stalePlayer->connection->connection != nullptr && stalePlayer->connection->connection->getSocket() != nullptr)
- oldSmallId = stalePlayer->connection->connection->getSocket()->getSmallId();
- app.DebugPrintf("RECONNECT: Force-disconnecting old player smallId=%d\n", oldSmallId);
- stalePlayer->connection->disconnect(DisconnectPacket::eDisconnect_Closed);
-
- // Queue the old SmallId for recycling so it's not permanently leaked.
- // PlayerList::tick() will call PushFreeSmallId/ClearSocketForSmallId.
- if (oldSmallId != 0)
- server->getPlayers()->queueSmallIdForRecycle(oldSmallId);
-
- app.DebugPrintf("RECONNECT: Old player force-disconnect complete\n");
- }
-
- // Accept the login now that the old entry is removed.
- app.DebugPrintf("RECONNECT: Calling handleAcceptedLogin for new connection\n");
- handleAcceptedLogin(packet);
- app.DebugPrintf("RECONNECT: handleAcceptedLogin complete\n");
+ // Reject the incoming connection — a player with this UID is already
+ // on the server. Allowing duplicates causes invisible players and
+ // other undefined behaviour.
+ app.DebugPrintf("LOGIN: Rejecting duplicate xuid for name: %ls\n", name.c_str());
+ disconnect(DisconnectPacket::eDisconnect_Banned);
}
#ifdef _WINDOWS64
else if (g_bRejectDuplicateNames)