mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-27 10:24:18 +00:00
Use sizeof(type) instead of sizeof(variableName) when (de)serializing data (#1505)
* Use sizeof(type) instead of sizeof(variableName) when (de)serializing data * Less usage of sizeof(variableName) while (de)serializing
This commit is contained in:
committed by
GitHub
parent
c9b41e2db8
commit
2915aa014f
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user