Skip to content

Commit

Permalink
fix OOS when undoing after deactivating DSU
Browse files Browse the repository at this point in the history
previously the 'auto_shroud' replay action also casued the shroud to be
updated (resources::undo_stack->commit_vision()), this caused bugs
becasue it added 2 entries on the undo stack, which caused 2 actionas to
be removed from the replay when undoing after deacticvating delayed
shroud updates.

Also there was no need to do resources::undo_stack->commit_vision(); on
'auto_shroud' replay command becasue we usually automaticly put a
'update_shroud'  command before every 'auto_shroud' command.
  • Loading branch information
gfgtdf committed Feb 23, 2015
1 parent 256c82f commit 730dcfd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/menu_events.cpp
Expand Up @@ -791,8 +791,6 @@ void menu_handler::toggle_shroud_updates(int side_num)
team &current_team = teams()[side_num - 1];
bool auto_shroud = current_team.auto_shroud_updates();
// If we're turning automatic shroud updates on, then commit all moves
// TODO: currently synced_context::run_in_synced_context("auto_shroud", replay_helper::get_auto_shroud(!auto_shroud));
// Also calls update_shroud_now so eigher remove this one or that one.
if (!auto_shroud) update_shroud_now(side_num);

// Toggle the setting and record this.
Expand Down
6 changes: 3 additions & 3 deletions src/synced_commands.cpp
Expand Up @@ -342,9 +342,9 @@ SYNCED_COMMAND_HANDLER_FUNCTION(auto_shroud, child, use_undo, /*show*/, /*error
team &current_team = (*resources::teams)[current_team_num - 1];

bool active = child["active"].to_bool();
// Turning on automatic shroud causes vision to be updated.
if ( active )
resources::undo_stack->commit_vision();
// We cannot update shroud here like 'if(active) resources::undo_stack->commit_vision();'.
// Becasue the undo.cpp code assumes exactly 1 entry in the undo stack per entry in the replay.
// And doing so would create a second entry in the undo stack for this 'auto_shroud' entry.
current_team.set_auto_shroud_updates(active);
resources::undo_stack->add_auto_shroud(active);
return true;
Expand Down

0 comments on commit 730dcfd

Please sign in to comment.