diff options
Diffstat (limited to 'Minecraft.Client/PendingConnection.cpp')
| -rw-r--r-- | Minecraft.Client/PendingConnection.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Minecraft.Client/PendingConnection.cpp b/Minecraft.Client/PendingConnection.cpp index b50669e5..72b8f382 100644 --- a/Minecraft.Client/PendingConnection.cpp +++ b/Minecraft.Client/PendingConnection.cpp @@ -161,6 +161,23 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet) //if (true)// 4J removed !server->onlineMode) bool sentDisconnect = false; + // Use the same Xuid choice as handleAcceptedLogin (offline first, online fallback). + // + PlayerUID loginXuid = packet->m_offlineXuid; + if (loginXuid == INVALID_XUID) loginXuid = packet->m_onlineXuid; + + bool duplicateXuid = false; + if (loginXuid != INVALID_XUID && server->getPlayers()->getPlayer(loginXuid) != nullptr) + { + duplicateXuid = true; + } + else if (packet->m_onlineXuid != INVALID_XUID && + packet->m_onlineXuid != loginXuid && + server->getPlayers()->getPlayer(packet->m_onlineXuid) != nullptr) + { + duplicateXuid = true; + } + if( sentDisconnect ) { // Do nothing @@ -169,6 +186,12 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet) { disconnect(DisconnectPacket::eDisconnect_Banned); } + else if (duplicateXuid) + { + // if same XUID already in use by another player so disconnect this one. + app.DebugPrintf("Rejecting duplicate xuid for name: %ls\n", name.c_str()); + disconnect(DisconnectPacket::eDisconnect_Banned); + } #ifdef _WINDOWS64 else if (g_bRejectDuplicateNames) { |
