Added code for skin offsets
Added code to the file which have the functionality to get skin boxes and duplicated the functionality for skin offsets. The code causes the game to crash when switching to third person. The error occurs with the skin offsets returning as an empty class object.
This commit is contained in:
@@ -12,7 +12,9 @@ TextureAndGeometryPacket::TextureAndGeometryPacket()
|
||||
this->dwTextureBytes = 0;
|
||||
this->pbData = nullptr;
|
||||
this->dwBoxC = 0;
|
||||
this->dwOffsetC = 0;
|
||||
this->BoxDataA = nullptr;
|
||||
this->OffsetDataA = nullptr;
|
||||
uiAnimOverrideBitmask=0;
|
||||
}
|
||||
|
||||
@@ -43,7 +45,9 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P
|
||||
this->pbData = pbData;
|
||||
this->dwTextureBytes = dwBytes;
|
||||
this->dwBoxC = 0;
|
||||
this->dwOffsetC = 0;
|
||||
this->BoxDataA=nullptr;
|
||||
this->OffsetDataA=nullptr;
|
||||
this->uiAnimOverrideBitmask=0;
|
||||
}
|
||||
|
||||
@@ -62,6 +66,7 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P
|
||||
this->dwTextureBytes = dwBytes;
|
||||
this->uiAnimOverrideBitmask = pDLCSkinFile->getAnimOverrideBitmask();
|
||||
this->dwBoxC = pDLCSkinFile->getAdditionalBoxesCount();
|
||||
this->dwOffsetC = pDLCSkinFile->getOffsetsCount();
|
||||
if(this->dwBoxC!=0)
|
||||
{
|
||||
this->BoxDataA= new SKIN_BOX [this->dwBoxC];
|
||||
@@ -77,9 +82,24 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P
|
||||
{
|
||||
this->BoxDataA=nullptr;
|
||||
}
|
||||
if(this->dwOffsetC!=0)
|
||||
{
|
||||
this->OffsetDataA= new SKIN_OFFSET [this->dwOffsetC];
|
||||
vector<SKIN_OFFSET *> *pSkinOffsets=pDLCSkinFile->getOffsets();
|
||||
int iCount=0;
|
||||
|
||||
for(auto& pSkinOffset : *pSkinOffsets)
|
||||
{
|
||||
this->OffsetDataA[iCount++]=*pSkinOffset;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this->OffsetDataA=nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes,vector<SKIN_BOX *> *pvSkinBoxes, unsigned int uiAnimOverrideBitmask)
|
||||
TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes, vector<SKIN_BOX *> *pvSkinBoxes, unsigned int uiAnimOverrideBitmask)
|
||||
{
|
||||
this->textureName = textureName;
|
||||
|
||||
@@ -112,6 +132,55 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, P
|
||||
|
||||
}
|
||||
|
||||
TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes, vector<SKIN_BOX *> *pvSkinBoxes, vector<SKIN_OFFSET *> *pvSkinOffsets, unsigned int uiAnimOverrideBitmask)
|
||||
{
|
||||
this->textureName = textureName;
|
||||
|
||||
wstring skinValue = textureName.substr(7,textureName.size());
|
||||
skinValue = skinValue.substr(0,skinValue.find_first_of(L'.'));
|
||||
std::wstringstream ss;
|
||||
ss << std::dec << skinValue.c_str();
|
||||
ss >> this->dwSkinID;
|
||||
this->dwSkinID = MAKE_SKIN_BITMASK(true, this->dwSkinID);
|
||||
|
||||
this->pbData = pbData;
|
||||
this->dwTextureBytes = dwBytes;
|
||||
this->uiAnimOverrideBitmask = uiAnimOverrideBitmask;
|
||||
if(pvSkinBoxes==nullptr)
|
||||
{
|
||||
this->dwBoxC=0;
|
||||
this->BoxDataA=nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->dwBoxC = static_cast<DWORD>(pvSkinBoxes->size());
|
||||
this->BoxDataA= new SKIN_BOX [this->dwBoxC];
|
||||
int iCount=0;
|
||||
|
||||
for(auto& pSkinBox : *pvSkinBoxes)
|
||||
{
|
||||
this->BoxDataA[iCount++]=*pSkinBox;
|
||||
}
|
||||
}
|
||||
if(pvSkinOffsets==nullptr)
|
||||
{
|
||||
this->dwOffsetC=0;
|
||||
this->OffsetDataA=nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->dwOffsetC = static_cast<DWORD>(pvSkinOffsets->size());
|
||||
this->OffsetDataA= new SKIN_OFFSET [this->dwOffsetC];
|
||||
int iCount=0;
|
||||
|
||||
for(auto& pSkinOffset : *pvSkinOffsets)
|
||||
{
|
||||
this->OffsetDataA[iCount++]=*pSkinOffset;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TextureAndGeometryPacket::handle(PacketListener *listener)
|
||||
{
|
||||
listener->handleTextureAndGeometry(shared_from_this());
|
||||
@@ -148,6 +217,7 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException
|
||||
uiAnimOverrideBitmask = dis->readInt();
|
||||
|
||||
short rawBoxC = dis->readShort();
|
||||
short rawOffsetC = dis->readShort();
|
||||
if (rawBoxC <= 0)
|
||||
{
|
||||
dwBoxC = 0;
|
||||
@@ -160,11 +230,27 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException
|
||||
dwBoxC = 0; // sane limit for skin boxes
|
||||
}
|
||||
}
|
||||
if (rawOffsetC <= 0)
|
||||
{
|
||||
dwOffsetC = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dwOffsetC = (DWORD)(unsigned short)rawOffsetC;
|
||||
if (dwOffsetC > 256)
|
||||
{
|
||||
dwOffsetC = 0; // sane limit for skin offsets
|
||||
}
|
||||
}
|
||||
|
||||
if(dwBoxC>0)
|
||||
{
|
||||
this->BoxDataA= new SKIN_BOX [dwBoxC];
|
||||
}
|
||||
if(dwOffsetC>0)
|
||||
{
|
||||
this->OffsetDataA= new SKIN_OFFSET [dwOffsetC];
|
||||
}
|
||||
|
||||
for(DWORD i=0;i<dwBoxC;i++)
|
||||
{
|
||||
@@ -177,6 +263,14 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException
|
||||
this->BoxDataA[i].fD = dis->readFloat();
|
||||
this->BoxDataA[i].fU = dis->readFloat();
|
||||
this->BoxDataA[i].fV = dis->readFloat();
|
||||
this->BoxDataA[i].fA = dis->readFloat();
|
||||
this->BoxDataA[i].fM = dis->readFloat();
|
||||
}
|
||||
for(DWORD i=0;i<dwOffsetC;i++)
|
||||
{
|
||||
this->OffsetDataA[i].ePart = static_cast<eBodyOffset>(dis->readShort());
|
||||
this->OffsetDataA[i].fD = dis->readChar();
|
||||
this->OffsetDataA[i].fO = dis->readFloat();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,6 +297,16 @@ void TextureAndGeometryPacket::write(DataOutputStream *dos) //throws IOException
|
||||
dos->writeFloat(this->BoxDataA[i].fD);
|
||||
dos->writeFloat(this->BoxDataA[i].fU);
|
||||
dos->writeFloat(this->BoxDataA[i].fV);
|
||||
dos->writeFloat(this->BoxDataA[i].fA);
|
||||
dos->writeFloat(this->BoxDataA[i].fM);
|
||||
}
|
||||
|
||||
dos->writeShort(static_cast<short>(dwOffsetC));
|
||||
for(DWORD i=0;i<dwOffsetC;i++)
|
||||
{
|
||||
dos->writeShort(static_cast<short>(this->OffsetDataA[i].ePart));
|
||||
dos->writeChar(this->OffsetDataA[i].fD);
|
||||
dos->writeFloat(this->OffsetDataA[i].fO);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user