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
This commit is contained in:
ModMaker101
2026-03-08 18:08:36 -05:00
committed by GitHub
parent 88798b501d
commit 28614b922f
1373 changed files with 20086 additions and 19527 deletions
+7 -7
View File
@@ -30,7 +30,7 @@ LoginPacket::LoginPacket()
m_playerCapeId = 0;
m_isGuest = false;
m_newSeaLevel = false;
m_pLevelType = NULL;
m_pLevelType = nullptr;
m_uiGamePrivileges = 0;
m_xzSize = LEVEL_MAX_WIDTH;
m_hellScale = HELL_LEVEL_MAX_SCALE;
@@ -59,7 +59,7 @@ LoginPacket::LoginPacket(const wstring& userName, int clientVersion, PlayerUID o
m_playerCapeId = capeId;
m_isGuest = isGuest;
m_newSeaLevel = false;
m_pLevelType = NULL;
m_pLevelType = nullptr;
m_uiGamePrivileges = 0;
m_xzSize = LEVEL_MAX_WIDTH;
m_hellScale = HELL_LEVEL_MAX_SCALE;
@@ -100,7 +100,7 @@ void LoginPacket::read(DataInputStream *dis) //throws IOException
userName = readUtf(dis, Player::MAX_NAME_LENGTH);
wstring typeName = readUtf(dis, 16);
m_pLevelType = LevelType::getLevelType(typeName);
if (m_pLevelType == NULL)
if (m_pLevelType == nullptr)
{
m_pLevelType = LevelType::lvl_normal;
}
@@ -135,7 +135,7 @@ void LoginPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeInt(clientVersion);
writeUtf(userName, dos);
if (m_pLevelType == NULL)
if (m_pLevelType == nullptr)
{
writeUtf(L"", dos);
}
@@ -174,10 +174,10 @@ void LoginPacket::handle(PacketListener *listener)
int LoginPacket::getEstimatedSize()
{
int length=0;
if (m_pLevelType != NULL)
if (m_pLevelType != nullptr)
{
length = (int)m_pLevelType->getGeneratorName().length();
length = static_cast<int>(m_pLevelType->getGeneratorName().length());
}
return (int)(sizeof(int) + userName.length() + 4 + 6 + sizeof(int64_t) + sizeof(char) + sizeof(int) + (2*sizeof(PlayerUID)) +1 + sizeof(char) + sizeof(BYTE) + sizeof(bool) + sizeof(bool) + length + sizeof(unsigned int));
return static_cast<int>(sizeof(int) + userName.length() + 4 + 6 + sizeof(int64_t) + sizeof(char) + sizeof(int) + (2 * sizeof(PlayerUID)) + 1 + sizeof(char) + sizeof(BYTE) + sizeof(bool) + sizeof(bool) + length + sizeof(unsigned int));
}