Author: tschmitz
Date: Tue Aug  2 12:18:22 2011
New Revision: 50564

URL: http://svn.gna.org/viewcvs/wesnoth?rev=50564&view=rev
Log:
Partly fixed whiteboard issue with droiding and player-switching.

Modified:
    trunk/src/game_display.cpp
    trunk/src/playturn.cpp
    trunk/src/whiteboard/manager.cpp
    trunk/src/whiteboard/manager.hpp
    trunk/src/whiteboard/visitor.hpp

Modified: trunk/src/game_display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_display.cpp?rev=50564&r1=50563&r2=50564&view=diff
==============================================================================
--- trunk/src/game_display.cpp (original)
+++ trunk/src/game_display.cpp Tue Aug  2 12:18:22 2011
@@ -1284,6 +1284,7 @@
                viewpoint_ = NULL;
        }
        labels().recalculate_labels();
+       resources::whiteboard->on_viewer_change(teamindex);
 }
 
 void game_display::set_playing_team(size_t teamindex)

Modified: trunk/src/playturn.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playturn.cpp?rev=50564&r1=50563&r2=50564&view=diff
==============================================================================
--- trunk/src/playturn.cpp (original)
+++ trunk/src/playturn.cpp Tue Aug  2 12:18:22 2011
@@ -179,6 +179,8 @@
                                restart = false;
                        }
 
+                       resources::whiteboard->on_change_controller(side,tm);
+
                        resources::screen->labels().recalculate_labels();
 
                        return restart ? PROCESS_RESTART_TURN : 
PROCESS_CONTINUE;

Modified: trunk/src/whiteboard/manager.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/manager.cpp?rev=50564&r1=50563&r2=50564&view=diff
==============================================================================
--- trunk/src/whiteboard/manager.cpp (original)
+++ trunk/src/whiteboard/manager.cpp Tue Aug  2 12:18:22 2011
@@ -245,6 +245,58 @@
        LOG_WB << "on_finish_side_turn()\n";
 }
 
+static void hide_all_plans()
+{
+       foreach(team& t, *resources::teams)
+               t.get_side_actions()->hide();
+}
+
+void manager::on_viewer_change(size_t team_index)
+{
+       //We don't control the "viewing" side ... we're probably an observer
+       if(!resources::teams->at(team_index).is_human())
+               hide_all_plans();
+       else //< normal circumstance
+       {
+               foreach(team& t, *resources::teams)
+               {
+                       if(t.is_enemy(team_index+1))
+                               t.get_side_actions()->hide();
+                       else
+                               t.get_side_actions()->show();
+               }
+       }
+}
+
+void manager::on_change_controller(int side, team& t)
+{
+       wb::side_actions& sa = *t.get_side_actions();
+       if(t.is_human()) //< we own this side now
+       {
+               //tell everyone to clear this side's actions -- we're starting 
anew
+               
resources::whiteboard->queue_net_cmd(sa.team_index(),sa.make_net_cmd_clear());
+               sa.clear();
+               //refresh the hidden_ attribute of every team's side_actions
+               on_viewer_change(viewer_team());
+       }
+       else if(t.is_ai() || t.is_network_ai()) //< no one owns this side 
anymore
+               sa.clear(); //< clear its plans away -- the ai doesn't plan ... 
yet
+       else if(t.is_network()) //< Another client is taking control of the side
+       {
+               if(side==viewer_side()) //< They're taking OUR side away!
+                       hide_all_plans(); //< give up knowledge of everyone's 
plans, in case we became an observer
+
+               //tell them our plans -- they may not have received them up to 
this point
+               size_t num_teams = resources::teams->size();
+               for(size_t i=0; i<num_teams; ++i)
+               {
+                       team& local_team = resources::teams->at(i);
+                       if(local_team.is_human() && !local_team.is_enemy(side))
+                               
resources::whiteboard->queue_net_cmd(i,local_team.get_side_actions()->make_net_cmd_refresh());
+               }
+       }
+}
+
 bool manager::current_side_has_actions()
 {
        return !current_side_actions()->empty();

Modified: trunk/src/whiteboard/manager.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/manager.hpp?rev=50564&r1=50563&r2=50564&view=diff
==============================================================================
--- trunk/src/whiteboard/manager.hpp (original)
+++ trunk/src/whiteboard/manager.hpp Tue Aug  2 12:18:22 2011
@@ -30,6 +30,7 @@
 #include <boost/noncopyable.hpp>
 
 class CKey;
+class team;
 
 namespace pathfind {
        struct marked_route;
@@ -74,6 +75,8 @@
        void on_mouseover_change(const map_location& hex);
        void on_deselect_hex(){ erase_temp_move();}
        void on_gamestate_change();
+       void on_viewer_change(size_t team_index);
+       void on_change_controller(int side, team& t);
 
        /// Called by replay_network_sender to add whiteboard data to the 
outgoing network packets
        void send_network_data();

Modified: trunk/src/whiteboard/visitor.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/visitor.hpp?rev=50564&r1=50563&r2=50564&view=diff
==============================================================================
--- trunk/src/whiteboard/visitor.hpp (original)
+++ trunk/src/whiteboard/visitor.hpp Tue Aug  2 12:18:22 2011
@@ -60,7 +60,7 @@
        //bool visit(size_t team_index, team&, side_actions&, 
side_actions::iterator);
 
        ///@return Whether or not to visit any of the contents of sa.
-       bool pre_visit_team(size_t team_index, team& t, side_actions& sa) 
{return true;}
+       bool pre_visit_team(size_t team_index, team& t, side_actions& sa) 
{return !sa.hidden();}
        ///@return Whether or not to visit any more teams after this one.
        bool post_visit_team(size_t team_index, team& t, side_actions& sa) 
{return true;}
 


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

Reply via email to