citybuilder
citybuilder copied to clipboard
[Suggestion] Part 5 - Improvement
Instead of the switch case in the function Map::load(...) in Part 5 of this series, why not the following -
std::string name = tileTypeToString(tileType);
//Convert to lowercase
for (auto &c : name) {
c = tolower(c);
}
//case TileType::VOID:
//case TileType::GRASS:
//Replacement
if (tileType != TileType::VOID) {
this->tiles.push_back(tileAlias.at(name));
} else {
this->tiles.push_back(tileAlias.at("grass"));
}
`
Of course, I have yet to test this, so I am not sure whether it works exactly the same.