wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src multiplayer_connect.cpp multiplayer...


From: Philippe Plantier
Subject: [Wesnoth-cvs-commits] wesnoth/src multiplayer_connect.cpp multiplayer...
Date: Tue, 22 Feb 2005 18:07:20 -0500

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Philippe Plantier <address@hidden>      05/02/22 23:07:20

Modified files:
        src            : multiplayer_connect.cpp multiplayer_connect.hpp 
                         multiplayer_create.cpp multiplayer_wait.cpp 
                         multiplayer_wait.hpp 
        src/server     : game.cpp 

Log message:
        * Changed the names of some WML parameters transmitted during client - 
host MP
        game setup:
        
        original_description => save_id
        id => description.
        
        * Now, use "id" as a faction id, to allow the factions name to be 
translated by
        the client. Made the client use the faction it to lookup the faction 
name, and
        not to use the faction name sent by the server.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/multiplayer_connect.cpp.diff?tr1=1.111&tr2=1.112&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/multiplayer_connect.hpp.diff?tr1=1.28&tr2=1.29&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/multiplayer_create.cpp.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/multiplayer_wait.cpp.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/multiplayer_wait.hpp.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/server/game.cpp.diff?tr1=1.29&tr2=1.30&r1=text&r2=text

Patches:
Index: wesnoth/src/multiplayer_connect.cpp
diff -u wesnoth/src/multiplayer_connect.cpp:1.111 
wesnoth/src/multiplayer_connect.cpp:1.112
--- wesnoth/src/multiplayer_connect.cpp:1.111   Tue Feb 22 20:34:29 2005
+++ wesnoth/src/multiplayer_connect.cpp Tue Feb 22 23:07:19 2005
@@ -1,4 +1,4 @@
-/* $Id: multiplayer_connect.cpp,v 1.111 2005/02/22 20:34:29 j_daniel Exp $ */
+/* $Id: multiplayer_connect.cpp,v 1.112 2005/02/22 23:07:19 gruikya Exp $ */
 /*
    Copyright (C) 
    Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -78,7 +78,7 @@
        slider_gold_.hide(!enabled_);
 
        id_ = ""; // Id is reset, and not imported from loading savegames
-       original_description_ = cfg_["description"];
+       save_id_ = cfg_["save_id"];
        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()) {
@@ -104,7 +104,7 @@
 
 connect::side::side(const side& a) :
        parent_(a.parent_), cfg_(a.cfg_), 
-       index_(a.index_), id_(a.id_), 
original_description_(a.original_description_),
+       index_(a.index_), id_(a.id_),  save_id_(a.save_id_), 
        controller_(a.controller_),
        faction_(a.faction_), team_(a.team_), colour_(a.colour_),
        gold_(a.gold_), leader_(a.leader_), /* taken_(a.taken_), */
@@ -254,30 +254,27 @@
        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_];
+       res["description"] = id_;
+
        if (id_.empty()) {
                switch(controller_) {
                case CNTR_NETWORK:
-                       res["description"] = "(Vacant slot)";
                        res["user_description"] = _("(Vacant slot)");
                        break;
                case CNTR_LOCAL:
                        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:
                        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["user_description"] = _("(Empty slot)");
                        break;
                default:
@@ -288,10 +285,8 @@
                        res["save_id"] = id_;
                }
 
-               res["description"] = id_;
                res["user_description"] = id_;
        }
-       res["original_description"] = original_description_;
 
        if(enabled_) {
                if (leader_.empty()) {
@@ -369,9 +364,9 @@
        update_ui();
 }
 
-const std::string& connect::side::get_original_description() const 
+const std::string& connect::side::get_save_id() const 
 {
-       return original_description_;
+       return save_id_;
 }
 
 void connect::side::import_network_user(const config& data)
@@ -476,7 +471,7 @@
 
        int side_choice = 0;
        for(side_list::const_iterator s = sides_.begin(); s != sides_.end(); 
++s) {
-               if(s->get_original_description() == preferences::login()) {
+               if(s->get_save_id() == preferences::login()) {
                        side_choice = s - sides_.begin();
                }
        }
Index: wesnoth/src/multiplayer_connect.hpp
diff -u wesnoth/src/multiplayer_connect.hpp:1.28 
wesnoth/src/multiplayer_connect.hpp:1.29
--- wesnoth/src/multiplayer_connect.hpp:1.28    Tue Feb 22 20:34:29 2005
+++ wesnoth/src/multiplayer_connect.hpp Tue Feb 22 23:07:19 2005
@@ -1,4 +1,4 @@
-/* $Id: multiplayer_connect.hpp,v 1.28 2005/02/22 20:34:29 j_daniel Exp $ */
+/* $Id: multiplayer_connect.hpp,v 1.29 2005/02/22 23:07:19 gruikya Exp $ */
 /*
    Copyright (C) 
    Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -72,7 +72,7 @@
                // Sets the username of this side
                void set_id(const std::string& id);
 
-               const std::string& get_original_description() const;
+               const std::string& get_save_id() const;
 
                // Imports data from the network into this side, and updates
                // the UI accordingly.
@@ -98,7 +98,7 @@
                // Configurable variables
                int index_;
                std::string id_;
-               std::string original_description_;
+               std::string save_id_;
                mp::controller controller_;
                int faction_;
                int team_;
Index: wesnoth/src/multiplayer_create.cpp
diff -u wesnoth/src/multiplayer_create.cpp:1.2 
wesnoth/src/multiplayer_create.cpp:1.3
--- wesnoth/src/multiplayer_create.cpp:1.2      Mon Feb 21 21:33:27 2005
+++ wesnoth/src/multiplayer_create.cpp  Tue Feb 22 23:07:19 2005
@@ -1,4 +1,4 @@
-/* $Id: multiplayer_create.cpp,v 1.2 2005/02/21 21:33:27 gruikya Exp $ */
+/* $Id: multiplayer_create.cpp,v 1.3 2005/02/22 23:07:19 gruikya Exp $ */
 /*
    Copyright (C) 
    Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -284,10 +284,8 @@
                for(int pos =  
parameters_.scenario_data.get_children("side").size(); pos < map_positions; 
++pos) {
                        config& side = 
parameters_.scenario_data.add_child("side");
                        side["enemy"] = "1";
-                       char buf[50];
-                       sprintf(buf,"%d",(pos+1));
-                       side["side"] = buf;
-                       side["team_name"] = buf;
+                       side["side"] = lexical_cast<std::string>(pos+1);
+                       side["team_name"] = lexical_cast<std::string>(pos+1);
                        side["canrecruit"] = "1";
                        side["controller"] = "human";
                }
Index: wesnoth/src/multiplayer_wait.cpp
diff -u wesnoth/src/multiplayer_wait.cpp:1.2 
wesnoth/src/multiplayer_wait.cpp:1.3
--- wesnoth/src/multiplayer_wait.cpp:1.2        Mon Feb 21 09:05:51 2005
+++ wesnoth/src/multiplayer_wait.cpp    Tue Feb 22 23:07:19 2005
@@ -1,4 +1,4 @@
-/* $Id: multiplayer_wait.cpp,v 1.2 2005/02/21 09:05:51 silene Exp $ */
+/* $Id: multiplayer_wait.cpp,v 1.3 2005/02/22 23:07:19 gruikya Exp $ */
 /*
    Copyright (C) 
    Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -61,7 +61,8 @@
 
        if(selection_ < side_list_.size()) {
                const config& side = *side_list_[selection_];
-               std::string faction = side["name"];
+               std::string faction = side["faction"];
+
                const std::string recruits = side["recruit"];
                const std::vector<std::string> recruit_list = 
utils::split(recruits);
                std::ostringstream recruit_string;
@@ -180,8 +181,8 @@
                //available side.
                int side_choice = 0;
                for(config::child_list::const_iterator s = sides_list.begin(); 
s != sides_list.end(); ++s) {
-                       if((**s)["controller"] == "network" && 
(**s)["id"].empty()) {
-                               if((**s)["original_description"] == 
preferences::login()) {
+                       if((**s)["controller"] == "network" && 
(**s)["description"].empty()) {
+                               if((**s)["save_id"] == preferences::login()) {
                                        side_choice = s - sides_list.begin();
                                }
                        }
@@ -195,6 +196,7 @@
                        throw network::error(_("Era not available"));
                        return;
                }
+               era_sides_ = *era_cfg;
 
                const config::child_list& possible_sides = 
era_cfg->get_children("multiplayer_side");
                if(possible_sides.empty()) {
@@ -254,7 +256,7 @@
        const config::child_list& sides_list = level_.get_children("side");
        for(config::child_list::const_iterator side = sides_list.begin(); 
                        side != sides_list.end(); ++side) {
-               if((**side)["controller"] == "network" && (**side)["id"] == 
preferences::login()) {
+               if((**side)["controller"] == "network" && 
(**side)["description"] == preferences::login()) {
                        (**side)["controller"] = preferences::client_type();
                } else if((**side)["controller"] != "null") {
                        (**side)["controller"] = "network";
@@ -351,11 +353,19 @@
                const config& sd = **s;
 
                std::string description = sd["description"];
-               std::string side_name = sd["name"];
+               const std::string faction_id = sd["id"];
+               const config* const faction_cfg = 
+                       era_sides_.find_child("multiplayer_side", "id", 
faction_id);
+               std::string side_name;
+               if (faction_cfg != NULL) {
+                       side_name = (*faction_cfg)["name"];
+               } else {
+                       side_name = sd["name"];
+               }
                std::string leader_type = sd["type"];
 
-               if(!sd["id"].empty())
-                       playerlist.push_back(sd["id"]);
+               if(!sd["description"].empty())
+                       playerlist.push_back(sd["description"]);
 
                std::string leader_name;
                std::string leader_image;
Index: wesnoth/src/multiplayer_wait.hpp
diff -u wesnoth/src/multiplayer_wait.hpp:1.1 
wesnoth/src/multiplayer_wait.hpp:1.2
--- wesnoth/src/multiplayer_wait.hpp:1.1        Sun Feb 20 22:30:27 2005
+++ wesnoth/src/multiplayer_wait.hpp    Tue Feb 22 23:07:19 2005
@@ -1,4 +1,4 @@
-/* $Id: multiplayer_wait.hpp,v 1.1 2005/02/20 22:30:27 gruikya Exp $ */
+/* $Id: multiplayer_wait.hpp,v 1.2 2005/02/22 23:07:19 gruikya Exp $ */
 /*
    Copyright (C) 
    Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -74,6 +74,8 @@
        // int team_;
        const game_data& game_data_;
 
+       config era_sides_;
+
        config level_;
        game_state state_;
 
Index: wesnoth/src/server/game.cpp
diff -u wesnoth/src/server/game.cpp:1.29 wesnoth/src/server/game.cpp:1.30
--- wesnoth/src/server/game.cpp:1.29    Sun Feb 20 22:30:29 2005
+++ wesnoth/src/server/game.cpp Tue Feb 22 23:07:20 2005
@@ -185,7 +185,7 @@
 
                config::child_iterator sd;
                for(sd = level_sides.first; sd != level_sides.second; ++sd) {
-                       if ((**sd)["id"] == info->second.name()) {
+                       if ((**sd)["description"] == info->second.name()) {
                                break;
                        }
                }
@@ -271,7 +271,7 @@
        const config::child_list& sides = level_.get_children("side");
        for(config::child_list::const_iterator i = sides.begin(); i != 
sides.end(); ++i) {
                std::cerr << "side controller: '" << (**i)["controller"] << 
"'\n";
-               if((**i)["controller"] == "network" && (**i)["id"].empty()) {
+               if((**i)["controller"] == "network" && 
(**i)["description"].empty()) {
                        ++available_slots;
                }
        }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]