aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/TextureAndGeometryPacket.cpp
diff options
context:
space:
mode:
authorqwasdrizzel <145519042+qwasdrizzel@users.noreply.github.com>2026-03-16 21:44:26 -0500
committerGitHub <noreply@github.com>2026-03-16 21:44:26 -0500
commitce739f6045ec72127491286ea3f3f21e537c1b55 (patch)
treef33bd42a47c1b4a7b2153a7fb77127ee3b407db9 /Minecraft.World/TextureAndGeometryPacket.cpp
parent255a18fe8e9b57377975f82e2b227afe2a12eda0 (diff)
parent5a59f5d146b43811dde6a5a0245ee9875d7b5cd1 (diff)
Merge branch 'smartcmd:main' into main
Diffstat (limited to 'Minecraft.World/TextureAndGeometryPacket.cpp')
-rw-r--r--Minecraft.World/TextureAndGeometryPacket.cpp57
1 files changed, 41 insertions, 16 deletions
diff --git a/Minecraft.World/TextureAndGeometryPacket.cpp b/Minecraft.World/TextureAndGeometryPacket.cpp
index d28fc862..1c920ee7 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<DWORD>(pvSkinBoxes->size());
this->BoxDataA= new SKIN_BOX [this->dwBoxC];
int iCount=0;
@@ -120,8 +120,21 @@ 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<DWORD>(dis->readInt());
+
+ short rawTextureBytes = dis->readShort();
+ if (rawTextureBytes <= 0)
+ {
+ dwTextureBytes = 0;
+ }
+ else
+ {
+ dwTextureBytes = (DWORD)(unsigned short)rawTextureBytes;
+ if (dwTextureBytes > 65536)
+ {
+ dwTextureBytes = 0;
+ }
+ }
if(dwTextureBytes>0)
{
@@ -134,7 +147,19 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException
}
uiAnimOverrideBitmask = dis->readInt();
- dwBoxC = (DWORD)dis->readShort();
+ short rawBoxC = dis->readShort();
+ if (rawBoxC <= 0)
+ {
+ dwBoxC = 0;
+ }
+ else
+ {
+ dwBoxC = (DWORD)(unsigned short)rawBoxC;
+ if (dwBoxC > 256)
+ {
+ dwBoxC = 0; // sane limit for skin boxes
+ }
+ }
if(dwBoxC>0)
{
@@ -143,7 +168,7 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException
for(DWORD i=0;i<dwBoxC;i++)
{
- this->BoxDataA[i].ePart = (eBodyPart) dis->readShort();
+ this->BoxDataA[i].ePart = static_cast<eBodyPart>(dis->readShort());
this->BoxDataA[i].fX = dis->readFloat();
this->BoxDataA[i].fY = dis->readFloat();
this->BoxDataA[i].fZ = dis->readFloat();
@@ -159,17 +184,17 @@ void TextureAndGeometryPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeUTF(textureName);
dos->writeInt(dwSkinID);
- dos->writeShort((short)dwTextureBytes);
+ dos->writeShort(static_cast<short>(dwTextureBytes));
for(DWORD i=0;i<dwTextureBytes;i++)
{
dos->writeByte(this->pbData[i]);
}
dos->writeInt(uiAnimOverrideBitmask);
- dos->writeShort((short)dwBoxC);
+ dos->writeShort(static_cast<short>(dwBoxC));
for(DWORD i=0;i<dwBoxC;i++)
{
- dos->writeShort((short)this->BoxDataA[i].ePart);
+ dos->writeShort(static_cast<short>(this->BoxDataA[i].ePart));
dos->writeFloat(this->BoxDataA[i].fX);
dos->writeFloat(this->BoxDataA[i].fY);
dos->writeFloat(this->BoxDataA[i].fZ);