@@ -61,11 +61,12 @@ class matchById: public std::unary_function<const AlienBase *, bool>
6161{
6262public:
6363 // / Remember ID.
64- matchById (int id) : _id(id) { /* Empty by design. */ }
64+ matchById (int id, std::string type ) : _id(id), _type(type ) { /* Empty by design. */ }
6565 // / Match with stored ID.
66- bool operator ()(const AlienBase *ab) const { return ab->getId () == _id; }
66+ bool operator ()(const AlienBase *ab) const { return ab->getId () == _id && ab-> getDeployment ()-> getMarkerName () == _type ; }
6767private:
6868 int _id;
69+ std::string _type;
6970};
7071
7172/* *
@@ -84,8 +85,15 @@ void AlienMission::load(const YAML::Node& node, SavedGame &game)
8485 _uniqueID = node[" uniqueID" ].as <int >(_uniqueID);
8586 if (const YAML ::Node &base = node[" alienBase" ])
8687 {
87- int id = base.as <int >();
88- std::vector<AlienBase*>::const_iterator found = std::find_if (game.getAlienBases ()->begin (), game.getAlienBases ()->end (), matchById (id));
88+ int id = base.as <int >(-1 );
89+ std::string type = " STR_ALIEN_BASE" ;
90+ // New format
91+ if (id == -1 )
92+ {
93+ id = base[" id" ].as <int >();
94+ type = base[" type" ].as <std::string>();
95+ }
96+ std::vector<AlienBase*>::const_iterator found = std::find_if (game.getAlienBases ()->begin (), game.getAlienBases ()->end (), matchById (id, type));
8997 if (found == game.getAlienBases ()->end ())
9098 {
9199 throw Exception (" Corrupted save: Invalid base for mission." );
@@ -112,7 +120,7 @@ YAML::Node AlienMission::save() const
112120 node[" uniqueID" ] = _uniqueID;
113121 if (_base)
114122 {
115- node[" alienBase" ] = _base->getId ();
123+ node[" alienBase" ] = _base->saveId ();
116124 }
117125 node[" missionSiteZone" ] = _missionSiteZone;
118126 return node;
0 commit comments