mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-25 13:26:28 +00:00
Automaticially update shroud when disabling DSU
Not having the shroud updated while dsu is disabled could lead to shroud not being updated at all or worse It is a bit annoying to works on code that should actually be removed (DSU), but the whiteboard still doesn't work perferctly.
This commit is contained in:
parent
451463d45b
commit
ca53d08fba
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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()) {
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user