mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-03 16:50:53 +00:00
fix team translation in mp game, thx to coren
This commit is contained in:
parent
7eda6b2244
commit
c323cfa7fa
@ -27,6 +27,7 @@ Version 1.3-svn:
|
||||
* game management
|
||||
* client now tells the server if a game ended in victory or defeat
|
||||
* configurable castle size for random map generator (patch #598, FR #3232)
|
||||
* team names translation now supported
|
||||
* scenarios
|
||||
* scenarios can set faction, recruit, leader, and some other initial settings
|
||||
previously ignored in multiplayer
|
||||
|
@ -591,6 +591,7 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
||||
std::string side = cfg["side"];
|
||||
std::string income = cfg["income"];
|
||||
std::string team_name = cfg["team_name"];
|
||||
std::string user_team_name = cfg["user_team_name"];
|
||||
std::string gold = cfg["gold"];
|
||||
wassert(state_of_game != NULL);
|
||||
side = utils::interpolate_variables_into_string(side, *state_of_game);
|
||||
@ -604,7 +605,8 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
||||
std::cerr << "modifying team: " << team_index << "\n";
|
||||
if(!team_name.empty()) {
|
||||
std::cerr << "change team to team_name '" << team_name << "'\n";
|
||||
(*teams)[team_index].change_team(team_name);
|
||||
(*teams)[team_index].change_team(team_name,
|
||||
user_team_name);
|
||||
}
|
||||
|
||||
if(!income.empty()) {
|
||||
|
@ -531,6 +531,7 @@ config connect::side::get_config() const
|
||||
}
|
||||
// res["team"] = lexical_cast<std::string>(team_);
|
||||
res["team_name"] = parent_->team_names_[team_];
|
||||
res["user_team_name"] = parent_->user_team_names_[team_];
|
||||
res["colour"] = lexical_cast<std::string>(colour_ + 1);
|
||||
res["gold"] = lexical_cast<std::string>(gold_);
|
||||
res["income"] = lexical_cast<std::string>(income_);
|
||||
@ -577,6 +578,7 @@ config connect::side::get_config() const
|
||||
trimmed["controller"] = "";
|
||||
trimmed["description"] = "";
|
||||
trimmed["team_name"] = "";
|
||||
trimmed["user_team_name"] = "";
|
||||
trimmed["colour"] = "";
|
||||
trimmed["gold"] = "";
|
||||
trimmed["income"] = "";
|
||||
@ -1153,14 +1155,21 @@ void connect::lists_init()
|
||||
for(sd = sides.first; sd != sides.second; ++sd) {
|
||||
const int side_num = sd - sides.first + 1;
|
||||
t_string& team_name = (**sd)["team_name"];
|
||||
t_string& user_team_name = (**sd)["user_team_name"];
|
||||
|
||||
if(team_name.empty())
|
||||
team_name = lexical_cast<std::string>(side_num);
|
||||
|
||||
if(user_team_name.empty())
|
||||
{
|
||||
user_team_name = team_name;
|
||||
}
|
||||
|
||||
std::vector<std::string>::const_iterator itor = std::find(team_names_.begin(), team_names_.end(), team_name);
|
||||
if(itor == team_names_.end()) {
|
||||
team_names_.push_back(team_name);
|
||||
player_teams_.push_back(team_name.str());
|
||||
user_team_names_.push_back(user_team_name);
|
||||
player_teams_.push_back(user_team_name.str());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1171,16 +1180,18 @@ void connect::lists_init()
|
||||
|
||||
if(team_name.empty())
|
||||
team_name = side_num;
|
||||
|
||||
|
||||
std::vector<std::string>::const_iterator itor = std::find(team_names.begin(), team_names.end(), team_name);
|
||||
if(itor == team_names.end()) {
|
||||
team_names.push_back(team_name);
|
||||
user_team_names_.push_back(team_name);
|
||||
team_name = lexical_cast<std::string>(team_names.size());
|
||||
} else {
|
||||
team_name = lexical_cast<std::string>(itor - team_names.begin() + 1);
|
||||
}
|
||||
|
||||
team_names_.push_back(side_num);
|
||||
user_team_names_.push_back(side_num);
|
||||
player_teams_.push_back(team_prefix_ + side_num);
|
||||
}
|
||||
}
|
||||
|
@ -221,6 +221,7 @@ private:
|
||||
|
||||
// team_name list and "Team" prefix
|
||||
std::vector<std::string> team_names_;
|
||||
std::vector<std::string> user_team_names_;
|
||||
const std::string team_prefix_;
|
||||
|
||||
side_list sides_;
|
||||
|
@ -439,7 +439,7 @@ void wait::generate_menu()
|
||||
str << sd["income"] << _(")");
|
||||
}
|
||||
|
||||
str << COLUMN_SEPARATOR << sd["team_name"];
|
||||
str << COLUMN_SEPARATOR << sd["user_team_name"];
|
||||
str << COLUMN_SEPARATOR << get_colour_string(lexical_cast_default<int>(sd["colour"], 0) - 1);
|
||||
details.push_back(str.str());
|
||||
}
|
||||
|
22
src/team.cpp
22
src/team.cpp
@ -94,9 +94,14 @@ team::team_info::team_info(const config& cfg)
|
||||
income = cfg["income"];
|
||||
name = cfg["name"];
|
||||
team_name = cfg["team_name"];
|
||||
user_team_name = cfg["user_team_name"];
|
||||
if(team_name.empty()) {
|
||||
team_name = cfg["side"];
|
||||
}
|
||||
|
||||
if(user_team_name.empty()) {
|
||||
user_team_name = team_name;
|
||||
}
|
||||
|
||||
save_id = cfg["save_id"];
|
||||
if(save_id.empty()) {
|
||||
@ -260,6 +265,7 @@ void team::team_info::write(config& cfg) const
|
||||
cfg["income"] = income;
|
||||
cfg["name"] = name;
|
||||
cfg["team_name"] = team_name;
|
||||
cfg["user_team_name"] = team_name;
|
||||
cfg["save_id"] = save_id;
|
||||
cfg["current_player"] = current_player;
|
||||
cfg["flag"] = flag;
|
||||
@ -600,9 +606,23 @@ const std::string& team::team_name() const
|
||||
return info_.team_name;
|
||||
}
|
||||
|
||||
void team::change_team(const std::string& name)
|
||||
const std::string& team::user_team_name() const
|
||||
{
|
||||
return info_.user_team_name;
|
||||
}
|
||||
|
||||
void team::change_team(const std::string& name,
|
||||
const std::string& user_name)
|
||||
{
|
||||
info_.team_name = name;
|
||||
if (!user_name.empty())
|
||||
{
|
||||
info_.user_team_name = user_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
info_.user_team_name = name;
|
||||
}
|
||||
|
||||
//reset the cache of allies for all teams
|
||||
if(teams != NULL) {
|
||||
|
@ -73,6 +73,7 @@ public:
|
||||
std::vector<std::string> recruitment_pattern;
|
||||
std::vector<int> enemies;
|
||||
std::string team_name;
|
||||
std::string user_team_name;
|
||||
std::string save_id;
|
||||
std::string current_player;
|
||||
std::string countdown_time;
|
||||
@ -185,7 +186,9 @@ public:
|
||||
void make_ai();
|
||||
|
||||
const std::string& team_name() const;
|
||||
void change_team(const std::string& name);
|
||||
const std::string& user_team_name() const;
|
||||
void change_team(const std::string& name,
|
||||
const std::string& user_name);
|
||||
|
||||
const std::string& flag() const;
|
||||
|
||||
|
@ -3331,13 +3331,15 @@ team_data calculate_team_data(const team& tm, int side, const unit_map& units)
|
||||
|
||||
std::string get_team_name(unsigned int side, const unit_map& units)
|
||||
{
|
||||
for(unit_map::const_iterator i = units.begin(); i != units.end(); ++i) {
|
||||
wassert(false); // deprecated code
|
||||
return team_name(side, units);
|
||||
/* for(unit_map::const_iterator i = units.begin(); i != units.end(); ++i) {
|
||||
if(i->second.can_recruit() && i->second.side() == side) {
|
||||
return i->second.description();
|
||||
}
|
||||
}
|
||||
|
||||
return "-";
|
||||
return "-";*/
|
||||
}
|
||||
|
||||
temporary_unit_placer::temporary_unit_placer(unit_map& m, const gamemap::location& loc, const unit& u)
|
||||
|
Loading…
x
Reference in New Issue
Block a user