Author: alink
Date: Sun Nov 22 04:46:49 2009
New Revision: 39865

URL: http://svn.gna.org/viewcvs/wesnoth?rev=39865&view=rev
Log:
Restore waypoints after undo/redo operations

Modified:
    trunk/src/actions.cpp
    trunk/src/menu_events.cpp
    trunk/src/unit.cpp

Modified: trunk/src/actions.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/actions.cpp?rev=39865&r1=39864&r2=39865&view=diff
==============================================================================
--- trunk/src/actions.cpp (original)
+++ trunk/src/actions.cpp Sun Nov 22 04:46:49 2009
@@ -2092,12 +2092,6 @@
 
                moves_left -= cost;
 
-               //remove used waypoints
-               std::list<map_location>& waypoints = ui->second.waypoints();
-               if(!waypoints.empty() && waypoints.front() == *step) {
-                       waypoints.pop_front();
-               }
-
                // If we use fog or shroud, see if we have sighted an enemy 
unit,
                // in which case we should stop immediately.
                // Cannot use check shroud, because also need to check if delay 
shroud is on.
@@ -2281,6 +2275,15 @@
                        undo_stack->push_back(
                                undo_action(ui->second,steps, starting_moves, 
action_time_bonus,
                                orig_village_owner, orig_dir));
+               }
+       }
+
+       //remove used waypoints
+       std::list<map_location>& waypoints = ui->second.waypoints();
+       if(!waypoints.empty()) {
+               foreach(const map_location& loc, steps) {
+                       if(waypoints.front() == loc)
+                               waypoints.pop_front();
                }
        }
 

Modified: trunk/src/menu_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.cpp?rev=39865&r1=39864&r2=39865&view=diff
==============================================================================
--- trunk/src/menu_events.cpp (original)
+++ trunk/src/menu_events.cpp Sun Nov 22 04:46:49 2009
@@ -1069,6 +1069,7 @@
 
                u = units_.find(route.back());
                u->second.set_goto(map_location());
+               std::swap(u->second.waypoints(), 
action.affected_unit.waypoints());
                u->second.set_movement(starting_moves);
                u->second.set_standing();
 
@@ -1206,6 +1207,7 @@
 
                unit::clear_status_caches();
                u->second.set_goto(action.affected_unit.get_goto());
+               std::swap(u->second.waypoints(), 
action.affected_unit.waypoints());
                u->second.set_movement(starting_moves);
                u->second.set_standing();
 

Modified: trunk/src/unit.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=39865&r1=39864&r2=39865&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Sun Nov 22 04:46:49 2009
@@ -141,6 +141,7 @@
            unit_value_(o.unit_value_),
            goto_(o.goto_),
            interrupted_move_(o.interrupted_move_),
+           waypoints_(o.waypoints_),
            flying_(o.flying_),
            is_fearless_(o.is_fearless_),
            is_healthy_(o.is_healthy_),


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

Reply via email to