Use sizeof(type) instead of sizeof(variableName) when (de)serializing data (#1505)

* Use sizeof(type) instead of sizeof(variableName) when (de)serializing data

* Less usage of sizeof(variableName) while (de)serializing
This commit is contained in:
Anonymous Maarten
2025-05-18 22:56:28 +02:00
committed by GitHub
parent c9b41e2db8
commit 2915aa014f
27 changed files with 227 additions and 234 deletions

View File

@@ -31,7 +31,7 @@ LegoResult LegoUnknownKey::Read(LegoStorage* p_storage)
return result;
}
if ((result = p_storage->Read(&m_z, sizeof(m_z))) != SUCCESS) {
if ((result = p_storage->Read(&m_z, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
@@ -48,7 +48,7 @@ LegoResult LegoUnknownKey::Write(LegoStorage* p_storage)
return result;
}
if ((result = p_storage->Write(&m_z, sizeof(m_z))) != SUCCESS) {
if ((result = p_storage->Write(&m_z, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
@@ -95,7 +95,7 @@ LegoResult LegoAnimScene::Write(LegoStorage* p_storage)
LegoResult result;
LegoS32 i;
if ((result = p_storage->Write(&m_unk0x00, sizeof(m_unk0x00))) != SUCCESS) {
if ((result = p_storage->Write(&m_unk0x00, sizeof(LegoU16))) != SUCCESS) {
return result;
}
if (m_unk0x00 != 0) {
@@ -106,7 +106,7 @@ LegoResult LegoAnimScene::Write(LegoStorage* p_storage)
}
}
if ((result = p_storage->Write(&m_unk0x08, sizeof(m_unk0x08))) != SUCCESS) {
if ((result = p_storage->Write(&m_unk0x08, sizeof(LegoU16))) != SUCCESS) {
return result;
}
if (m_unk0x08 != 0) {
@@ -117,7 +117,7 @@ LegoResult LegoAnimScene::Write(LegoStorage* p_storage)
}
}
if ((result = p_storage->Write(&m_unk0x10, sizeof(m_unk0x10))) != SUCCESS) {
if ((result = p_storage->Write(&m_unk0x10, sizeof(LegoU16))) != SUCCESS) {
return result;
}
if (m_unk0x10 != 0) {
@@ -137,7 +137,7 @@ LegoResult LegoAnimScene::Read(LegoStorage* p_storage)
LegoResult result;
LegoS32 i;
if ((result = p_storage->Read(&m_unk0x00, sizeof(m_unk0x00))) != SUCCESS) {
if ((result = p_storage->Read(&m_unk0x00, sizeof(LegoU16))) != SUCCESS) {
return result;
}
if (m_unk0x00 != 0) {
@@ -149,7 +149,7 @@ LegoResult LegoAnimScene::Read(LegoStorage* p_storage)
}
}
if ((result = p_storage->Read(&m_unk0x08, sizeof(m_unk0x08))) != SUCCESS) {
if ((result = p_storage->Read(&m_unk0x08, sizeof(LegoU16))) != SUCCESS) {
return result;
}
if (m_unk0x08 != 0) {
@@ -161,7 +161,7 @@ LegoResult LegoAnimScene::Read(LegoStorage* p_storage)
}
}
if ((result = p_storage->Read(&m_unk0x10, sizeof(m_unk0x10))) != SUCCESS) {
if ((result = p_storage->Read(&m_unk0x10, sizeof(LegoU16))) != SUCCESS) {
return result;
}
if (m_unk0x10 != 0) {
@@ -295,7 +295,7 @@ LegoResult LegoAnimKey::Read(LegoStorage* p_storage)
LegoResult result;
LegoS32 timeAndFlags;
if ((result = p_storage->Read(&timeAndFlags, sizeof(timeAndFlags))) != SUCCESS) {
if ((result = p_storage->Read(&timeAndFlags, sizeof(LegoS32))) != SUCCESS) {
return result;
}
@@ -311,7 +311,7 @@ LegoResult LegoAnimKey::Write(LegoStorage* p_storage)
LegoResult result;
LegoS32 timeAndFlags = (LegoS32) m_time | (m_flags << 24);
if ((result = p_storage->Write(&timeAndFlags, sizeof(timeAndFlags))) != SUCCESS) {
if ((result = p_storage->Write(&timeAndFlags, sizeof(LegoS32))) != SUCCESS) {
return result;
}
@@ -335,15 +335,15 @@ LegoResult LegoTranslationKey::Read(LegoStorage* p_storage)
return result;
}
if ((result = p_storage->Read(&m_x, sizeof(m_x))) != SUCCESS) {
if ((result = p_storage->Read(&m_x, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_y, sizeof(m_y))) != SUCCESS) {
if ((result = p_storage->Read(&m_y, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_z, sizeof(m_z))) != SUCCESS) {
if ((result = p_storage->Read(&m_z, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
@@ -364,15 +364,15 @@ LegoResult LegoTranslationKey::Write(LegoStorage* p_storage)
return result;
}
if ((result = p_storage->Write(&m_x, sizeof(m_x))) != SUCCESS) {
if ((result = p_storage->Write(&m_x, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_y, sizeof(m_y))) != SUCCESS) {
if ((result = p_storage->Write(&m_y, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_z, sizeof(m_z))) != SUCCESS) {
if ((result = p_storage->Write(&m_z, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
@@ -398,19 +398,19 @@ LegoResult LegoRotationKey::Read(LegoStorage* p_storage)
return result;
}
if ((result = p_storage->Read(&m_angle, sizeof(m_angle))) != SUCCESS) {
if ((result = p_storage->Read(&m_angle, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_x, sizeof(m_x))) != SUCCESS) {
if ((result = p_storage->Read(&m_x, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_y, sizeof(m_y))) != SUCCESS) {
if ((result = p_storage->Read(&m_y, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_z, sizeof(m_z))) != SUCCESS) {
if ((result = p_storage->Read(&m_z, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
@@ -435,15 +435,15 @@ LegoResult LegoRotationKey::Write(LegoStorage* p_storage)
return result;
}
if ((result = p_storage->Write(&m_x, sizeof(m_x))) != SUCCESS) {
if ((result = p_storage->Write(&m_x, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_y, sizeof(m_y))) != SUCCESS) {
if ((result = p_storage->Write(&m_y, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_z, sizeof(m_z))) != SUCCESS) {
if ((result = p_storage->Write(&m_z, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
@@ -467,15 +467,15 @@ LegoResult LegoScaleKey::Read(LegoStorage* p_storage)
return result;
}
if ((result = p_storage->Read(&m_x, sizeof(m_x))) != SUCCESS) {
if ((result = p_storage->Read(&m_x, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_y, sizeof(m_y))) != SUCCESS) {
if ((result = p_storage->Read(&m_y, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_z, sizeof(m_z))) != SUCCESS) {
if ((result = p_storage->Read(&m_z, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
@@ -496,15 +496,15 @@ LegoResult LegoScaleKey::Write(LegoStorage* p_storage)
return result;
}
if ((result = p_storage->Write(&m_x, sizeof(m_x))) != SUCCESS) {
if ((result = p_storage->Write(&m_x, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_y, sizeof(m_y))) != SUCCESS) {
if ((result = p_storage->Write(&m_y, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_z, sizeof(m_z))) != SUCCESS) {
if ((result = p_storage->Write(&m_z, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
@@ -560,7 +560,7 @@ LegoResult LegoAnimNodeData::Read(LegoStorage* p_storage)
LegoResult result;
LegoU32 length;
if ((result = p_storage->Read(&length, sizeof(length))) != SUCCESS) {
if ((result = p_storage->Read(&length, sizeof(LegoU32))) != SUCCESS) {
return result;
}
@@ -578,7 +578,7 @@ LegoResult LegoAnimNodeData::Read(LegoStorage* p_storage)
LegoU32 i;
if ((result = p_storage->Read(&m_numTranslationKeys, sizeof(m_numTranslationKeys))) != SUCCESS) {
if ((result = p_storage->Read(&m_numTranslationKeys, sizeof(LegoU16))) != SUCCESS) {
return result;
}
if (m_translationKeys) {
@@ -594,7 +594,7 @@ LegoResult LegoAnimNodeData::Read(LegoStorage* p_storage)
}
}
if ((result = p_storage->Read(&m_numRotationKeys, sizeof(m_numRotationKeys))) != SUCCESS) {
if ((result = p_storage->Read(&m_numRotationKeys, sizeof(LegoU16))) != SUCCESS) {
return result;
}
if (m_rotationKeys) {
@@ -610,7 +610,7 @@ LegoResult LegoAnimNodeData::Read(LegoStorage* p_storage)
}
}
if ((result = p_storage->Read(&m_numScaleKeys, sizeof(m_numScaleKeys))) != SUCCESS) {
if ((result = p_storage->Read(&m_numScaleKeys, sizeof(LegoU16))) != SUCCESS) {
return result;
}
if (m_scaleKeys) {
@@ -626,7 +626,7 @@ LegoResult LegoAnimNodeData::Read(LegoStorage* p_storage)
}
}
if ((result = p_storage->Read(&m_numMorphKeys, sizeof(m_numMorphKeys))) != SUCCESS) {
if ((result = p_storage->Read(&m_numMorphKeys, sizeof(LegoU16))) != SUCCESS) {
return result;
}
if (m_morphKeys) {
@@ -665,7 +665,7 @@ LegoResult LegoAnimNodeData::Write(LegoStorage* p_storage)
return result;
}
if ((result = p_storage->Write(&m_numTranslationKeys, sizeof(m_numTranslationKeys))) != SUCCESS) {
if ((result = p_storage->Write(&m_numTranslationKeys, sizeof(LegoU16))) != SUCCESS) {
return result;
}
if (m_numTranslationKeys != 0) {
@@ -676,7 +676,7 @@ LegoResult LegoAnimNodeData::Write(LegoStorage* p_storage)
}
}
if ((result = p_storage->Write(&m_numRotationKeys, sizeof(m_numRotationKeys))) != SUCCESS) {
if ((result = p_storage->Write(&m_numRotationKeys, sizeof(LegoU16))) != SUCCESS) {
return result;
}
if (m_numRotationKeys != 0) {
@@ -687,7 +687,7 @@ LegoResult LegoAnimNodeData::Write(LegoStorage* p_storage)
}
}
if ((result = p_storage->Write(&m_numScaleKeys, sizeof(m_numScaleKeys))) != SUCCESS) {
if ((result = p_storage->Write(&m_numScaleKeys, sizeof(LegoU16))) != SUCCESS) {
return result;
}
if (m_numScaleKeys != 0) {
@@ -698,7 +698,7 @@ LegoResult LegoAnimNodeData::Write(LegoStorage* p_storage)
}
}
if ((result = p_storage->Write(&m_numMorphKeys, sizeof(m_numMorphKeys))) != SUCCESS) {
if ((result = p_storage->Write(&m_numMorphKeys, sizeof(LegoU16))) != SUCCESS) {
return result;
}
if (m_numMorphKeys != 0) {
@@ -1040,7 +1040,7 @@ LegoResult LegoAnim::Read(LegoStorage* p_storage, LegoS32 p_parseScene)
LegoResult result = FAILURE;
LegoU32 length, i;
if (p_storage->Read(&length, sizeof(length)) != SUCCESS) {
if (p_storage->Read(&length, sizeof(LegoU32)) != SUCCESS) {
goto done;
}
@@ -1049,7 +1049,7 @@ LegoResult LegoAnim::Read(LegoStorage* p_storage, LegoS32 p_parseScene)
for (i = 0; i < length; i++) {
LegoU32 length;
if (p_storage->Read(&length, sizeof(length)) != SUCCESS) {
if (p_storage->Read(&length, sizeof(LegoU32)) != SUCCESS) {
goto done;
}
@@ -1062,7 +1062,7 @@ LegoResult LegoAnim::Read(LegoStorage* p_storage, LegoS32 p_parseScene)
m_modelList[i].m_name[length] = '\0';
if (p_storage->Read(&m_modelList[i].m_unk0x04, sizeof(m_modelList[i].m_unk0x04)) != SUCCESS) {
if (p_storage->Read(&m_modelList[i].m_unk0x04, sizeof(undefined4)) != SUCCESS) {
goto done;
}
}
@@ -1070,7 +1070,7 @@ LegoResult LegoAnim::Read(LegoStorage* p_storage, LegoS32 p_parseScene)
m_numActors++;
}
if ((result = p_storage->Read(&m_duration, sizeof(m_duration))) != SUCCESS) {
if ((result = p_storage->Read(&m_duration, sizeof(LegoS32))) != SUCCESS) {
goto done;
}
@@ -1183,7 +1183,7 @@ LegoResult LegoMorphKey::Read(LegoStorage* p_storage)
return result;
}
if ((result = p_storage->Read(&m_unk0x08, sizeof(m_unk0x08))) != SUCCESS) {
if ((result = p_storage->Read(&m_unk0x08, sizeof(LegoU8))) != SUCCESS) {
return result;
}
@@ -1200,7 +1200,7 @@ LegoResult LegoMorphKey::Write(LegoStorage* p_storage)
return result;
}
if ((result = p_storage->Write(&m_unk0x08, sizeof(m_unk0x08))) != SUCCESS) {
if ((result = p_storage->Write(&m_unk0x08, sizeof(LegoU8))) != SUCCESS) {
return result;
}

View File

@@ -19,13 +19,13 @@ LegoPaletteEntry::LegoPaletteEntry()
LegoResult LegoPaletteEntry::Read(LegoStorage* p_storage)
{
LegoResult result;
if ((result = p_storage->Read(&m_red, sizeof(m_red))) != SUCCESS) {
if ((result = p_storage->Read(&m_red, sizeof(LegoU8))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_green, sizeof(m_green))) != SUCCESS) {
if ((result = p_storage->Read(&m_green, sizeof(LegoU8))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_blue, sizeof(m_blue))) != SUCCESS) {
if ((result = p_storage->Read(&m_blue, sizeof(LegoU8))) != SUCCESS) {
return result;
}
return SUCCESS;
@@ -35,13 +35,13 @@ LegoResult LegoPaletteEntry::Read(LegoStorage* p_storage)
LegoResult LegoPaletteEntry::Write(LegoStorage* p_storage)
{
LegoResult result;
if ((result = p_storage->Write(&m_red, sizeof(m_red))) != SUCCESS) {
if ((result = p_storage->Write(&m_red, sizeof(LegoU8))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_green, sizeof(m_green))) != SUCCESS) {
if ((result = p_storage->Write(&m_green, sizeof(LegoU8))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_blue, sizeof(m_blue))) != SUCCESS) {
if ((result = p_storage->Write(&m_blue, sizeof(LegoU8))) != SUCCESS) {
return result;
}
return SUCCESS;
@@ -77,13 +77,13 @@ LegoImage::~LegoImage()
LegoResult LegoImage::Read(LegoStorage* p_storage, LegoU32 p_square)
{
LegoResult result;
if ((result = p_storage->Read(&m_width, sizeof(m_width))) != SUCCESS) {
if ((result = p_storage->Read(&m_width, sizeof(LegoU32))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_height, sizeof(m_height))) != SUCCESS) {
if ((result = p_storage->Read(&m_height, sizeof(LegoU32))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_count, sizeof(m_height))) != SUCCESS) {
if ((result = p_storage->Read(&m_count, sizeof(LegoU32))) != SUCCESS) {
return result;
}
for (LegoU32 i = 0; i < m_count; i++) {
@@ -153,13 +153,13 @@ LegoResult LegoImage::Read(LegoStorage* p_storage, LegoU32 p_square)
LegoResult LegoImage::Write(LegoStorage* p_storage)
{
LegoResult result;
if ((result = p_storage->Write(&m_width, sizeof(m_width))) != SUCCESS) {
if ((result = p_storage->Write(&m_width, sizeof(LegoU32))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_height, sizeof(m_height))) != SUCCESS) {
if ((result = p_storage->Write(&m_height, sizeof(LegoU32))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_count, sizeof(m_height))) != SUCCESS) {
if ((result = p_storage->Write(&m_count, sizeof(LegoU32))) != SUCCESS) {
return result;
}
for (LegoU32 i = 0; i < m_count; i++) {

View File

@@ -45,21 +45,21 @@ public:
// FUNCTION: BETA10 0x1004b0d0
LegoStorage* WriteU8(LegoU8 p_data)
{
Write(&p_data, sizeof(p_data));
Write(&p_data, sizeof(LegoU8));
return this;
}
// FUNCTION: BETA10 0x10017ce0
LegoStorage* WriteS16(LegoS16 p_data)
{
Write(&p_data, sizeof(p_data));
Write(&p_data, sizeof(LegoS16));
return this;
}
// FUNCTION: BETA10 0x1004b110
LegoStorage* WriteU16(LegoU16 p_data)
{
Write(&p_data, sizeof(p_data));
Write(&p_data, sizeof(LegoU16));
return this;
}
@@ -67,7 +67,7 @@ public:
// FUNCTION: BETA10 0x10088540
LegoStorage* WriteS32(MxS32 p_data)
{
Write(&p_data, sizeof(p_data));
Write(&p_data, sizeof(MxS32));
return this;
}
@@ -75,14 +75,14 @@ public:
// FUNCTION: BETA10 0x1004b150
LegoStorage* WriteU32(MxU32 p_data)
{
Write(&p_data, sizeof(p_data));
Write(&p_data, sizeof(MxU32));
return this;
}
// FUNCTION: BETA10 0x10073610
LegoStorage* WriteFloat(LegoFloat p_data)
{
Write(&p_data, sizeof(p_data));
Write(&p_data, sizeof(LegoFloat));
return this;
}
@@ -116,21 +116,21 @@ public:
// FUNCTION: BETA10 0x1004b190
LegoStorage* ReadU8(LegoU8& p_data)
{
Read(&p_data, sizeof(p_data));
Read(&p_data, sizeof(LegoU8));
return this;
}
// FUNCTION: BETA10 0x10024680
LegoStorage* ReadS16(LegoS16& p_data)
{
Read(&p_data, sizeof(p_data));
Read(&p_data, sizeof(LegoS16));
return this;
}
// FUNCTION: BETA10 0x1004b1d0
LegoStorage* ReadU16(LegoU16& p_data)
{
Read(&p_data, sizeof(p_data));
Read(&p_data, sizeof(LegoU16));
return this;
}
@@ -138,7 +138,7 @@ public:
// FUNCTION: BETA10 0x10088580
LegoStorage* ReadS32(MxS32& p_data)
{
Read(&p_data, sizeof(p_data));
Read(&p_data, sizeof(MxS32));
return this;
}
@@ -146,14 +146,14 @@ public:
// FUNCTION: BETA10 0x1004b210
LegoStorage* ReadU32(MxU32& p_data)
{
Read(&p_data, sizeof(p_data));
Read(&p_data, sizeof(MxU32));
return this;
}
// FUNCTION: BETA10 0x10073650
LegoStorage* ReadFloat(LegoFloat& p_data)
{
Read(&p_data, sizeof(p_data));
Read(&p_data, sizeof(LegoFloat));
return this;
}

View File

@@ -64,7 +64,7 @@ LegoResult LegoTree::Read(LegoStorage* p_storage, LegoTreeNode*& p_node)
return result;
}
LegoU32 numChildren;
if ((result = p_storage->Read(&numChildren, sizeof(numChildren))) != SUCCESS) {
if ((result = p_storage->Read(&numChildren, sizeof(LegoU32))) != SUCCESS) {
return result;
}
if (numChildren) {
@@ -91,7 +91,7 @@ LegoResult LegoTree::Write(LegoStorage* p_storage, LegoTreeNode* p_node)
}
}
LegoU32 numChildren = p_node->GetNumChildren();
if ((result = p_storage->Write(&numChildren, sizeof(numChildren))) != SUCCESS) {
if ((result = p_storage->Write(&numChildren, sizeof(LegoU32))) != SUCCESS) {
return result;
}
for (LegoU32 i = 0; i < p_node->GetNumChildren(); i++) {

View File

@@ -69,7 +69,7 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text
LegoU32 i, meshUnd1, meshUnd2, tempNumVertsAndNormals;
unsigned char paletteEntries[256];
if (p_storage->Read(&m_unk0x08, sizeof(m_unk0x08)) != SUCCESS) {
if (p_storage->Read(&m_unk0x08, sizeof(undefined4)) != SUCCESS) {
goto done;
}
@@ -79,7 +79,7 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text
m_meshBuilder = p_renderer->CreateMeshBuilder();
if (p_storage->Read(&m_numMeshes, sizeof(m_numMeshes)) != SUCCESS) {
if (p_storage->Read(&m_numMeshes, sizeof(LegoU32)) != SUCCESS) {
goto done;
}
@@ -96,34 +96,34 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text
meshUnd1 = m_numMeshes - 1;
meshUnd2 = 0;
if (p_storage->Read(&tempNumVertsAndNormals, sizeof(tempNumVertsAndNormals)) != SUCCESS) {
if (p_storage->Read(&tempNumVertsAndNormals, sizeof(LegoU32)) != SUCCESS) {
goto done;
}
numVerts = *((LegoU16*) &tempNumVertsAndNormals) & MAXSHORT;
numNormals = (*((LegoU16*) &tempNumVertsAndNormals + 1) >> 1) & MAXSHORT;
if (p_storage->Read(&numTextureVertices, sizeof(numTextureVertices)) != SUCCESS) {
if (p_storage->Read(&numTextureVertices, sizeof(LegoS32)) != SUCCESS) {
goto done;
}
if (numVerts > 0) {
vertices = new float[numVerts][sizeOfArray(*vertices)];
if (p_storage->Read(vertices, numVerts * sizeof(*vertices)) != SUCCESS) {
if (p_storage->Read(vertices, numVerts * 3 * sizeof(float)) != SUCCESS) {
goto done;
}
}
if (numNormals > 0) {
normals = new float[numNormals][sizeOfArray(*normals)];
if (p_storage->Read(normals, numNormals * sizeof(*normals)) != SUCCESS) {
if (p_storage->Read(normals, numNormals * 3 * sizeof(float)) != SUCCESS) {
goto done;
}
}
if (numTextureVertices > 0) {
textureVertices = new float[numTextureVertices][sizeOfArray(*textureVertices)];
if (p_storage->Read(textureVertices, numTextureVertices * sizeof(*textureVertices)) != SUCCESS) {
if (p_storage->Read(textureVertices, numTextureVertices * 2 * sizeof(float)) != SUCCESS) {
goto done;
}
}
@@ -144,7 +144,7 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text
}
polyIndices = new LegoU32[numPolys & USHRT_MAX][sizeOfArray(*polyIndices)];
if (p_storage->Read(polyIndices, (numPolys & USHRT_MAX) * sizeof(*polyIndices)) != SUCCESS) {
if (p_storage->Read(polyIndices, (numPolys & USHRT_MAX) * 3 * sizeof(LegoU32)) != SUCCESS) {
goto done;
}
@@ -154,7 +154,7 @@ LegoResult LegoLOD::Read(Tgl::Renderer* p_renderer, LegoTextureContainer* p_text
if (numTextureIndices > 0) {
textureIndices = new LegoU32[numPolys & USHRT_MAX][sizeOfArray(*textureIndices)];
if (p_storage->Read(textureIndices, (numPolys & USHRT_MAX) * sizeof(*textureIndices)) != SUCCESS) {
if (p_storage->Read(textureIndices, (numPolys & USHRT_MAX) * 3 * sizeof(LegoU32)) != SUCCESS) {
goto done;
}
}

View File

@@ -128,7 +128,7 @@ LegoResult LegoROI::Read(
m_parentROI = p_unk0xd4;
if (p_storage->Read(&length, sizeof(length)) != SUCCESS) {
if (p_storage->Read(&length, sizeof(LegoU32)) != SUCCESS) {
goto done;
}
m_name = new LegoChar[length + 1];
@@ -153,7 +153,7 @@ LegoResult LegoROI::Read(
SET3(m_unk0x80.Min(), box.GetMin());
SET3(m_unk0x80.Max(), box.GetMax());
if (p_storage->Read(&length, sizeof(length)) != SUCCESS) {
if (p_storage->Read(&length, sizeof(LegoU32)) != SUCCESS) {
goto done;
}
@@ -169,7 +169,7 @@ LegoResult LegoROI::Read(
textureName = NULL;
}
if (p_storage->Read(&m_unk0x100, sizeof(m_unk0x100)) != SUCCESS) {
if (p_storage->Read(&m_unk0x100, sizeof(undefined)) != SUCCESS) {
goto done;
}
@@ -192,7 +192,7 @@ LegoResult LegoROI::Read(
}
}
else {
if (p_storage->Read(&numLODs, sizeof(numLODs)) != SUCCESS) {
if (p_storage->Read(&numLODs, sizeof(LegoU32)) != SUCCESS) {
goto done;
}
@@ -203,7 +203,7 @@ LegoResult LegoROI::Read(
const LegoChar* roiName = m_name;
LegoU32 offset;
if (p_storage->Read(&offset, sizeof(offset)) != SUCCESS) {
if (p_storage->Read(&offset, sizeof(LegoU32)) != SUCCESS) {
goto done;
}
@@ -312,7 +312,7 @@ LegoResult LegoROI::Read(
}
}
if (p_storage->Read(&numROIs, sizeof(numROIs)) != SUCCESS) {
if (p_storage->Read(&numROIs, sizeof(LegoU32)) != SUCCESS) {
goto done;
}

View File

@@ -9,13 +9,13 @@ DECOMP_SIZE_ASSERT(LegoColor, 0x03)
LegoResult LegoColor::Read(LegoStorage* p_storage)
{
LegoResult result;
if ((result = p_storage->Read(&m_red, sizeof(m_red))) != SUCCESS) {
if ((result = p_storage->Read(&m_red, sizeof(LegoU8))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_green, sizeof(m_green))) != SUCCESS) {
if ((result = p_storage->Read(&m_green, sizeof(LegoU8))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_blue, sizeof(m_blue))) != SUCCESS) {
if ((result = p_storage->Read(&m_blue, sizeof(LegoU8))) != SUCCESS) {
return result;
}
return SUCCESS;

View File

@@ -43,23 +43,23 @@ LegoResult LegoMesh::Read(LegoStorage* p_storage)
if ((result = m_color.Read(p_storage)) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_alpha, sizeof(m_alpha))) != SUCCESS) {
if ((result = p_storage->Read(&m_alpha, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_shading, sizeof(m_shading))) != SUCCESS) {
if ((result = p_storage->Read(&m_shading, sizeof(LegoU8))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_unk0x0d, sizeof(m_unk0x0d))) != SUCCESS) {
if ((result = p_storage->Read(&m_unk0x0d, sizeof(LegoU8))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_unk0x20, sizeof(m_unk0x20))) != SUCCESS) {
if ((result = p_storage->Read(&m_unk0x20, sizeof(undefined))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_unk0x21, sizeof(m_unk0x21))) != SUCCESS) {
if ((result = p_storage->Read(&m_unk0x21, sizeof(LegoU8))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&textureLength, sizeof(textureLength))) != SUCCESS) {
if ((result = p_storage->Read(&textureLength, sizeof(LegoU32))) != SUCCESS) {
return result;
}
if (textureLength) {
@@ -73,7 +73,7 @@ LegoResult LegoMesh::Read(LegoStorage* p_storage)
strlwr(m_textureName);
}
if ((result = p_storage->Read(&materialLength, sizeof(materialLength))) != SUCCESS) {
if ((result = p_storage->Read(&materialLength, sizeof(LegoU32))) != SUCCESS) {
return result;
}
if (materialLength) {

View File

@@ -12,7 +12,7 @@ LegoResult LegoSphere::Read(LegoStorage* p_storage)
if ((result = m_center.Read(p_storage)) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_radius, sizeof(m_radius))) != SUCCESS) {
if ((result = p_storage->Read(&m_radius, sizeof(LegoFloat))) != SUCCESS) {
return result;
}
return SUCCESS;

View File

@@ -17,13 +17,13 @@ LegoVertex::LegoVertex()
LegoResult LegoVertex::Read(LegoStorage* p_storage)
{
LegoResult result;
if ((result = p_storage->Read(&m_coordinates[0], sizeof(m_coordinates[0]))) != SUCCESS) {
if ((result = p_storage->Read(&m_coordinates[0], sizeof(LegoFloat))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_coordinates[1], sizeof(m_coordinates[1]))) != SUCCESS) {
if ((result = p_storage->Read(&m_coordinates[1], sizeof(LegoFloat))) != SUCCESS) {
return result;
}
if ((result = p_storage->Read(&m_coordinates[2], sizeof(m_coordinates[2]))) != SUCCESS) {
if ((result = p_storage->Read(&m_coordinates[2], sizeof(LegoFloat))) != SUCCESS) {
return result;
}
return SUCCESS;