mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-13 10:42:24 +00:00
move some savegame manipulation to saved_game.cpp
This commit is contained in:
parent
91b845d0a5
commit
618cc110b3
@ -684,26 +684,12 @@ bool game_launcher::load_game()
|
||||
}
|
||||
|
||||
if(state_.classification().campaign_type == game_classification::MULTIPLAYER) {
|
||||
BOOST_FOREACH(config &side, state_.get_starting_pos().child_range("side"))
|
||||
{
|
||||
if (side["controller"] == "network")
|
||||
side["controller"] = "human";
|
||||
if (side["controller"] == "network_ai")
|
||||
side["controller"] = "ai";
|
||||
}
|
||||
state_.unify_controllers();
|
||||
gui2::show_message(disp().video(), _("Warning") , _("This is a multiplayer scenario. Some parts of it may not work properly in single-player. It is recommended to load this scenario through the <b>Multiplayer</b> → <b>Load Game</b> dialog instead."), "", true, true);
|
||||
}
|
||||
|
||||
if (load.cancel_orders()) {
|
||||
BOOST_FOREACH(config &side, state_.get_starting_pos().child_range("side"))
|
||||
{
|
||||
if (side["controller"] != "human") continue;
|
||||
BOOST_FOREACH(config &unit, side.child_range("unit"))
|
||||
{
|
||||
unit["goto_x"] = -999;
|
||||
unit["goto_y"] = -999;
|
||||
}
|
||||
}
|
||||
state_.cancel_orders();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -506,3 +506,29 @@ void saved_game::update_label()
|
||||
classification().label = classification().abbrev + "-" + starting_pos_["name"];
|
||||
}
|
||||
}
|
||||
|
||||
void saved_game::cancel_orders()
|
||||
{
|
||||
BOOST_FOREACH(config &side, this->starting_pos_.child_range("side"))
|
||||
{
|
||||
// TODO: was this line needed, was it just an optimisation, or was ist just wrong?
|
||||
// if (side["controller"] != "human") continue;
|
||||
// reenable it iff it was needed for some reason but please explain why.
|
||||
BOOST_FOREACH(config &unit, side.child_range("unit"))
|
||||
{
|
||||
unit["goto_x"] = -999;
|
||||
unit["goto_y"] = -999;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void saved_game::unify_controllers()
|
||||
{
|
||||
BOOST_FOREACH(config &side, this->starting_pos_.child_range("side"))
|
||||
{
|
||||
if (side["controller"] == "network")
|
||||
side["controller"] = "human";
|
||||
if (side["controller"] == "network_ai")
|
||||
side["controller"] = "ai";
|
||||
}
|
||||
}
|
||||
|
@ -89,6 +89,10 @@ public:
|
||||
/** sets classification().label to the correct value. */
|
||||
void update_label();
|
||||
|
||||
void cancel_orders();
|
||||
/* removes network_ai and network controller types*/
|
||||
void unify_controllers();
|
||||
|
||||
/**
|
||||
* If the game is saved mid-level, we have a series of replay steps
|
||||
* to take the game up to the position it was saved at.
|
||||
|
Loading…
x
Reference in New Issue
Block a user