add a note and new variable name to better indicate the risk...

...of WML event invalidating iterator.  also fix indentation.
This commit is contained in:
Ali El Gariani 2009-11-24 02:20:04 +00:00
parent 0c89bc2c32
commit 3f642a770f

View File

@ -2266,19 +2266,21 @@ size_t move_unit(move_unit_spectator *move_spectator,
event_mutated |= game_events::pump();
ui = units.find(steps.back());
//NOTE: an wml event may have removed the unit pointed by ui
unit_map::iterator maybe_ui = units.find(steps.back());
if (move_spectator!=NULL) {
move_spectator->set_unit(ui);
move_spectator->set_unit(maybe_ui);
}
if(undo_stack != NULL) {
if(event_mutated || should_clear_stack || ui == units.end()) {
if(event_mutated || should_clear_stack || maybe_ui == units.end()) {
apply_shroud_changes(*undo_stack, team_num + 1);
undo_stack->clear();
} else {
// MP_COUNTDOWN: added param
undo_stack->push_back(
undo_action(ui->second, steps,
undo_action(maybe_ui->second, steps,
starting_waypoints, starting_moves,
action_time_bonus, orig_village_owner, orig_dir));
}