diff --git a/src/actions/undo.cpp b/src/actions/undo.cpp index b650884f756..336a8e7121f 100644 --- a/src/actions/undo.cpp +++ b/src/actions/undo.cpp @@ -145,17 +145,11 @@ undo_list::~undo_list() */ void undo_list::add_auto_shroud(bool turned_on) { - // TODO: Consecutive shroud actions can be collapsed into one. - - // Do not call add(), as this should not clear the redo stack. add(new undo::auto_shroud_action(turned_on)); } void undo_list::add_dummy() { - // TODO: Consecutive shroud actions can be collapsed into one. - - // Do not call add(), as this should not clear the redo stack. add(new undo_dummy_action()); } @@ -204,8 +198,6 @@ void undo_list::add_recruit(const unit_const_ptr u, const map_location& loc, */ void undo_list::add_update_shroud() { - // TODO: Consecutive shroud actions can be collapsed into one. - add(new undo::update_shroud_action()); } diff --git a/src/synced_commands.cpp b/src/synced_commands.cpp index f2c8524bf44..d231866f3d0 100644 --- a/src/synced_commands.cpp +++ b/src/synced_commands.cpp @@ -370,9 +370,9 @@ SYNCED_COMMAND_HANDLER_FUNCTION(auto_shroud, child, use_undo, /*show*/, /*error team ¤t_team = resources::controller->current_team(); bool active = child["active"].to_bool(); - // We cannot update shroud here like 'if(active) resources::undo_stack->commit_vision();'. - // because 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. + if(active && !current_team.auto_shroud_updates()) { + resources::undo_stack->commit_vision(); + } current_team.set_auto_shroud_updates(active); if(resources::undo_stack->can_undo()) { resources::undo_stack->add_auto_shroud(active); @@ -380,16 +380,12 @@ SYNCED_COMMAND_HANDLER_FUNCTION(auto_shroud, child, use_undo, /*show*/, /*error return true; } -/** from resources::undo_stack->commit_vision(bool is_replay): - * Updates fog/shroud based on the undo stack, then updates stack as needed. - * Call this when "updating shroud now". - * This may fire events and change the game state. - * - * This means it is a synced command like any other. - */ - SYNCED_COMMAND_HANDLER_FUNCTION(update_shroud, /*child*/, use_undo, /*show*/, error_handler) { + // When "updating shroud now" is used. + // Updates fog/shroud based on the undo stack, then updates stack as needed. + // This may fire events and change the game state. + assert(use_undo); team ¤t_team = resources::controller->current_team(); if(current_team.auto_shroud_updates()) { diff --git a/src/whiteboard/manager.cpp b/src/whiteboard/manager.cpp index b843eac42a4..6979a172db0 100644 --- a/src/whiteboard/manager.cpp +++ b/src/whiteboard/manager.cpp @@ -186,7 +186,6 @@ void manager::set_active(bool active) { if(should_clear_undo()) { if(!resources::controller->current_team().auto_shroud_updates()) { - synced_context::run_and_throw("update_shroud", replay_helper::get_update_shroud()); synced_context::run_and_throw("auto_shroud", replay_helper::get_auto_shroud(true)); } resources::undo_stack->clear();