From 8b28c20d7adc3824f96fbcc34ad65d778a97a05b Mon Sep 17 00:00:00 2001 From: lspepinho <162769565+lspepinho@users.noreply.github.com> Date: Mon, 2 Mar 2026 20:30:22 -0300 Subject: Fixes for PR #96 (#170) * Implement basic multiplayer functionality * Update README.md --------- Co-authored-by: Slenderman --- Minecraft.Client/PendingConnection.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'Minecraft.Client/PendingConnection.cpp') diff --git a/Minecraft.Client/PendingConnection.cpp b/Minecraft.Client/PendingConnection.cpp index e9b37fc6..8034dff2 100644 --- a/Minecraft.Client/PendingConnection.cpp +++ b/Minecraft.Client/PendingConnection.cpp @@ -20,6 +20,10 @@ Random *PendingConnection::random = new Random(); +#ifdef _WINDOWS64 +bool g_bRejectDuplicateNames = true; +#endif + PendingConnection::PendingConnection(MinecraftServer *server, Socket *socket, const wstring& id) { // 4J - added initialisers @@ -166,6 +170,30 @@ void PendingConnection::handleLogin(shared_ptr packet) { disconnect(DisconnectPacket::eDisconnect_Banned); } +#ifdef _WINDOWS64 + else if (g_bRejectDuplicateNames) + { + bool nameTaken = false; + vector >& pl = server->getPlayers()->players; + for (unsigned int i = 0; i < pl.size(); i++) + { + if (pl[i] != NULL && pl[i]->name == name) + { + nameTaken = true; + break; + } + } + if (nameTaken) + { + app.DebugPrintf("Rejecting duplicate name: %ls\n", name.c_str()); + disconnect(DisconnectPacket::eDisconnect_Banned); + } + else + { + handleAcceptedLogin(packet); + } + } +#endif else { handleAcceptedLogin(packet); -- cgit v1.2.3