Commit bbc0b48e authored by hybrid's avatar hybrid

Added line counting in .x loader, useful for easy debugging.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1639 dfc29bdd-3216-0410-991c-e03cc46cb475
parent a5da1f13
......@@ -368,6 +368,7 @@ bool CXMeshFileLoader::readFileIntoMemory(io::IReadFile* file)
return false;
}
Line = 1;
End = Buffer + size;
//! check header "xof "
......@@ -507,6 +508,7 @@ bool CXMeshFileLoader::parseDataObjectTemplate()
{
os::Printer::log("Left delimiter in template data object missing.",
name.c_str(), ELL_ERROR);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -549,6 +551,7 @@ bool CXMeshFileLoader::parseDataObjectFrame( CSkinnedMesh::SJoint *Parent )
if (!readHeadOfDataObject(&name))
{
os::Printer::log("No opening brace in Frame found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -599,6 +602,7 @@ bool CXMeshFileLoader::parseDataObjectFrame( CSkinnedMesh::SJoint *Parent )
if (objectName.size() == 0)
{
os::Printer::log("Unexpected ending found in Frame in x file.", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
else
......@@ -661,6 +665,7 @@ bool CXMeshFileLoader::parseDataObjectTransformationMatrix(core::matrix4 &mat)
if (!readHeadOfDataObject())
{
os::Printer::log("No opening brace in Transformation Matrix found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -669,12 +674,14 @@ bool CXMeshFileLoader::parseDataObjectTransformationMatrix(core::matrix4 &mat)
if (!checkForOneFollowingSemicolons())
{
os::Printer::log("No finishing semicolon in Transformation Matrix found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
if (!checkForClosingBrace())
{
os::Printer::log("No closing brace in Transformation Matrix found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -692,6 +699,7 @@ bool CXMeshFileLoader::parseDataObjectMesh(SXMesh &mesh)
os::Printer::log("CXFileReader: Reading mesh");
#endif
os::Printer::log("No opening brace in Mesh found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -713,6 +721,7 @@ bool CXMeshFileLoader::parseDataObjectMesh(SXMesh &mesh)
if (!checkForTwoFollowingSemicolons())
{
os::Printer::log("No finishing semicolon in Mesh Vertex Array found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -734,6 +743,7 @@ bool CXMeshFileLoader::parseDataObjectMesh(SXMesh &mesh)
if (fcnt < 3)
{
os::Printer::log("Invalid face count (<3) found in Mesh x file reader.", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -767,6 +777,7 @@ bool CXMeshFileLoader::parseDataObjectMesh(SXMesh &mesh)
if (!checkForTwoFollowingSemicolons())
{
os::Printer::log("No finishing semicolon in Mesh Face Array found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -783,6 +794,7 @@ bool CXMeshFileLoader::parseDataObjectMesh(SXMesh &mesh)
if (objectName.size() == 0)
{
os::Printer::log("Unexpected ending found in Mesh in x file.", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
else
......@@ -870,6 +882,7 @@ bool CXMeshFileLoader::parseDataObjectSkinWeights(SXMesh &mesh)
if (!readHeadOfDataObject())
{
os::Printer::log("No opening brace in Skin Weights found in .x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -878,6 +891,7 @@ bool CXMeshFileLoader::parseDataObjectSkinWeights(SXMesh &mesh)
if (!getNextTokenAsString(TransformNodeName))
{
os::Printer::log("Unknown syntax while reading transfrom node name string in .x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -946,12 +960,14 @@ bool CXMeshFileLoader::parseDataObjectSkinWeights(SXMesh &mesh)
if (!checkForOneFollowingSemicolons())
{
os::Printer::log("No finishing semicolon in Skin Weights found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
if (!checkForClosingBrace())
{
os::Printer::log("No closing brace in Skin Weights found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -968,6 +984,7 @@ bool CXMeshFileLoader::parseDataObjectSkinMeshHeader(SXMesh& mesh)
if (!readHeadOfDataObject())
{
os::Printer::log("No opening brace in Skin Mesh header found in .x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -981,6 +998,7 @@ bool CXMeshFileLoader::parseDataObjectSkinMeshHeader(SXMesh& mesh)
if (!checkForClosingBrace())
{
os::Printer::log("No closing brace in skin mesh header in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -997,6 +1015,7 @@ bool CXMeshFileLoader::parseDataObjectMeshNormals(SXMesh &mesh)
if (!readHeadOfDataObject())
{
os::Printer::log("No opening brace in Mesh Normals found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1012,6 +1031,7 @@ bool CXMeshFileLoader::parseDataObjectMeshNormals(SXMesh &mesh)
if (!checkForTwoFollowingSemicolons())
{
os::Printer::log("No finishing semicolon in Mesh Normals Array found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1032,6 +1052,7 @@ bool CXMeshFileLoader::parseDataObjectMeshNormals(SXMesh &mesh)
if (indexcount != mesh.IndexCountPerFace[k])
{
os::Printer::log("Not matching normal and face index count found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1063,12 +1084,14 @@ bool CXMeshFileLoader::parseDataObjectMeshNormals(SXMesh &mesh)
if (!checkForTwoFollowingSemicolons())
{
os::Printer::log("No finishing semicolon in Mesh Face Normals Array found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
if (!checkForClosingBrace())
{
os::Printer::log("No closing brace in Mesh Normals found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1085,6 +1108,7 @@ bool CXMeshFileLoader::parseDataObjectMeshTextureCoords(SXMesh &mesh)
if (!readHeadOfDataObject())
{
os::Printer::log("No opening brace in Mesh Texture Coordinates found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1095,12 +1119,14 @@ bool CXMeshFileLoader::parseDataObjectMeshTextureCoords(SXMesh &mesh)
if (!checkForTwoFollowingSemicolons())
{
os::Printer::log("No finishing semicolon in Mesh Texture Coordinates Array found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
if (!checkForClosingBrace())
{
os::Printer::log("No closing brace in Mesh Texture Coordinates Array found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1117,6 +1143,7 @@ bool CXMeshFileLoader::parseDataObjectMeshVertexColors(SXMesh &mesh)
if (!readHeadOfDataObject())
{
os::Printer::log("No opening brace for Mesh Vertex Colors found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1128,6 +1155,7 @@ bool CXMeshFileLoader::parseDataObjectMeshVertexColors(SXMesh &mesh)
if (Index>=mesh.Vertices.size())
{
os::Printer::log("index value in parseDataObjectMeshVertexColors out of bounds", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
readRGBA(mesh.Vertices[Index].Color);
......@@ -1137,12 +1165,14 @@ bool CXMeshFileLoader::parseDataObjectMeshVertexColors(SXMesh &mesh)
if (!checkForOneFollowingSemicolons())
{
os::Printer::log("No finishing semicolon in Mesh Vertex Colors Array found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
if (!checkForClosingBrace())
{
os::Printer::log("No closing brace in Mesh Texture Coordinates Array found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1159,6 +1189,7 @@ bool CXMeshFileLoader::parseDataObjectMeshMaterialList(SXMesh &mesh)
if (!readHeadOfDataObject())
{
os::Printer::log("No opening brace in Mesh Material List found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1204,6 +1235,7 @@ bool CXMeshFileLoader::parseDataObjectMeshMaterialList(SXMesh &mesh)
if (objectName.size() == 0)
{
os::Printer::log("Unexpected ending found in Mesh Material list in .x file.", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
else
......@@ -1253,6 +1285,7 @@ bool CXMeshFileLoader::parseDataObjectMaterial(video::SMaterial& material)
if (!readHeadOfDataObject())
{
os::Printer::log("No opening brace in Mesh Material found in .x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1276,6 +1309,7 @@ bool CXMeshFileLoader::parseDataObjectMaterial(video::SMaterial& material)
if (objectName.size() == 0)
{
os::Printer::log("Unexpected ending found in Mesh Material in .x file.", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
else
......@@ -1328,6 +1362,7 @@ bool CXMeshFileLoader::parseDataObjectAnimationSet()
if (!readHeadOfDataObject(&AnimationName))
{
os::Printer::log("No opening brace in Animation Set found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1338,6 +1373,7 @@ bool CXMeshFileLoader::parseDataObjectAnimationSet()
if (objectName.size() == 0)
{
os::Printer::log("Unexpected ending found in Animation set in x file.", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
else
......@@ -1371,6 +1407,7 @@ bool CXMeshFileLoader::parseDataObjectAnimation()
if (!readHeadOfDataObject())
{
os::Printer::log("No opening brace in Animation found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1387,6 +1424,7 @@ bool CXMeshFileLoader::parseDataObjectAnimation()
if (objectName.size() == 0)
{
os::Printer::log("Unexpected ending found in Animation in x file.", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
else
......@@ -1416,6 +1454,7 @@ bool CXMeshFileLoader::parseDataObjectAnimation()
if (!checkForClosingBrace())
{
os::Printer::log("Unexpected ending found in Animation in x file.", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
}
......@@ -1487,6 +1526,7 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
if (!readHeadOfDataObject())
{
os::Printer::log("No opening brace in Animation Key found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1497,6 +1537,7 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
if (keyType > 4)
{
os::Printer::log("Unknown key type found in Animation Key in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1524,6 +1565,7 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
if (readInt() != 4)
{
os::Printer::log("Expected 4 numbers in animation key in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1535,6 +1577,7 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
if (!checkForTwoFollowingSemicolons())
{
os::Printer::log("No finishing semicolon after quaternion animation key in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1552,6 +1595,7 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
if (readInt() != 3)
{
os::Printer::log("Expected 3 numbers in animation key in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1561,6 +1605,7 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
if (!checkForTwoFollowingSemicolons())
{
os::Printer::log("No finishing semicolon after vector animation key in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1587,6 +1632,7 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
if (readInt() != 16)
{
os::Printer::log("Expected 16 numbers in animation key in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1599,6 +1645,7 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
if (!checkForOneFollowingSemicolons())
{
os::Printer::log("No finishing semicolon after matrix animation key in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1637,6 +1684,7 @@ bool CXMeshFileLoader::parseDataObjectAnimationKey(ISkinnedMesh::SJoint *joint)
if (!checkForClosingBrace())
{
os::Printer::log("No closing brace in animation key in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1653,18 +1701,21 @@ bool CXMeshFileLoader::parseDataObjectTextureFilename(core::stringc& texturename
if (!readHeadOfDataObject())
{
os::Printer::log("No opening brace in Texture filename found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
if (!getNextTokenAsString(texturename))
{
os::Printer::log("Unknown syntax while reading texture filename string in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
if (!checkForClosingBrace())
{
os::Printer::log("No closing brace in Texture filename found in x file", ELL_WARNING);
os::Printer::log("Line", core::stringc(Line).c_str(), ELL_ERROR);
return false;
}
......@@ -1912,7 +1963,11 @@ void CXMeshFileLoader::findNextNoneWhiteSpace()
while(true)
{
while((P < End) && core::isspace(P[0]))
{
if (*P=='\n')
++Line;
++P;
}
if (P >= End)
return;
......@@ -1968,6 +2023,7 @@ void CXMeshFileLoader::readUntilEndOfLine()
if (P[0] == '\n' || P[0] == '\r')
{
++P;
++Line;
return;
}
......
......@@ -184,6 +184,7 @@ private:
const c8* P;
c8* End;
c8 FloatSize;
u32 Line;
core::stringc FilePath;
CSkinnedMesh::SJoint *CurFrame;
......
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