[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src multiplayer_connect.cpp multiplayer...
From: |
Jon Daniel |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src multiplayer_connect.cpp multiplayer... |
Date: |
Tue, 22 Feb 2005 15:34:29 -0500 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Jon Daniel <address@hidden> 05/02/22 20:34:29
Modified files:
src : multiplayer_connect.cpp multiplayer_connect.hpp
Log message:
Fixed team_names not working and wrong colour indices. Also started to
use user_description for translated descriptions.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/multiplayer_connect.cpp.diff?tr1=1.110&tr2=1.111&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/multiplayer_connect.hpp.diff?tr1=1.27&tr2=1.28&r1=text&r2=text
Patches:
Index: wesnoth/src/multiplayer_connect.cpp
diff -u wesnoth/src/multiplayer_connect.cpp:1.110
wesnoth/src/multiplayer_connect.cpp:1.111
--- wesnoth/src/multiplayer_connect.cpp:1.110 Mon Feb 21 21:44:59 2005
+++ wesnoth/src/multiplayer_connect.cpp Tue Feb 22 20:34:29 2005
@@ -1,4 +1,4 @@
-/* $Id: multiplayer_connect.cpp,v 1.110 2005/02/21 21:44:59 gruikya Exp $ */
+/* $Id: multiplayer_connect.cpp,v 1.111 2005/02/22 20:34:29 j_daniel Exp $ */
/*
Copyright (C)
Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -79,9 +79,15 @@
id_ = ""; // Id is reset, and not imported from loading savegames
original_description_ = cfg_["description"];
- faction_ = lexical_cast_default<int>(cfg_["team"], 0);
- team_ = lexical_cast_default<int>(cfg_["team"], index_);
- colour_ = lexical_cast_default<int>(cfg_["colour"], index_);
+ faction_ = lexical_cast_default<int>(cfg_["faction"], 0);
+ std::vector<std::string>::const_iterator itor =
std::find(parent_->team_names_.begin(), parent_->team_names_.end(),
cfg_["team_name"]);
+ if(itor == parent_->team_names_.end()) {
+ wassert(!parent_->team_names_.empty());
+ team_ = 0;
+ } else {
+ team_ = itor - parent_->team_names_.begin();
+ }
+ colour_ = lexical_cast_default<int>(cfg_["colour"], index_ + 1) - 1;
gold_ = lexical_cast_default<int>(cfg_["gold"], 100);
// "Faction name" hack
@@ -245,28 +251,45 @@
// Merge the faction data to res
res.append(*(parent_->era_sides_[faction_]));
}
-
- res["controller"] = controller_names[controller_];
+ if(cfg_["side"].empty() || cfg_["side"] !=
lexical_cast<std::string>(index_ + 1)) {
+ res["side"] = lexical_cast<std::string>(index_ + 1);
+ }
res["id"] = id_;
+ res["controller"] = controller_names[controller_];
if (id_.empty()) {
switch(controller_) {
case CNTR_NETWORK:
- res["description"] = _("(Vacant slot)");
+ res["description"] = "(Vacant slot)";
+ res["user_description"] = _("(Vacant slot)");
break;
case CNTR_LOCAL:
- res["description"] = _("Anonymous local player");
+ if(enabled_ && cfg_["save_id"].empty()) {
+ res["save_id"] = "local" + res["side"];
+ }
+ res["description"] = "Anonymous local player";
+ res["user_description"] = _("Anonymous local player");
break;
case CNTR_COMPUTER:
- res["description"] = _("Computer player");
+ if(enabled_ && cfg_["save_id"].empty()) {
+ res["save_id"] = "ai" + res["side"];
+ }
+ res["description"] = "Computer player";
+ res["user_description"] = _("Computer player");
break;
case CNTR_EMPTY:
- res["description"] = _("(Empty slot)");
+ res["description"] = "(Empty slot)";
+ res["user_description"] = _("(Empty slot)");
break;
default:
break;
}
} else {
+ if(enabled_ && cfg_["save_id"].empty()) {
+ res["save_id"] = id_;
+ }
+
res["description"] = id_;
+ res["user_description"] = id_;
}
res["original_description"] = original_description_;
@@ -277,8 +300,8 @@
res["type"] = leader_;
}
// res["team"] = lexical_cast<std::string>(team_);
- res["team_name"] = lexical_cast<std::string>(team_ + 1);
- res["colour"] = lexical_cast<std::string>(colour_);
+ res["team_name"] = parent_->team_names_[team_];
+ res["colour"] = lexical_cast<std::string>(colour_ + 1);
res["gold"] = lexical_cast<std::string>(gold_);
res["fog"] = parent_->params_.fog_game ? "yes" : "no";
@@ -286,7 +309,6 @@
res["share_maps"] = parent_->params_.share_maps ? "yes" : "no";
res["share_view"] = parent_->params_.share_view ? "yes" : "no";
res["village_gold"] =
lexical_cast<std::string>(parent_->params_.village_gold);
- res["experience_modifier"] =
lexical_cast<std::string>(parent_->params_.xp_modifier);
res["allow_changes"] = "yes";
} else {
@@ -433,7 +455,8 @@
ai_(disp, _("Computer vs Computer")),
launch_(disp, _("I'm Ready")),
- cancel_(disp, _("Cancel"))
+ cancel_(disp, _("Cancel")),
+ team_prefix_(_("Team "))
{
// Send Initial information
config response;
@@ -446,9 +469,9 @@
// Adds the current user as default user.
users_.push_back(connected_user(preferences::login(), CNTR_LOCAL, 0));
- update_user_combos();
- if(sides_.empty()) {
- throw config::error(_("The scenario is invalid because it has
no sides."));
+ update_user_combos();
+ if(sides_.empty()) {
+ throw config::error(_("The scenario is invalid because it has
no sides."));
}
int side_choice = 0;
@@ -791,14 +814,19 @@
//Teams
config::child_iterator sd;
for(sd = sides.first; sd != sides.second; ++sd) {
- const int team_num = sd - sides.first;
+ const int side_num = sd - sides.first + 1;
std::string& team_name = (**sd)["team_name"];
if(team_name.empty()) {
- team_name = lexical_cast<std::string>(team_num+1);
+ team_name = lexical_cast<std::string>(side_num);
}
-
- player_teams_.push_back(_("Team") + std::string(" ") +
team_name);
- (**sd)["colour"] =
lexical_cast_default<std::string>(team_num+1);
+ 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_prefix_ + team_name);
+ }
+
+ //Side color
+ (**sd)["colour"] = lexical_cast_default<std::string>(side_num);
}
std::string prefix;
Index: wesnoth/src/multiplayer_connect.hpp
diff -u wesnoth/src/multiplayer_connect.hpp:1.27
wesnoth/src/multiplayer_connect.hpp:1.28
--- wesnoth/src/multiplayer_connect.hpp:1.27 Mon Feb 21 21:33:27 2005
+++ wesnoth/src/multiplayer_connect.hpp Tue Feb 22 20:34:29 2005
@@ -1,4 +1,4 @@
-/* $Id: multiplayer_connect.hpp,v 1.27 2005/02/21 21:33:27 gruikya Exp $ */
+/* $Id: multiplayer_connect.hpp,v 1.28 2005/02/22 20:34:29 j_daniel Exp $ */
/*
Copyright (C)
Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -207,6 +207,10 @@
std::vector<std::string> player_teams_;
std::vector<std::string> player_colours_;
+ // team_name list and "Team" prefix
+ std::vector<std::string> team_names_;
+ const std::string team_prefix_;
+
side_list sides_;
connected_user_list users_;