diff options
| author | lspepinho <162769565+lspepinho@users.noreply.github.com> | 2026-03-02 20:30:22 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-03 06:30:22 +0700 |
| commit | 8b28c20d7adc3824f96fbcc34ad65d778a97a05b (patch) | |
| tree | e61705a557e4e064d707ec542c53dbdac1acbe09 /Minecraft.Client/PendingConnection.cpp | |
| parent | 15129932da9442c2815974c519258345b22d5588 (diff) | |
Fixes for PR #96 (#170)
* Implement basic multiplayer functionality
* Update README.md
---------
Co-authored-by: Slenderman <ssimulpong@outlook.com>
Diffstat (limited to 'Minecraft.Client/PendingConnection.cpp')
| -rw-r--r-- | Minecraft.Client/PendingConnection.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
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<LoginPacket> packet) { disconnect(DisconnectPacket::eDisconnect_Banned); } +#ifdef _WINDOWS64 + else if (g_bRejectDuplicateNames) + { + bool nameTaken = false; + vector<shared_ptr<ServerPlayer> >& 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); |
