* Loads the terrain from a YAML file. * @param node YAML node. * @param ruleset Ruleset for the terrain. */
| 50 | * @param ruleset Ruleset for the terrain. |
| 51 | */ |
| 52 | void RuleTerrain::load(const YAML::Node &node, Ruleset *ruleset) |
| 53 | { |
| 54 | if (const YAML::Node &map = node["mapDataSets"]) |
| 55 | { |
| 56 | _mapDataSets.clear(); |
| 57 | for (YAML::const_iterator i = map.begin(); i != map.end(); ++i) |
| 58 | { |
| 59 | _mapDataSets.push_back(ruleset->getMapDataSet(i->as<std::string>())); |
| 60 | } |
| 61 | } |
| 62 | if (const YAML::Node &map = node["mapBlocks"]) |
| 63 | { |
| 64 | _mapBlocks.clear(); |
| 65 | for (YAML::const_iterator i = map.begin(); i != map.end(); ++i) |
| 66 | { |
| 67 | MapBlock *map = new MapBlock((*i)["name"].as<std::string>(), 0, 0, MT_DEFAULT); |
| 68 | map->load(*i); |
| 69 | _mapBlocks.push_back(map); |
| 70 | } |
| 71 | } |
| 72 | _name = node["name"].as<std::string>(_name); |
| 73 | _largeBlockLimit = node["largeBlockLimit"].as<int>(_largeBlockLimit); |
| 74 | _textures = node["textures"].as< std::vector<int> >(_textures); |
| 75 | _hemisphere = node["hemisphere"].as<int>(_hemisphere); |
| 76 | _roadTypeOdds = node["roadTypeOdds"].as< std::vector<int> >(_roadTypeOdds); |
| 77 | |
| 78 | if (const YAML::Node &civs = node["civilianTypes"]) |
| 79 | { |
| 80 | _civilianTypes = civs.as<std::vector<std::string> >(_civilianTypes); |
| 81 | } |
| 82 | else |
| 83 | { |
| 84 | _civilianTypes.push_back("MALE_CIVILIAN"); |
| 85 | _civilianTypes.push_back("FEMALE_CIVILIAN"); |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Gets the array of mapblocks. |
nothing calls this directly
no test coverage detected