fixed issue when we put negative in a saving file

This commit is contained in:
EternalRat
2021-06-16 16:19:59 +02:00
parent 6616a99c04
commit 1fe8c0da4d
+10
View File
@@ -371,6 +371,8 @@ namespace BBM {
{
if (line.find(": ") == std::string::npos || !_isInteger(line.substr(line.find(": ") + 2)))
throw (ParserError("Error with saved map: Couldn't parse max bomb.\n Loading default maps..."));
if (line.find("-") != std::string::npos)
throw (ParserError("Error with saved map: Couldn't parse max bomb.\n Loading default maps..."));
return (std::atoi(line.substr(line.find(": ") + 2).c_str()));
}
@@ -378,6 +380,8 @@ namespace BBM {
{
if (line.find(": ") == std::string::npos || !_isFloat(line.substr(line.find(": ") + 2)))
throw (ParserError("Error with saved map: Couldn't parse explosion radius.\n Loading default maps..."));
if (line.find("-") != std::string::npos)
throw (ParserError("Error with saved map: Couldn't parse explosion radius.\n Loading default maps..."));
return (std::atof(line.substr(line.find(": ") + 2).c_str()));
}
@@ -385,6 +389,8 @@ namespace BBM {
{
if (line.find(": ") == std::string::npos || !_isFloat(line.substr(line.find(": ") + 2)))
throw (ParserError("Error with saved map: Couldn't parse speed.\n Loading default maps..."));
if (line.find("-") != std::string::npos)
throw (ParserError("Error with saved map: Couldn't parse speed.\n Loading default maps..."));
return (std::atof(line.substr(line.find(": ") + 2).c_str()));
}
@@ -392,6 +398,8 @@ namespace BBM {
{
if (blockType.find(": ") == std::string::npos || !_isInteger(blockType.substr(blockType.find(": ") + 2)))
throw (ParserError("Error with saved map: Couldn't parse block type.\n Loading default maps..."));
if (blockType.find("-") != std::string::npos)
throw (ParserError("Error with saved map: Couldn't parse block type.\n Loading default maps..."));
return (static_cast<MapGenerator::BlockType>(std::atoi(blockType.substr(blockType.find(": ") + 2).c_str())));
}
@@ -399,6 +407,8 @@ namespace BBM {
{
if (bonusType.find(": ") == std::string::npos || !_isInteger(bonusType.substr(bonusType.find(": ") + 2)))
throw (ParserError("Error with saved map: Couldn't parse bonus type.\n Loading default maps..."));
if (bonusType.find("-") != std::string::npos)
throw (ParserError("Error with saved map: Couldn't parse bonus type.\n Loading default maps..."));
return (static_cast<Bonus::BonusType>(std::atoi(bonusType.substr(bonusType.find(": ") + 2).c_str())));
}