From 2915aa014f718357b8aa6272ff7f41a194ac7f0a Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sun, 18 May 2025 22:56:28 +0200 Subject: [PATCH] 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 --- .../src/common/legoanimationmanager.cpp | 34 +++---- .../src/common/legobuildingmanager.cpp | 18 ++-- .../src/common/legocharactermanager.cpp | 29 +++--- .../legoomni/src/common/legogamestate.cpp | 4 +- .../legoomni/src/common/legoplantmanager.cpp | 12 +-- .../src/entity/legoworldpresenter.cpp | 4 +- .../legoomni/src/paths/legopathcontroller.cpp | 32 +++---- .../legoomni/src/video/legoanimpresenter.cpp | 14 +-- .../legoomni/src/video/legomodelpresenter.cpp | 12 +-- .../src/video/legopalettepresenter.cpp | 4 +- .../legoomni/src/video/legopartpresenter.cpp | 14 +-- .../src/video/legotexturepresenter.cpp | 4 +- LEGO1/lego/sources/anim/legoanim.cpp | 88 +++++++++---------- LEGO1/lego/sources/misc/legoimage.cpp | 24 ++--- LEGO1/lego/sources/misc/legostorage.h | 24 ++--- LEGO1/lego/sources/misc/legotree.cpp | 4 +- LEGO1/lego/sources/roi/legolod.cpp | 18 ++-- LEGO1/lego/sources/roi/legoroi.cpp | 12 +-- LEGO1/lego/sources/shape/legocolor.cpp | 6 +- LEGO1/lego/sources/shape/legomesh.cpp | 14 +-- LEGO1/lego/sources/shape/legosphere.cpp | 2 +- LEGO1/lego/sources/shape/legovertex.cpp | 6 +- LEGO1/modeldb/modeldb.cpp | 28 +++--- LEGO1/omni/src/action/mxdsaction.cpp | 18 ++-- LEGO1/omni/src/action/mxdsmediaaction.cpp | 24 ++--- LEGO1/omni/src/stream/mxstreamchunk.cpp | 8 +- LEGO1/omni/src/video/mxbitmap.cpp | 4 +- 27 files changed, 227 insertions(+), 234 deletions(-) diff --git a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp index 2e1c4466..5629919b 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp @@ -658,7 +658,7 @@ MxResult LegoAnimationManager::LoadWorldInfo(LegoOmni::World p_worldId) } MxU32 version; - if (storage.Read(&version, sizeof(version)) == FAILURE) { + if (storage.Read(&version, sizeof(MxU32)) == FAILURE) { goto done; } @@ -667,7 +667,7 @@ MxResult LegoAnimationManager::LoadWorldInfo(LegoOmni::World p_worldId) goto done; } - if (storage.Read(&m_animCount, sizeof(m_animCount)) == FAILURE) { + if (storage.Read(&m_animCount, sizeof(MxU16)) == FAILURE) { goto done; } @@ -760,7 +760,7 @@ MxResult LegoAnimationManager::ReadAnimInfo(LegoStorage* p_storage, AnimInfo* p_ MxU8 length; MxS32 i, j; - if (p_storage->Read(&length, sizeof(length)) == FAILURE) { + if (p_storage->Read(&length, sizeof(MxU8)) == FAILURE) { goto done; } @@ -770,33 +770,33 @@ MxResult LegoAnimationManager::ReadAnimInfo(LegoStorage* p_storage, AnimInfo* p_ } p_info->m_name[length] = 0; - if (p_storage->Read(&p_info->m_objectId, sizeof(p_info->m_objectId)) == FAILURE) { + if (p_storage->Read(&p_info->m_objectId, sizeof(MxU32)) == FAILURE) { goto done; } - if (p_storage->Read(&p_info->m_location, sizeof(p_info->m_location)) == FAILURE) { + if (p_storage->Read(&p_info->m_location, sizeof(MxS16)) == FAILURE) { goto done; } - if (p_storage->Read(&p_info->m_unk0x0a, sizeof(p_info->m_unk0x0a)) == FAILURE) { + if (p_storage->Read(&p_info->m_unk0x0a, sizeof(MxU8)) == FAILURE) { goto done; } - if (p_storage->Read(&p_info->m_unk0x0b, sizeof(p_info->m_unk0x0b)) == FAILURE) { + if (p_storage->Read(&p_info->m_unk0x0b, sizeof(MxU8)) == FAILURE) { goto done; } - if (p_storage->Read(&p_info->m_unk0x0c, sizeof(p_info->m_unk0x0c)) == FAILURE) { + if (p_storage->Read(&p_info->m_unk0x0c, sizeof(MxU8)) == FAILURE) { goto done; } - if (p_storage->Read(&p_info->m_unk0x0d, sizeof(p_info->m_unk0x0d)) == FAILURE) { + if (p_storage->Read(&p_info->m_unk0x0d, sizeof(MxU8)) == FAILURE) { goto done; } for (i = 0; i < (MxS32) sizeOfArray(p_info->m_unk0x10); i++) { - if (p_storage->Read(&p_info->m_unk0x10[i], sizeof(*p_info->m_unk0x10)) != SUCCESS) { + if (p_storage->Read(&p_info->m_unk0x10[i], sizeof(float)) != SUCCESS) { goto done; } } - if (p_storage->Read(&p_info->m_modelCount, sizeof(p_info->m_modelCount)) == FAILURE) { + if (p_storage->Read(&p_info->m_modelCount, sizeof(MxU8)) == FAILURE) { goto done; } @@ -821,7 +821,7 @@ MxResult LegoAnimationManager::ReadModelInfo(LegoStorage* p_storage, ModelInfo* MxResult result = FAILURE; MxU8 length; - if (p_storage->Read(&length, 1) == FAILURE) { + if (p_storage->Read(&length, sizeof(MxU8)) == FAILURE) { goto done; } @@ -831,20 +831,20 @@ MxResult LegoAnimationManager::ReadModelInfo(LegoStorage* p_storage, ModelInfo* } p_info->m_name[length] = 0; - if (p_storage->Read(&p_info->m_unk0x04, sizeof(p_info->m_unk0x04)) == FAILURE) { + if (p_storage->Read(&p_info->m_unk0x04, sizeof(MxU8)) == FAILURE) { goto done; } - if (p_storage->Read(p_info->m_location, sizeof(p_info->m_location)) != SUCCESS) { + if (p_storage->Read(p_info->m_location, 3 * sizeof(float)) != SUCCESS) { goto done; } - if (p_storage->Read(p_info->m_direction, sizeof(p_info->m_direction)) != SUCCESS) { + if (p_storage->Read(p_info->m_direction, 3 * sizeof(float)) != SUCCESS) { goto done; } - if (p_storage->Read(p_info->m_up, sizeof(p_info->m_up)) != SUCCESS) { + if (p_storage->Read(p_info->m_up, 3 * sizeof(float)) != SUCCESS) { goto done; } - if (p_storage->Read(&p_info->m_unk0x2c, sizeof(p_info->m_unk0x2c)) == FAILURE) { + if (p_storage->Read(&p_info->m_unk0x2c, sizeof(MxU8)) == FAILURE) { goto done; } diff --git a/LEGO1/lego/legoomni/src/common/legobuildingmanager.cpp b/LEGO1/lego/legoomni/src/common/legobuildingmanager.cpp index fa6f83ef..dd76ba5e 100644 --- a/LEGO1/lego/legoomni/src/common/legobuildingmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legobuildingmanager.cpp @@ -334,21 +334,21 @@ MxResult LegoBuildingManager::Write(LegoStorage* p_storage) for (MxS32 i = 0; i < sizeOfArray(g_buildingInfo); i++) { LegoBuildingInfo* info = &g_buildingInfo[i]; - if (p_storage->Write(&info->m_sound, sizeof(info->m_sound)) != SUCCESS) { + if (p_storage->Write(&info->m_sound, sizeof(MxU32)) != SUCCESS) { goto done; } - if (p_storage->Write(&info->m_move, sizeof(info->m_move)) != SUCCESS) { + if (p_storage->Write(&info->m_move, sizeof(MxU32)) != SUCCESS) { goto done; } - if (p_storage->Write(&info->m_mood, sizeof(info->m_mood)) != SUCCESS) { + if (p_storage->Write(&info->m_mood, sizeof(MxU8)) != SUCCESS) { goto done; } - if (p_storage->Write(&info->m_initialUnk0x11, sizeof(info->m_initialUnk0x11)) != SUCCESS) { + if (p_storage->Write(&info->m_initialUnk0x11, sizeof(MxS8)) != SUCCESS) { goto done; } } - if (p_storage->Write(&m_nextVariant, sizeof(m_nextVariant)) != SUCCESS) { + if (p_storage->Write(&m_nextVariant, sizeof(MxU8)) != SUCCESS) { goto done; } @@ -367,16 +367,16 @@ MxResult LegoBuildingManager::Read(LegoStorage* p_storage) for (MxS32 i = 0; i < sizeOfArray(g_buildingInfo); i++) { LegoBuildingInfo* info = &g_buildingInfo[i]; - if (p_storage->Read(&info->m_sound, sizeof(info->m_sound)) != SUCCESS) { + if (p_storage->Read(&info->m_sound, sizeof(MxU32)) != SUCCESS) { goto done; } - if (p_storage->Read(&info->m_move, sizeof(info->m_move)) != SUCCESS) { + if (p_storage->Read(&info->m_move, sizeof(MxU32)) != SUCCESS) { goto done; } - if (p_storage->Read(&info->m_mood, sizeof(info->m_mood)) != SUCCESS) { + if (p_storage->Read(&info->m_mood, sizeof(MxU8)) != SUCCESS) { goto done; } - if (p_storage->Read(&info->m_unk0x11, sizeof(info->m_unk0x11)) != SUCCESS) { + if (p_storage->Read(&info->m_unk0x11, sizeof(MxS8)) != SUCCESS) { goto done; } diff --git a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp index 3805ab5c..15e945e7 100644 --- a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp @@ -178,43 +178,34 @@ MxResult LegoCharacterManager::Read(LegoStorage* p_storage) for (MxS32 i = 0; i < sizeOfArray(g_actorInfo); i++) { LegoActorInfo* info = &g_actorInfo[i]; - if (p_storage->Read(&info->m_sound, sizeof(info->m_sound)) != SUCCESS) { + if (p_storage->Read(&info->m_sound, sizeof(MxS32)) != SUCCESS) { goto done; } - if (p_storage->Read(&info->m_move, sizeof(info->m_move)) != SUCCESS) { + if (p_storage->Read(&info->m_move, sizeof(MxS32)) != SUCCESS) { goto done; } - if (p_storage->Read(&info->m_mood, sizeof(info->m_mood)) != SUCCESS) { + if (p_storage->Read(&info->m_mood, sizeof(MxU8)) != SUCCESS) { goto done; } - if (p_storage->Read(&info->m_parts[c_infohatPart].m_unk0x08, sizeof(info->m_parts[c_infohatPart].m_unk0x08)) != - SUCCESS) { + if (p_storage->Read(&info->m_parts[c_infohatPart].m_unk0x08, sizeof(MxU8)) != SUCCESS) { goto done; } - if (p_storage->Read(&info->m_parts[c_infohatPart].m_unk0x14, sizeof(info->m_parts[c_infohatPart].m_unk0x14)) != - SUCCESS) { + if (p_storage->Read(&info->m_parts[c_infohatPart].m_unk0x14, sizeof(MxU8)) != SUCCESS) { goto done; } - if (p_storage->Read( - &info->m_parts[c_infogronPart].m_unk0x14, - sizeof(info->m_parts[c_infogronPart].m_unk0x14) - ) != SUCCESS) { + if (p_storage->Read(&info->m_parts[c_infogronPart].m_unk0x14, sizeof(MxU8)) != SUCCESS) { goto done; } - if (p_storage->Read(&info->m_parts[c_armlftPart].m_unk0x14, sizeof(info->m_parts[c_armlftPart].m_unk0x14)) != - SUCCESS) { + if (p_storage->Read(&info->m_parts[c_armlftPart].m_unk0x14, sizeof(MxU8)) != SUCCESS) { goto done; } - if (p_storage->Read(&info->m_parts[c_armrtPart].m_unk0x14, sizeof(info->m_parts[c_armrtPart].m_unk0x14)) != - SUCCESS) { + if (p_storage->Read(&info->m_parts[c_armrtPart].m_unk0x14, sizeof(MxU8)) != SUCCESS) { goto done; } - if (p_storage->Read(&info->m_parts[c_leglftPart].m_unk0x14, sizeof(info->m_parts[c_leglftPart].m_unk0x14)) != - SUCCESS) { + if (p_storage->Read(&info->m_parts[c_leglftPart].m_unk0x14, sizeof(MxU8)) != SUCCESS) { goto done; } - if (p_storage->Read(&info->m_parts[c_legrtPart].m_unk0x14, sizeof(info->m_parts[c_legrtPart].m_unk0x14)) != - SUCCESS) { + if (p_storage->Read(&info->m_parts[c_legrtPart].m_unk0x14, sizeof(MxU8)) != SUCCESS) { goto done; } } diff --git a/LEGO1/lego/legoomni/src/common/legogamestate.cpp b/LEGO1/lego/legoomni/src/common/legogamestate.cpp index de6726d3..0ed85265 100644 --- a/LEGO1/lego/legoomni/src/common/legogamestate.cpp +++ b/LEGO1/lego/legoomni/src/common/legogamestate.cpp @@ -513,7 +513,7 @@ MxS32 LegoGameState::ReadVariable(LegoStorage* p_storage, MxVariableTable* p_to) MxS32 result = 1; MxU8 len; - if (p_storage->Read(&len, sizeof(len)) != SUCCESS) { + if (p_storage->Read(&len, sizeof(MxU8)) != SUCCESS) { goto done; } @@ -531,7 +531,7 @@ MxS32 LegoGameState::ReadVariable(LegoStorage* p_storage, MxVariableTable* p_to) goto done; } - if (p_storage->Read(&len, sizeof(len)) != SUCCESS) { + if (p_storage->Read(&len, sizeof(MxU8)) != SUCCESS) { goto done; } diff --git a/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp b/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp index c7a821ae..0350fcb4 100644 --- a/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp @@ -305,22 +305,22 @@ MxResult LegoPlantManager::Read(LegoStorage* p_storage) for (MxS32 i = 0; i < sizeOfArray(g_plantInfo); i++) { LegoPlantInfo* info = &g_plantInfo[i]; - if (p_storage->Read(&info->m_variant, sizeof(info->m_variant)) != SUCCESS) { + if (p_storage->Read(&info->m_variant, sizeof(MxU8)) != SUCCESS) { goto done; } - if (p_storage->Read(&info->m_sound, sizeof(info->m_sound)) != SUCCESS) { + if (p_storage->Read(&info->m_sound, sizeof(MxU32)) != SUCCESS) { goto done; } - if (p_storage->Read(&info->m_move, sizeof(info->m_move)) != SUCCESS) { + if (p_storage->Read(&info->m_move, sizeof(MxU32)) != SUCCESS) { goto done; } - if (p_storage->Read(&info->m_mood, sizeof(info->m_mood)) != SUCCESS) { + if (p_storage->Read(&info->m_mood, sizeof(MxU8)) != SUCCESS) { goto done; } - if (p_storage->Read(&info->m_color, sizeof(info->m_color)) != SUCCESS) { + if (p_storage->Read(&info->m_color, sizeof(MxU8)) != SUCCESS) { goto done; } - if (p_storage->Read(&info->m_unk0x16, sizeof(info->m_unk0x16)) != SUCCESS) { + if (p_storage->Read(&info->m_unk0x16, sizeof(MxS8)) != SUCCESS) { goto done; } diff --git a/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp b/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp index 54bbba6a..7027fa48 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp @@ -209,7 +209,7 @@ MxResult LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world) } if (g_wdbOffset == 0) { - if (fread(&size, sizeof(size), 1, wdbFile) != 1) { + if (fread(&size, sizeof(MxU32), 1, wdbFile) != 1) { return FAILURE; } @@ -229,7 +229,7 @@ MxResult LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world) delete[] buff; - if (fread(&size, sizeof(size), 1, wdbFile) != 1) { + if (fread(&size, sizeof(MxU32), 1, wdbFile) != 1) { return FAILURE; } diff --git a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp index d9027245..e8c89711 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp @@ -461,28 +461,28 @@ MxResult LegoPathController::Reset() // FUNCTION: BETA10 0x100b781f MxResult LegoPathController::Read(LegoStorage* p_storage) { - if (p_storage->Read(&m_numT, sizeof(m_numT)) != SUCCESS) { + if (p_storage->Read(&m_numT, sizeof(MxU16)) != SUCCESS) { return FAILURE; } if (m_numT > 0) { m_structs = new LegoPathStruct[m_numT]; } - if (p_storage->Read(&m_numN, sizeof(m_numN)) != SUCCESS) { + if (p_storage->Read(&m_numN, sizeof(MxU16)) != SUCCESS) { return FAILURE; } if (m_numN > 0) { m_unk0x10 = new Mx3DPointFloat[m_numN]; } - if (p_storage->Read(&m_numE, sizeof(m_numE)) != SUCCESS) { + if (p_storage->Read(&m_numE, sizeof(MxU16)) != SUCCESS) { return FAILURE; } if (m_numE > 0) { m_edges = new LegoPathCtrlEdge[m_numE]; } - if (p_storage->Read(&m_numL, sizeof(m_numL)) != SUCCESS) { + if (p_storage->Read(&m_numL, sizeof(MxU16)) != SUCCESS) { return FAILURE; } if (m_numL > 0) { @@ -523,7 +523,7 @@ MxResult LegoPathController::ReadStructs(LegoStorage* p_storage) for (MxS32 i = 0; i < m_numT; i++) { MxU8 length = 0; - if (p_storage->Read(&length, sizeof(length)) != SUCCESS) { + if (p_storage->Read(&length, sizeof(MxU8)) != SUCCESS) { return FAILURE; } @@ -537,7 +537,7 @@ MxResult LegoPathController::ReadStructs(LegoStorage* p_storage) m_structs[i].m_name[length] = '\0'; } - if (p_storage->Read(&m_structs[i].m_flags, sizeof(m_structs[i].m_flags)) != SUCCESS) { + if (p_storage->Read(&m_structs[i].m_flags, sizeof(MxU32)) != SUCCESS) { return FAILURE; } } @@ -553,49 +553,49 @@ MxResult LegoPathController::ReadEdges(LegoStorage* p_storage) LegoPathCtrlEdge& edge = m_edges[i]; MxU16 s; - if (p_storage->Read(&edge.m_flags, sizeof(edge.m_flags)) != SUCCESS) { + if (p_storage->Read(&edge.m_flags, sizeof(LegoU16)) != SUCCESS) { return FAILURE; } - if (p_storage->Read(&s, sizeof(s)) != SUCCESS) { + if (p_storage->Read(&s, sizeof(MxU16)) != SUCCESS) { return FAILURE; } edge.m_pointA = &m_unk0x10[s]; - if (p_storage->Read(&s, sizeof(s)) != SUCCESS) { + if (p_storage->Read(&s, sizeof(MxU16)) != SUCCESS) { return FAILURE; } edge.m_pointB = &m_unk0x10[s]; if (edge.m_flags & LegoUnknown100db7f4::c_bit3) { - if (p_storage->Read(&s, sizeof(s)) != SUCCESS) { + if (p_storage->Read(&s, sizeof(MxU16)) != SUCCESS) { return FAILURE; } edge.m_faceA = &m_boundaries[s]; - if (p_storage->Read(&s, sizeof(s)) != SUCCESS) { + if (p_storage->Read(&s, sizeof(MxU16)) != SUCCESS) { return FAILURE; } edge.m_ccwA = &m_edges[s]; - if (p_storage->Read(&s, sizeof(s)) != SUCCESS) { + if (p_storage->Read(&s, sizeof(MxU16)) != SUCCESS) { return FAILURE; } edge.m_cwA = &m_edges[s]; } if (edge.m_flags & LegoUnknown100db7f4::c_bit4) { - if (p_storage->Read(&s, sizeof(s)) != SUCCESS) { + if (p_storage->Read(&s, sizeof(MxU16)) != SUCCESS) { return FAILURE; } edge.m_faceB = &m_boundaries[s]; - if (p_storage->Read(&s, sizeof(s)) != SUCCESS) { + if (p_storage->Read(&s, sizeof(MxU16)) != SUCCESS) { return FAILURE; } edge.m_ccwB = &m_edges[s]; - if (p_storage->Read(&s, sizeof(s)) != SUCCESS) { + if (p_storage->Read(&s, sizeof(MxU16)) != SUCCESS) { return FAILURE; } edge.m_cwB = &m_edges[s]; @@ -605,7 +605,7 @@ MxResult LegoPathController::ReadEdges(LegoStorage* p_storage) return FAILURE; } - if (p_storage->Read(&edge.m_unk0x3c, sizeof(edge.m_unk0x3c)) != SUCCESS) { + if (p_storage->Read(&edge.m_unk0x3c, sizeof(float)) != SUCCESS) { return FAILURE; } } diff --git a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp index 4c0b13f2..e8a09972 100644 --- a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp @@ -142,25 +142,25 @@ MxResult LegoAnimPresenter::CreateAnim(MxStreamChunk* p_chunk) LegoS32 parseScene = 0; MxS32 val3; - if (storage.Read(&magicSig, sizeof(magicSig)) != SUCCESS || magicSig != 0x11) { + if (storage.Read(&magicSig, sizeof(MxS32)) != SUCCESS || magicSig != 0x11) { goto done; } - if (storage.Read(&m_unk0xa4, sizeof(m_unk0xa4)) != SUCCESS) { + if (storage.Read(&m_unk0xa4, sizeof(float)) != SUCCESS) { goto done; } - if (storage.Read(&m_unk0xa8[0], sizeof(m_unk0xa8[0])) != SUCCESS) { + if (storage.Read(&m_unk0xa8[0], sizeof(float)) != SUCCESS) { goto done; } - if (storage.Read(&m_unk0xa8[1], sizeof(m_unk0xa8[1])) != SUCCESS) { + if (storage.Read(&m_unk0xa8[1], sizeof(float)) != SUCCESS) { goto done; } - if (storage.Read(&m_unk0xa8[2], sizeof(m_unk0xa8[2])) != SUCCESS) { + if (storage.Read(&m_unk0xa8[2], sizeof(float)) != SUCCESS) { goto done; } - if (storage.Read(&parseScene, sizeof(parseScene)) != SUCCESS) { + if (storage.Read(&parseScene, sizeof(LegoS32)) != SUCCESS) { goto done; } - if (storage.Read(&val3, sizeof(val3)) != SUCCESS) { + if (storage.Read(&val3, sizeof(MxS32)) != SUCCESS) { goto done; } diff --git a/LEGO1/lego/legoomni/src/video/legomodelpresenter.cpp b/LEGO1/lego/legoomni/src/video/legomodelpresenter.cpp index a3040d37..3f66c840 100644 --- a/LEGO1/lego/legoomni/src/video/legomodelpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legomodelpresenter.cpp @@ -65,29 +65,29 @@ MxResult LegoModelPresenter::CreateROI(MxDSChunk* p_chunk) if (!(m_roi = new LegoROI(VideoManager()->GetRenderer()))) { goto done; } - if (storage.Read(&version, sizeof(version)) != SUCCESS) { + if (storage.Read(&version, sizeof(LegoU32)) != SUCCESS) { goto done; } if (version != MODEL_VERSION) { goto done; } - if (storage.Read(&textureInfoOffset, sizeof(textureInfoOffset)) != SUCCESS) { + if (storage.Read(&textureInfoOffset, sizeof(LegoU32)) != SUCCESS) { goto done; } storage.SetPosition(textureInfoOffset); - if (storage.Read(&numTextures, sizeof(numTextures)) != SUCCESS) { + if (storage.Read(&numTextures, sizeof(LegoU32)) != SUCCESS) { goto done; } - if (storage.Read(&skipTextures, sizeof(skipTextures)) != SUCCESS) { + if (storage.Read(&skipTextures, sizeof(LegoU32)) != SUCCESS) { goto done; } for (i = 0; i < numTextures; i++) { LegoU32 textureNameLength; - storage.Read(&textureNameLength, sizeof(textureNameLength)); + storage.Read(&textureNameLength, sizeof(LegoU32)); textureName = new LegoChar[textureNameLength + 1]; storage.Read(textureName, textureNameLength); textureName[textureNameLength] = '\0'; @@ -149,7 +149,7 @@ MxResult LegoModelPresenter::CreateROI(MxDSChunk* p_chunk) storage.SetPosition(8); - if (storage.Read(&numROIs, sizeof(numROIs)) != SUCCESS) { + if (storage.Read(&numROIs, sizeof(LegoU32)) != SUCCESS) { goto done; } if (anim.Read(&storage, FALSE) != SUCCESS) { diff --git a/LEGO1/lego/legoomni/src/video/legopalettepresenter.cpp b/LEGO1/lego/legoomni/src/video/legopalettepresenter.cpp index 880f1b9f..6ad7f6ec 100644 --- a/LEGO1/lego/legoomni/src/video/legopalettepresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legopalettepresenter.cpp @@ -56,8 +56,8 @@ MxResult LegoPalettePresenter::ParsePalette(MxStreamChunk* p_chunk) MxResult result = FAILURE; LegoMemory stream((char*) p_chunk->GetData()); - if (stream.Read(buffer, sizeof(buffer)) == SUCCESS) { - if (stream.Read(palette, sizeof(palette)) == SUCCESS) { + if (stream.Read(buffer, 40 * sizeof(MxU8)) == SUCCESS) { + if (stream.Read(palette, 256 * 4 * sizeof(MxU8)) == SUCCESS) { m_palette = new MxPalette(palette); if (m_palette) { result = SUCCESS; diff --git a/LEGO1/lego/legoomni/src/video/legopartpresenter.cpp b/LEGO1/lego/legoomni/src/video/legopartpresenter.cpp index fba9373f..f1d55a6d 100644 --- a/LEGO1/lego/legoomni/src/video/legopartpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legopartpresenter.cpp @@ -68,20 +68,20 @@ MxResult LegoPartPresenter::Read(MxDSChunk& p_chunk) LegoTextureInfo* textureInfo = NULL; LegoS32 hardwareMode = VideoManager()->GetDirect3D()->AssignedDevice()->GetHardwareMode(); - if (storage.Read(&textureInfoOffset, sizeof(textureInfoOffset)) != SUCCESS) { + if (storage.Read(&textureInfoOffset, sizeof(LegoU32)) != SUCCESS) { goto done; } if (storage.SetPosition(textureInfoOffset) != SUCCESS) { goto done; } - if (storage.Read(&numTextures, sizeof(numTextures)) != SUCCESS) { + if (storage.Read(&numTextures, sizeof(LegoU32)) != SUCCESS) { goto done; } for (i = 0; i < numTextures; i++) { LegoU32 textureNameLength; - storage.Read(&textureNameLength, sizeof(textureNameLength)); + storage.Read(&textureNameLength, sizeof(LegoU32)); textureName = new LegoChar[textureNameLength + 1]; storage.Read(textureName, textureNameLength); textureName[textureNameLength] = '\0'; @@ -145,12 +145,12 @@ MxResult LegoPartPresenter::Read(MxDSChunk& p_chunk) m_parts = new LegoNamedPartList(); - if (storage.Read(&numROIs, sizeof(numROIs)) != SUCCESS) { + if (storage.Read(&numROIs, sizeof(LegoU32)) != SUCCESS) { goto done; } for (i = 0; i < numROIs; i++) { - if (storage.Read(&roiNameLength, sizeof(roiNameLength)) != SUCCESS) { + if (storage.Read(&roiNameLength, sizeof(LegoU32)) != SUCCESS) { goto done; } @@ -162,10 +162,10 @@ MxResult LegoPartPresenter::Read(MxDSChunk& p_chunk) roiName[roiNameLength] = '\0'; strlwr(roiName); - if (storage.Read(&numLODs, sizeof(numLODs)) != SUCCESS) { + if (storage.Read(&numLODs, sizeof(LegoU32)) != SUCCESS) { goto done; } - if (storage.Read(&roiInfoOffset, sizeof(roiInfoOffset)) != SUCCESS) { + if (storage.Read(&roiInfoOffset, sizeof(LegoU32)) != SUCCESS) { goto done; } diff --git a/LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp b/LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp index 0c76b447..29e76223 100644 --- a/LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp @@ -38,7 +38,7 @@ MxResult LegoTexturePresenter::Read(MxDSChunk& p_chunk) m_textures = new LegoNamedTextureList(); LegoU32 numTextures, i; - if (storage.Read(&numTextures, sizeof(numTextures)) != SUCCESS) { + if (storage.Read(&numTextures, sizeof(LegoU32)) != SUCCESS) { goto done; } @@ -47,7 +47,7 @@ MxResult LegoTexturePresenter::Read(MxDSChunk& p_chunk) LegoTexture* texture; LegoNamedTexture* namedTexture; - if (storage.Read(&textureNameLength, sizeof(textureNameLength)) != SUCCESS) { + if (storage.Read(&textureNameLength, sizeof(LegoU32)) != SUCCESS) { goto done; } diff --git a/LEGO1/lego/sources/anim/legoanim.cpp b/LEGO1/lego/sources/anim/legoanim.cpp index 562601a5..152bce19 100644 --- a/LEGO1/lego/sources/anim/legoanim.cpp +++ b/LEGO1/lego/sources/anim/legoanim.cpp @@ -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; } diff --git a/LEGO1/lego/sources/misc/legoimage.cpp b/LEGO1/lego/sources/misc/legoimage.cpp index da3f04a0..d3fcab18 100644 --- a/LEGO1/lego/sources/misc/legoimage.cpp +++ b/LEGO1/lego/sources/misc/legoimage.cpp @@ -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++) { diff --git a/LEGO1/lego/sources/misc/legostorage.h b/LEGO1/lego/sources/misc/legostorage.h index 60ee9015..26d107c9 100644 --- a/LEGO1/lego/sources/misc/legostorage.h +++ b/LEGO1/lego/sources/misc/legostorage.h @@ -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; } diff --git a/LEGO1/lego/sources/misc/legotree.cpp b/LEGO1/lego/sources/misc/legotree.cpp index f9fb626a..55d60f5f 100644 --- a/LEGO1/lego/sources/misc/legotree.cpp +++ b/LEGO1/lego/sources/misc/legotree.cpp @@ -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++) { diff --git a/LEGO1/lego/sources/roi/legolod.cpp b/LEGO1/lego/sources/roi/legolod.cpp index d8b7e0d9..5a70bb73 100644 --- a/LEGO1/lego/sources/roi/legolod.cpp +++ b/LEGO1/lego/sources/roi/legolod.cpp @@ -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; } } diff --git a/LEGO1/lego/sources/roi/legoroi.cpp b/LEGO1/lego/sources/roi/legoroi.cpp index d3cd7e70..e6d6fecb 100644 --- a/LEGO1/lego/sources/roi/legoroi.cpp +++ b/LEGO1/lego/sources/roi/legoroi.cpp @@ -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; } diff --git a/LEGO1/lego/sources/shape/legocolor.cpp b/LEGO1/lego/sources/shape/legocolor.cpp index 146e8818..69728742 100644 --- a/LEGO1/lego/sources/shape/legocolor.cpp +++ b/LEGO1/lego/sources/shape/legocolor.cpp @@ -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; diff --git a/LEGO1/lego/sources/shape/legomesh.cpp b/LEGO1/lego/sources/shape/legomesh.cpp index 51b61fb0..537bbbe8 100644 --- a/LEGO1/lego/sources/shape/legomesh.cpp +++ b/LEGO1/lego/sources/shape/legomesh.cpp @@ -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) { diff --git a/LEGO1/lego/sources/shape/legosphere.cpp b/LEGO1/lego/sources/shape/legosphere.cpp index 7b916326..59860ab7 100644 --- a/LEGO1/lego/sources/shape/legosphere.cpp +++ b/LEGO1/lego/sources/shape/legosphere.cpp @@ -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; diff --git a/LEGO1/lego/sources/shape/legovertex.cpp b/LEGO1/lego/sources/shape/legovertex.cpp index 2977d60a..30bb27ab 100644 --- a/LEGO1/lego/sources/shape/legovertex.cpp +++ b/LEGO1/lego/sources/shape/legovertex.cpp @@ -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; diff --git a/LEGO1/modeldb/modeldb.cpp b/LEGO1/modeldb/modeldb.cpp index 66958e73..c59e5c8e 100644 --- a/LEGO1/modeldb/modeldb.cpp +++ b/LEGO1/modeldb/modeldb.cpp @@ -19,7 +19,7 @@ MxResult ModelDbModel::Read(FILE* p_file) { MxU32 len; - if (fread(&len, sizeof(len), 1, p_file) != 1) { + if (fread(&len, sizeof(MxU32), 1, p_file) != 1) { return FAILURE; } @@ -28,13 +28,13 @@ MxResult ModelDbModel::Read(FILE* p_file) return FAILURE; } - if (fread(&m_modelDataLength, sizeof(m_modelDataLength), 1, p_file) != 1) { + if (fread(&m_modelDataLength, sizeof(MxU32), 1, p_file) != 1) { return FAILURE; } - if (fread(&m_modelDataOffset, sizeof(m_modelDataOffset), 1, p_file) != 1) { + if (fread(&m_modelDataOffset, sizeof(MxU32), 1, p_file) != 1) { return FAILURE; } - if (fread(&len, sizeof(len), 1, p_file) != 1) { + if (fread(&len, sizeof(MxU32), 1, p_file) != 1) { return FAILURE; } @@ -43,16 +43,16 @@ MxResult ModelDbModel::Read(FILE* p_file) return FAILURE; } - if (fread(&m_location, sizeof(*m_location), 3, p_file) != 3) { + if (fread(&m_location, sizeof(float), 3, p_file) != 3) { return FAILURE; } - if (fread(&m_direction, sizeof(*m_direction), 3, p_file) != 3) { + if (fread(&m_direction, sizeof(float), 3, p_file) != 3) { return FAILURE; } - if (fread(&m_up, sizeof(*m_up), 3, p_file) != 3) { + if (fread(&m_up, sizeof(float), 3, p_file) != 3) { return FAILURE; } - if (fread(&m_unk0x34, sizeof(m_unk0x34), 1, p_file) != 1) { + if (fread(&m_unk0x34, sizeof(undefined), 1, p_file) != 1) { return FAILURE; } @@ -65,7 +65,7 @@ MxResult ModelDbPart::Read(FILE* p_file) MxU32 len; char buff[128]; - if (fread(&len, sizeof(len), 1, p_file) != 1) { + if (fread(&len, sizeof(MxU32), 1, p_file) != 1) { return FAILURE; } @@ -76,10 +76,10 @@ MxResult ModelDbPart::Read(FILE* p_file) m_roiName = buff; - if (fread(&m_partDataLength, sizeof(m_partDataLength), 1, p_file) != 1) { + if (fread(&m_partDataLength, sizeof(undefined4), 1, p_file) != 1) { return FAILURE; } - if (fread(&m_partDataOffset, sizeof(m_partDataOffset), 1, p_file) != 1) { + if (fread(&m_partDataOffset, sizeof(undefined4), 1, p_file) != 1) { return FAILURE; } @@ -101,7 +101,7 @@ MxResult ReadModelDbWorlds(FILE* p_file, ModelDbWorld*& p_worlds, MxS32& p_numWo MxS32 worldNameLen, numParts, i, j; for (i = 0; i < numWorlds; i++) { - if (fread(&worldNameLen, sizeof(worldNameLen), 1, p_file) != 1) { + if (fread(&worldNameLen, sizeof(MxS32), 1, p_file) != 1) { return FAILURE; } @@ -110,7 +110,7 @@ MxResult ReadModelDbWorlds(FILE* p_file, ModelDbWorld*& p_worlds, MxS32& p_numWo return FAILURE; } - if (fread(&numParts, sizeof(numParts), 1, p_file) != 1) { + if (fread(&numParts, sizeof(MxS32), 1, p_file) != 1) { return FAILURE; } @@ -126,7 +126,7 @@ MxResult ReadModelDbWorlds(FILE* p_file, ModelDbWorld*& p_worlds, MxS32& p_numWo worlds[i].m_partList->Append(part); } - if (fread(&worlds[i].m_numModels, sizeof(worlds[i].m_numModels), 1, p_file) != 1) { + if (fread(&worlds[i].m_numModels, sizeof(MxS32), 1, p_file) != 1) { return FAILURE; } diff --git a/LEGO1/omni/src/action/mxdsaction.cpp b/LEGO1/omni/src/action/mxdsaction.cpp index caab7f99..035b1046 100644 --- a/LEGO1/omni/src/action/mxdsaction.cpp +++ b/LEGO1/omni/src/action/mxdsaction.cpp @@ -113,14 +113,14 @@ undefined4 MxDSAction::VTable0x14() MxU32 MxDSAction::GetSizeOnDisk() { MxU32 size = MxDSObject::GetSizeOnDisk(); - size += sizeof(m_flags); - size += sizeof(m_startTime); - size += sizeof(m_duration); - size += sizeof(m_loopCount); + size += sizeof(MxU32); + size += sizeof(MxS32); + size += sizeof(MxS32); + size += sizeof(MxS32); size += sizeof(double) * 3; // m_location size += sizeof(double) * 3; // m_direction size += sizeof(double) * 3; // m_up - size += sizeof(m_extraLength); + size += sizeof(MxU16); size += m_extraLength; m_sizeOnDisk = size - MxDSObject::GetSizeOnDisk(); @@ -261,10 +261,10 @@ void MxDSAction::Deserialize(MxU8*& p_source, MxS16 p_flags) MxDSObject::Deserialize(p_source, p_flags); // clang-format off - m_flags = *( MxU32*) p_source; p_source += sizeof(m_flags); - m_startTime = *(MxLong*) p_source; p_source += sizeof(m_startTime); - m_duration = *(MxLong*) p_source; p_source += sizeof(m_duration); - m_loopCount = *( MxS32*) p_source; p_source += sizeof(m_loopCount); + m_flags = *( MxU32*) p_source; p_source += sizeof(MxU32); + m_startTime = *(MxLong*) p_source; p_source += sizeof(MxS32); + m_duration = *(MxLong*) p_source; p_source += sizeof(MxS32); + m_loopCount = *( MxS32*) p_source; p_source += sizeof(MxS32); m_location[0] = *(double*) p_source; p_source += sizeof(double); m_location[1] = *(double*) p_source; p_source += sizeof(double); m_location[2] = *(double*) p_source; p_source += sizeof(double); diff --git a/LEGO1/omni/src/action/mxdsmediaaction.cpp b/LEGO1/omni/src/action/mxdsmediaaction.cpp index dbd61ca4..47a43f19 100644 --- a/LEGO1/omni/src/action/mxdsmediaaction.cpp +++ b/LEGO1/omni/src/action/mxdsmediaaction.cpp @@ -116,12 +116,12 @@ MxU32 MxDSMediaAction::GetSizeOnDisk() totalSizeOnDisk++; } - totalSizeOnDisk += sizeof(m_unk0x9c.m_unk0x00); - totalSizeOnDisk += sizeof(m_unk0x9c.m_unk0x04); - totalSizeOnDisk += sizeof(m_framesPerSecond); - totalSizeOnDisk += sizeof(m_mediaFormat); - totalSizeOnDisk += sizeof(m_paletteManagement); - totalSizeOnDisk += sizeof(m_sustainTime); + totalSizeOnDisk += sizeof(undefined4); + totalSizeOnDisk += sizeof(undefined4); + totalSizeOnDisk += sizeof(MxS32); + totalSizeOnDisk += sizeof(MxS32); + totalSizeOnDisk += sizeof(MxS32); + totalSizeOnDisk += sizeof(MxS32); m_sizeOnDisk = totalSizeOnDisk - MxDSAction::GetSizeOnDisk(); return totalSizeOnDisk; @@ -137,12 +137,12 @@ void MxDSMediaAction::Deserialize(MxU8*& p_source, MxS16 p_flags) p_source += strlen(m_mediaSrcPath) + 1; // clang-format off - m_unk0x9c.SetUnk0x00(*(MxU32*) p_source); p_source += sizeof(m_unk0x9c.m_unk0x00); - m_unk0x9c.SetUnk0x04(*(MxU32*) p_source); p_source += sizeof(m_unk0x9c.m_unk0x04); + m_unk0x9c.SetUnk0x00(*(MxU32*) p_source); p_source += sizeof(undefined4); + m_unk0x9c.SetUnk0x04(*(MxU32*) p_source); p_source += sizeof(undefined4); - m_framesPerSecond = *(MxS32*) p_source; p_source += sizeof(m_framesPerSecond); - m_mediaFormat = *(MxS32*) p_source; p_source += sizeof(m_mediaFormat); - m_paletteManagement = *(MxS32*) p_source; p_source += sizeof(m_paletteManagement); - m_sustainTime = *(MxS32*) p_source; p_source += sizeof(m_sustainTime); + m_framesPerSecond = *(MxS32*) p_source; p_source += sizeof(MxS32); + m_mediaFormat = *(MxS32*) p_source; p_source += sizeof(MxS32); + m_paletteManagement = *(MxS32*) p_source; p_source += sizeof(MxS32); + m_sustainTime = *(MxS32*) p_source; p_source += sizeof(MxS32); // clang-format on } diff --git a/LEGO1/omni/src/stream/mxstreamchunk.cpp b/LEGO1/omni/src/stream/mxstreamchunk.cpp index 7944b2f2..03bcb5d6 100644 --- a/LEGO1/omni/src/stream/mxstreamchunk.cpp +++ b/LEGO1/omni/src/stream/mxstreamchunk.cpp @@ -38,16 +38,16 @@ MxU32 MxStreamChunk::ReadChunkHeader(MxU8* p_chunkData) MxU8* chunkData = p_chunkData; memcpy(&m_flags, p_chunkData, sizeof(m_flags)); - p_chunkData += sizeof(m_flags); + p_chunkData += sizeof(MxU16); memcpy(&m_objectId, p_chunkData, sizeof(m_objectId)); - p_chunkData += sizeof(m_objectId); + p_chunkData += sizeof(MxU32); memcpy(&m_time, p_chunkData, sizeof(m_time)); - p_chunkData += sizeof(m_time); + p_chunkData += sizeof(MxU32); memcpy(&m_length, p_chunkData, sizeof(m_length)); - p_chunkData += sizeof(m_length); + p_chunkData += sizeof(MxU32); m_data = p_chunkData; headersize = p_chunkData - chunkData; diff --git a/LEGO1/omni/src/video/mxbitmap.cpp b/LEGO1/omni/src/video/mxbitmap.cpp index d74008a0..9d2bffdc 100644 --- a/LEGO1/omni/src/video/mxbitmap.cpp +++ b/LEGO1/omni/src/video/mxbitmap.cpp @@ -7,6 +7,8 @@ DECOMP_SIZE_ASSERT(MxBitmap, 0x20); DECOMP_SIZE_ASSERT(MxBITMAPINFO, 0x428); +DECOMP_SIZE_ASSERT(BITMAPFILEHEADER, 0xe); + // GLOBAL: LEGO1 0x10102184 // GLOBAL: BETA10 0x10203030 MxU16 g_bitmapSignature = TWOCC('B', 'M'); @@ -207,7 +209,7 @@ MxResult MxBitmap::LoadFile(HANDLE p_handle) MxLong size; DWORD bytesRead; BITMAPFILEHEADER hdr; - if (!ReadFile(p_handle, &hdr, sizeof(hdr), &bytesRead, NULL)) { + if (!ReadFile(p_handle, &hdr, 14, &bytesRead, NULL)) { goto done; }