* @param node The YAML node containing the data. * @param game The game data, required to locate the alien base. */
| 74 | * @param game The game data, required to locate the alien base. |
| 75 | */ |
| 76 | void AlienMission::load(const YAML::Node& node, SavedGame &game) |
| 77 | { |
| 78 | _region = node["region"].as<std::string>(_region); |
| 79 | _race = node["race"].as<std::string>(_race); |
| 80 | _nextWave = node["nextWave"].as<size_t>(_nextWave); |
| 81 | _nextUfoCounter = node["nextUfoCounter"].as<size_t>(_nextUfoCounter); |
| 82 | _spawnCountdown = node["spawnCountdown"].as<size_t>(_spawnCountdown); |
| 83 | _liveUfos = node["liveUfos"].as<size_t>(_liveUfos); |
| 84 | _uniqueID = node["uniqueID"].as<int>(_uniqueID); |
| 85 | if (const YAML::Node &base = node["alienBase"]) |
| 86 | { |
| 87 | int id = base.as<int>(); |
| 88 | std::vector<AlienBase*>::const_iterator found = std::find_if(game.getAlienBases()->begin(), game.getAlienBases()->end(), matchById(id)); |
| 89 | if (found == game.getAlienBases()->end()) |
| 90 | { |
| 91 | throw Exception("Corrupted save: Invalid base for mission."); |
| 92 | } |
| 93 | _base = *found; |
| 94 | } |
| 95 | |
| 96 | } |
| 97 | |
| 98 | YAML::Node AlienMission::save() const |
| 99 | { |
nothing calls this directly
no test coverage detected