Saved Game: reame "starting pos" to "starting point" to avoid confusion
The old name was too easy to confuse with a side's map staring position, something I've done several times.
This commit is contained in:
parent
ce7faae4f4
commit
8f93d0a7c6
9 changed files with 109 additions and 109 deletions
|
@ -30,7 +30,7 @@ namespace ng
|
|||
configure_engine::configure_engine(saved_game& state, const config* initial)
|
||||
: state_(state)
|
||||
, parameters_(state_.mp_settings())
|
||||
, initial_(initial ? initial : &state_.get_starting_pos())
|
||||
, initial_(initial ? initial : &state_.get_starting_point())
|
||||
{
|
||||
set_use_map_settings(use_map_settings_default());
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ const config& configure_engine::options_default() const
|
|||
|
||||
void configure_engine::write_parameters()
|
||||
{
|
||||
config& scenario = this->state_.get_starting_pos();
|
||||
config& scenario = this->state_.get_starting_point();
|
||||
const mp_game_settings& params = this->state_.mp_settings();
|
||||
|
||||
if(params.random_start_time) {
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace mp
|
|||
static void add_multiplayer_classification(config& multiplayer, saved_game& state)
|
||||
{
|
||||
multiplayer["mp_scenario"] = state.get_scenario_id();
|
||||
multiplayer["mp_scenario_name"] = state.get_starting_pos()["name"];
|
||||
multiplayer["mp_scenario_name"] = state.get_starting_point()["name"];
|
||||
multiplayer["difficulty_define"] = state.classification().difficulty;
|
||||
multiplayer["mp_campaign"] = state.classification().campaign;
|
||||
multiplayer["mp_campaign_name"] = state.classification().campaign_name;
|
||||
|
@ -62,7 +62,7 @@ config initial_level_config(saved_game& state)
|
|||
throw config::error("Failed to load the scenario");
|
||||
}
|
||||
|
||||
config& scenario = state.get_starting_pos();
|
||||
config& scenario = state.get_starting_point();
|
||||
if(!state.mp_settings().saved_game) {
|
||||
state.set_random_seed();
|
||||
}
|
||||
|
|
|
@ -743,9 +743,9 @@ void start_local_game_commandline(const config& game_config, saved_game& state,
|
|||
state.expand_mp_options();
|
||||
|
||||
// Should number of turns be determined from scenario data?
|
||||
if(parameters.use_map_settings && state.get_starting_pos()["turns"]) {
|
||||
DBG_MP << "setting turns from scenario data: " << state.get_starting_pos()["turns"] << std::endl;
|
||||
parameters.num_turns = state.get_starting_pos()["turns"];
|
||||
if(parameters.use_map_settings && state.get_starting_point()["turns"]) {
|
||||
DBG_MP << "setting turns from scenario data: " << state.get_starting_point()["turns"] << std::endl;
|
||||
parameters.num_turns = state.get_starting_point()["turns"];
|
||||
}
|
||||
|
||||
DBG_MP << "entering connect mode" << std::endl;
|
||||
|
|
|
@ -190,7 +190,7 @@ void campaign_controller::show_carryover_message(
|
|||
|
||||
LEVEL_RESULT campaign_controller::playsingle_scenario(end_level_data& end_level)
|
||||
{
|
||||
playsingle_controller playcontroller(is_replay_ ? state_.get_replay_starting_pos() : state_.get_starting_pos(),
|
||||
playsingle_controller playcontroller(is_replay_ ? state_.get_replay_starting_point() : state_.get_starting_point(),
|
||||
state_, game_config_, tdata_, false);
|
||||
|
||||
LOG_NG << "created objects... " << (SDL_GetTicks() - playcontroller.get_ticks()) << "\n";
|
||||
|
@ -200,7 +200,7 @@ LEVEL_RESULT campaign_controller::playsingle_scenario(end_level_data& end_level)
|
|||
}
|
||||
|
||||
LEVEL_RESULT res =
|
||||
playcontroller.play_scenario(is_replay_ ? state_.get_replay_starting_pos() : state_.get_starting_pos());
|
||||
playcontroller.play_scenario(is_replay_ ? state_.get_replay_starting_point() : state_.get_starting_point());
|
||||
|
||||
if(res == LEVEL_RESULT::QUIT) {
|
||||
return LEVEL_RESULT::QUIT;
|
||||
|
@ -227,8 +227,8 @@ LEVEL_RESULT campaign_controller::playsingle_scenario(end_level_data& end_level)
|
|||
|
||||
LEVEL_RESULT campaign_controller::playmp_scenario(end_level_data& end_level)
|
||||
{
|
||||
playmp_controller playcontroller(state_.get_starting_pos(), state_, game_config_, tdata_, mp_info_);
|
||||
LEVEL_RESULT res = playcontroller.play_scenario(state_.get_starting_pos());
|
||||
playmp_controller playcontroller(state_.get_starting_point(), state_, game_config_, tdata_, mp_info_);
|
||||
LEVEL_RESULT res = playcontroller.play_scenario(state_.get_starting_point());
|
||||
|
||||
// Check if the player started as mp client and changed to host
|
||||
|
||||
|
@ -370,7 +370,7 @@ LEVEL_RESULT campaign_controller::play_game()
|
|||
|
||||
if(state_.valid()) {
|
||||
// note that although starting_pos is const it might be changed by gamestate.some_non_const_operation().
|
||||
const config& starting_pos = state_.get_starting_pos();
|
||||
const config& starting_pos = state_.get_starting_point();
|
||||
|
||||
const bool is_mp = state_.classification().is_normal_mp_game();
|
||||
state_.mp_settings().num_turns = starting_pos["turns"].to_int(-1);
|
||||
|
|
|
@ -90,8 +90,8 @@ saved_game::saved_game()
|
|||
, replay_start_()
|
||||
, classification_()
|
||||
, mp_settings_()
|
||||
, starting_pos_type_(STARTINGPOS_NONE)
|
||||
, starting_pos_()
|
||||
, starting_point_type_(STARTING_POINT_NONE)
|
||||
, starting_point_()
|
||||
, replay_data_()
|
||||
{
|
||||
}
|
||||
|
@ -102,8 +102,8 @@ saved_game::saved_game(config cfg)
|
|||
, replay_start_()
|
||||
, classification_(cfg)
|
||||
, mp_settings_()
|
||||
, starting_pos_type_(STARTINGPOS_NONE)
|
||||
, starting_pos_()
|
||||
, starting_point_type_(STARTING_POINT_NONE)
|
||||
, starting_point_()
|
||||
, replay_data_()
|
||||
|
||||
{
|
||||
|
@ -116,8 +116,8 @@ saved_game::saved_game(const saved_game& state)
|
|||
, replay_start_(state.replay_start_)
|
||||
, classification_(state.classification_)
|
||||
, mp_settings_(state.mp_settings_)
|
||||
, starting_pos_type_(state.starting_pos_type_)
|
||||
, starting_pos_(state.starting_pos_)
|
||||
, starting_point_type_(state.starting_point_type_)
|
||||
, starting_point_(state.starting_point_)
|
||||
, replay_data_(state.replay_data_)
|
||||
{
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ void saved_game::set_random_seed()
|
|||
void saved_game::write_config(config_writer& out) const
|
||||
{
|
||||
write_general_info(out);
|
||||
write_starting_pos(out);
|
||||
write_starting_point(out);
|
||||
|
||||
if(!this->replay_start_.empty()) {
|
||||
out.write_child("replay_start", replay_start_);
|
||||
|
@ -154,12 +154,12 @@ void saved_game::write_config(config_writer& out) const
|
|||
write_carryover(out);
|
||||
}
|
||||
|
||||
void saved_game::write_starting_pos(config_writer& out) const
|
||||
void saved_game::write_starting_point(config_writer& out) const
|
||||
{
|
||||
if(starting_pos_type_ == STARTINGPOS_SNAPSHOT) {
|
||||
out.write_child("snapshot", starting_pos_);
|
||||
} else if(starting_pos_type_ == STARTINGPOS_SCENARIO) {
|
||||
out.write_child("scenario", starting_pos_);
|
||||
if(starting_point_type_ == STARTING_POINT_SNAPSHOT) {
|
||||
out.write_child("snapshot", starting_point_);
|
||||
} else if(starting_point_type_ == STARTING_POINT_SCENARIO) {
|
||||
out.write_child("scenario", starting_point_);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ void saved_game::write_general_info(config_writer& out) const
|
|||
|
||||
void saved_game::set_defaults()
|
||||
{
|
||||
const bool is_loaded_game = this->starting_pos_type_ != STARTINGPOS_SCENARIO;
|
||||
const bool is_loaded_game = this->starting_point_type_ != STARTING_POINT_SCENARIO;
|
||||
const bool is_multiplayer_tag = classification().get_tagname() == "multiplayer";
|
||||
|
||||
static const std::vector<std::string> team_defaults {
|
||||
|
@ -185,7 +185,7 @@ void saved_game::set_defaults()
|
|||
"carryover_add",
|
||||
};
|
||||
|
||||
for(config& side : starting_pos_.child_range("side")) {
|
||||
for(config& side : starting_point_.child_range("side")) {
|
||||
// Set save_id default value directly after loading to its default to prevent different default behaviour in
|
||||
// mp_connect code and sp code.
|
||||
|
||||
|
@ -211,7 +211,7 @@ void saved_game::set_defaults()
|
|||
|
||||
// Set some team specific values to their defaults specified in scenario
|
||||
for(const std::string& att_name : team_defaults) {
|
||||
const config::attribute_value* scenario_value = starting_pos_.get(att_name);
|
||||
const config::attribute_value* scenario_value = starting_point_.get(att_name);
|
||||
config::attribute_value& team_value = side[att_name];
|
||||
|
||||
if(scenario_value && team_value.empty()) {
|
||||
|
@ -223,7 +223,7 @@ void saved_game::set_defaults()
|
|||
|
||||
void saved_game::expand_scenario()
|
||||
{
|
||||
if(this->starting_pos_type_ == STARTINGPOS_NONE && !has_carryover_expanded_) {
|
||||
if(this->starting_point_type_ == STARTING_POINT_NONE && !has_carryover_expanded_) {
|
||||
game_config_manager::get()->load_game_config_for_game(this->classification());
|
||||
|
||||
const config& game_config = game_config_manager::get()->game_config();
|
||||
|
@ -231,8 +231,8 @@ void saved_game::expand_scenario()
|
|||
game_config.find_child(classification().get_tagname(), "id", carryover_["next_scenario"]);
|
||||
|
||||
if(scenario) {
|
||||
this->starting_pos_type_ = STARTINGPOS_SCENARIO;
|
||||
this->starting_pos_ = scenario;
|
||||
this->starting_point_type_ = STARTING_POINT_SCENARIO;
|
||||
this->starting_point_ = scenario;
|
||||
|
||||
// A hash has to be generated using an unmodified scenario data.
|
||||
mp_settings_.hash = scenario.hash();
|
||||
|
@ -252,8 +252,8 @@ void saved_game::expand_scenario()
|
|||
update_label();
|
||||
set_defaults();
|
||||
} else {
|
||||
this->starting_pos_type_ = STARTINGPOS_INVALID;
|
||||
this->starting_pos_.clear();
|
||||
this->starting_point_type_ = STARTING_POINT_INVALID;
|
||||
this->starting_point_.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -306,18 +306,18 @@ void saved_game::load_mod(const std::string& type, const std::string& id)
|
|||
if(modevent["enable_if"].empty()
|
||||
|| variable_to_bool(carryover_.child_or_empty("variables"), modevent["enable_if"])
|
||||
) {
|
||||
this->starting_pos_.add_child("event", modevent);
|
||||
this->starting_point_.add_child("event", modevent);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy lua
|
||||
for(const config& modlua : cfg.child_range("lua")) {
|
||||
this->starting_pos_.add_child("lua", modlua);
|
||||
this->starting_point_.add_child("lua", modlua);
|
||||
}
|
||||
|
||||
// Copy load_resource
|
||||
for(const config& load_resource : cfg.child_range("load_resource")) {
|
||||
this->starting_pos_.add_child("load_resource", load_resource);
|
||||
this->starting_point_.add_child("load_resource", load_resource);
|
||||
}
|
||||
} else {
|
||||
// TODO: A user message instead?
|
||||
|
@ -326,14 +326,14 @@ void saved_game::load_mod(const std::string& type, const std::string& id)
|
|||
}
|
||||
|
||||
// Gets the ids of the mp_era and modifications which were set to be active, then fetches these configs from the
|
||||
// game_config and copies their [event] and [lua] to the starting_pos_.
|
||||
// game_config and copies their [event] and [lua] to the starting_point_.
|
||||
// At this time, also collect the addon_id attributes which appeared in them and put this list in the addon_ids
|
||||
// attribute of the mp_settings.
|
||||
void saved_game::expand_mp_events()
|
||||
{
|
||||
expand_scenario();
|
||||
|
||||
if(this->starting_pos_type_ == STARTINGPOS_SCENARIO && !this->starting_pos_["has_mod_events"].to_bool(false)) {
|
||||
if(this->starting_point_type_ == STARTING_POINT_SCENARIO && !this->starting_point_["has_mod_events"].to_bool(false)) {
|
||||
std::vector<modevents_entry> mods;
|
||||
std::set<std::string> loaded_resources;
|
||||
|
||||
|
@ -358,7 +358,7 @@ void saved_game::expand_mp_events()
|
|||
|
||||
mods.clear();
|
||||
|
||||
for(const config& cfg : starting_pos_.child_range("load_resource")) {
|
||||
for(const config& cfg : starting_point_.child_range("load_resource")) {
|
||||
if(loaded_resources.find(cfg["id"].str()) == loaded_resources.end()) {
|
||||
mods.emplace_back("resource", cfg["id"].str());
|
||||
|
||||
|
@ -366,16 +366,16 @@ void saved_game::expand_mp_events()
|
|||
}
|
||||
}
|
||||
|
||||
starting_pos_.clear_children("load_resource");
|
||||
starting_point_.clear_children("load_resource");
|
||||
} while(!mods.empty());
|
||||
|
||||
this->starting_pos_["has_mod_events"] = true;
|
||||
this->starting_point_["has_mod_events"] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void saved_game::expand_mp_options()
|
||||
{
|
||||
if(starting_pos_type_ == STARTINGPOS_SCENARIO && !has_carryover_expanded_) {
|
||||
if(starting_point_type_ == STARTING_POINT_SCENARIO && !has_carryover_expanded_) {
|
||||
std::vector<modevents_entry> mods;
|
||||
|
||||
std::transform(mp_settings_.active_mods.begin(), mp_settings_.active_mods.end(), std::back_inserter(mods),
|
||||
|
@ -418,40 +418,40 @@ void saved_game::expand_random_scenario()
|
|||
{
|
||||
expand_scenario();
|
||||
|
||||
if(this->starting_pos_type_ == STARTINGPOS_SCENARIO) {
|
||||
if(this->starting_point_type_ == STARTING_POINT_SCENARIO) {
|
||||
// If the entire scenario should be randomly generated
|
||||
if(!starting_pos_["scenario_generation"].empty()) {
|
||||
if(!starting_point_["scenario_generation"].empty()) {
|
||||
LOG_NG << "randomly generating scenario...\n";
|
||||
const cursor::setter cursor_setter(cursor::WAIT);
|
||||
|
||||
config scenario_new =
|
||||
random_generate_scenario(starting_pos_["scenario_generation"], starting_pos_.child("generator"));
|
||||
random_generate_scenario(starting_point_["scenario_generation"], starting_point_.child("generator"));
|
||||
|
||||
// Preserve "story" form the scenario toplevel.
|
||||
for(config& story : starting_pos_.child_range("story")) {
|
||||
for(config& story : starting_point_.child_range("story")) {
|
||||
scenario_new.add_child("story", story);
|
||||
}
|
||||
|
||||
scenario_new["id"] = starting_pos_["id"];
|
||||
starting_pos_ = scenario_new;
|
||||
scenario_new["id"] = starting_point_["id"];
|
||||
starting_point_ = scenario_new;
|
||||
|
||||
update_label();
|
||||
set_defaults();
|
||||
}
|
||||
|
||||
// If no map_data is provided, try to load the specified file directly
|
||||
if(starting_pos_["map_data"].empty() && !starting_pos_["map_file"].empty()) {
|
||||
starting_pos_["map_data"] = filesystem::read_map(starting_pos_["map_file"]);
|
||||
if(starting_point_["map_data"].empty() && !starting_point_["map_file"].empty()) {
|
||||
starting_point_["map_data"] = filesystem::read_map(starting_point_["map_file"]);
|
||||
}
|
||||
|
||||
// If the map should be randomly generated
|
||||
// We don’t want that we accidentally to this twice so we check for starting_pos_["map_data"].empty()
|
||||
if(starting_pos_["map_data"].empty() && !starting_pos_["map_generation"].empty()) {
|
||||
// We don’t want that we accidentally to this twice so we check for starting_point_["map_data"].empty()
|
||||
if(starting_point_["map_data"].empty() && !starting_point_["map_generation"].empty()) {
|
||||
LOG_NG << "randomly generating map...\n";
|
||||
const cursor::setter cursor_setter(cursor::WAIT);
|
||||
|
||||
starting_pos_["map_data"] =
|
||||
random_generate_map(starting_pos_["map_generation"], starting_pos_.child("generator"));
|
||||
starting_point_["map_data"] =
|
||||
random_generate_map(starting_point_["map_generation"], starting_point_.child("generator"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -459,11 +459,11 @@ void saved_game::expand_random_scenario()
|
|||
void saved_game::expand_carryover()
|
||||
{
|
||||
expand_scenario();
|
||||
if(this->starting_pos_type_ == STARTINGPOS_SCENARIO && !has_carryover_expanded_) {
|
||||
if(this->starting_point_type_ == STARTING_POINT_SCENARIO && !has_carryover_expanded_) {
|
||||
carryover_info sides(carryover_);
|
||||
|
||||
sides.transfer_to(get_starting_pos());
|
||||
for(config& side_cfg : get_starting_pos().child_range("side")) {
|
||||
sides.transfer_to(get_starting_point());
|
||||
for(config& side_cfg : get_starting_point().child_range("side")) {
|
||||
sides.transfer_all_to(side_cfg);
|
||||
}
|
||||
|
||||
|
@ -474,21 +474,21 @@ void saved_game::expand_carryover()
|
|||
|
||||
bool saved_game::valid() const
|
||||
{
|
||||
return this->starting_pos_type_ != STARTINGPOS_INVALID;
|
||||
return this->starting_point_type_ != STARTING_POINT_INVALID;
|
||||
}
|
||||
|
||||
config& saved_game::set_snapshot(config snapshot)
|
||||
{
|
||||
this->starting_pos_type_ = STARTINGPOS_SNAPSHOT;
|
||||
this->starting_pos_.swap(snapshot);
|
||||
this->starting_point_type_ = STARTING_POINT_SNAPSHOT;
|
||||
this->starting_point_.swap(snapshot);
|
||||
|
||||
return this->starting_pos_;
|
||||
return this->starting_point_;
|
||||
}
|
||||
|
||||
void saved_game::set_scenario(config scenario)
|
||||
{
|
||||
this->starting_pos_type_ = STARTINGPOS_SCENARIO;
|
||||
this->starting_pos_.swap(scenario);
|
||||
this->starting_point_type_ = STARTING_POINT_SCENARIO;
|
||||
this->starting_point_.swap(scenario);
|
||||
|
||||
has_carryover_expanded_ = false;
|
||||
|
||||
|
@ -497,16 +497,16 @@ void saved_game::set_scenario(config scenario)
|
|||
|
||||
void saved_game::remove_snapshot()
|
||||
{
|
||||
this->starting_pos_type_ = STARTINGPOS_NONE;
|
||||
this->starting_pos_.clear();
|
||||
this->starting_point_type_ = STARTING_POINT_NONE;
|
||||
this->starting_point_.clear();
|
||||
}
|
||||
|
||||
config& saved_game::get_starting_pos()
|
||||
config& saved_game::get_starting_point()
|
||||
{
|
||||
return starting_pos_;
|
||||
return starting_point_;
|
||||
}
|
||||
|
||||
const config& saved_game::get_replay_starting_pos()
|
||||
const config& saved_game::get_replay_starting_point()
|
||||
{
|
||||
if(!replay_start_.empty()) {
|
||||
return replay_start_;
|
||||
|
@ -518,8 +518,8 @@ const config& saved_game::get_replay_starting_pos()
|
|||
expand_carryover();
|
||||
}
|
||||
|
||||
if(starting_pos_type_ == STARTINGPOS_SCENARIO) {
|
||||
return starting_pos_;
|
||||
if(starting_point_type_ == STARTING_POINT_SCENARIO) {
|
||||
return starting_point_;
|
||||
}
|
||||
|
||||
return this->replay_start_.child("some_non_existet_invalid");
|
||||
|
@ -527,9 +527,9 @@ const config& saved_game::get_replay_starting_pos()
|
|||
|
||||
void saved_game::convert_to_start_save()
|
||||
{
|
||||
assert(starting_pos_type_ == STARTINGPOS_SNAPSHOT);
|
||||
assert(starting_point_type_ == STARTING_POINT_SNAPSHOT);
|
||||
|
||||
carryover_info sides(starting_pos_, true);
|
||||
carryover_info sides(starting_point_, true);
|
||||
|
||||
sides.merge_old_carryover(carryover_info(carryover_));
|
||||
sides.rng().rotate_random();
|
||||
|
@ -555,10 +555,10 @@ config saved_game::to_config() const
|
|||
|
||||
replay_data_.write(r.add_child("replay"));
|
||||
|
||||
if(starting_pos_type_ == STARTINGPOS_SNAPSHOT) {
|
||||
r.add_child("snapshot", starting_pos_);
|
||||
} else if(starting_pos_type_ == STARTINGPOS_SCENARIO) {
|
||||
r.add_child("scenario", starting_pos_);
|
||||
if(starting_point_type_ == STARTING_POINT_SNAPSHOT) {
|
||||
r.add_child("snapshot", starting_point_);
|
||||
} else if(starting_point_type_ == STARTING_POINT_SCENARIO) {
|
||||
r.add_child("scenario", starting_point_);
|
||||
}
|
||||
|
||||
r.add_child(has_carryover_expanded_ ? "carryover_sides" : "carryover_sides_start", carryover_);
|
||||
|
@ -571,8 +571,8 @@ std::string saved_game::get_scenario_id()
|
|||
{
|
||||
std::string scenario_id;
|
||||
|
||||
if(this->starting_pos_type_ == STARTINGPOS_SNAPSHOT || this->starting_pos_type_ == STARTINGPOS_SCENARIO) {
|
||||
scenario_id = starting_pos_["id"].str();
|
||||
if(this->starting_point_type_ == STARTING_POINT_SNAPSHOT || this->starting_point_type_ == STARTING_POINT_SCENARIO) {
|
||||
scenario_id = starting_point_["id"].str();
|
||||
} else if(!has_carryover_expanded_) {
|
||||
scenario_id = carryover_["next_scenario"].str();
|
||||
} else {
|
||||
|
@ -591,15 +591,15 @@ bool saved_game::not_corrupt() const
|
|||
void saved_game::update_label()
|
||||
{
|
||||
if(classification().abbrev.empty()) {
|
||||
classification().label = starting_pos_["name"].str();
|
||||
classification().label = starting_point_["name"].str();
|
||||
} else {
|
||||
classification().label = classification().abbrev + "-" + starting_pos_["name"];
|
||||
classification().label = classification().abbrev + "-" + starting_point_["name"];
|
||||
}
|
||||
}
|
||||
|
||||
void saved_game::cancel_orders()
|
||||
{
|
||||
for(config& side : this->starting_pos_.child_range("side")) {
|
||||
for(config& side : this->starting_point_.child_range("side")) {
|
||||
// for humans "goto_x/y" is used for multi-turn-moves
|
||||
// for the ai "goto_x/y" is a way for wml to order the ai to move a unit to a certain place.
|
||||
// we want to cancel human order but not to break wml.
|
||||
|
@ -616,7 +616,7 @@ void saved_game::cancel_orders()
|
|||
|
||||
void saved_game::unify_controllers()
|
||||
{
|
||||
for(config& side : this->starting_pos_.child_range("side")) {
|
||||
for(config& side : this->starting_point_.child_range("side")) {
|
||||
side.remove_attribute("is_local");
|
||||
//TODO: the old code below is probably not needed anymore
|
||||
if(side["controller"] == "network") {
|
||||
|
@ -645,9 +645,9 @@ void saved_game::swap(saved_game& other)
|
|||
|
||||
replay_data_.swap(other.replay_data_);
|
||||
replay_start_.swap(other.replay_start_);
|
||||
starting_pos_.swap(other.starting_pos_);
|
||||
starting_point_.swap(other.starting_point_);
|
||||
|
||||
std::swap(starting_pos_type_, other.starting_pos_type_);
|
||||
std::swap(starting_point_type_, other.starting_point_type_);
|
||||
}
|
||||
|
||||
void saved_game::set_data(config& cfg)
|
||||
|
@ -681,14 +681,14 @@ void saved_game::set_data(config& cfg)
|
|||
replay_data_.set_to_end();
|
||||
|
||||
if(config& snapshot = cfg.child("snapshot")) {
|
||||
this->starting_pos_type_ = STARTINGPOS_SNAPSHOT;
|
||||
this->starting_pos_.swap(snapshot);
|
||||
this->starting_point_type_ = STARTING_POINT_SNAPSHOT;
|
||||
this->starting_point_.swap(snapshot);
|
||||
} else if(config& scenario = cfg.child("scenario")) {
|
||||
this->starting_pos_type_ = STARTINGPOS_SCENARIO;
|
||||
this->starting_pos_.swap(scenario);
|
||||
this->starting_point_type_ = STARTING_POINT_SCENARIO;
|
||||
this->starting_point_.swap(scenario);
|
||||
} else {
|
||||
this->starting_pos_type_ = STARTINGPOS_NONE;
|
||||
this->starting_pos_.clear();
|
||||
this->starting_point_type_ = STARTING_POINT_NONE;
|
||||
this->starting_point_.clear();
|
||||
}
|
||||
|
||||
LOG_NG << "scenario: '" << carryover_["next_scenario"].str() << "'\n";
|
||||
|
@ -712,8 +712,8 @@ void saved_game::clear()
|
|||
mp_settings_ = mp_game_settings();
|
||||
replay_data_.swap(replay_recorder_base());
|
||||
replay_start_.clear();
|
||||
starting_pos_.clear();
|
||||
starting_pos_type_ = STARTINGPOS_NONE;
|
||||
starting_point_.clear();
|
||||
starting_point_type_ = STARTING_POINT_NONE;
|
||||
}
|
||||
|
||||
void swap(saved_game& lhs, saved_game& rhs)
|
||||
|
|
|
@ -23,16 +23,16 @@ class config_writer;
|
|||
|
||||
class saved_game
|
||||
{
|
||||
enum STARTING_POS_TYPE
|
||||
enum STARTING_POINT_TYPE
|
||||
{
|
||||
/// There is no scenario stating pos data (start-of-scenario).
|
||||
STARTINGPOS_NONE,
|
||||
STARTING_POINT_NONE,
|
||||
/// We have a [snapshot] (mid-game-savefile).
|
||||
STARTINGPOS_SNAPSHOT,
|
||||
STARTING_POINT_SNAPSHOT,
|
||||
/// We have a [scenario] (start-of-scenario) savefile.
|
||||
STARTINGPOS_SCENARIO,
|
||||
STARTING_POINT_SCENARIO,
|
||||
/// We failed to get a starting pos in expand_scenario.
|
||||
STARTINGPOS_INVALID
|
||||
STARTING_POINT_INVALID
|
||||
};
|
||||
public:
|
||||
saved_game();
|
||||
|
@ -50,7 +50,7 @@ public:
|
|||
void write_config(config_writer& out) const;
|
||||
void write_general_info(config_writer& out) const;
|
||||
void write_carryover(config_writer& out) const;
|
||||
void write_starting_pos(config_writer& out) const;
|
||||
void write_starting_point(config_writer& out) const;
|
||||
config to_config() const;
|
||||
game_classification& classification() { return classification_; }
|
||||
const game_classification& classification() const { return classification_; }
|
||||
|
@ -78,17 +78,17 @@ public:
|
|||
/// of a campaign but calling it multiple times is no harm eigher
|
||||
void expand_mp_options();
|
||||
/// takes care of generate_map=, generate_scenario=, map= attributes
|
||||
/// This should be called before expanding carryover or mp_events because this might completely replace starting_pos_.
|
||||
/// This should be called before expanding carryover or mp_events because this might completely replace starting_point_.
|
||||
void expand_random_scenario();
|
||||
bool valid() const;
|
||||
/// @return the snapshot in the savefile (get_starting_pos)
|
||||
/// @return the snapshot in the savefile (get_starting_point)
|
||||
config& set_snapshot(config snapshot);
|
||||
void set_scenario(config scenario);
|
||||
void remove_snapshot();
|
||||
|
||||
bool is_mid_game_save() const
|
||||
{
|
||||
return starting_pos_type_ == STARTINGPOS_SNAPSHOT;
|
||||
return starting_point_type_ == STARTING_POINT_SNAPSHOT;
|
||||
}
|
||||
/// converts a normal savegame form the end of a scenaio to a start-of-scenario savefile for the next scenaio,
|
||||
/// The saved_game must contain a [snapshot] made during the linger mode of the last scenaio.
|
||||
|
@ -96,12 +96,12 @@ public:
|
|||
/// sets the random seed if that didn't already happen.
|
||||
void set_random_seed();
|
||||
/// @return the starting pos for replays. Usually this is [replay_start] but it can also be a [scenario] if no [replay_start] is present
|
||||
const config& get_replay_starting_pos();
|
||||
const config& get_replay_starting_point();
|
||||
/// @return the id of the currently played scenario or the id of the next scenario if this is a between-scenaios-save (also called start-of-scenario-save).
|
||||
std::string get_scenario_id();
|
||||
/// @return the config from which the game will be started. (this is [scenario] or [snapshot] in the savefile)
|
||||
config& get_starting_pos();
|
||||
const config& get_starting_pos() const { return starting_pos_; }
|
||||
config& get_starting_point();
|
||||
const config& get_starting_point() const { return starting_point_; }
|
||||
config& replay_start() { return replay_start_; }
|
||||
const config& replay_start() const { return replay_start_; }
|
||||
|
||||
|
@ -131,12 +131,12 @@ private:
|
|||
game_classification classification_;
|
||||
mp_game_settings mp_settings_;
|
||||
|
||||
STARTING_POS_TYPE starting_pos_type_;
|
||||
STARTING_POINT_TYPE starting_point_type_;
|
||||
/**
|
||||
The starting pos where the (non replay) game will be started from.
|
||||
This can eigher be a [scenario] for a fresh game or a [snapshot] if this is a reloaded game
|
||||
*/
|
||||
config starting_pos_;
|
||||
config starting_point_;
|
||||
|
||||
replay_recorder_base replay_data_;
|
||||
};
|
||||
|
|
|
@ -635,14 +635,14 @@ std::string ingame_savegame::create_initial_filename(unsigned int turn_number) c
|
|||
void ingame_savegame::write_game(config_writer &out) {
|
||||
log_scope("write_game");
|
||||
|
||||
if(!gamestate().get_starting_pos().validate_wml()) {
|
||||
if(!gamestate().get_starting_point().validate_wml()) {
|
||||
throw game::save_game_failed(_("Game state is corrupted"));
|
||||
}
|
||||
|
||||
savegame::write_game(out);
|
||||
|
||||
gamestate().write_carryover(out);
|
||||
out.write_child("snapshot",gamestate().get_starting_pos());
|
||||
out.write_child("snapshot",gamestate().get_starting_point());
|
||||
out.write_child("replay_start", gamestate().replay_start());
|
||||
out.open_child("replay");
|
||||
gamestate().get_replay().write(out);
|
||||
|
|
|
@ -173,7 +173,7 @@ public:
|
|||
/** Build the filename according to the specific savegame's needs. */
|
||||
std::string create_filename() const
|
||||
{
|
||||
return create_filename(gamestate().get_starting_pos()["turn_at"]);
|
||||
return create_filename(gamestate().get_starting_point()["turn_at"]);
|
||||
}
|
||||
|
||||
/** Build the filename for the specified turn. */
|
||||
|
|
|
@ -69,7 +69,7 @@ struct mp_connect_fixture {
|
|||
state->set_scenario(config_manager->
|
||||
game_config().find_child("multiplayer", "id", state->mp_settings().name));
|
||||
|
||||
state->mp_settings().num_turns = state->get_starting_pos()["turns"];
|
||||
state->mp_settings().num_turns = state->get_starting_point()["turns"];
|
||||
|
||||
rng.reset(new randomness::mt_rng());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue