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.
This commit is contained in:
@@ -190,34 +190,11 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet)
|
|||||||
}
|
}
|
||||||
else if (duplicateXuid)
|
else if (duplicateXuid)
|
||||||
{
|
{
|
||||||
// The old player is still in PlayerList (disconnect hasn't been
|
// Reject the incoming connection — a player with this UID is already
|
||||||
// processed yet). Force-close the stale connection so the
|
// on the server. Allowing duplicates causes invisible players and
|
||||||
// reconnecting client isn't rejected.
|
// other undefined behaviour.
|
||||||
app.DebugPrintf("RECONNECT: Duplicate xuid for name: %ls, forcing old connection closed\n", name.c_str());
|
app.DebugPrintf("LOGIN: Rejecting duplicate xuid for name: %ls\n", name.c_str());
|
||||||
shared_ptr<ServerPlayer> stalePlayer = server->getPlayers()->getPlayer(loginXuid);
|
disconnect(DisconnectPacket::eDisconnect_Banned);
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
#ifdef _WINDOWS64
|
#ifdef _WINDOWS64
|
||||||
else if (g_bRejectDuplicateNames)
|
else if (g_bRejectDuplicateNames)
|
||||||
|
|||||||
@@ -998,11 +998,7 @@ static void RADLINK gdraw_SetViewSizeAndWorldScale(S32 w, S32 h, F32 scalex, F32
|
|||||||
{
|
{
|
||||||
static S32 s_lastW = 0, s_lastH = 0;
|
static S32 s_lastW = 0, s_lastH = 0;
|
||||||
static F32 s_lastSx = 0, s_lastSy = 0;
|
static F32 s_lastSx = 0, s_lastSy = 0;
|
||||||
if (w != s_lastW || h != s_lastH || scalex != s_lastSx || scaley != s_lastSy) {
|
|
||||||
app.DebugPrintf("[GDRAW] SetViewSize: fw=%d fh=%d scale=%.6f,%.6f frametex=%dx%d vx=%d vy=%d\n",
|
|
||||||
w, h, scalex, scaley, gdraw->frametex_width, gdraw->frametex_height, gdraw->vx, gdraw->vy);
|
|
||||||
s_lastW = w; s_lastH = h; s_lastSx = scalex; s_lastSy = scaley;
|
|
||||||
}
|
|
||||||
memset(gdraw->frame, 0, sizeof(gdraw->frame));
|
memset(gdraw->frame, 0, sizeof(gdraw->frame));
|
||||||
gdraw->cur = gdraw->frame;
|
gdraw->cur = gdraw->frame;
|
||||||
gdraw->fw = w;
|
gdraw->fw = w;
|
||||||
|
|||||||
Reference in New Issue
Block a user