Commit ad14e9c0 authored by hybrid's avatar hybrid

Add warning message if element size does not match size of read components.

Move debug messages into ELL_DEBUG space.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3535 dfc29bdd-3216-0410-991c-e03cc46cb475
parent a8be8a8c
...@@ -200,7 +200,7 @@ bool COgreMeshFileLoader::readChunk(io::IReadFile* file) ...@@ -200,7 +200,7 @@ bool COgreMeshFileLoader::readChunk(io::IReadFile* file)
bool COgreMeshFileLoader::readObjectChunk(io::IReadFile* file, ChunkData& parent, OgreMesh& mesh) bool COgreMeshFileLoader::readObjectChunk(io::IReadFile* file, ChunkData& parent, OgreMesh& mesh)
{ {
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Read Object Chunk"); os::Printer::log("Read Object Chunk", ELL_DEBUG);
#endif #endif
readBool(file, parent, mesh.SkeletalAnimation); readBool(file, parent, mesh.SkeletalAnimation);
bool skeleton_loaded=false; bool skeleton_loaded=false;
...@@ -221,7 +221,7 @@ bool COgreMeshFileLoader::readObjectChunk(io::IReadFile* file, ChunkData& parent ...@@ -221,7 +221,7 @@ bool COgreMeshFileLoader::readObjectChunk(io::IReadFile* file, ChunkData& parent
case COGRE_MESH_BOUNDS: case COGRE_MESH_BOUNDS:
{ {
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Read Mesh Bounds"); os::Printer::log("Read Mesh Bounds", ELL_DEBUG);
#endif #endif
readVector(file, data, mesh.BBoxMinEdge); readVector(file, data, mesh.BBoxMinEdge);
readVector(file, data, mesh.BBoxMaxEdge); readVector(file, data, mesh.BBoxMaxEdge);
...@@ -231,7 +231,7 @@ bool COgreMeshFileLoader::readObjectChunk(io::IReadFile* file, ChunkData& parent ...@@ -231,7 +231,7 @@ bool COgreMeshFileLoader::readObjectChunk(io::IReadFile* file, ChunkData& parent
case COGRE_SKELETON_LINK: case COGRE_SKELETON_LINK:
{ {
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Read Skeleton link"); os::Printer::log("Read Skeleton link", ELL_DEBUG);
#endif #endif
core::stringc name; core::stringc name;
readString(file, data, name); readString(file, data, name);
...@@ -256,7 +256,7 @@ bool COgreMeshFileLoader::readObjectChunk(io::IReadFile* file, ChunkData& parent ...@@ -256,7 +256,7 @@ bool COgreMeshFileLoader::readObjectChunk(io::IReadFile* file, ChunkData& parent
break; break;
default: default:
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Skipping", core::stringc(data.header.id)); os::Printer::log("Skipping", core::stringc(data.header.id), ELL_DEBUG);
#endif #endif
// ignore chunk // ignore chunk
file->seek(data.header.length-data.read, true); file->seek(data.header.length-data.read, true);
...@@ -274,7 +274,7 @@ bool COgreMeshFileLoader::readObjectChunk(io::IReadFile* file, ChunkData& parent ...@@ -274,7 +274,7 @@ bool COgreMeshFileLoader::readObjectChunk(io::IReadFile* file, ChunkData& parent
bool COgreMeshFileLoader::readGeometry(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry) bool COgreMeshFileLoader::readGeometry(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry)
{ {
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Read Geometry"); os::Printer::log("Read Geometry", ELL_DEBUG);
#endif #endif
readInt(file, parent, &geometry.NumVertex); readInt(file, parent, &geometry.NumVertex);
while(parent.read < parent.header.length) while(parent.read < parent.header.length)
...@@ -293,13 +293,15 @@ bool COgreMeshFileLoader::readGeometry(io::IReadFile* file, ChunkData& parent, O ...@@ -293,13 +293,15 @@ bool COgreMeshFileLoader::readGeometry(io::IReadFile* file, ChunkData& parent, O
default: default:
// ignore chunk // ignore chunk
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Skipping", core::stringc(data.header.id)); os::Printer::log("Skipping", core::stringc(data.header.id), ELL_DEBUG);
#endif #endif
file->seek(data.header.length-data.read, true); file->seek(data.header.length-data.read, true);
data.read += data.header.length-data.read; data.read += data.header.length-data.read;
} }
parent.read += data.read; parent.read += data.read;
} }
if (parent.read != parent.header.length)
os::Printer::log("Incorrect geometry length. File might be corrupted.");
return true; return true;
} }
...@@ -307,7 +309,7 @@ bool COgreMeshFileLoader::readGeometry(io::IReadFile* file, ChunkData& parent, O ...@@ -307,7 +309,7 @@ bool COgreMeshFileLoader::readGeometry(io::IReadFile* file, ChunkData& parent, O
bool COgreMeshFileLoader::readVertexDeclaration(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry) bool COgreMeshFileLoader::readVertexDeclaration(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry)
{ {
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Read Vertex Declaration"); os::Printer::log("Read Vertex Declaration", ELL_DEBUG);
#endif #endif
NumUV = 0; NumUV = 0;
while(parent.read < parent.header.length) while(parent.read < parent.header.length)
...@@ -340,6 +342,8 @@ bool COgreMeshFileLoader::readVertexDeclaration(io::IReadFile* file, ChunkData& ...@@ -340,6 +342,8 @@ bool COgreMeshFileLoader::readVertexDeclaration(io::IReadFile* file, ChunkData&
} }
parent.read += data.read; parent.read += data.read;
} }
if (parent.read != parent.header.length)
os::Printer::log("Incorrect vertex declaration length. File might be corrupted.");
return true; return true;
} }
...@@ -347,7 +351,7 @@ bool COgreMeshFileLoader::readVertexDeclaration(io::IReadFile* file, ChunkData& ...@@ -347,7 +351,7 @@ bool COgreMeshFileLoader::readVertexDeclaration(io::IReadFile* file, ChunkData&
bool COgreMeshFileLoader::readVertexBuffer(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry) bool COgreMeshFileLoader::readVertexBuffer(io::IReadFile* file, ChunkData& parent, OgreGeometry& geometry)
{ {
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Read Vertex Buffer"); os::Printer::log("Read Vertex Buffer", ELL_DEBUG);
#endif #endif
OgreVertexBuffer buf; OgreVertexBuffer buf;
readShort(file, parent, &buf.BindIndex); readShort(file, parent, &buf.BindIndex);
...@@ -364,6 +368,8 @@ bool COgreMeshFileLoader::readVertexBuffer(io::IReadFile* file, ChunkData& paren ...@@ -364,6 +368,8 @@ bool COgreMeshFileLoader::readVertexBuffer(io::IReadFile* file, ChunkData& paren
geometry.Buffers.push_back(buf); geometry.Buffers.push_back(buf);
parent.read += data.read; parent.read += data.read;
if (parent.read != parent.header.length)
os::Printer::log("Incorrect vertex buffer length. File might be corrupted.");
return true; return true;
} }
...@@ -371,11 +377,11 @@ bool COgreMeshFileLoader::readVertexBuffer(io::IReadFile* file, ChunkData& paren ...@@ -371,11 +377,11 @@ bool COgreMeshFileLoader::readVertexBuffer(io::IReadFile* file, ChunkData& paren
bool COgreMeshFileLoader::readSubMesh(io::IReadFile* file, ChunkData& parent, OgreSubMesh& subMesh) bool COgreMeshFileLoader::readSubMesh(io::IReadFile* file, ChunkData& parent, OgreSubMesh& subMesh)
{ {
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Read Submesh"); os::Printer::log("Read Submesh", ELL_DEBUG);
#endif #endif
readString(file, parent, subMesh.Material); readString(file, parent, subMesh.Material);
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("using material", subMesh.Material); os::Printer::log("using material", subMesh.Material, ELL_DEBUG);
#endif #endif
readBool(file, parent, subMesh.SharedVertices); readBool(file, parent, subMesh.SharedVertices);
...@@ -410,7 +416,7 @@ bool COgreMeshFileLoader::readSubMesh(io::IReadFile* file, ChunkData& parent, Og ...@@ -410,7 +416,7 @@ bool COgreMeshFileLoader::readSubMesh(io::IReadFile* file, ChunkData& parent, Og
case COGRE_SUBMESH_OPERATION: case COGRE_SUBMESH_OPERATION:
readShort(file, data, &subMesh.Operation); readShort(file, data, &subMesh.Operation);
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Read Submesh Operation",core::stringc(subMesh.Operation)); os::Printer::log("Read Submesh Operation",core::stringc(subMesh.Operation), ELL_DEBUG);
#endif #endif
if (subMesh.Operation != 4) if (subMesh.Operation != 4)
os::Printer::log("Primitive type != trilist not yet implemented", ELL_WARNING); os::Printer::log("Primitive type != trilist not yet implemented", ELL_WARNING);
...@@ -418,7 +424,7 @@ bool COgreMeshFileLoader::readSubMesh(io::IReadFile* file, ChunkData& parent, Og ...@@ -418,7 +424,7 @@ bool COgreMeshFileLoader::readSubMesh(io::IReadFile* file, ChunkData& parent, Og
case COGRE_SUBMESH_TEXTURE_ALIAS: case COGRE_SUBMESH_TEXTURE_ALIAS:
{ {
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Read Submesh Texture Alias"); os::Printer::log("Read Submesh Texture Alias", ELL_DEBUG);
#endif #endif
core::stringc texture, alias; core::stringc texture, alias;
readString(file, data, texture); readString(file, data, texture);
...@@ -436,7 +442,7 @@ bool COgreMeshFileLoader::readSubMesh(io::IReadFile* file, ChunkData& parent, Og ...@@ -436,7 +442,7 @@ bool COgreMeshFileLoader::readSubMesh(io::IReadFile* file, ChunkData& parent, Og
break; break;
default: default:
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Skipping", core::stringc(data.header.id)); os::Printer::log("Skipping", core::stringc(data.header.id), ELL_DEBUG);
#endif #endif
parent.read=parent.header.length; parent.read=parent.header.length;
file->seek(-(long)sizeof(ChunkHeader), true); file->seek(-(long)sizeof(ChunkHeader), true);
...@@ -444,6 +450,11 @@ bool COgreMeshFileLoader::readSubMesh(io::IReadFile* file, ChunkData& parent, Og ...@@ -444,6 +450,11 @@ bool COgreMeshFileLoader::readSubMesh(io::IReadFile* file, ChunkData& parent, Og
} }
parent.read += data.read; parent.read += data.read;
} }
if (parent.read != parent.header.length)
os::Printer::log("Incorrect submesh length. File might be corrupted.");
#ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Done with submesh", ELL_DEBUG);
#endif
return true; return true;
} }
...@@ -1071,7 +1082,7 @@ void COgreMeshFileLoader::readPass(io::IReadFile* file, OgreTechnique& technique ...@@ -1071,7 +1082,7 @@ void COgreMeshFileLoader::readPass(io::IReadFile* file, OgreTechnique& technique
else if (token=="texture_unit") else if (token=="texture_unit")
{ {
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Read Texture unit"); os::Printer::log("Read Texture unit", ELL_DEBUG);
#endif #endif
getMaterialToken(file, token); //open brace getMaterialToken(file, token); //open brace
getMaterialToken(file, token); getMaterialToken(file, token);
...@@ -1081,7 +1092,7 @@ void COgreMeshFileLoader::readPass(io::IReadFile* file, OgreTechnique& technique ...@@ -1081,7 +1092,7 @@ void COgreMeshFileLoader::readPass(io::IReadFile* file, OgreTechnique& technique
{ {
getMaterialToken(file, pass.Texture.Filename); getMaterialToken(file, pass.Texture.Filename);
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Read Texture", pass.Texture.Filename.c_str()); os::Printer::log("Read Texture", pass.Texture.Filename.c_str(), ELL_DEBUG);
#endif #endif
getMaterialToken(file, pass.Texture.CoordsType, true); getMaterialToken(file, pass.Texture.CoordsType, true);
getMaterialToken(file, pass.Texture.MipMaps, true); getMaterialToken(file, pass.Texture.MipMaps, true);
...@@ -1217,7 +1228,7 @@ void COgreMeshFileLoader::readTechnique(io::IReadFile* file, OgreMaterial& mat) ...@@ -1217,7 +1228,7 @@ void COgreMeshFileLoader::readTechnique(io::IReadFile* file, OgreMaterial& mat)
void COgreMeshFileLoader::loadMaterials(io::IReadFile* meshFile) void COgreMeshFileLoader::loadMaterials(io::IReadFile* meshFile)
{ {
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Load Materials"); os::Printer::log("Load Materials", ELL_DEBUG);
#endif #endif
core::stringc token; core::stringc token;
io::IReadFile* file = 0; io::IReadFile* file = 0;
...@@ -1268,7 +1279,7 @@ void COgreMeshFileLoader::loadMaterials(io::IReadFile* meshFile) ...@@ -1268,7 +1279,7 @@ void COgreMeshFileLoader::loadMaterials(io::IReadFile* meshFile)
getMaterialToken(file, mat.Name); getMaterialToken(file, mat.Name);
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Load Material", mat.Name.c_str()); os::Printer::log("Load Material", mat.Name.c_str(), ELL_DEBUG);
#endif #endif
getMaterialToken(file, token); //open brace getMaterialToken(file, token); //open brace
getMaterialToken(file, token); getMaterialToken(file, token);
...@@ -1300,7 +1311,7 @@ void COgreMeshFileLoader::loadMaterials(io::IReadFile* meshFile) ...@@ -1300,7 +1311,7 @@ void COgreMeshFileLoader::loadMaterials(io::IReadFile* meshFile)
file->drop(); file->drop();
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Finished loading Materials"); os::Printer::log("Finished loading Materials", ELL_DEBUG);
#endif #endif
} }
...@@ -1308,7 +1319,7 @@ void COgreMeshFileLoader::loadMaterials(io::IReadFile* meshFile) ...@@ -1308,7 +1319,7 @@ void COgreMeshFileLoader::loadMaterials(io::IReadFile* meshFile)
bool COgreMeshFileLoader::loadSkeleton(io::IReadFile* meshFile, const core::stringc& name) bool COgreMeshFileLoader::loadSkeleton(io::IReadFile* meshFile, const core::stringc& name)
{ {
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Load Skeleton", name); os::Printer::log("Load Skeleton", name, ELL_DEBUG);
#endif #endif
io::IReadFile* file = 0; io::IReadFile* file = 0;
io::path filename; io::path filename;
...@@ -1363,9 +1374,9 @@ bool COgreMeshFileLoader::loadSkeleton(io::IReadFile* meshFile, const core::stri ...@@ -1363,9 +1374,9 @@ bool COgreMeshFileLoader::loadSkeleton(io::IReadFile* meshFile, const core::stri
readVector(file, data, bone.Position); readVector(file, data, bone.Position);
readQuaternion(file, data, bone.Orientation); readQuaternion(file, data, bone.Orientation);
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Bone", bone.Name+" ("+core::stringc(bone.Handle)+")"); os::Printer::log("Bone", bone.Name+" ("+core::stringc(bone.Handle)+")", ELL_DEBUG);
os::Printer::log("Position", core::stringc(bone.Position.X)+" "+core::stringc(bone.Position.Y)+" "+core::stringc(bone.Position.Z)); os::Printer::log("Position", core::stringc(bone.Position.X)+" "+core::stringc(bone.Position.Y)+" "+core::stringc(bone.Position.Z), ELL_DEBUG);
os::Printer::log("Rotation quat", core::stringc(bone.Orientation.W)+" "+core::stringc(bone.Orientation.X)+" "+core::stringc(bone.Orientation.Y)+" "+core::stringc(bone.Orientation.Z)); os::Printer::log("Rotation quat", core::stringc(bone.Orientation.W)+" "+core::stringc(bone.Orientation.X)+" "+core::stringc(bone.Orientation.Y)+" "+core::stringc(bone.Orientation.Z), ELL_DEBUG);
// core::vector3df rot; // core::vector3df rot;
// bone.Orientation.toEuler(rot); // bone.Orientation.toEuler(rot);
// rot *= core::RADTODEG; // rot *= core::RADTODEG;
...@@ -1399,14 +1410,14 @@ bool COgreMeshFileLoader::loadSkeleton(io::IReadFile* meshFile, const core::stri ...@@ -1399,14 +1410,14 @@ bool COgreMeshFileLoader::loadSkeleton(io::IReadFile* meshFile, const core::stri
readString(file, data, anim.Name); readString(file, data, anim.Name);
readFloat(file, data, &anim.Length); readFloat(file, data, &anim.Length);
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Animation", anim.Name); os::Printer::log("Animation", anim.Name, ELL_DEBUG);
os::Printer::log("Length", core::stringc(anim.Length)); os::Printer::log("Length", core::stringc(anim.Length), ELL_DEBUG);
#endif #endif
} }
break; break;
case COGRE_ANIMATION_TRACK: case COGRE_ANIMATION_TRACK:
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("for Bone ", core::stringc(bone)); os::Printer::log("for Bone ", core::stringc(bone), ELL_DEBUG);
#endif #endif
readShort(file, data, &bone); // store current bone readShort(file, data, &bone); // store current bone
break; break;
...@@ -1430,7 +1441,7 @@ bool COgreMeshFileLoader::loadSkeleton(io::IReadFile* meshFile, const core::stri ...@@ -1430,7 +1441,7 @@ bool COgreMeshFileLoader::loadSkeleton(io::IReadFile* meshFile, const core::stri
break; break;
case COGRE_ANIMATION_LINK: case COGRE_ANIMATION_LINK:
#ifdef IRR_OGRE_LOADER_DEBUG #ifdef IRR_OGRE_LOADER_DEBUG
os::Printer::log("Animation link"); os::Printer::log("Animation link", ELL_DEBUG);
#endif #endif
break; break;
default: default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment