Reject duplicate UIDs on login and remove noisy gdraw debug log#1013
Merged
codeHusky merged 1 commit intosmartcmd:mainfrom Mar 9, 2026
Merged
Reject duplicate UIDs on login and remove noisy gdraw debug log#1013codeHusky merged 1 commit intosmartcmd:mainfrom
codeHusky merged 1 commit intosmartcmd:mainfrom
Conversation
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 smartcmd#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.
Contributor
Author
|
@codeHusky hope this doesn't fall in the not do two things at once, just removing some logging i missed earlier, spams the console. |
piebotc
pushed a commit
to piebotc/LegacyEvolved
that referenced
this pull request
Mar 9, 2026
…tcmd#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 smartcmd#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.
MrTheShy
added a commit
to MrTheShy/MinecraftConsoles
that referenced
this pull request
Mar 9, 2026
…ain compile error Merges 19 commits from smartcmd/MinecraftConsoles (upstream/main) into the dedicated-server branch and resolves the resulting networking conflicts while preserving all dedicated-server-specific behaviour. --- Upstream commits included in this merge: - Port over RCE Patches from LCEMP (smartcmd#1023) Hardened packet parsing across ByteArrayInputStream/OutputStream, Tag, Socket, Connection, and a dozen packet types; bounds-checked reads, length limits, and safe decompression paths to close known RCE vectors. - Revert accidentally pushed "LCEMP RCE fixes" / LCEMP RCE fixes Intermediate clean-up of the above work. - Reject duplicate UIDs on login and remove noisy gdraw debug log (smartcmd#1013) Incoming players whose UID is already active are now disconnected instead of force-kicking the existing player. Removes a per-frame debug printf left in gdraw_SetViewSizeAndWorldScale. - Always show version overlay, add more info Version string is now always visible at runtime. - Fix split-screen UI wrong positioning on window resize (smartcmd#989) - Reimplement boat gravity again (smartcmd#988) - Use correctly sized icons on 720p (smartcmd#883) - Revert workaround for loading HD textures (smartcmd#999) - Fix crash when launching at 720p or lower resolutions (smartcmd#981) - Modernize project codebase (smartcmd#906): NULL → nullptr, C-style cast → C++ cast, shared_ptr(new …) → make_shared, misc type fixes. - Split screen, widescreen support, font rendering and UI scaling fixes (smartcmd#767) - Flame not working with one-shot arrow (smartcmd#856) - Fix focus sound playing repeatedly on mouse hover (smartcmd#890) - Fix stale held item appearing when switching worlds (smartcmd#910) - Fix F3 debug crash when throwing ender pearl long distance (smartcmd#934) - Allow closing some menus with inventory/crafting keys (smartcmd#868) - Fix second-person nametag pitch (smartcmd#963) --- Conflict resolutions (4 files): Minecraft.Client/Common/Network/GameNetworkManager.cpp Conflict 1 — variable declarations in StartNetworkGame: Kept HEAD. The dedicated-server branch declares `dedicatedNoLocalHostPlayer` here and reads it from NetworkGameInitData. Upstream had dropped that variable while modernising the NULL → nullptr style; keeping it is required for the dedicated-server startup path. Conflict 2 — primary-player connection block: Kept HEAD. When `dedicatedNoLocalHostPlayer` is true the branch intentionally skips creating a local-host ClientConnection and goes straight to setting the game mode. Upstream's refactor created a ClientConnection with a null socket even for the dedicated path and ran the full tick loop; that approach is incompatible with headless operation. Minecraft.Client/PendingConnection.cpp Kept HEAD. The branch wraps the duplicate-XUID rejection path with a #if MINECRAFT_SERVER_BUILD guard that calls ServerLogManager::OnRejectedPlayerLogin. Upstream's version removed that call and rewrote only the comment. Preserving the guard keeps the server-build audit log intact. Minecraft.Client/ServerConnection.cpp Kept HEAD comment. Both sides changed only a single-line comment above the playerSnapshot vector. HEAD's comment ("Disconnect through PlayerConnection so clients receive a proper DisconnectPacket before socket close") describes the functional intent; it was kept as the more meaningful description for this branch. Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp Conflicts 1 & 2 — shutdown thread teardown: Hybrid: adopted upstream's nullptr style (consistent with the rest of the file after the modernisation PR) while keeping HEAD's more precise comment ("Ensure all host-side receive threads have exited before destroying locks"). Conflict 3 — AcceptThreadProc accept() call: Kept HEAD. HEAD passes sockaddr_in remoteAddress to accept() so that TryGetNumericRemoteIp can extract the client IP for connection logging and the IP-ban check (ServerRuntime::Access::IsIpBanned). Upstream had simplified the call to accept(…, nullptr, nullptr), which would have silently broken IP-based access control in the server build. --- fix: declare extern ConsoleUIController ui in ServerMain.cpp Windows64_UIController.h (included by ServerMain.cpp) defines the class but does not forward-declare the global `ui` instance. The `extern ConsoleUIController ui` declaration lives only in Common/UI/UI.h, which is not in ServerMain.cpp's include chain. The object is defined in Windows64_UIController.cpp, which IS compiled as part of Minecraft.Server.vcxproj, so the linker already sees it; the missing declaration caused a C2065 compile error only in the server translation unit. Added the extern declaration alongside the other extern globals at the top of ServerMain.cpp.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Prevents players from joining a server if their UID is already in use by another connected player, fixing invisible players and undefined behaviour caused by duplicate UIDs coexisting in the player list.
Changes
Previous Behavior
When a player tried to join a server with a UID matching an already-connected player, the server would force-disconnect the existing player and accept the new connection. This allowed two clients with the same UID to briefly or permanently coexist in the player list, resulting in invisible players and other undefined behaviour.
Root Cause
PR #767 introduced a reconnect-handling code path in
PendingConnection::handleLoginthat, upon detecting a duplicate UID, would force-kick the stale player and callhandleAcceptedLoginfor the incoming connection. While intended for reconnect scenarios, this unconditionally allowed any duplicate-UID connection through at the cost of evicting the legitimate existing player.New Behavior
When a duplicate UID is detected during login, the incoming connection is disconnected. The existing player remains on the server unaffected.
Fix Implementation
In
PendingConnection::handleLogin, theelse if (duplicateXuid)branch previously force-disconnected the stale player, recycled theirsmallId, and calledhandleAcceptedLoginfor the new connection. This block has been replaced with a simpledisconnect(DisconnectPacket::eDisconnect_Banned)call on the incoming connection, consistent with how duplicate names are already handled underg_bRejectDuplicateNames.A leftover per-frame
DebugPrintfingdraw_SetViewSizeAndWorldScale(introduced during the resolution-fix work in #767) is also removed.AI Use Disclosure
No AI was used to write the code in this PR.
AI fully wrote this PR description
Related Issues