fixed one segf

This commit is contained in:
HENRY Benjamin
2021-06-16 15:04:04 +02:00
parent 9cb097c8b7
commit cc73dafb4e
+9 -5
View File
@@ -144,9 +144,9 @@ namespace BBM {
blockFile << _block.str() << std::endl; blockFile << _block.str() << std::endl;
playerFile << _player.str() << std::endl; playerFile << _player.str() << std::endl;
bonusFile << _bonus.str() << std::endl; bonusFile << _bonus.str() << std::endl;
_block.clear(); _block = std::stringstream();
_player.clear(); _player = std::stringstream();
_bonus.clear(); _bonus = std::stringstream();
} }
void ParserYAML::_loadPlayer(std::shared_ptr<WAL::Scene> scene, std::vector<std::string> lines, int &index) void ParserYAML::_loadPlayer(std::shared_ptr<WAL::Scene> scene, std::vector<std::string> lines, int &index)
@@ -202,7 +202,7 @@ namespace BBM {
if (!file.good()) if (!file.good())
throw (ParserError("File error")); throw (ParserError("File error"));
while (std::getline(file, line)) { while (std::getline(file, line)) {
if (line.empty() || !line.compare("players:")) if (line.empty() || line.find("players:") != std::string::npos)
continue; continue;
lines.push_back(line); lines.push_back(line);
} }
@@ -287,6 +287,10 @@ namespace BBM {
_parseEntityName(lines[index], entity); _parseEntityName(lines[index], entity);
} }
} }
if (bonusType == Bonus::NOTHING) {
entity.scheduleDeletion();
return;
}
MapGenerator::createBonus(entity, pos, bonusType); MapGenerator::createBonus(entity, pos, bonusType);
} }
@@ -299,7 +303,7 @@ namespace BBM {
if (!file.good()) if (!file.good())
throw (ParserError("File error")); throw (ParserError("File error"));
while (std::getline(file, line)) { while (std::getline(file, line)) {
if (line.empty() || !line.compare("bonuses:")) if (line.empty() || line.find("bonuses:") != std::string::npos)
continue; continue;
lines.push_back(line); lines.push_back(line);
} }