Project modernization (#630)

* 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
This commit is contained in:
ModMaker101
2026-03-07 21:56:03 -05:00
committed by GitHub
parent 1be5faaea7
commit a9be52c41a
1373 changed files with 19903 additions and 19449 deletions

View File

@@ -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));
}
}
@@ -201,7 +201,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;
@@ -264,10 +264,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;
@@ -284,7 +284,7 @@ void PendingConnection::handleGetInfo(shared_ptr<GetInfoPacket> packet)
//try {
//String message = server->motd + "<22>" + server->players->getPlayerCount() + "<22>" + 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;