Fixes overriding special recall lists for a scenario if loading from a savegame.

This commit is contained in:
Jörg Hinrichs 2007-03-06 21:56:23 +00:00
parent 819b0103b1
commit 711db6d6d7
2 changed files with 27 additions and 9 deletions

View File

@ -458,7 +458,7 @@ game_state read_game(const game_data& data, const config* cfg)
//backwards compatibility for 1.2 and 1.2.1,
//------------------------------------------
//add recall list units to the snapshot so they don't get lost
if (!snapshot->empty())
if (!snapshot->empty() && (res.version < "1.2.2") )
{
//find the side of this player in the snapshot
config* current_side = NULL;

View File

@ -157,6 +157,7 @@ LEVEL_RESULT play_game(display& disp, game_state& gamestate, const config& game_
if (!gamestate.snapshot["label"].empty()){
gamestate.label = gamestate.snapshot["label"];
}
{
//get the current gold values of players so they don't start with the amount
//they had at the start of the scenario
const std::vector<config*>& player_cfg = gamestate.snapshot.get_children("player");
@ -168,6 +169,23 @@ LEVEL_RESULT play_game(display& disp, game_state& gamestate, const config& game_
}
}
}
{
//also get the recruitment list if there are some specialties in this scenario
const std::vector<config*>& player_cfg = gamestate.snapshot.get_children("side");
for (std::vector<config*>::const_iterator p = player_cfg.begin(); p != player_cfg.end(); p++){
std::string save_id = (**p)["save_id"];
player_info* player = gamestate.get_player(save_id);
if (player != NULL){
const std::string& can_recruit_str = (**p)["recruit"];
if(can_recruit_str != "") {
player->can_recruit.clear();
const std::vector<std::string> can_recruit = utils::split(can_recruit_str);
std::copy(can_recruit.begin(),can_recruit.end(),std::inserter(player->can_recruit,player->can_recruit.end()));
}
}
}
}
}
controller_map controllers;