diff options
| author | ModMaker101 <119018978+ModMaker101@users.noreply.github.com> | 2026-03-08 19:08:36 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-08 18:08:36 -0500 |
| commit | 28614b922fb77149a54da1a87bebfbc98736f296 (patch) | |
| tree | 7f828ba86a4ee18d0a80d29de64f6199a5412512 /Minecraft.Client/PendingConnection.cpp | |
| parent | 88798b501d0cf6287b6f87acb2592676e3cec58d (diff) | |
Modernize project codebase (#906)
* Fixed boats falling and a TP glitch #266
* Replaced every C-style cast with C++ ones
* Replaced every C-style cast with C++ ones
* Fixed boats falling and a TP glitch #266
* Updated NULL to nullptr and fixing some type issues
* Modernized and fixed a few bugs
- Replaced most instances of `NULL` with `nullptr`.
- Replaced most `shared_ptr(new ...)` with `make_shared`.
- Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances.
* Fixing more conflicts
* Replace int loops with size_t and start work on overrides
* Add safety checks and fix a issue with vector going OOR
Diffstat (limited to 'Minecraft.Client/PendingConnection.cpp')
| -rw-r--r-- | Minecraft.Client/PendingConnection.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Minecraft.Client/PendingConnection.cpp b/Minecraft.Client/PendingConnection.cpp index 839cd550..0a0f3c44 100644 --- a/Minecraft.Client/PendingConnection.cpp +++ b/Minecraft.Client/PendingConnection.cpp @@ -45,7 +45,7 @@ PendingConnection::~PendingConnection() void PendingConnection::tick() { - if (acceptedLogin != NULL) + if (acceptedLogin != nullptr) { this->handleAcceptedLogin(acceptedLogin); acceptedLogin = nullptr; @@ -65,7 +65,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<DisconnectPacket>( new DisconnectPacket(reason) ) ); + connection->send(std::make_shared<DisconnectPacket>(reason)); connection->sendAndQuit(); done = true; // } catch (Exception e) { @@ -121,7 +121,7 @@ void PendingConnection::sendPreLoginResponse() // Need to use the online XUID otherwise friend checks will fail on the client ugcXuids[ugcXuidCount] = player->connection->m_onlineXUID; - if( player->connection->getNetworkPlayer() != NULL && player->connection->getNetworkPlayer()->IsHost() ) hostIndex = ugcXuidCount; + if( player->connection->getNetworkPlayer() != nullptr && player->connection->getNetworkPlayer()->IsHost() ) hostIndex = ugcXuidCount; ++ugcXuidCount; } @@ -136,9 +136,9 @@ void PendingConnection::sendPreLoginResponse() else #endif { - DWORD cappedCount = (ugcXuidCount > 255u) ? 255u : static_cast<DWORD>(ugcXuidCount); + DWORD cappedCount = (ugcXuidCount > 255u) ? 255u : ugcXuidCount; BYTE cappedHostIndex = (hostIndex >= 255u) ? 254 : static_cast<BYTE>(hostIndex); - connection->send( shared_ptr<PreLoginPacket>( new PreLoginPacket(L"-", ugcXuids, cappedCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion,szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),cappedHostIndex, server->m_texturePackId) ) ); + connection->send(std::make_shared<PreLoginPacket>(L"-", ugcXuids, cappedCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion, szUniqueMapName, app.GetGameHostOption(eGameHostOption_All), cappedHostIndex, server->m_texturePackId)); } } @@ -226,7 +226,7 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet) vector<shared_ptr<ServerPlayer> >& pl = server->getPlayers()->players; for (const auto& i : pl) { - if (i != NULL && i->name == name) + if (i != nullptr && i->name == name) { nameTaken = true; break; @@ -289,10 +289,10 @@ void PendingConnection::handleAcceptedLogin(shared_ptr<LoginPacket> packet) if(playerXuid == INVALID_XUID) playerXuid = packet->m_onlineXuid; shared_ptr<ServerPlayer> playerEntity = server->getPlayers()->getPlayerForLogin(this, name, playerXuid,packet->m_onlineXuid); - if (playerEntity != NULL) + if (playerEntity != nullptr) { server->getPlayers()->placeNewPlayer(connection, playerEntity, packet); - connection = NULL; // We've moved responsibility for this over to the new PlayerConnection, NULL so we don't delete our reference to it here in our dtor + connection = nullptr; // We've moved responsibility for this over to the new PlayerConnection, nullptr so we don't delete our reference to it here in our dtor } done = true; @@ -309,7 +309,7 @@ void PendingConnection::handleGetInfo(shared_ptr<GetInfoPacket> packet) //try { //String message = server->motd + "�" + server->players->getPlayerCount() + "�" + server->players->getMaxPlayers(); //connection->send(new DisconnectPacket(message)); - connection->send(shared_ptr<DisconnectPacket>(new DisconnectPacket(DisconnectPacket::eDisconnect_ServerFull) ) ); + connection->send(std::make_shared<DisconnectPacket>(DisconnectPacket::eDisconnect_ServerFull)); connection->sendAndQuit(); server->connection->removeSpamProtection(connection->getSocket()); done = true; |
