Fix signedness of indices to read the correct array elements. Bug found by randomMesh.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@840 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2007-08-15 15:55:20 +00:00
parent 3253bc95c2
commit 153c682578
2 changed files with 10 additions and 9 deletions

View File

@ -879,8 +879,8 @@ void C3DSMeshFileLoader::composeObject(io::IReadFile* file, const core::stringc&
// no material group, so add all
SMaterialGroup group;
group.faceCount = CountFaces;
group.faces = new s16[group.faceCount];
for (int i=0; i<group.faceCount; ++i)
group.faces = new u16[group.faceCount];
for (u32 i=0; i<group.faceCount; ++i)
group.faces[i] = i;
MaterialGroups.push_back(group);
@ -1177,12 +1177,13 @@ void C3DSMeshFileLoader::readMaterialGroup(io::IReadFile* file, ChunkData& data)
data.read += sizeof(group.faceCount);
// read faces
group.faces = new s16[group.faceCount];
file->read(group.faces, sizeof(s16) * group.faceCount);
group.faces = new u16[group.faceCount];
file->read(group.faces, sizeof(u16) * group.faceCount);
#ifdef __BIG_ENDIAN__
for (int i=0;i<group.faceCount;i++) group.faces[i] = os::Byteswap::byteswap(group.faces[i]);
for (u32 i=0;i<group.faceCount;++i)
group.faces[i] = os::Byteswap::byteswap(group.faces[i]);
#endif
data.read += sizeof(s16) * group.faceCount;
data.read += sizeof(u16) * group.faceCount;
MaterialGroups.push_back(group);
}

View File

@ -120,14 +120,14 @@ private:
{
MaterialName = o.MaterialName;
faceCount = o.faceCount;
faces = new s16[faceCount];
for (s32 i=0; i<faceCount; ++i)
faces = new u16[faceCount];
for (u32 i=0; i<faceCount; ++i)
faces[i] = o.faces[i];
}
core::stringc MaterialName;
u16 faceCount;
s16* faces;
u16* faces;
};
bool readChunk(io::IReadFile* file, ChunkData* parent);