Author: suokko
Date: Thu Sep 18 18:42:29 2008
New Revision: 29533

URL: http://svn.gna.org/viewcvs/wesnoth?rev=29533&view=rev
Log:
Fixed invalid iterator in clear_shourd when unit_placer changes underlying id 
for unit

Modified:
    trunk/src/actions.cpp

Modified: trunk/src/actions.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/actions.cpp?rev=29533&r1=29532&r2=29533&view=diff
==============================================================================
--- trunk/src/actions.cpp (original)
+++ trunk/src/actions.cpp Thu Sep 18 18:42:29 2008
@@ -2553,21 +2553,22 @@
                //NOTE: for the moment shroud cleared during recall seems never 
delayed
                if(un->is_recall() || un->is_recruit()) continue;
 
+               // Make a temporary unit move in map and hide the original
+               unit_map::iterator unit_itor = 
units.find(un->affected_unit.underlying_id());
+               assert(unit_itor != units.end());
+               unit temporary_unit(unit_itor->second);
                // We're not really going to mutate the unit, just temporarily
                // set its moves to maximum, but then switch them back.
-               // TODO: do this for the temporary unit instead
-               // (and maybe move it instead or recreate it for each step ?)
-               const unit_movement_resetter move_resetter(un->affected_unit);
+               const unit_movement_resetter move_resetter(temporary_unit);
 
                std::vector<gamemap::location>::const_iterator step;
                for(step = un->route.begin(); step != un->route.end(); ++step) {
                        // we search where is the unit now, before placing its 
temporary clone
-                       unit_map::const_iterator real_unit = 
units.find(un->affected_unit.underlying_id());
 
                        // We have to swap out any unit that is already in the 
hex,
                        // so we can put our unit there, then we'll swap back 
at the end.
                        // FIXME: in other move functions, we are blind when 
traversing occupied hex
-                       const temporary_unit_placer 
unit_placer(units,*step,un->affected_unit);
+                       const temporary_unit_placer unit_placer(units,*step, 
temporary_unit);
 
                        // In theory we don't know this clone, but
                        // - he can't be in newly cleared locations
@@ -2592,7 +2593,7 @@
                                assert(new_unit != units.end());
                                teams[team].see(new_unit->second.side()-1);
 
-                               
game_events::raise("sighted",*sight_it,real_unit->first);
+                               
game_events::raise("sighted",*sight_it,unit_itor->first);
                                sighted_event = true;
                        }
 


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

Reply via email to