Skip to content

Commit

Permalink
Move animationless moving unit hiding to a more appropriate place
Browse files Browse the repository at this point in the history
Unit hiding is usually done in replace_temporary, which is called by
proceed_to. As proceed_to exits at the beginning if animate is false, this
would seem like a good place to hide the unit, but it is also unhidden during
this function. This means that was_hidden_ is set multiple times, with the
second time overwriting it with the temporary state of being hidden.
As animate remains false for the entire lifetime of the unit mover, we hide it
at the start and let finish unhide it again.

Reported at http://r.wesnoth.org/p570866
  • Loading branch information
AI0867 committed May 27, 2014
1 parent 30c179b commit e701fe6
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/unit_display.cpp
Expand Up @@ -244,8 +244,14 @@ void unit_mover::update_shown_unit()
void unit_mover::start(unit& u)
{
// Nothing to do here if there is nothing to animate.
if ( !can_draw_ || !animate_ )
if ( !can_draw_ )
return;
// If no animation then hide unit until end of movement
if ( !animate_ ) {
was_hidden_ = u.get_hidden();
u.set_hidden(true);
return;
}

// This normally does nothing, but just in case...
wait_for_anims();
Expand Down Expand Up @@ -309,17 +315,9 @@ void unit_mover::start(unit& u)
void unit_mover::proceed_to(unit& u, size_t path_index, bool update, bool wait)
{
// Nothing to do here if animations cannot be shown.
if ( !can_draw_ )
if ( !can_draw_ || !animate_ )
return;

// If no animation then hide unit until end of movement
if (!animate_)
{
was_hidden_ = u.get_hidden();
u.set_hidden(true);
return;
}

// Handle pending visibility issues before introducing new ones.
wait_for_anims();

Expand Down

0 comments on commit e701fe6

Please sign in to comment.