Author: tschmitz
Date: Wed Jul 27 00:44:10 2011
New Revision: 50458

URL: http://svn.gna.org/viewcvs/wesnoth?rev=50458&view=rev
Log:
Moved some code to fix a problem with whiteboard and ambush.

Modified:
    trunk/src/whiteboard/attack.cpp
    trunk/src/whiteboard/move.cpp

Modified: trunk/src/whiteboard/attack.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/attack.cpp?rev=50458&r1=50457&r2=50458&view=diff
==============================================================================
--- trunk/src/whiteboard/attack.cpp (original)
+++ trunk/src/whiteboard/attack.cpp Wed Jul 27 00:44:10 2011
@@ -111,21 +111,12 @@
 
        LOG_WB << "Executing: " << shared_from_this() << "\n";
 
-       events::mouse_handler const& mouse_handler = 
resources::controller->get_mouse_handler_base();
-
-       std::set<map_location> adj_enemies = 
mouse_handler.get_adj_enemies(get_dest_hex(), side_number());
-
        if (route_->steps.size() >= 2)
        {
                if(move::execute() != action::SUCCESS)
                {
                        //Move failed for some reason, so don't attack.
                        result = action::FAIL;
-               }
-               //check if new enemies are now visible
-               else if(mouse_handler.get_adj_enemies(get_dest_hex(), 
side_number()) != adj_enemies)
-               {
-                       result = action::FAIL; //ambush, interrupt attack
                }
        }
 

Modified: trunk/src/whiteboard/move.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/move.cpp?rev=50458&r1=50457&r2=50458&view=diff
==============================================================================
--- trunk/src/whiteboard/move.cpp (original)
+++ trunk/src/whiteboard/move.cpp Wed Jul 27 00:44:10 2011
@@ -228,6 +228,9 @@
        set_arrow_brightness(ARROW_BRIGHTNESS_HIGHLIGHTED);
        fake_unit_->set_hidden(true);
 
+       events::mouse_handler const& mouse_handler = 
resources::controller->get_mouse_handler_base();
+       std::set<map_location> adj_enemies = 
mouse_handler.get_adj_enemies(get_dest_hex(), side_number());
+
        map_location final_location;
        bool steps_finished;
        bool enemy_sighted;
@@ -256,7 +259,9 @@
        {
                if (steps_finished && route_->steps.back() == final_location) 
//reached destination
                {
-                       if(enemy_sighted)
+                       //check if new enemies are now visible
+                       if(enemy_sighted
+                                       || 
mouse_handler.get_adj_enemies(final_location,side_number()) != adj_enemies)
                        {
                                LOG_WB << "Move completed, but interrupted on 
final hex. Halting.\n";
                                //reset to a single-hex path, just in case 
*this is a wb::attack


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

Reply via email to