Author: soliton
Date: Fri May 29 00:41:46 2009
New Revision: 35923

URL: http://svn.gna.org/viewcvs/wesnoth?rev=35923&view=rev
Log:
always update side data on start_game

..and don't on take_side since the host ultimately decides (which will then be
processed in update_side_data())
this hopefully fixes a race condition on game start that could lead to an
inconsistent state

Modified:
    branches/1.6/src/server/game.cpp

Modified: branches/1.6/src/server/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/src/server/game.cpp?rev=35923&r1=35922&r2=35923&view=diff
==============================================================================
--- branches/1.6/src/server/game.cpp (original)
+++ branches/1.6/src/server/game.cpp Fri May 29 00:41:46 2009
@@ -172,6 +172,8 @@
                        "\tturn bonus: "     + 
s["mp_countdown_turn_bonus"].to_string() : "")
                << "\n";
 
+       update_side_data();
+
        nsides_ = 0;
        // Set all side controllers to 'human' so that observers will understand
        // that they can't take control of any sides if they happen to have the
@@ -179,7 +181,7 @@
        const simple_wml::node::child_list& sides = 
level_.root().children("side");
        for(simple_wml::node::child_list::const_iterator s = sides.begin(); s 
!= sides.end(); ++s) {
                nsides_++;
-               if((**s)["controller"] != "null" && !advance) {
+               if ((**s)["controller"] != "null") {
                        (*s)->set_attr("controller", "human");
                }
        }
@@ -198,8 +200,6 @@
        end_turn();
        clear_history();
        if (advance) {
-               // Re-assign sides to allow correct filtering of commands.
-               update_side_data();
                // When the host advances tell everyone that the next scenario 
data is
                // available.
                static simple_wml::document 
notify_next_scenario("[notify_next_scenario]\n[/notify_next_scenario]\n", 
simple_wml::INIT_COMPRESSED);
@@ -233,8 +233,6 @@
                        side_num = (**side)["side"].to_int();
                        if (side_num < 1 || side_num > gamemap::MAX_PLAYERS) 
continue;
                        if (sides_[side_num - 1] != 0) continue;
-                       side_controllers_[side_num - 1] = "human";
-                       sides_[side_num - 1] = user->first;
                        cfg.root().set_attr_dup("side", (**side)["side"]);
                        // Tell the host which side the new player should take.
 
@@ -248,15 +246,10 @@
        // If there was no fitting side just take the first available.
        for(simple_wml::node::child_list::const_iterator side = sides.begin(); 
side != sides.end(); ++side) {
                if((**side)["controller"] == "network") {
-                       //don't allow players to take sides in games with 
invalid side numbers
-                       try {
-                               side_num = (**side)["side"].to_int();
-                       } catch (bad_lexical_cast&) { continue; }
+                       side_num = (**side)["side"].to_int();
                        if (side_num < 1 || side_num > gamemap::MAX_PLAYERS) 
continue;
                        if (sides_[side_num - 1] != 0) continue;
                        // we expect that the host will really use our proposed 
side number (he could do different)
-                       side_controllers_[side_num - 1] = "human";
-                       sides_[side_num - 1] = user->first;
                        cfg.root().set_attr_dup("side", (**side)["side"]);
                        // Tell the host which side the new player should take.
                        simple_wml::string_span data = cfg.output_compressed();


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to