Author: dragonking
Date: Fri Jul  4 23:23:40 2008
New Revision: 27726

URL: http://svn.gna.org/viewcvs/wesnoth?rev=27726&view=rev
Log:
Made possible to fallback from ai to human player for testing purposes

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

Modified: trunk/src/menu_events.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.hpp?rev=27726&r1=27725&r2=27726&view=diff
==============================================================================
--- trunk/src/menu_events.hpp (original)
+++ trunk/src/menu_events.hpp Fri Jul  4 23:23:40 2008
@@ -69,6 +69,8 @@
        end_turn_exception(unsigned int r = 0): redo(r) {}
        unsigned int redo;
 };
+
+struct fallback_ai_to_human_exception {};
 
 namespace events{
 

Modified: trunk/src/playsingle_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playsingle_controller.cpp?rev=27726&r1=27725&r2=27726&view=diff
==============================================================================
--- trunk/src/playsingle_controller.cpp (original)
+++ trunk/src/playsingle_controller.cpp Fri Jul  4 23:23:40 2008
@@ -519,6 +519,8 @@
 
 void playsingle_controller::play_side(const unsigned int team_index, bool save)
 {
+       //flag used when we fallback from ai and give temporarily control to 
human
+       bool temporary_human = false;
        do {
                // Although this flag is used only in this method,
                // it has to be a class member since derived classes
@@ -526,9 +528,10 @@
                player_type_changed_ = false;
                end_turn_ = false;
 
+
                statistics::reset_turn_stats(player_number_);
 
-               if(current_team().is_human()) {
+               if(current_team().is_human() || temporary_human) {
                        LOG_NG << "is human...\n";
                        try{
                                before_human_turn(save);
@@ -556,7 +559,13 @@
 
                        LOG_NG << "human finished turn...\n";
                } else if(current_team().is_ai()) {
-                       play_ai_turn();
+                       try {
+                               play_ai_turn();
+                       } catch(fallback_ai_to_human_exception& e) {
+                               //give control to human for the rest of this 
turn
+                               player_type_changed_ = true;
+                               temporary_human = true;
+                       }
                }
        } while (player_type_changed_);
        // Keep looping if the type of a team (human/ai/networked)


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

Reply via email to