more removal of unnecessary code in mp_game_settings
This commit is contained in:
parent
4ec3d15288
commit
760e967060
3 changed files with 33 additions and 71 deletions
|
@ -54,75 +54,38 @@ mp_game_settings::mp_game_settings() :
|
|||
options()
|
||||
{}
|
||||
|
||||
mp_game_settings::mp_game_settings(const config& cfg) :
|
||||
savegame_config(),
|
||||
name(),
|
||||
password(),
|
||||
hash(),
|
||||
mp_era(),
|
||||
mp_scenario(),
|
||||
mp_scenario_name(),
|
||||
mp_campaign(),
|
||||
difficulty_define(),
|
||||
active_mods(),
|
||||
side_users(),
|
||||
show_configure(true),
|
||||
show_connect(true),
|
||||
num_turns(0),
|
||||
village_gold(0),
|
||||
village_support(1),
|
||||
xp_modifier(100),
|
||||
mp_countdown_init_time(0),
|
||||
mp_countdown_reservoir_time(0),
|
||||
mp_countdown_turn_bonus(0),
|
||||
mp_countdown_action_bonus(0),
|
||||
mp_countdown(false),
|
||||
use_map_settings(false),
|
||||
random_start_time(false),
|
||||
fog_game(false),
|
||||
shroud_game(false),
|
||||
allow_observers(false),
|
||||
shuffle_sides(false),
|
||||
saved_game(false),
|
||||
options()
|
||||
mp_game_settings::mp_game_settings(const config& cfg)
|
||||
: savegame_config()
|
||||
, name(cfg["scenario"].str())
|
||||
, password()
|
||||
, hash(cfg["hash"].str())
|
||||
, mp_era(cfg["mp_era"].str())
|
||||
, mp_scenario(cfg["mp_scenario"].str())
|
||||
, mp_scenario_name(cfg["mp_scenario_name"].str())
|
||||
, mp_campaign(cfg["mp_campaign"].str())
|
||||
, difficulty_define(cfg["difficulty_define"].str())
|
||||
, active_mods(utils::split(cfg["active_mods"], ','))
|
||||
, side_users(utils::map_split(cfg["side_users"]))
|
||||
, show_configure(cfg["show_configure"].to_bool(true))
|
||||
, show_connect(cfg["show_connect"].to_bool(true))
|
||||
, num_turns(cfg["mp_num_turns"])
|
||||
, village_gold(cfg["mp_village_gold"])
|
||||
, village_support(cfg["mp_village_support"])
|
||||
, xp_modifier(cfg["experience_modifier"].to_int(100))
|
||||
, mp_countdown_init_time(cfg["mp_countdown_init_time"])
|
||||
, mp_countdown_reservoir_time(cfg["mp_countdown_reservoir_time"])
|
||||
, mp_countdown_turn_bonus(cfg["mp_countdown_turn_bonus"])
|
||||
, mp_countdown_action_bonus(cfg["mp_countdown_action_bonus"])
|
||||
, mp_countdown(cfg["mp_countdown"].to_bool())
|
||||
, use_map_settings(cfg["mp_use_map_settings"].to_bool())
|
||||
, random_start_time(cfg["mp_random_start_time"].to_bool())
|
||||
, fog_game(cfg["mp_fog"].to_bool())
|
||||
, shroud_game(cfg["mp_shroud"].to_bool())
|
||||
, allow_observers(cfg["observer"].to_bool())
|
||||
, shuffle_sides(cfg["shuffle_sides"].to_bool())
|
||||
, saved_game(cfg["savegame"].to_bool())
|
||||
, options(cfg.child_or_empty("options"))
|
||||
{
|
||||
set_from_config(cfg);
|
||||
}
|
||||
|
||||
void mp_game_settings::set_from_config(const config& game_cfg)
|
||||
{
|
||||
const config& mp = game_cfg.child("multiplayer");
|
||||
const config& rs = game_cfg.child("replay_start");
|
||||
// if it's a replay the multiplayer section can be in the replay_start tag else fallback to top level
|
||||
const config& cfg = mp ? mp : rs ? (rs.child("multiplayer") ? rs.child("multiplayer") : game_cfg) : game_cfg;
|
||||
name = cfg["scenario"].str();
|
||||
hash = cfg["hash"].str();
|
||||
mp_era = cfg["mp_era"].str();
|
||||
mp_scenario = cfg["mp_scenario"].str();
|
||||
mp_scenario_name = cfg["mp_scenario_name"].str();
|
||||
mp_campaign = cfg["mp_campaign"].str();
|
||||
difficulty_define = cfg["difficulty_define"].str();
|
||||
active_mods = utils::split(cfg["active_mods"], ',');
|
||||
side_users = utils::map_split(cfg["side_users"]);
|
||||
show_configure = cfg["show_configure"].to_bool(true);
|
||||
show_connect = cfg["show_connect"].to_bool(true);
|
||||
xp_modifier = cfg["experience_modifier"].to_int(100);
|
||||
use_map_settings = cfg["mp_use_map_settings"].to_bool();
|
||||
random_start_time = cfg["mp_random_start_time"].to_bool();
|
||||
fog_game = cfg["mp_fog"].to_bool();
|
||||
shroud_game = cfg["mp_shroud"].to_bool();
|
||||
mp_countdown = cfg["mp_countdown"].to_bool();
|
||||
mp_countdown_init_time = cfg["mp_countdown_init_time"];
|
||||
mp_countdown_turn_bonus = cfg["mp_countdown_turn_bonus"];
|
||||
mp_countdown_reservoir_time = cfg["mp_countdown_reservoir_time"];
|
||||
mp_countdown_action_bonus = cfg["mp_countdown_action_bonus"];
|
||||
num_turns = cfg["mp_num_turns"];
|
||||
village_gold = cfg["mp_village_gold"];
|
||||
village_support = cfg["mp_village_support"];
|
||||
allow_observers = cfg["observer"].to_bool();
|
||||
shuffle_sides = cfg["shuffle_sides"].to_bool();
|
||||
saved_game = cfg["savegame"].to_bool();
|
||||
options = cfg.child_or_empty("options");
|
||||
}
|
||||
|
||||
config mp_game_settings::to_config() const
|
||||
|
|
|
@ -25,7 +25,6 @@ struct mp_game_settings : public savegame::savegame_config
|
|||
mp_game_settings();
|
||||
mp_game_settings(const config& cfg);
|
||||
|
||||
void set_from_config(const config& game_cfg);
|
||||
config to_config() const;
|
||||
|
||||
// The items returned while configuring the game
|
||||
|
|
|
@ -73,7 +73,7 @@ saved_game::saved_game(config cfg)
|
|||
, carryover_()
|
||||
, replay_start_()
|
||||
, classification_(cfg)
|
||||
, mp_settings_(cfg)
|
||||
, mp_settings_()
|
||||
, starting_pos_type_(STARTINGPOS_NONE)
|
||||
, starting_pos_()
|
||||
, replay_data_()
|
||||
|
@ -571,6 +571,6 @@ void saved_game::set_data(config& cfg)
|
|||
}
|
||||
|
||||
classification_ = game_classification(cfg);
|
||||
mp_settings_ = mp_game_settings(cfg);
|
||||
mp_settings_ = mp_game_settings(cfg.child_or_empty("multiplayer"));
|
||||
cfg.clear();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue