Skip to content

Commit

Permalink
mp create engine uses Team + # syntax when use_map_settings=false
Browse files Browse the repository at this point in the history
The old behavior was that when use_map_settings=false, every side
would have team=# for some number. This causes problems because
config might secretly decide that that is an int, and cause string
comparisons to fail.

Whether or not that is a bug is a separate issue, it seems clearly
desirable for sides to always have a team name of the form
"Team #", to side-step the potential problems.

This fixes up problems which appeared after
4d73031
852b698
  • Loading branch information
cbeck88 committed Jul 1, 2014
1 parent 79b95f7 commit f15eed1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/multiplayer_connect_engine.cpp
Expand Up @@ -138,19 +138,20 @@ connect_engine::connect_engine(saved_game& state,
if (name_itor == original_team_names.end()) {
original_team_names.push_back(team_name);

team_name =
team_name = "Team " +
lexical_cast<std::string>(original_team_names.size());
} else {
team_name = lexical_cast<std::string>(
name_itor - original_team_names.begin() + 1);
}
} // Note that the prefix "Team " is untranslatable, as team_name is not meant to be translated. This is needed so that the attribute
// is not interpretted as an int when reading from config, which causes bugs later.

user_team_name = team_prefix + side_str;
}

if (add_team) {
team_names_.push_back(params_.use_map_settings ? team_name :
side_str);
"Team " + side_str);
user_team_names_.push_back(user_team_name.t_str().to_serialized());

if (side["allow_player"].to_bool(true) || game_config::debug) {
Expand Down
2 changes: 1 addition & 1 deletion src/multiplayer_create_engine.cpp
Expand Up @@ -181,7 +181,7 @@ void scenario::set_sides()
pos < map_positions; ++pos) {
config& side = data_.add_child("side");
side["side"] = pos + 1;
side["team_name"] = pos + 1;
side["team_name"] = "Team " + lexical_cast<std::string>(pos + 1);
side["canrecruit"] = true;
side["controller"] = "human";
}
Expand Down

0 comments on commit f15eed1

Please sign in to comment.