/** * Loads the terrain from a YAML file. * @param node YAML node. * @param mod Mod for the terrain. */ void RuleTerrain::load(const YAML::Node &node, Mod *mod) { if (const YAML::Node &map = node["mapDataSets"]) { _mapDataSets.clear(); for (YAML::const_iterator i = map.begin(); i != map.end(); ++i) { _mapDataSets.push_back(mod->getMapDataSet(i->as<std::string>())); } } if (const YAML::Node &map = node["mapBlocks"]) { _mapBlocks.clear(); for (YAML::const_iterator i = map.begin(); i != map.end(); ++i) { MapBlock *mapBlock = new MapBlock((*i)["name"].as<std::string>()); mapBlock->load(*i); _mapBlocks.push_back(mapBlock); } } _name = node["name"].as<std::string>(_name); if (const YAML::Node &civs = node["civilianTypes"]) { _civilianTypes = civs.as<std::vector<std::string> >(_civilianTypes); } else { _civilianTypes.push_back("MALE_CIVILIAN"); _civilianTypes.push_back("FEMALE_CIVILIAN"); } for (YAML::const_iterator i = node["music"].begin(); i != node["music"].end(); ++i) { _music.push_back((*i).as<std::string>("")); } if (node["depth"]) { _minDepth = node["depth"][0].as<int>(_minDepth); _maxDepth = node["depth"][1].as<int>(_maxDepth); } if (node["ambience"]) { _ambience = mod->getSoundOffset(node["ambience"].as<int>(_ambience), "BATTLE.CAT"); } _ambientVolume = node["ambientVolume"].as<double>(_ambientVolume); _script = node["script"].as<std::string>(_script); }
/** * Loads the terrain from a YAML file. * @param node YAML node. * @param ruleset Ruleset for the terrain. */ void RuleTerrain::load(const YAML::Node &node, Ruleset *ruleset) { if (const YAML::Node &map = node["mapDataSets"]) { _mapDataSets.clear(); for (YAML::const_iterator i = map.begin(); i != map.end(); ++i) { _mapDataSets.push_back(ruleset->getMapDataSet(i->as<std::string>())); } } if (const YAML::Node &map = node["mapBlocks"]) { _mapBlocks.clear(); for (YAML::const_iterator i = map.begin(); i != map.end(); ++i) { MapBlock *map = new MapBlock((*i)["name"].as<std::string>(), 0, 0, MT_DEFAULT); map->load(*i); _mapBlocks.push_back(map); } } _name = node["name"].as<std::string>(_name); _largeBlockLimit = node["largeBlockLimit"].as<int>(_largeBlockLimit); _textures = node["textures"].as< std::vector<int> >(_textures); _hemisphere = node["hemisphere"].as<int>(_hemisphere); _roadTypeOdds = node["roadTypeOdds"].as< std::vector<int> >(_roadTypeOdds); if (const YAML::Node &civs = node["civilianTypes"]) { _civilianTypes = civs.as<std::vector<std::string> >(_civilianTypes); } else { _civilianTypes.push_back("MALE_CIVILIAN"); _civilianTypes.push_back("FEMALE_CIVILIAN"); } _minDepth = node["minDepth"].as<int>(_minDepth); _maxDepth = node["maxDepth"].as<int>(_maxDepth); }