Skip to content

Commit

Permalink
Merge pull request #622 from gfgtdf/side_name
Browse files Browse the repository at this point in the history
Side name
  • Loading branch information
gfgtdf committed Mar 8, 2016
2 parents 6b297ed + c941f60 commit 41f5853
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/game_initialization/connect_engine.cpp
Expand Up @@ -1027,6 +1027,7 @@ config side_engine::new_config() const
desc = player_id_;
}
if(res["name"].str().empty() && !desc.empty()) {
//TODO: maybe we should add this in to the leaders config instead of the side config?
res["name"] = desc;
}

Expand Down
2 changes: 1 addition & 1 deletion src/game_initialization/playcampaign.cpp
Expand Up @@ -176,7 +176,7 @@ void campaign_controller::show_carryover_message(playsingle_controller& playcont
continue;
}
if (persistent_teams > 1) {
report << "\n<b>" << t.current_player() << "</b>\n";
report << "\n<b>" << t.side_name() << "</b>\n";
}

report_victory(report, t, finishing_bonus_per_turn, turns_left, finishing_bonus);
Expand Down
2 changes: 1 addition & 1 deletion src/leader_scroll_dialog.cpp
Expand Up @@ -240,7 +240,7 @@ void scenario_settings_table(display& gui, int selected)
}

str << COLUMN_SEPARATOR << team::get_side_highlight(n)
<< teams[n].current_player() << COLUMN_SEPARATOR
<< teams[n].side_name() << COLUMN_SEPARATOR
<< n + 1 << COLUMN_SEPARATOR
<< teams[n].start_gold() << COLUMN_SEPARATOR
<< teams[n].base_income() << COLUMN_SEPARATOR
Expand Down
6 changes: 3 additions & 3 deletions src/menu_events.cpp
Expand Up @@ -154,7 +154,7 @@ void menu_handler::show_statistics(int side_num)
{
team &current_team = teams()[side_num - 1];
// Current Player name
const std::string &player = current_team.current_player();
const std::string &player = current_team.side_name();
//add player's name to title of dialog
std::stringstream title_str;
title_str << _("Statistics") << " (" << player << ")";
Expand Down Expand Up @@ -272,7 +272,7 @@ void menu_handler::status_table(int selected)
}

if (pc_.get_classification().campaign_type == game_classification::CAMPAIGN_TYPE::MULTIPLAYER)
leader_name = teams()[n].current_player();
leader_name = teams()[n].side_name();

} else {
leader_bools.push_back(false);
Expand Down Expand Up @@ -393,7 +393,7 @@ void menu_handler::scenario_settings_table(int selected)
}

str << COLUMN_SEPARATOR << team::get_side_highlight(n)
<< teams()[n].current_player() << COLUMN_SEPARATOR
<< teams()[n].side_name() << COLUMN_SEPARATOR
<< n + 1 << COLUMN_SEPARATOR
<< teams()[n].start_gold() << COLUMN_SEPARATOR
<< teams()[n].base_income() << COLUMN_SEPARATOR
Expand Down
2 changes: 1 addition & 1 deletion src/playsingle_controller.cpp
Expand Up @@ -430,7 +430,7 @@ void playsingle_controller::show_turn_dialog(){
gui_->recalculate_minimap();
std::string message = _("It is now $name|’s turn");
utils::string_map symbols;
symbols["name"] = gamestate().board_.teams()[current_side() - 1].current_player();
symbols["name"] = gamestate().board_.teams()[current_side() - 1].side_name();
message = utils::interpolate_variables_into_string(message, &symbols);
gui2::show_transient_message(gui_->video(), "", message);
}
Expand Down
4 changes: 2 additions & 2 deletions src/reports.cpp
Expand Up @@ -216,7 +216,7 @@ static config unit_side(reports::context & rc, const unit* u)
std::stringstream text;
text << " " << u->side();

add_image(report, flag_icon + mods, u_team.current_player(), "");
add_image(report, flag_icon + mods, u_team.side_name(), "");
add_text(report, text.str(), "", "");
return report;
}
Expand Down Expand Up @@ -1485,7 +1485,7 @@ REPORT_GENERATOR(side_playing, rc)
std::string mods = "~RC(" + old_rgb + ">" + new_rgb + ")";
if (flag_icon.empty())
flag_icon = game_config::images::flag_icon;
return image_report(flag_icon + mods, active_team.current_player());
return image_report(flag_icon + mods, active_team.side_name());
}

REPORT_GENERATOR(observers, rc)
Expand Down
5 changes: 5 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_multiplayer_tag = classification().get_tagname() == "multiplayer";
static const std::vector<std::string> team_defaults = boost::assign::list_of
("carryover_percentage")
("carryover_add")
Expand All @@ -179,6 +180,10 @@ void saved_game::set_defaults()
{
side["save_id"] = side["id"];
}
if(!is_multiplayer_tag && side["side_name"].blank())
{
side["side_name"] = side["name"];
}
// Set some team specific values to their defaults specified in scenario
BOOST_FOREACH(const std::string& att_name, team_defaults)
{
Expand Down
18 changes: 9 additions & 9 deletions src/team.cpp
Expand Up @@ -62,10 +62,10 @@ const boost::container::flat_set<std::string> team::attributes = boost::assign::
("carryover_add")("carryover_percentage")("color")("controller")("current_player")("defeat_condition")("flag")
("flag_icon")("fog")("fog_data")("gold")("hidden")("income")
("no_leader")("objectives")("objectives_changed")("persistent")("lost")
("recall_cost")("recruit")("save_id")("scroll_to_leader")
("recall_cost")("recruit")("save_id")("id")("scroll_to_leader")
("share_vision")("share_maps")("share_view")("shroud")("shroud_data")("start_gold")
("suppress_end_turn_confirmation")
("team_name")("user_team_name")("village_gold")("village_support")("is_local")
("team_name")("user_team_name")("side_name")("village_gold")("village_support")("is_local")
// Multiplayer attributes.
("action_bonus_count")("allow_changes")("allow_player")("color_lock")
("countdown_time")("disallow_observers")("faction")
Expand All @@ -85,13 +85,14 @@ team::team_info::team_info() :
can_recruit(),
team_name(),
user_team_name(),
side_name(),
save_id(),
current_player(),
countdown_time(),
action_bonus_count(0),
flag(),
flag_icon(),
description(),
id(),
scroll_to_leader(true),
objectives(),
objectives_changed(false),
Expand Down Expand Up @@ -123,13 +124,14 @@ void team::team_info::read(const config &cfg)
income = cfg["income"];
team_name = cfg["team_name"].str();
user_team_name = cfg["user_team_name"];
side_name = cfg["side_name"];
save_id = cfg["save_id"].str();
current_player = cfg["current_player"].str();
countdown_time = cfg["countdown_time"].str();
action_bonus_count = cfg["action_bonus_count"];
flag = cfg["flag"].str();
flag_icon = cfg["flag_icon"].str();
description = cfg["id"].str();
id = cfg["id"].str();
scroll_to_leader = cfg["scroll_to_leader"].to_bool(true);
objectives = cfg["objectives"];
objectives_changed = cfg["objectives_changed"].to_bool();
Expand Down Expand Up @@ -182,10 +184,7 @@ void team::team_info::read(const config &cfg)
}

if(save_id.empty()) {
save_id = description;
}
if (current_player.empty()) {
current_player = save_id;
save_id = id;
}

income_per_village = cfg["village_gold"].to_int(game_config::village_income);
Expand Down Expand Up @@ -242,11 +241,12 @@ void team::team_info::write(config& cfg) const
cfg["income"] = income;
cfg["team_name"] = team_name;
cfg["user_team_name"] = user_team_name;
cfg["side_name"] = side_name;
cfg["save_id"] = save_id;
cfg["current_player"] = current_player;
cfg["flag"] = flag;
cfg["flag_icon"] = flag_icon;
cfg["id"] = description;
cfg["id"] = id;
cfg["objectives"] = objectives;
cfg["objectives_changed"] = objectives_changed;
cfg["countdown_time"]= countdown_time;
Expand Down
4 changes: 3 additions & 1 deletion src/team.hpp
Expand Up @@ -117,6 +117,7 @@ class team : public savegame::savegame_config
std::set<std::string> can_recruit;
std::string team_name;
t_string user_team_name;
t_string side_name;
std::string save_id;
// 'id' of the current player (not necessarily unique)
std::string current_player;
Expand All @@ -126,7 +127,7 @@ class team : public savegame::savegame_config
std::string flag;
std::string flag_icon;

std::string description;
std::string id;

bool scroll_to_leader;

Expand Down Expand Up @@ -302,6 +303,7 @@ class team : public savegame::savegame_config
void set_flag(const std::string& flag) { info_.flag = flag; }
void set_flag_icon(const std::string& flag_icon) { info_.flag_icon = flag_icon; }

const std::string& side_name() const { return info_.side_name.empty() ? info_.current_player : info_.side_name; }
//Returns true if the hex is shrouded/fogged for this side, or
//any other ally with shared vision.
bool shrouded(const map_location& loc) const;
Expand Down
6 changes: 0 additions & 6 deletions src/teambuilder.cpp
Expand Up @@ -297,12 +297,6 @@ class team_builder {
BOOST_FOREACH(const config *u, unit_configs_) {
uc.add_unit(*u);
}

// Find the first leader and use its name as the player name.
unit_map::iterator u = board_.units().find_first_leader(t_->side());
if ((u != board_.units().end()) && t_->current_player().empty())
t_->set_current_player(u->name());

}

};
Expand Down

0 comments on commit 41f5853

Please sign in to comment.