remove function we had twice
convert_old_saves is already defined in gamestatus.cpp
This commit is contained in:
parent
7154ab4609
commit
3bc9e0476d
1 changed files with 0 additions and 105 deletions
|
@ -62,111 +62,6 @@ saved_game::saved_game(const config& cfg)
|
|||
|
||||
}
|
||||
|
||||
static void convert_old_saves(config& cfg){
|
||||
if(!cfg.has_child("snapshot")){
|
||||
return;
|
||||
}
|
||||
|
||||
const config& snapshot = cfg.child("snapshot");
|
||||
const config& replay_start = cfg.child("replay_start");
|
||||
const config& replay = cfg.child("replay");
|
||||
|
||||
if(!cfg.has_child("carryover_sides") && !cfg.has_child("carryover_sides_start")){
|
||||
config carryover;
|
||||
//copy rng and menu items from toplevel to new carryover_sides
|
||||
carryover["random_seed"] = cfg["random_seed"];
|
||||
carryover["random_calls"] = cfg["random_calls"];
|
||||
BOOST_FOREACH(const config& menu_item, cfg.child_range("menu_item")){
|
||||
carryover.add_child("menu_item", menu_item);
|
||||
}
|
||||
carryover["difficulty"] = cfg["difficulty"];
|
||||
carryover["random_mode"] = cfg["random_mode"];
|
||||
//the scenario to be played is always stored as next_scenario in carryover_sides_start
|
||||
carryover["next_scenario"] = cfg["scenario"];
|
||||
|
||||
config carryover_start = carryover;
|
||||
|
||||
//copy sides from either snapshot or replay_start to new carryover_sides
|
||||
if(!snapshot.empty()){
|
||||
BOOST_FOREACH(const config& side, snapshot.child_range("side")){
|
||||
carryover.add_child("side", side);
|
||||
}
|
||||
//for compatibility with old savegames that use player instead of side
|
||||
BOOST_FOREACH(const config& side, snapshot.child_range("player")){
|
||||
carryover.add_child("side", side);
|
||||
}
|
||||
//save the sides from replay_start in carryover_sides_start
|
||||
BOOST_FOREACH(const config& side, replay_start.child_range("side")){
|
||||
carryover_start.add_child("side", side);
|
||||
}
|
||||
//for compatibility with old savegames that use player instead of side
|
||||
BOOST_FOREACH(const config& side, replay_start.child_range("player")){
|
||||
carryover_start.add_child("side", side);
|
||||
}
|
||||
} else if (!replay_start.empty()){
|
||||
BOOST_FOREACH(const config& side, replay_start.child_range("side")){
|
||||
carryover.add_child("side", side);
|
||||
carryover_start.add_child("side", side);
|
||||
}
|
||||
//for compatibility with old savegames that use player instead of side
|
||||
BOOST_FOREACH(const config& side, replay_start.child_range("player")){
|
||||
carryover.add_child("side", side);
|
||||
carryover_start.add_child("side", side);
|
||||
}
|
||||
}
|
||||
|
||||
//get variables according to old hierarchy and copy them to new carryover_sides
|
||||
if(!snapshot.empty()){
|
||||
if(const config& variables = snapshot.child("variables")){
|
||||
carryover.add_child("variables", variables);
|
||||
carryover_start.add_child("variables", replay_start.child_or_empty("variables"));
|
||||
} else if (const config& variables = cfg.child("variables")){
|
||||
carryover.add_child("variables", variables);
|
||||
carryover_start.add_child("variables", variables);
|
||||
}
|
||||
} else if (!replay_start.empty()){
|
||||
if(const config& variables = replay_start.child("variables")){
|
||||
carryover.add_child("variables", variables);
|
||||
carryover_start.add_child("variables", variables);
|
||||
}
|
||||
} else {
|
||||
carryover.add_child("variables", cfg.child("variables"));
|
||||
carryover_start.add_child("variables", cfg.child("variables"));
|
||||
}
|
||||
|
||||
cfg.add_child("carryover_sides", carryover);
|
||||
cfg.add_child("carryover_sides_start", carryover_start);
|
||||
}
|
||||
|
||||
//if replay and snapshot are empty we've got a start of scenario save and don't want replay_start either
|
||||
if(replay.empty() && snapshot.empty()){
|
||||
LOG_RG<<"removing replay_start \n";
|
||||
cfg.remove_child("replay_start", 0);
|
||||
}
|
||||
|
||||
//remove empty replay or snapshot so type of save can be detected more easily
|
||||
if(replay.empty()){
|
||||
LOG_RG<<"removing replay \n";
|
||||
cfg.remove_child("replay", 0);
|
||||
}
|
||||
|
||||
if(snapshot.empty()){
|
||||
LOG_RG<<"removing snapshot \n";
|
||||
cfg.remove_child("snapshot", 0);
|
||||
}
|
||||
//?-1.11.? end
|
||||
//1.12-1.13 begin
|
||||
if(config& carryover_sides_start = cfg.child("carryover_sides_start"))
|
||||
{
|
||||
if(!carryover_sides_start.has_attribute("next_underlying_unit_id"))
|
||||
{
|
||||
carryover_sides_start["next_underlying_unit_id"] = cfg["next_underlying_unit_id"];
|
||||
}
|
||||
}
|
||||
//1.12-1.13 end
|
||||
LOG_RG<<"cfg after conversion "<<cfg<<"\n";
|
||||
}
|
||||
|
||||
saved_game::saved_game(const saved_game& state) :
|
||||
replay_data(state.replay_data),
|
||||
snapshot(state.snapshot),
|
||||
|
|
Loading…
Add table
Reference in a new issue