diff --git a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp index 3948f3c9..c7c619cc 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp @@ -661,7 +661,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; } @@ -670,7 +670,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; } @@ -763,7 +763,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; } @@ -773,33 +773,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; } @@ -824,7 +824,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; } @@ -834,20 +834,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 1d9c07a0..d2270098 100644 --- a/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legocharactermanager.cpp @@ -180,43 +180,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 3c8a9542..a7bae791 100644 --- a/LEGO1/lego/legoomni/src/common/legogamestate.cpp +++ b/LEGO1/lego/legoomni/src/common/legogamestate.cpp @@ -515,7 +515,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; } @@ -533,7 +533,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 f3d57cf7..2145b191 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 (SDL_ReadIO(wdbFile, &size, sizeof(size)) != sizeof(size)) { + if (SDL_ReadIO(wdbFile, &size, sizeof(MxU32)) != sizeof(MxU32)) { return FAILURE; } @@ -229,7 +229,7 @@ MxResult LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world) delete[] buff; - if (SDL_ReadIO(wdbFile, &size, sizeof(size)) != sizeof(size)) { + if (SDL_ReadIO(wdbFile, &size, sizeof(MxU32)) != sizeof(MxU32)) { return FAILURE; } diff --git a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp index c00963c0..c7dc69ba 100644 --- a/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp +++ b/LEGO1/lego/legoomni/src/paths/legopathcontroller.cpp @@ -463,28 +463,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) { @@ -525,7 +525,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; } @@ -539,7 +539,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; } } @@ -555,49 +555,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]; @@ -607,7 +607,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 6a258708..b7b5a751 100644 --- a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp @@ -145,25 +145,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 d64ec94d..f1fe63bc 100644 --- a/LEGO1/lego/legoomni/src/video/legomodelpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legomodelpresenter.cpp @@ -67,29 +67,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'; @@ -151,7 +151,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 01cc04b6..9cbb716f 100644 --- a/LEGO1/lego/legoomni/src/video/legopartpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legopartpresenter.cpp @@ -70,20 +70,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'; @@ -147,12 +147,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; } @@ -164,10 +164,10 @@ MxResult LegoPartPresenter::Read(MxDSChunk& p_chunk) roiName[roiNameLength] = '\0'; SDL_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 6d4fe81e..9897f1fa 100644 --- a/LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp @@ -40,7 +40,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; } @@ -49,7 +49,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 0e72b1fe..cfa27b94 100644 --- a/LEGO1/lego/sources/misc/legoimage.cpp +++ b/LEGO1/lego/sources/misc/legoimage.cpp @@ -20,13 +20,13 @@ LegoPaletteEntry::LegoPaletteEntry() LegoResult LegoPaletteEntry::Read(LegoStorage* p_storage) { LegoResult result; - if ((result = p_storage->Read(&m_color.r, sizeof(m_color.r))) != SUCCESS) { + if ((result = p_storage->Read(&m_color.r, sizeof(Uint8))) != SUCCESS) { return result; } - if ((result = p_storage->Read(&m_color.g, sizeof(m_color.g))) != SUCCESS) { + if ((result = p_storage->Read(&m_color.g, sizeof(Uint8))) != SUCCESS) { return result; } - if ((result = p_storage->Read(&m_color.b, sizeof(m_color.b))) != SUCCESS) { + if ((result = p_storage->Read(&m_color.b, sizeof(Uint8))) != SUCCESS) { return result; } return SUCCESS; @@ -36,13 +36,13 @@ LegoResult LegoPaletteEntry::Read(LegoStorage* p_storage) LegoResult LegoPaletteEntry::Write(LegoStorage* p_storage) const { LegoResult result; - if ((result = p_storage->Write(&m_color.r, sizeof(m_color.r))) != SUCCESS) { + if ((result = p_storage->Write(&m_color.r, sizeof(Uint8))) != SUCCESS) { return result; } - if ((result = p_storage->Write(&m_color.g, sizeof(m_color.g))) != SUCCESS) { + if ((result = p_storage->Write(&m_color.g, sizeof(Uint8))) != SUCCESS) { return result; } - if ((result = p_storage->Write(&m_color.b, sizeof(m_color.b))) != SUCCESS) { + if ((result = p_storage->Write(&m_color.b, sizeof(Uint8))) != SUCCESS) { return result; } return SUCCESS; @@ -74,13 +74,13 @@ LegoResult LegoImage::Read(LegoStorage* p_storage, LegoU32 p_square) { LegoResult result; LegoU32 width, height, count; - if ((result = p_storage->Read(&width, sizeof(width))) != SUCCESS) { + if ((result = p_storage->Read(&width, sizeof(LegoU32))) != SUCCESS) { return result; } - if ((result = p_storage->Read(&height, sizeof(height))) != SUCCESS) { + if ((result = p_storage->Read(&height, sizeof(LegoU32))) != SUCCESS) { return result; } - if ((result = p_storage->Read(&count, sizeof(height))) != SUCCESS) { + if ((result = p_storage->Read(&count, sizeof(LegoU32))) != SUCCESS) { return result; } if (m_palette) { @@ -156,13 +156,13 @@ LegoResult LegoImage::Read(LegoStorage* p_storage, LegoU32 p_square) LegoResult LegoImage::Write(LegoStorage* p_storage) { LegoResult result; - if ((result = p_storage->Write(&m_surface->w, sizeof(m_surface->w))) != SUCCESS) { + if ((result = p_storage->Write(&m_surface->w, sizeof(int))) != SUCCESS) { return result; } - if ((result = p_storage->Write(&m_surface->h, sizeof(m_surface->h))) != SUCCESS) { + if ((result = p_storage->Write(&m_surface->h, sizeof(int))) != SUCCESS) { return result; } - if ((result = p_storage->Write(&m_surface->h, sizeof(m_surface->h))) != SUCCESS) { + if ((result = p_storage->Write(&m_surface->h, sizeof(int))) != SUCCESS) { return result; } if (m_palette) { diff --git a/LEGO1/lego/sources/misc/legostorage.h b/LEGO1/lego/sources/misc/legostorage.h index bb2af82a..da084b05 100644 --- a/LEGO1/lego/sources/misc/legostorage.h +++ b/LEGO1/lego/sources/misc/legostorage.h @@ -45,21 +45,21 @@ class LegoStorage { // 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 @@ class LegoStorage { // 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 @@ class LegoStorage { // 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 @@ class LegoStorage { // 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 @@ class LegoStorage { // 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 @@ class LegoStorage { // 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 cca41af0..f3a9092e 100644 --- a/LEGO1/lego/sources/roi/legolod.cpp +++ b/LEGO1/lego/sources/roi/legolod.cpp @@ -71,7 +71,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; } @@ -81,7 +81,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; } @@ -98,34 +98,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; } } @@ -146,7 +146,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; } @@ -156,7 +156,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 7e466424..d4f95f18 100644 --- a/LEGO1/lego/sources/roi/legoroi.cpp +++ b/LEGO1/lego/sources/roi/legoroi.cpp @@ -129,7 +129,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]; @@ -154,7 +154,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; } @@ -170,7 +170,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; } @@ -193,7 +193,7 @@ LegoResult LegoROI::Read( } } else { - if (p_storage->Read(&numLODs, sizeof(numLODs)) != SUCCESS) { + if (p_storage->Read(&numLODs, sizeof(LegoU32)) != SUCCESS) { goto done; } @@ -204,7 +204,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; } @@ -313,7 +313,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 df293fc6..dbdc9a6b 100644 --- a/LEGO1/lego/sources/shape/legomesh.cpp +++ b/LEGO1/lego/sources/shape/legomesh.cpp @@ -45,23 +45,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) { @@ -75,7 +75,7 @@ LegoResult LegoMesh::Read(LegoStorage* p_storage) SDL_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 a038651c..90803570 100644 --- a/LEGO1/modeldb/modeldb.cpp +++ b/LEGO1/modeldb/modeldb.cpp @@ -19,7 +19,7 @@ MxResult ModelDbModel::Read(SDL_IOStream* p_file) { MxU32 len; - if (SDL_ReadIO(p_file, &len, sizeof(len)) != sizeof(len)) { + if (SDL_ReadIO(p_file, &len, sizeof(MxU32)) != sizeof(MxU32)) { return FAILURE; } @@ -28,10 +28,10 @@ MxResult ModelDbModel::Read(SDL_IOStream* p_file) return FAILURE; } - if (SDL_ReadIO(p_file, &m_modelDataLength, sizeof(m_modelDataLength)) != sizeof(m_modelDataLength)) { + if (SDL_ReadIO(p_file, &m_modelDataLength, sizeof(MxU32)) != sizeof(MxU32)) { return FAILURE; } - if (SDL_ReadIO(p_file, &m_modelDataOffset, sizeof(m_modelDataOffset)) != sizeof(m_modelDataOffset)) { + if (SDL_ReadIO(p_file, &m_modelDataOffset, sizeof(MxU32)) != sizeof(MxU32)) { return FAILURE; } if (SDL_ReadIO(p_file, &len, sizeof(len)) != sizeof(len)) { @@ -43,16 +43,16 @@ MxResult ModelDbModel::Read(SDL_IOStream* p_file) return FAILURE; } - if (SDL_ReadIO(p_file, m_location, sizeof(m_location)) != sizeof(m_location)) { + if (SDL_ReadIO(p_file, m_location, 3 * sizeof(float)) != 3 * sizeof(float)) { return FAILURE; } - if (SDL_ReadIO(p_file, m_direction, sizeof(m_direction)) != sizeof(m_direction)) { + if (SDL_ReadIO(p_file, m_direction, 3 * sizeof(float)) != 3 * sizeof(float)) { return FAILURE; } - if (SDL_ReadIO(p_file, m_up, sizeof(m_up)) != sizeof(m_up)) { + if (SDL_ReadIO(p_file, m_up, 3 * sizeof(float)) != 3 * sizeof(float)) { return FAILURE; } - if (SDL_ReadIO(p_file, &m_unk0x34, sizeof(m_unk0x34)) != sizeof(m_unk0x34)) { + if (SDL_ReadIO(p_file, &m_unk0x34, sizeof(undefined)) != sizeof(undefined)) { return FAILURE; } @@ -64,7 +64,7 @@ MxResult ModelDbPart::Read(SDL_IOStream* p_file) { MxU32 len; - if (SDL_ReadIO(p_file, &len, sizeof(len)) != sizeof(len)) { + if (SDL_ReadIO(p_file, &len, sizeof(MxU32)) != sizeof(MxU32)) { return FAILURE; } @@ -77,10 +77,10 @@ MxResult ModelDbPart::Read(SDL_IOStream* p_file) m_roiName = buff; delete[] buff; - if (SDL_ReadIO(p_file, &m_partDataLength, sizeof(m_partDataLength)) != sizeof(m_partDataLength)) { + if (SDL_ReadIO(p_file, &m_partDataLength, sizeof(undefined4)) != sizeof(undefined4)) { return FAILURE; } - if (SDL_ReadIO(p_file, &m_partDataOffset, sizeof(m_partDataOffset)) != sizeof(m_partDataOffset)) { + if (SDL_ReadIO(p_file, &m_partDataOffset, sizeof(undefined4)) != sizeof(undefined4)) { return FAILURE; } @@ -102,7 +102,7 @@ MxResult ReadModelDbWorlds(SDL_IOStream* p_file, ModelDbWorld*& p_worlds, MxS32& MxS32 worldNameLen, numParts, i, j; for (i = 0; i < numWorlds; i++) { - if (SDL_ReadIO(p_file, &worldNameLen, sizeof(worldNameLen)) != sizeof(worldNameLen)) { + if (SDL_ReadIO(p_file, &worldNameLen, sizeof(MxS32)) != sizeof(MxS32)) { return FAILURE; } @@ -111,7 +111,7 @@ MxResult ReadModelDbWorlds(SDL_IOStream* p_file, ModelDbWorld*& p_worlds, MxS32& return FAILURE; } - if (SDL_ReadIO(p_file, &numParts, sizeof(numParts)) != sizeof(numParts)) { + if (SDL_ReadIO(p_file, &numParts, sizeof(MxS32)) != sizeof(MxS32)) { return FAILURE; } @@ -127,8 +127,7 @@ MxResult ReadModelDbWorlds(SDL_IOStream* p_file, ModelDbWorld*& p_worlds, MxS32& worlds[i].m_partList->Append(part); } - if (SDL_ReadIO(p_file, &worlds[i].m_numModels, sizeof(worlds[i].m_numModels)) != - sizeof(worlds[i].m_numModels)) { + if (SDL_ReadIO(p_file, &worlds[i].m_numModels, sizeof(MxS32)) != sizeof(MxS32)) { return FAILURE; } diff --git a/LEGO1/omni/src/action/mxdsaction.cpp b/LEGO1/omni/src/action/mxdsaction.cpp index e67ad9d8..cd422d0d 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(); @@ -275,7 +275,7 @@ void MxDSAction::Deserialize(MxU8*& p_source, MxS16 p_flags) m_up[1] = UnalignedRead(p_source); p_source += sizeof(double); m_up[2] = UnalignedRead(p_source); p_source += sizeof(double); - MxU16 extraLength = UnalignedRead(p_source); p_source += sizeof(extraLength); + MxU16 extraLength = UnalignedRead(p_source); p_source += sizeof(MxU16); // clang-format on if (extraLength) { diff --git a/LEGO1/omni/src/action/mxdsmediaaction.cpp b/LEGO1/omni/src/action/mxdsmediaaction.cpp index 5787ba37..3cdf8334 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; diff --git a/LEGO1/omni/src/stream/mxstreamchunk.cpp b/LEGO1/omni/src/stream/mxstreamchunk.cpp index f3c5f191..38b68db4 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 6f09717c..90f41663 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'); @@ -206,7 +208,9 @@ MxResult MxBitmap::LoadFile(SDL_IOStream* p_handle) MxLong size; BITMAPFILEHEADER hdr; - if (!SDL_ReadIO(p_handle, &hdr, sizeof(hdr))) { + + static_assert(sizeof(BITMAPFILEHEADER) == 14, "Incorrect size"); + if (!SDL_ReadIO(p_handle, &hdr, 14)) { goto done; }