commitb40530fa5eAuthor: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Wed Apr 15 19:59:46 2026 -0700 Implemented skin offsets in UI Added code to render skin offsets in the skin select UI. commita8384d9840Author: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Wed Apr 15 19:38:08 2026 -0700 Partially implemented offsets Added code that visually shifts the player's model parts, but only in game not in the skin select UI. commit875100cf9aAuthor: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Wed Apr 15 16:48:03 2026 -0700 Minor change Simplified redundant conditions in HumanoidModel.cpp commit96f683d1fbMerge:db685a7424c74aa2Author: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Tue Apr 14 16:37:30 2026 -0700 Merge branch 'feat/64x64-skins' into feat/skin-offsets commitdb685a74f3Author: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Tue Apr 14 15:35:38 2026 -0700 Fixed skin offset data Fixed skin offsets so they now return the actual data instead of the defaults, added a few minor tweaks, and added code in PlayerRenderer.cpp to access offsets (Can read the offsets but can not apply them). commitaa769d54adAuthor: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Sat Apr 11 19:36:52 2026 -0700 Fixed crashes Fixed code for offsets preventing crashes. The amount of offsets is correctly obtain, but lacks the actual data. commitf18ac12cc0Merge:8e76763afd2fd659Author: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Fri Apr 10 16:06:57 2026 -0700 Merge branch 'feat/64x64-skins' into feat/skin-offsets commit8e76763a3dAuthor: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Tue Apr 7 16:50:43 2026 -0700 Made more changes Made more changes in files to support skin offsets. The game still crashes when trying to load skins. commit1a8f353297Merge:a1d9ae59bb5fa506Author: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Tue Apr 7 13:12:39 2026 -0700 Merge branch 'feat/64x64-skins' into feat/skin-offsets commita1d9ae591aAuthor: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Fri Apr 3 21:50:42 2026 -0700 Added small additions Added more code referencing skin offsets. Still doesn't work correctly. commitd28a751d9cMerge:3888de7a8bf03435Author: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Thu Apr 2 17:09:08 2026 -0700 Merge branch 'smartcmd:main' into feat/skin-offsets commit3888de7ab4Author: Langtanium <94726057+Langtanium@users.noreply.github.com> Date: Thu Apr 2 17:07:48 2026 -0700 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.
286 lines
7.1 KiB
C++
286 lines
7.1 KiB
C++
#include "stdafx.h"
|
|
#include <iostream>
|
|
#include "InputOutputStream.h"
|
|
#include "PacketListener.h"
|
|
#include "TextureAndGeometryPacket.h"
|
|
|
|
|
|
|
|
TextureAndGeometryPacket::TextureAndGeometryPacket()
|
|
{
|
|
this->textureName = L"";
|
|
this->dwTextureBytes = 0;
|
|
this->pbData = nullptr;
|
|
this->dwBoxC = 0;
|
|
this->dwOffsetC = 0;
|
|
this->BoxDataA = nullptr;
|
|
this->OffsetDataA = nullptr;
|
|
uiAnimOverrideBitmask=0;
|
|
}
|
|
|
|
TextureAndGeometryPacket::~TextureAndGeometryPacket()
|
|
{
|
|
// can't free these - they're used elsewhere
|
|
// if(this->BoxDataA!=nullptr)
|
|
// {
|
|
// delete [] this->BoxDataA;
|
|
// }
|
|
//
|
|
// if(this->pbData!=nullptr)
|
|
// {
|
|
// delete [] this->pbData;
|
|
// }
|
|
}
|
|
|
|
TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes)
|
|
{
|
|
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->dwBoxC = 0;
|
|
this->dwOffsetC = 0;
|
|
this->BoxDataA=nullptr;
|
|
this->OffsetDataA=nullptr;
|
|
this->uiAnimOverrideBitmask=0;
|
|
}
|
|
|
|
TextureAndGeometryPacket::TextureAndGeometryPacket(const wstring &textureName, PBYTE pbData, DWORD dwBytes, DLCSkinFile *pDLCSkinFile)
|
|
{
|
|
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 = pDLCSkinFile->getAnimOverrideBitmask();
|
|
this->dwBoxC = pDLCSkinFile->getAdditionalBoxesCount();
|
|
this->dwOffsetC = pDLCSkinFile->getOffsetsCount();
|
|
if(this->dwBoxC!=0)
|
|
{
|
|
this->BoxDataA= new SKIN_BOX [this->dwBoxC];
|
|
vector<SKIN_BOX *> *pSkinBoxes=pDLCSkinFile->getAdditionalBoxes();
|
|
int iCount=0;
|
|
|
|
for(auto& pSkinBox : *pSkinBoxes)
|
|
{
|
|
this->BoxDataA[iCount++]=*pSkinBox;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
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, 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());
|
|
}
|
|
|
|
void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException
|
|
{
|
|
textureName = dis->readUTF();
|
|
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)
|
|
{
|
|
this->pbData= new BYTE [dwTextureBytes];
|
|
|
|
for(DWORD i=0;i<dwTextureBytes;i++)
|
|
{
|
|
this->pbData[i] = dis->readByte();
|
|
}
|
|
}
|
|
uiAnimOverrideBitmask = dis->readInt();
|
|
|
|
short rawBoxC = dis->readShort();
|
|
short rawOffsetC = dis->readShort();
|
|
if (rawBoxC <= 0)
|
|
{
|
|
dwBoxC = 0;
|
|
}
|
|
else
|
|
{
|
|
dwBoxC = (DWORD)(unsigned short)rawBoxC;
|
|
if (dwBoxC > 256)
|
|
{
|
|
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++)
|
|
{
|
|
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();
|
|
this->BoxDataA[i].fH = dis->readFloat();
|
|
this->BoxDataA[i].fW = dis->readFloat();
|
|
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();
|
|
this->BoxDataA[i].fS = dis->readFloat();
|
|
}
|
|
for(DWORD i=0;i<dwOffsetC;i++)
|
|
{
|
|
this->OffsetDataA[i].ePart = static_cast<eBodyOffset>(dis->readShort());
|
|
this->OffsetDataA[i].fD = dis->readFloat();
|
|
this->OffsetDataA[i].fO = dis->readFloat();
|
|
}
|
|
}
|
|
|
|
void TextureAndGeometryPacket::write(DataOutputStream *dos) //throws IOException
|
|
{
|
|
dos->writeUTF(textureName);
|
|
dos->writeInt(dwSkinID);
|
|
dos->writeShort(static_cast<short>(dwTextureBytes));
|
|
for(DWORD i=0;i<dwTextureBytes;i++)
|
|
{
|
|
dos->writeByte(this->pbData[i]);
|
|
}
|
|
dos->writeInt(uiAnimOverrideBitmask);
|
|
|
|
dos->writeShort(static_cast<short>(dwBoxC));
|
|
for(DWORD i=0;i<dwBoxC;i++)
|
|
{
|
|
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);
|
|
dos->writeFloat(this->BoxDataA[i].fH);
|
|
dos->writeFloat(this->BoxDataA[i].fW);
|
|
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->writeFloat(this->BoxDataA[i].fS);
|
|
}
|
|
|
|
dos->writeShort(static_cast<short>(dwOffsetC));
|
|
for(DWORD i=0;i<dwOffsetC;i++)
|
|
{
|
|
dos->writeShort(static_cast<short>(this->OffsetDataA[i].ePart));
|
|
dos->writeFloat(this->OffsetDataA[i].fD);
|
|
dos->writeFloat(this->OffsetDataA[i].fO);
|
|
}
|
|
}
|
|
|
|
int TextureAndGeometryPacket::getEstimatedSize()
|
|
{
|
|
return 4096+ +sizeof(int) + sizeof(float)*8*4;
|
|
}
|