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

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

[Wesnoth-cvs-commits] wesnoth/src playturn.cpp playturn.hpp server/ga...


From: David White
Subject: [Wesnoth-cvs-commits] wesnoth/src playturn.cpp playturn.hpp server/ga...
Date: Wed, 01 Dec 2004 21:05:25 -0500

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     David White <address@hidden>    04/12/02 01:59:05

Modified files:
        src            : playturn.cpp playturn.hpp 
        src/server     : game.cpp input_stream.cpp metrics.cpp 
                         player.cpp server.cpp variable.cpp 

Log message:
        made replacing of sides with observers possible again

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playturn.cpp.diff?tr1=1.301&tr2=1.302&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playturn.hpp.diff?tr1=1.54&tr2=1.55&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/server/game.cpp.diff?tr1=1.21&tr2=1.22&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/server/input_stream.cpp.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/server/metrics.cpp.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/server/player.cpp.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/server/server.cpp.diff?tr1=1.60&tr2=1.61&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/server/variable.cpp.diff?tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: wesnoth/src/playturn.cpp
diff -u wesnoth/src/playturn.cpp:1.301 wesnoth/src/playturn.cpp:1.302
--- wesnoth/src/playturn.cpp:1.301      Sat Nov 27 10:53:22 2004
+++ wesnoth/src/playturn.cpp    Thu Dec  2 01:59:04 2004
@@ -1,4 +1,4 @@
-/* $Id: playturn.cpp,v 1.301 2004/11/27 10:53:22 silene Exp $ */
+/* $Id: playturn.cpp,v 1.302 2004/12/02 01:59:04 Sirp Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -1197,7 +1197,11 @@
                                << ", which has no recall list!\n";
                } else {
                        // Undo a recall action
-                       team& current_team = teams_[team_num_-1];
+                       team& current_team = teams_[team_num_-1];
+                       if(units_.count(action.recall_loc) == 0) {
+                               return;
+                       }
+
                        const unit& un = units_.find(action.recall_loc)->second;
                        statistics::un_recall_unit(un);
                        current_team.spend_gold(-game_config::recall_cost);
@@ -1214,7 +1218,8 @@
                std::reverse(route.begin(),route.end());
                const unit_map::iterator u = units_.find(route.front());
                if(u == units_.end()) {
-                       assert(false);
+                       //this can actually happen if the scenario designer has 
abused the [allow_undo] command
+                       lg::err(lg::engine) << "Illegal 'undo' found. Possible 
abuse of [allow_undo]?\n";
                        return;
                }
        
@@ -2235,7 +2240,7 @@
                const std::string::const_iterator j = 
std::find(data.begin(),data.end(),' ');
                if(j != data.end()) {
                        const std::string side(data.begin(),j);
-                       const std::string player(j+1,data.end());
+                       const std::string player(j+1,data.end());
 
                        change_side_controller(side,player);
                }
@@ -2271,12 +2276,16 @@
        }
 }
 
-void turn_info::change_side_controller(const std::string& side, const 
std::string& player)
+void turn_info::change_side_controller(const std::string& side, const 
std::string& player, bool orphan_side)
 {
        config cfg;
        config& change = cfg.add_child("change_controller");
        change["side"] = side;
-       change["player"] = player;
+       change["player"] = player;
+
+       if(orphan_side) {
+               change["orphan_side"] = "yes";
+       }
 
        network::send_data(cfg);
 }
@@ -2496,9 +2505,9 @@
                        teams_[side].make_human();
                        return PROCESS_RESTART_TURN;
                } else if(action > 2) {
-                       const size_t index = size_t(action - 2);
+                       const size_t index = size_t(action - 3);
                        if(index < observers.size()) {
-                               
change_side_controller(cfg["side_drop"],observers[index]);
+                               
change_side_controller(cfg["side_drop"],observers[index],true);
                        }
 
                        teams_[side].make_human();
Index: wesnoth/src/playturn.hpp
diff -u wesnoth/src/playturn.hpp:1.54 wesnoth/src/playturn.hpp:1.55
--- wesnoth/src/playturn.hpp:1.54       Sun Nov 21 21:25:48 2004
+++ wesnoth/src/playturn.hpp    Thu Dec  2 01:59:04 2004
@@ -1,4 +1,4 @@
-/* $Id: playturn.hpp,v 1.54 2004/11/21 21:25:48 silene Exp $ */
+/* $Id: playturn.hpp,v 1.55 2004/12/02 01:59:04 Sirp Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -193,7 +193,7 @@
        
        bool enemies_visible() const;
 
-       void change_side_controller(const std::string& side, const std::string& 
player);
+       void change_side_controller(const std::string& side, const std::string& 
player, bool orphan_side=false);
 
        game_data& gameinfo_;
        game_state& state_of_game_;
Index: wesnoth/src/server/game.cpp
diff -u wesnoth/src/server/game.cpp:1.21 wesnoth/src/server/game.cpp:1.22
--- wesnoth/src/server/game.cpp:1.21    Sat Aug 21 22:21:05 2004
+++ wesnoth/src/server/game.cpp Thu Dec  2 01:59:05 2004
@@ -1,4 +1,7 @@
+#include "../global.hpp"
+
 #include "game.hpp"
+#include "../util.hpp"
 
 #include <cassert>
 #include <iostream>
@@ -190,6 +193,16 @@
                return already;
        }
 
+       if(cfg["orphan_side"] != "yes") {
+               const size_t nsides = level_.get_children("side").size();
+               const size_t active_side = end_turn_/nsides + 1;
+
+               if(lexical_cast_default<size_t>(side,0) == active_side) {
+                       static const std::string not_during_turn = "You cannot 
change a side's controller during its turn";
+                       return not_during_turn;
+               }
+       }
+
        config response;
        config& change = response.add_child("change_controller");
 
@@ -207,6 +220,11 @@
 
        sides_taken_.insert(side);
        
+       //send everyone a message saying that the observer who is taking the 
side has quit
+       config observer_quit;
+       observer_quit.add_child("observer_quit").values["name"] = player;
+       send_data(observer_quit);
+
        static const std::string success = "";
        return success;
 }
Index: wesnoth/src/server/input_stream.cpp
diff -u wesnoth/src/server/input_stream.cpp:1.3 
wesnoth/src/server/input_stream.cpp:1.4
--- wesnoth/src/server/input_stream.cpp:1.3     Thu Nov 25 19:50:51 2004
+++ wesnoth/src/server/input_stream.cpp Thu Dec  2 01:59:05 2004
@@ -1,3 +1,5 @@
+#include "../global.hpp"
+
 #include "input_stream.hpp"
 
 #ifndef _WIN32
Index: wesnoth/src/server/metrics.cpp
diff -u wesnoth/src/server/metrics.cpp:1.3 wesnoth/src/server/metrics.cpp:1.4
--- wesnoth/src/server/metrics.cpp:1.3  Sun Oct 31 15:21:04 2004
+++ wesnoth/src/server/metrics.cpp      Thu Dec  2 01:59:05 2004
@@ -1,3 +1,5 @@
+#include "../global.hpp"
+
 #include "metrics.hpp"
 
 #include <time.h>
Index: wesnoth/src/server/player.cpp
diff -u wesnoth/src/server/player.cpp:1.3 wesnoth/src/server/player.cpp:1.4
--- wesnoth/src/server/player.cpp:1.3   Tue Jul 20 11:56:58 2004
+++ wesnoth/src/server/player.cpp       Thu Dec  2 01:59:05 2004
@@ -1,3 +1,5 @@
+#include "../global.hpp"
+
 #include "player.hpp"
 
 player::player(const std::string& n, config& cfg) : name_(n), cfg_(cfg)
Index: wesnoth/src/server/server.cpp
diff -u wesnoth/src/server/server.cpp:1.60 wesnoth/src/server/server.cpp:1.61
--- wesnoth/src/server/server.cpp:1.60  Sun Oct 31 15:21:04 2004
+++ wesnoth/src/server/server.cpp       Thu Dec  2 01:59:05 2004
@@ -1,3 +1,5 @@
+#include "../global.hpp"
+
 #include "../config.hpp"
 #include "../game_config.hpp"
 #include "../network.hpp"
@@ -477,6 +479,8 @@
                                                        const config& msg = 
construct_server_message(result,*g);
                                                        
network::send_data(msg,sock);
                                                }
+
+                                               continue;
                                        }
 
                                        //if the owner is banning someone from 
the game
Index: wesnoth/src/server/variable.cpp
diff -u wesnoth/src/server/variable.cpp:1.4 wesnoth/src/server/variable.cpp:1.5
--- wesnoth/src/server/variable.cpp:1.4 Fri Jun  4 02:57:00 2004
+++ wesnoth/src/server/variable.cpp     Thu Dec  2 01:59:05 2004
@@ -1,3 +1,5 @@
+#include "../global.hpp"
+
 #include "../game_events.hpp"
 
 //this is an 'identity' implementation of variables, that just returns the name




reply via email to

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