From 711db6d6d7d0fc46cf7e66f257518ff6c5ec1fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Hinrichs?= Date: Tue, 6 Mar 2007 21:56:23 +0000 Subject: [PATCH] Fixes overriding special recall lists for a scenario if loading from a savegame. --- src/gamestatus.cpp | 2 +- src/playcampaign.cpp | 34 ++++++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/gamestatus.cpp b/src/gamestatus.cpp index 973d5577ce4..56f68e63c6e 100644 --- a/src/gamestatus.cpp +++ b/src/gamestatus.cpp @@ -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; diff --git a/src/playcampaign.cpp b/src/playcampaign.cpp index 04fee0cfe79..b1c820d359f 100644 --- a/src/playcampaign.cpp +++ b/src/playcampaign.cpp @@ -157,14 +157,32 @@ 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& player_cfg = gamestate.snapshot.get_children("player"); - for (std::vector::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){ - player->gold = lexical_cast ((**p)["gold"]); + { + //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& player_cfg = gamestate.snapshot.get_children("player"); + for (std::vector::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){ + player->gold = lexical_cast ((**p)["gold"]); + } + } + } + { + //also get the recruitment list if there are some specialties in this scenario + const std::vector& player_cfg = gamestate.snapshot.get_children("side"); + for (std::vector::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 can_recruit = utils::split(can_recruit_str); + std::copy(can_recruit.begin(),can_recruit.end(),std::inserter(player->can_recruit,player->can_recruit.end())); + } + } } } }