Fix bug #14826 :"Attempt to dereference invalid iterator"...

...assert in TSL scenario 2

Prevent the crash but I still need to check waypoints(if used) for
these special cases
This commit is contained in:
Ali El Gariani 2009-11-24 00:26:38 +00:00
parent 3420f3dfbc
commit cb5bc1f022

View File

@ -2279,11 +2279,14 @@ size_t move_unit(move_unit_spectator *move_spectator,
}
//remove used waypoints
std::list<map_location>& waypoints = ui->second.waypoints();
if(!waypoints.empty()) {
//TODO:deal with the other case too
if(ui != units.end()) {
std::list<map_location>& waypoints = ui->second.waypoints();
foreach(const map_location& loc, steps) {
if(waypoints.front() == loc)
waypoints.pop_front();
if(waypoints.empty())
break;
if(waypoints.front() == loc)
waypoints.pop_front();
}
}