Patch #2622 by tschmitz
* "Redo" action now calls on_gamestate_change() to tell whiteboard to revalidate the planned moves. * Attempting to make the first planned action occur earlier in the planned actions list will no longer crash Wesnoth. * Fixed bug #16845 * Probably fixed bug #16669 (testing under MSVC is needed to confirm both)
This commit is contained in:
parent
694170893f
commit
74b0c3e406
3 changed files with 21 additions and 8 deletions
|
@ -1141,6 +1141,9 @@
|
|||
[entry]
|
||||
name = "Tomasz Sikorski (Tomsik)"
|
||||
[/entry]
|
||||
[entry]
|
||||
name = "Tommy Schmitz"
|
||||
[/entry]
|
||||
[entry]
|
||||
name = "Tommy (yobbo)"
|
||||
[/entry]
|
||||
|
|
|
@ -1165,11 +1165,12 @@ void menu_handler::redo(int side_num)
|
|||
ERR_NG << "trying to redo a dismiss for side " << side_num
|
||||
<< ", which has no recall list!\n";
|
||||
} else {
|
||||
//redo a dismissal
|
||||
recorder.add_disband(action.affected_unit.id());
|
||||
std::vector<unit>::iterator unit_it = std::find_if(current_team.recall_list().begin(),
|
||||
current_team.recall_list().end(), boost::bind(&unit::matches_id, _1, action.affected_unit.id()));
|
||||
current_team.recall_list().erase(unit_it);
|
||||
//redo a dismissal
|
||||
recorder.add_disband(action.affected_unit.id());
|
||||
std::vector<unit>::iterator unit_it = std::find_if(current_team.recall_list().begin(),
|
||||
current_team.recall_list().end(), boost::bind(&unit::matches_id, _1, action.affected_unit.id()));
|
||||
current_team.recall_list().erase(unit_it);
|
||||
resources::whiteboard->on_gamestate_change();
|
||||
}
|
||||
} else if(action.is_recall()) {
|
||||
if(!current_team.persistent()) {
|
||||
|
@ -1200,6 +1201,7 @@ void menu_handler::redo(int side_num)
|
|||
recorder.undo();
|
||||
gui::dialog(*gui_,"",msg,gui::OK_ONLY).show();
|
||||
}
|
||||
resources::whiteboard->on_gamestate_change();
|
||||
}
|
||||
} else if(action.is_recruit()) {
|
||||
// Redo recruit action
|
||||
|
@ -1243,6 +1245,7 @@ void menu_handler::redo(int side_num)
|
|||
recorder.undo();
|
||||
gui::dialog(*gui_,"",msg,gui::OK_ONLY).show();
|
||||
}
|
||||
resources::whiteboard->on_gamestate_change();
|
||||
} else {
|
||||
// Redo movement action
|
||||
const int starting_moves = action.starting_moves;
|
||||
|
@ -1276,6 +1279,7 @@ void menu_handler::redo(int side_num)
|
|||
}
|
||||
|
||||
gui_->invalidate_unit_after_move(route.front(), route.back());
|
||||
resources::whiteboard->on_gamestate_change();
|
||||
gui_->draw();
|
||||
|
||||
recorder.add_movement(action.route);
|
||||
|
|
|
@ -280,8 +280,9 @@ side_actions::iterator side_actions::bump_earlier(side_actions::iterator positio
|
|||
}
|
||||
|
||||
assert(validate_iterator(position));
|
||||
//Do nothing if the result position would be impossible
|
||||
if(!validate_iterator(position - 1))
|
||||
|
||||
//Do nothing if ...
|
||||
if(position == begin()) //... because (position-1) would cause deque assertion failure.
|
||||
return end();
|
||||
|
||||
side_actions::iterator previous = position - 1;
|
||||
|
@ -456,7 +457,12 @@ side_actions::iterator side_actions::remove_action(side_actions::iterator positi
|
|||
if (!actions_.empty() && validate_iterator(position))
|
||||
{
|
||||
LOG_WB << "Erasing action at position #" << distance + 1 << "\n";
|
||||
actions_.erase(position);
|
||||
|
||||
{//prevent erase() statement from destroying action object, potentially causing infinite recursion
|
||||
action_ptr action = *position;
|
||||
actions_.erase(position);
|
||||
}//Now safely destruct action object (if zero references)
|
||||
|
||||
if (validate_after_delete)
|
||||
{
|
||||
validate_actions();
|
||||
|
|
Loading…
Add table
Reference in a new issue