mail[Wesnoth-commits] r13644 - in /trunk/src: playturn.cpp server/game.cpp server/game.hpp server/server.cpp


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

Header


Content

Posted by edb on September 24, 2006 - 15:47:
Author: edb
Date: Sun Sep 24 15:47:18 2006
New Revision: 13644

URL: http://svn.gna.org/viewcvs/wesnoth?rev=13644&view=rev
Log:
fixe the green game bug.
note that game still be displaying in green as long as host don't set the new 
controller.
empty slot won't be show as available now.

Modified:
    trunk/src/playturn.cpp
    trunk/src/server/game.cpp
    trunk/src/server/game.hpp
    trunk/src/server/server.cpp

Modified: trunk/src/playturn.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playturn.cpp?rev=13644&r1=13643&r2=13644&view=diff
==============================================================================
--- trunk/src/playturn.cpp (original)
+++ trunk/src/playturn.cpp Sun Sep 24 15:47:18 2006
@@ -15,6 +15,7 @@
 
 #include "game_config.hpp"
 #include "gettext.hpp"
+#include "preferences.hpp"
 #include "replay.hpp"
 #include "show_dialog.hpp"
 #include "sound.hpp"
@@ -214,9 +215,19 @@
                switch(action) {
                        case 0:
                                teams_[side].make_ai();
+                               {
+                               config cfg;
+                               cfg.values["side"] = 
lexical_cast<std::string>(side+1);
+                               network::send_data(cfg);
+                               }
                                return PROCESS_RESTART_TURN;
                        case 1:
                                teams_[side].make_human();
+                               {
+                               config cfg;
+                               cfg.values["side"] = 
lexical_cast<std::string>(side+1);
+                               network::send_data(cfg);
+                               }
                                return PROCESS_RESTART_TURN;
                        default:
                                if (action > 2) {

Modified: trunk/src/server/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/game.cpp?rev=13644&r1=13643&r2=13644&view=diff
==============================================================================
--- trunk/src/server/game.cpp (original)
+++ trunk/src/server/game.cpp Sun Sep 24 15:47:18 2006
@@ -358,7 +358,7 @@
        }
 
        //get the socket of the player that issued the command
-       bool host = false; //we need to save this information before the 
player is erased 
+       bool host = false; //we need to save this information before the 
player is erased
        network::connection sock;
        bool foundCommandPlayer = false;
        std::multimap<network::connection, size_t>::iterator oldside;
@@ -455,37 +455,29 @@
                players_.push_back(*i);
                observers_.erase(i);
        }
+
        static const std::string success = "";
        return success;
 }
 
-size_t game::available_slots() const
-{
-       size_t n_sides = level_.get_children("side").size();
-       size_t available_slots = 0;
-       for(int s = 0; s < n_sides; ++s) {
-               if(! sides_taken_[s]) {
-                       available_slots++;
-               }
-       }
-
-       return available_slots;
-}
-
 bool game::describe_slots()
 {
        if(description() == NULL)
                return false;
 
-       const int val = int(available_slots());
+       int available_slots = 0;
        char buf[50];
        int num_sides = level_.get_children("side").size();
-       for(config::child_list::const_iterator it = 
level_.get_children("side").begin(); it != level_.get_children("side").end(); 
++it) {
-               if((**it)["allow_player"] == "no") {
+       int i = 0;
+       for(config::child_list::const_iterator it = 
level_.get_children("side").begin(); it != level_.get_children("side").end(); 
++it, ++i) {
+               if((**it)["allow_player"] == "no" or (**it)["no_leader"] == 
"yes") {
                        num_sides--;
-               }
-       }
-       snprintf(buf,sizeof(buf),"%d/%d",val,num_sides);
+               } else {
+                       if(!sides_taken_[i])
+                       available_slots++;
+               }
+       }
+       snprintf(buf,sizeof(buf), "%d/%d", available_slots, num_sides);
 
        if(buf != (*description())["slots"]) {
                description()->values["slots"] = buf;

Modified: trunk/src/server/game.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/game.hpp?rev=13644&r1=13643&r2=13644&view=diff
==============================================================================
--- trunk/src/server/game.hpp (original)
+++ trunk/src/server/game.hpp Sun Sep 24 15:47:18 2006
@@ -55,8 +55,6 @@
        void update_side_data();
 
        const std::string& transfer_side_control(const config& cfg);
-
-       size_t available_slots() const;
 
        //function to set the description to the number of slots
        //returns true if the number of slots has changed

Modified: trunk/src/server/server.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/server.cpp?rev=13644&r1=13643&r2=13644&view=diff
==============================================================================
--- trunk/src/server/server.cpp (original)
+++ trunk/src/server/server.cpp Sun Sep 24 15:47:18 2006
@@ -980,7 +980,7 @@
        //if the owner is banning someone from the game
        if(g->is_owner(sock) && (data.child("ban") != NULL || 
data.child("kick") != NULL)) {
                std::string name;
-               bool ban;
+               bool ban = false;;
                if (data.child("ban") != NULL) {
                        const config& u = *data.child("ban");
                        name = u["username"];




Related Messages


Powered by MHonArc, Updated Sun Sep 24 16:20:11 2006