/** * 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. * @param[in] is_replay Set to true when this is called during a replay. */ void undo_list::commit_vision() { // Update fog/shroud. bool cleared_something = apply_shroud_changes(); if (cleared_something) { // The actions that led to information being revealed can no longer // be undone. undos_.clear(); //undos_.erase(undos_.begin(), undos_.begin() + erase_to); committed_actions_ = true; } }
/** * Clears the stack of undoable (and redoable) actions. * (Also handles updating fog/shroud if needed.) * Call this if an action alters the game state, but add that action to the * stack before calling this (if the action is a kind that can be undone). * This may fire events and change the game state. */ void undo_list::clear() { // The fact that this function was called indicates that something was done. // (Some actions, such as attacks, are never put on the stack.) committed_actions_ = true; // We can save some overhead by not calling apply_shroud_changes() for an // empty stack. if ( !undos_.empty() ) { apply_shroud_changes(); undos_.clear(); } // No special handling for redos, so just clear that stack. redos_.clear(); }
/** * 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. * @param[in] is_replay Set to true when this is called during a replay. */ void undo_list::commit_vision() { // Update fog/shroud. size_t erase_to = apply_shroud_changes(); if ( erase_to != 0 ) { // The actions that led to information being revealed can no longer // be undone. undos_.erase(undos_.begin(), undos_.begin() + erase_to); committed_actions_ = true; } // Record that vision was updated. add_update_shroud(); }