Prevent a bug if [recall] is used on a valid, but unusable location...

...and no usable location can be found.
This commit is contained in:
Alexander van Gessel 2011-11-05 01:32:54 +01:00
parent d0e16cd4c4
commit 8c09e8b11f

View file

@ -1835,12 +1835,15 @@ WML_HANDLER_FUNCTION(recall, /*event_info*/, cfg)
if(pass_check || (resources::units->count(loc) > 0))
loc = pathfind::find_vacant_tile(*resources::game_map,
*resources::units, loc, pathfind::VACANT_ANY, pass_check);
DBG_NG << "No usable leader found, but found usable location. Recalling.\n";
avail.erase(u); // Erase before recruiting, since recruiting can fire more events
map_location null_location = map_location::null_location;
place_recruit(to_recruit, loc, null_location, true,
cfg["show"].to_bool(true), cfg["fire_event"].to_bool(false), true, true);
return;
// Check if we still have a valid location
if (resources::game_map->on_board(loc)) {
DBG_NG << "No usable leader found, but found usable location. Recalling.\n";
avail.erase(u); // Erase before recruiting, since recruiting can fire more events
map_location null_location = map_location::null_location;
place_recruit(to_recruit, loc, null_location, true,
cfg["show"].to_bool(true), cfg["fire_event"].to_bool(false), true, true);
return;
}
}
}
}