mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-28 00:31:50 +00:00
fixed issue when we put negative in a saving file
This commit is contained in:
@@ -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())));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user