Utility/OBJParser: Abort parsing when there's more than one error per two line
Former-commit-id: 37075de6e7d10996af4c30ffcf74ead74b27905f [formerly 25597dd190b82dc40de1eaf7f4c75c9b058784ec] Former-commit-id: 5383d58fd326b61cce4c415707dd06a0376e6dbe
This commit is contained in:
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user