aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/PlayerList.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Minecraft.Client/PlayerList.cpp')
-rw-r--r--Minecraft.Client/PlayerList.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/Minecraft.Client/PlayerList.cpp b/Minecraft.Client/PlayerList.cpp
index 1742756e..80fcb112 100644
--- a/Minecraft.Client/PlayerList.cpp
+++ b/Minecraft.Client/PlayerList.cpp
@@ -19,6 +19,9 @@
#include "..\Minecraft.World\net.minecraft.network.packet.h"
#include "..\Minecraft.World\net.minecraft.network.h"
#include "Windows64\Windows64_Xuid.h"
+#ifdef _WINDOWS64
+#include "Windows64\Network\WinsockNetLayer.h"
+#endif
#include "..\Minecraft.World\Pos.h"
#include "..\Minecraft.World\ProgressListener.h"
#include "..\Minecraft.World\HellRandomLevelSource.h"
@@ -237,6 +240,14 @@ bool PlayerList::placeNewPlayer(Connection *connection, shared_ptr<ServerPlayer>
addPlayerToReceiving( player );
int maxPlayersForPacket = getMaxPlayers() > 255 ? 255 : getMaxPlayers();
+
+ BYTE newSmallId = 0;
+ Socket *sock = connection->getSocket();
+ INetworkPlayer *np = sock ? sock->getPlayer() : nullptr;
+ if (np) newSmallId = np->GetSmallId();
+ app.DebugPrintf("RECONNECT: placeNewPlayer smallId=%d entityId=%d dim=%d\n",
+ newSmallId, player->entityId, level->dimension->id);
+
playerConnection->send( shared_ptr<LoginPacket>( new LoginPacket(L"", player->entityId, level->getLevelData()->getGenerator(), level->getSeed(), player->gameMode->getGameModeForPlayer()->getId(),
(byte) level->dimension->id, (byte) level->getMaxBuildHeight(), (byte) maxPlayersForPacket,
level->difficulty, TelemetryManager->GetMultiplayerInstanceID(), (BYTE)playerIndex, level->useNewSeaLevel(), player->getAllPlayerGamePrivileges(),
@@ -979,6 +990,14 @@ void PlayerList::tick()
{
player->connection->disconnect( DisconnectPacket::eDisconnect_Closed );
}
+
+#ifdef _WINDOWS64
+ // The old Connection's read/write threads are now dead (disconnect waits
+ // for them). Safe to recycle the smallId — no stale write thread can
+ // resolve getPlayer() to a new connection that reuses this slot.
+ WinsockNetLayer::PushFreeSmallId(smallId);
+ WinsockNetLayer::ClearSocketForSmallId(smallId);
+#endif
}
LeaveCriticalSection(&m_closePlayersCS);
@@ -1618,6 +1637,13 @@ void PlayerList::closePlayerConnectionBySmallId(BYTE networkSmallId)
LeaveCriticalSection(&m_closePlayersCS);
}
+void PlayerList::queueSmallIdForRecycle(BYTE smallId)
+{
+ EnterCriticalSection(&m_closePlayersCS);
+ m_smallIdsToClose.push_back(smallId);
+ LeaveCriticalSection(&m_closePlayersCS);
+}
+
bool PlayerList::isXuidBanned(PlayerUID xuid)
{
if( xuid == INVALID_XUID ) return false;