mail[Wesnoth-commits] r44979 - in /trunk/src: mouse_events.cpp mouse_events.hpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by gabrielmorin on July 31, 2010 - 12:15:
Author: gabba
Date: Sat Jul 31 12:15:27 2010
New Revision: 44979

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44979&view=rev
Log:
mouse_handler: split a part of move_unit_along_current_route() into new 
public method move_unit_along_route()

Modified:
    trunk/src/mouse_events.cpp
    trunk/src/mouse_events.hpp

Modified: trunk/src/mouse_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/mouse_events.cpp?rev=44979&r1=44978&r2=44979&view=diff
==============================================================================
--- trunk/src/mouse_events.cpp (original)
+++ trunk/src/mouse_events.cpp Sat Jul 31 12:15:27 2010
@@ -685,11 +685,6 @@
 
 bool mouse_handler::move_unit_along_current_route(bool check_shroud)
 {
-       const std::vector<map_location> steps = current_route_.steps;
-       if(steps.empty()) {
-               return false;
-       }
-
        // do not show footsteps during movement
        gui().set_route(NULL);
 
@@ -697,13 +692,25 @@
        selected_hex_ = map_location();
        gui().select_hex(map_location());
 
-       // will be invalid after the move
+       bool finished_moves = move_unit_along_route(current_route_, 
&next_unit_, check_shroud);
+
+       // invalid after the move
        current_paths_ = pathfind::paths();
        current_route_.steps.clear();
 
+       return finished_moves;
+}
+
+bool mouse_handler::move_unit_along_route(pathfind::marked_route const& 
route, map_location* next_unit, bool check_shroud)
+{
+       const std::vector<map_location> steps = route.steps;
+       if(steps.empty()) {
+               return false;
+       }
+
        size_t moves = 0;
        try {
-                       moves = ::move_unit(NULL, steps, &recorder, 
resources::undo_stack, true, &next_unit_, false, check_shroud);
+                       moves = ::move_unit(NULL, steps, &recorder, 
resources::undo_stack, true, next_unit, false, check_shroud);
        } catch(end_turn_exception&) {
                cursor::set(cursor::NORMAL);
                gui().invalidate_game_status();
@@ -711,7 +718,6 @@
        }
 
        cursor::set(cursor::NORMAL);
-
        gui().invalidate_game_status();
 
        if(moves == 0)
@@ -739,7 +745,6 @@
 
        return moves == steps.size();
 }
-
 
 int mouse_handler::fill_weapon_choices(std::vector<battle_context>& 
bc_vector, unit_map::iterator attacker, unit_map::iterator defender)
 {

Modified: trunk/src/mouse_events.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/mouse_events.hpp?rev=44979&r1=44978&r2=44979&view=diff
==============================================================================
--- trunk/src/mouse_events.hpp (original)
+++ trunk/src/mouse_events.hpp Sat Jul 31 12:15:27 2010
@@ -71,6 +71,8 @@
        int show_attack_dialog(const map_location& attacker_loc, const 
map_location& defender_loc);
        // wrapper to catch bad_alloc so this should be called
        void attack_enemy(const map_location& attacker_loc, const 
map_location& defender_loc, int choice);
+
+       bool move_unit_along_route(pathfind::marked_route const& route, 
map_location* next_unit, bool check_shroud);
 
 protected:
        /**




Related Messages


Powered by MHonArc, Updated Sat Jul 31 12:20:17 2010