Author: tschmitz
Date: Wed Jul 27 00:46:09 2011
New Revision: 50459

URL: http://svn.gna.org/viewcvs/wesnoth?rev=50459&view=rev
Log:
Fixed inability to plan a move to a hex containing a hidden unit.

Modified:
    trunk/src/whiteboard/move.cpp
    trunk/src/whiteboard/move.hpp
    trunk/src/whiteboard/validate_visitor.cpp

Modified: trunk/src/whiteboard/move.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/move.cpp?rev=50459&r1=50458&r2=50459&view=diff
==============================================================================
--- trunk/src/whiteboard/move.cpp (original)
+++ trunk/src/whiteboard/move.cpp Wed Jul 27 00:46:09 2011
@@ -69,7 +69,8 @@
   fake_unit_(fake_unit),
   valid_(true),
   arrow_brightness_(),
-  arrow_texture_()
+  arrow_texture_(),
+  mover_()
 {
        assert(!route_->steps.empty());
 
@@ -89,6 +90,7 @@
        , valid_(true)
        , arrow_brightness_()
        , arrow_texture_()
+       , mover_()
 {
        // Construct and validate unit_
        unit_map::iterator unit_itor = resources::units->find(cfg["unit_"]);
@@ -218,7 +220,7 @@
                return action::SUCCESS; //zero-hex move, used by attack subclass
 
        //Ensure destination hex is free
-       if (resources::units->find(get_dest_hex()) != resources::units->end())
+       if 
(get_visible_unit(get_dest_hex(),resources::teams->at(viewer_team())) != NULL)
                return action::FAIL;
 
        LOG_WB << "Executing: " << shared_from_this() << "\n";
@@ -293,6 +295,7 @@
                                                << ") to (" << new_path.back() 
<< ").\n";
                                //FIXME: probably better to use the new 
calculate_new_route instead of doing this
                                route_->steps = new_path;
+                               arrow_->set_path(new_path);
                        }
                        else //Unit ended up in location outside path, likely 
due to a WML event
                        {
@@ -371,11 +374,10 @@
        // Move the unit
        DBG_WB << "Move: Temporarily moving unit " << unit.name() << " [" << 
unit.id()
                        << "] from (" << get_source_hex() << ") to (" << 
get_dest_hex() <<")\n";
-       unit_map.move(get_source_hex(), get_dest_hex());
-
-}
-
-void move::remove_temp_modifier(unit_map& unit_map)
+       mover_.reset(new temporary_unit_mover(unit_map,get_source_hex(), 
get_dest_hex()));
+}
+
+void move::remove_temp_modifier(unit_map&)
 {
        if (get_source_hex() == get_dest_hex())
                return; //zero-hex move, probably used by attack subclass
@@ -391,8 +393,7 @@
        unit.set_movement(unit.movement_left() + movement_cost_);
 
        // Restore the unit to its original position
-       unit_map.move(get_dest_hex(), get_source_hex());
-
+       mover_.reset();
 }
 
 void move::draw_hex(const map_location& hex)

Modified: trunk/src/whiteboard/move.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/move.hpp?rev=50459&r1=50458&r2=50459&view=diff
==============================================================================
--- trunk/src/whiteboard/move.hpp (original)
+++ trunk/src/whiteboard/move.hpp Wed Jul 27 00:46:09 2011
@@ -22,6 +22,8 @@
 
 #include "action.hpp"
 #include "map_location.hpp"
+
+struct temporary_unit_mover;
 
 namespace wb {
 
@@ -103,6 +105,7 @@
 private:
        void init();
        void update_arrow_style();
+       boost::scoped_ptr<temporary_unit_mover> mover_;
 };
 
 /** Dumps an move on a stream, for debug purposes. */

Modified: trunk/src/whiteboard/validate_visitor.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/validate_visitor.cpp?rev=50459&r1=50458&r2=50459&view=diff
==============================================================================
--- trunk/src/whiteboard/validate_visitor.cpp (original)
+++ trunk/src/whiteboard/validate_visitor.cpp Wed Jul 27 00:46:09 2011
@@ -117,7 +117,7 @@
        if (m.get_source_hex() != m.get_dest_hex()) //allow for zero-hex, move, 
in which case we skip pathfinding
        {
                //verify that the destination hex is free
-               if (resources::units->find(m.get_dest_hex()) != 
resources::units->end())
+               if 
(get_visible_unit(m.get_dest_hex(),resources::teams->at(viewer_team())) != NULL)
                        return OBSTRUCTED;
 
                pathfind::marked_route new_route;


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

Reply via email to