Skip to content

Commit

Permalink
add warning if current_player attribute is specified by wml
Browse files Browse the repository at this point in the history
specifying this attribute in [side] can result in assertion failure.
  • Loading branch information
gfgtdf committed Mar 9, 2016
1 parent f4590e6 commit 4810e2c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/saved_game.cpp
Expand Up @@ -168,6 +168,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_multiplayer_tag = classification().get_tagname() == "multiplayer";
static const std::vector<std::string> team_defaults = boost::assign::list_of
("carryover_percentage")
Expand All @@ -184,6 +185,11 @@ void saved_game::set_defaults()
{
side["side_name"] = side["name"];
}
if(!is_loaded_game && !side["current_player"].empty())
{
ERR_NG << "Removed invalid 'current_player' attribute from [side] while loading a scenario. Consider using 'side_name' instead\n";
side["current_player"] = config::attribute_value();
}
// Set some team specific values to their defaults specified in scenario
BOOST_FOREACH(const std::string& att_name, team_defaults)
{
Expand Down
2 changes: 1 addition & 1 deletion src/saved_game.hpp
Expand Up @@ -111,7 +111,7 @@ class saved_game
void cancel_orders();
/* removes network_ai and network controller types*/
void unify_controllers();

/** does some post loading stuff must be used before passing the data to connect_engine */
void set_defaults();
replay_recorder_base& get_replay() { return replay_data_; }
const replay_recorder_base& get_replay() const { return replay_data_; }
Expand Down

0 comments on commit 4810e2c

Please sign in to comment.