From 28614b922fb77149a54da1a87bebfbc98736f296 Mon Sep 17 00:00:00 2001 From: ModMaker101 <119018978+ModMaker101@users.noreply.github.com> Date: Sun, 8 Mar 2026 19:08:36 -0400 Subject: 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 --- Minecraft.World/TextureAndGeometryPacket.cpp | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'Minecraft.World/TextureAndGeometryPacket.cpp') diff --git a/Minecraft.World/TextureAndGeometryPacket.cpp b/Minecraft.World/TextureAndGeometryPacket.cpp index d28fc862..bf5eccdb 100644 --- a/Minecraft.World/TextureAndGeometryPacket.cpp +++ b/Minecraft.World/TextureAndGeometryPacket.cpp @@ -10,21 +10,21 @@ TextureAndGeometryPacket::TextureAndGeometryPacket() { this->textureName = L""; this->dwTextureBytes = 0; - this->pbData = NULL; + this->pbData = nullptr; this->dwBoxC = 0; - this->BoxDataA = NULL; + this->BoxDataA = nullptr; uiAnimOverrideBitmask=0; } TextureAndGeometryPacket::~TextureAndGeometryPacket() { // can't free these - they're used elsewhere -// if(this->BoxDataA!=NULL) +// if(this->BoxDataA!=nullptr) // { // delete [] this->BoxDataA; // } // -// if(this->pbData!=NULL) +// if(this->pbData!=nullptr) // { // delete [] this->pbData; // } @@ -43,7 +43,7 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P this->pbData = pbData; this->dwTextureBytes = dwBytes; this->dwBoxC = 0; - this->BoxDataA=NULL; + this->BoxDataA=nullptr; this->uiAnimOverrideBitmask=0; } @@ -75,7 +75,7 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P } else { - this->BoxDataA=NULL; + this->BoxDataA=nullptr; } } @@ -93,14 +93,14 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P this->pbData = pbData; this->dwTextureBytes = dwBytes; this->uiAnimOverrideBitmask = uiAnimOverrideBitmask; - if(pvSkinBoxes==NULL) + if(pvSkinBoxes==nullptr) { this->dwBoxC=0; - this->BoxDataA=NULL; + this->BoxDataA=nullptr; } else { - this->dwBoxC = (DWORD)pvSkinBoxes->size(); + this->dwBoxC = static_cast(pvSkinBoxes->size()); this->BoxDataA= new SKIN_BOX [this->dwBoxC]; int iCount=0; @@ -120,8 +120,8 @@ void TextureAndGeometryPacket::handle(PacketListener *listener) void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException { textureName = dis->readUTF(); - dwSkinID = (DWORD)dis->readInt(); - dwTextureBytes = (DWORD)dis->readShort(); + dwSkinID = static_cast(dis->readInt()); + dwTextureBytes = static_cast(dis->readShort()); if(dwTextureBytes>0) { @@ -134,7 +134,7 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException } uiAnimOverrideBitmask = dis->readInt(); - dwBoxC = (DWORD)dis->readShort(); + dwBoxC = static_cast(dis->readShort()); if(dwBoxC>0) { @@ -143,7 +143,7 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException for(DWORD i=0;iBoxDataA[i].ePart = (eBodyPart) dis->readShort(); + this->BoxDataA[i].ePart = static_cast(dis->readShort()); this->BoxDataA[i].fX = dis->readFloat(); this->BoxDataA[i].fY = dis->readFloat(); this->BoxDataA[i].fZ = dis->readFloat(); @@ -159,17 +159,17 @@ void TextureAndGeometryPacket::write(DataOutputStream *dos) //throws IOException { dos->writeUTF(textureName); dos->writeInt(dwSkinID); - dos->writeShort((short)dwTextureBytes); + dos->writeShort(static_cast(dwTextureBytes)); for(DWORD i=0;iwriteByte(this->pbData[i]); } dos->writeInt(uiAnimOverrideBitmask); - dos->writeShort((short)dwBoxC); + dos->writeShort(static_cast(dwBoxC)); for(DWORD i=0;iwriteShort((short)this->BoxDataA[i].ePart); + dos->writeShort(static_cast(this->BoxDataA[i].ePart)); dos->writeFloat(this->BoxDataA[i].fX); dos->writeFloat(this->BoxDataA[i].fY); dos->writeFloat(this->BoxDataA[i].fZ); -- cgit v1.2.3