mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-07 09:14:21 +00:00
Fixes overriding special recall lists for a scenario if loading from a savegame.
This commit is contained in:
parent
819b0103b1
commit
711db6d6d7
@ -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;
|
||||
|
@ -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<config*>& player_cfg = gamestate.snapshot.get_children("player");
|
||||
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){
|
||||
player->gold = lexical_cast <int> ((**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<config*>& player_cfg = gamestate.snapshot.get_children("player");
|
||||
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){
|
||||
player->gold = lexical_cast <int> ((**p)["gold"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
//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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user