Utility/OBJParser: Abort parsing when there's more than one error per two line

Former-commit-id: b8126ca529f91492a1d116da7cb446b8eaa25a90 [formerly c33f7b8d27ba18303b839693aa3ef056d1f48ae1]
Former-commit-id: 701965304b9e51ddf1ee2233559f2f97d4a51894
This commit is contained in:
Lynix
2016-07-29 13:37:44 +02:00
parent 9fa7267523
commit 5d6cee8291
3 changed files with 45 additions and 23 deletions

View File

@@ -86,7 +86,7 @@ namespace Nz
inline void Error(const String& message);
inline void Flush() const;
inline void Warning(const String& message);
inline void UnrecognizedLine(bool error = false);
inline bool UnrecognizedLine(bool error = false);
std::vector<Mesh> m_meshes;
std::vector<String> m_materials;
@@ -99,6 +99,7 @@ namespace Nz
mutable StringStream m_outputStream;
bool m_keepLastLine;
unsigned int m_lineCount;
unsigned int m_errorCount;
};
}

View File

@@ -168,7 +168,7 @@ namespace Nz
NazaraWarning(message + " at line #" + String::Number(m_lineCount));
}
inline void OBJParser::UnrecognizedLine(bool error)
inline bool OBJParser::UnrecognizedLine(bool error)
{
String message = "Unrecognized \"" + m_currentLine + '"';
@@ -176,6 +176,16 @@ namespace Nz
Error(message);
else
Warning(message);
m_errorCount++;
if (m_lineCount > 20 && (m_errorCount * 100 / m_lineCount) > 50)
{
NazaraError("Aborting parsing because of error percentage");
return false; //< Abort parsing if error percentage is too high
}
return true;
}
}