From 7074f35e4ba831e358117842b99ee35b87f85ae5 Mon Sep 17 00:00:00 2001 From: void_17 Date: Mon, 2 Mar 2026 15:58:20 +0700 Subject: shared_ptr -> std::shared_ptr This is one of the first commits in a plan to remove all `using namespace std;` lines in the entire codebase as it is considered anti-pattern today. --- Minecraft.Client/PendingConnection.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'Minecraft.Client/PendingConnection.cpp') diff --git a/Minecraft.Client/PendingConnection.cpp b/Minecraft.Client/PendingConnection.cpp index 841863b6..f8f61bdb 100644 --- a/Minecraft.Client/PendingConnection.cpp +++ b/Minecraft.Client/PendingConnection.cpp @@ -61,7 +61,7 @@ void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason) // try { // 4J - removed try/catch // logger.info("Disconnecting " + getName() + ": " + reason); app.DebugPrintf("Pending connection disconnect: %d\n", reason ); - connection->send( shared_ptr( new DisconnectPacket(reason) ) ); + connection->send( std::shared_ptr( new DisconnectPacket(reason) ) ); connection->sendAndQuit(); done = true; // } catch (Exception e) { @@ -69,7 +69,7 @@ void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason) // } } -void PendingConnection::handlePreLogin(shared_ptr packet) +void PendingConnection::handlePreLogin(std::shared_ptr packet) { if (packet->m_netcodeVersion != MINECRAFT_NET_VERSION) { @@ -103,10 +103,10 @@ void PendingConnection::sendPreLoginResponse() PlayerList *playerList = MinecraftServer::getInstance()->getPlayers(); for(AUTO_VAR(it, playerList->players.begin()); it != playerList->players.end(); ++it) { - shared_ptr player = *it; + std::shared_ptr player = *it; // If the offline Xuid is invalid but the online one is not then that's guest which we should ignore // If the online Xuid is invalid but the offline one is not then we are definitely an offline game so dont care about UGC - + // PADDY - this is failing when a local player with chat restrictions joins an online game if( player != NULL && player->connection->m_offlineXUID != INVALID_XUID && player->connection->m_onlineXUID != INVALID_XUID ) @@ -128,16 +128,16 @@ void PendingConnection::sendPreLoginResponse() if (false)// server->onlineMode) // 4J - removed { loginKey = L"TOIMPLEMENT"; // 4J - todo Long.toHexString(random.nextLong()); - connection->send( shared_ptr( new PreLoginPacket(loginKey, ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion, szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex) ) ); + connection->send( std::shared_ptr( new PreLoginPacket(loginKey, ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion, szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex) ) ); } else #endif { - connection->send( shared_ptr( new PreLoginPacket(L"-", ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion,szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex, server->m_texturePackId) ) ); + connection->send( std::shared_ptr( new PreLoginPacket(L"-", ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion,szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex, server->m_texturePackId) ) ); } } -void PendingConnection::handleLogin(shared_ptr packet) +void PendingConnection::handleLogin(std::shared_ptr packet) { // printf("Server: handleLogin\n"); //name = packet->userName; @@ -173,7 +173,7 @@ void PendingConnection::handleLogin(shared_ptr packet) //else { //4J - removed -#if 0 +#if 0 new Thread() { public void run() { try { @@ -198,7 +198,7 @@ void PendingConnection::handleLogin(shared_ptr packet) } -void PendingConnection::handleAcceptedLogin(shared_ptr packet) +void PendingConnection::handleAcceptedLogin(std::shared_ptr packet) { if(packet->m_ugcPlayersVersion != server->m_ugcPlayersVersion) { @@ -211,7 +211,7 @@ void PendingConnection::handleAcceptedLogin(shared_ptr packet) PlayerUID playerXuid = packet->m_offlineXuid; if(playerXuid == INVALID_XUID) playerXuid = packet->m_onlineXuid; - shared_ptr playerEntity = server->getPlayers()->getPlayerForLogin(this, name, playerXuid,packet->m_onlineXuid); + std::shared_ptr playerEntity = server->getPlayers()->getPlayerForLogin(this, name, playerXuid,packet->m_onlineXuid); if (playerEntity != NULL) { server->getPlayers()->placeNewPlayer(connection, playerEntity, packet); @@ -227,12 +227,12 @@ void PendingConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason, done = true; } -void PendingConnection::handleGetInfo(shared_ptr packet) +void PendingConnection::handleGetInfo(std::shared_ptr packet) { //try { - //String message = server->motd + "§" + server->players->getPlayerCount() + "§" + server->players->getMaxPlayers(); + //String message = server->motd + "�" + server->players->getPlayerCount() + "�" + server->players->getMaxPlayers(); //connection->send(new DisconnectPacket(message)); - connection->send(shared_ptr(new DisconnectPacket(DisconnectPacket::eDisconnect_ServerFull) ) ); + connection->send(std::shared_ptr(new DisconnectPacket(DisconnectPacket::eDisconnect_ServerFull) ) ); connection->sendAndQuit(); server->connection->removeSpamProtection(connection->getSocket()); done = true; @@ -241,17 +241,17 @@ void PendingConnection::handleGetInfo(shared_ptr packet) //} } -void PendingConnection::handleKeepAlive(shared_ptr packet) +void PendingConnection::handleKeepAlive(std::shared_ptr packet) { // Ignore } -void PendingConnection::onUnhandledPacket(shared_ptr packet) +void PendingConnection::onUnhandledPacket(std::shared_ptr packet) { disconnect(DisconnectPacket::eDisconnect_UnexpectedPacket); } -void PendingConnection::send(shared_ptr packet) +void PendingConnection::send(std::shared_ptr packet) { connection->send(packet); } -- cgit v1.2.3