mail[Wesnoth-commits] r14125 - in /trunk/src: menu_events.cpp menu_events.hpp playturn.cpp playturn.hpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edb on October 31, 2006 - 11:09:
Author: edb
Date: Tue Oct 31 11:09:11 2006
New Revision: 14125

URL: http://svn.gna.org/viewcvs/wesnoth?rev=14125&view=rev
Log:
some clean

Modified:
    trunk/src/menu_events.cpp
    trunk/src/menu_events.hpp
    trunk/src/playturn.cpp
    trunk/src/playturn.hpp

Modified: trunk/src/menu_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.cpp?rev=14125&r1=14124&r2=14125&view=diff
==============================================================================
--- trunk/src/menu_events.cpp (original)
+++ trunk/src/menu_events.cpp Tue Oct 31 11:09:11 2006
@@ -1736,7 +1736,7 @@
                        cfg.add_child(cmd);
 
                        network::send_data(cfg);
-               } else if(cmd == "control") {
+               } else if(cmd == "control" && network::nconnections() != 0) {
                        const std::string::const_iterator j = 
std::find(data.begin(),data.end(),' ');
                        if(j != data.end()) {
                                const std::string side(data.begin(),j);

Modified: trunk/src/menu_events.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.hpp?rev=14125&r1=14124&r2=14125&view=diff
==============================================================================
--- trunk/src/menu_events.hpp (original)
+++ trunk/src/menu_events.hpp Tue Oct 31 11:09:11 2006
@@ -121,7 +121,7 @@
        void write_game_snapshot(config& start) const;
        bool has_friends() const;
        bool clear_shroud(const unsigned int team_num);
-       void change_side_controller(const std::string& side, const 
std::string& player, bool own_side=false);
+       static void change_side_controller(const std::string& side, const 
std::string& player, bool own_side=false);
 
        display* gui_;
        unit_map& units_;

Modified: trunk/src/playturn.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playturn.cpp?rev=14125&r1=14124&r2=14125&view=diff
==============================================================================
--- trunk/src/playturn.cpp (original)
+++ trunk/src/playturn.cpp Tue Oct 31 11:09:11 2006
@@ -173,11 +173,8 @@
                        teams_[side_index].make_ai();
                        teams_[side_index].set_current_player("ai"+side_str);
 
-                       config cfg;
-                       cfg.values["side"] = side_str;
-                       cfg.values["controller"] = "ai";
-                       cfg.values["name"] = "ai"+side_str;
-                       network::send_data(cfg);
+                       take_side(side_str, "ai");
+
                        return PROCESS_RESTART_TURN;
                }
 
@@ -225,24 +222,14 @@
                        case 0:
                                teams_[side_index].make_ai();
                                
teams_[side_index].set_current_player("ai"+side_str);
-                               {
-                               config cfg;
-                               cfg.values["side"] = side_str;
-                               cfg.values["controller"] = "ai";
-                               cfg.values["name"] = "ai"+side_str;
-                               network::send_data(cfg);
-                               }
+                               take_side(side_str, "ai");
                                return PROCESS_RESTART_TURN;
                        case 1:
                                teams_[side_index].make_human();
                                
teams_[side_index].set_current_player("human"+side_str);
-                               {
-                               config cfg;
-                               cfg.values["side"] = side_str;
-                               cfg.values["controller"] = "human";
-                               cfg.values["name"] = "human"+side_str;
-                               network::send_data(cfg);
-                               }
+
+                               take_side(side_str, "human");
+
                                return PROCESS_RESTART_TURN;
                        default:
                                if (action > 2) {
@@ -257,13 +244,8 @@
                                        } else {
                                                teams_[side_index].make_ai();
                                                
teams_[side_index].set_current_player("ai"+side_str);
-                                               {
-                                               config cfg;
-                                               cfg.values["side"] = side_str;
-                                               cfg.values["controller"] = 
"ai";
-                                               cfg.values["name"] = 
"ai"+side_str;
-                                               network::send_data(cfg);
-                                               }
+
+                                               take_side(side_str, "ai");
                                        }
                                        return PROCESS_RESTART_TURN;
                                }
@@ -288,3 +270,12 @@
 
        network::send_data(cfg);
 }
+
+void turn_info::take_side(const std::string& side, const std::string& 
controller)
+{
+       config cfg;
+       cfg.values["side"] = side;
+       cfg.values["controller"] = controller;
+       cfg.values["name"] = controller+side;
+       network::send_data(cfg);
+}

Modified: trunk/src/playturn.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playturn.hpp?rev=14125&r1=14124&r2=14125&view=diff
==============================================================================
--- trunk/src/playturn.hpp (original)
+++ trunk/src/playturn.hpp Tue Oct 31 11:09:11 2006
@@ -57,7 +57,8 @@
 
        events::generic_event& replay_error() { return replay_error_; }
 private:
-       void change_side_controller(const std::string& side, const 
std::string& player, bool own_side=false);
+       static void change_side_controller(const std::string& side, const 
std::string& player, bool own_side=false);
+       static void take_side(const std::string& side, const std::string& 
controller);
 
        const game_data& gameinfo_;
        game_state& state_of_game_;




Related Messages


Powered by MHonArc, Updated Tue Oct 31 19:21:20 2006