Restore unit bars after moving even if the animator is disabled

This fixes an issue where unit bars disappeared for individual units
after a movement action with Quick Replays on or when using the Skip
Animations replay option, so that they'd only reappear after playing an
attack or select animation (or any other animation, probably).

The cause was that these options cause the replay code to hold a CVideo
lock, which causes the unit_display::unit_mover::finish() to return
early without restoring the animated unit's bars. Since this also makes
the u_d::unit_mover not hide the bars in the first place, it wouldn't
normally be an issue; the bug is actually caused by an interaction with
actions::unit_mover::do_move(), which unconditionally hides a unit's
bars for every movement step.

Since I don't want to call unit::set_standing() more times than
necessary (even though a::u_m::do_move() appears to do just that), I
decided to have u_d::u_m::finish() reset the unit's state even when
it's not supposed to do anything due to display locks.

I also added comments in a::u_m::do_move() and u_d::u_m::finish() to
warn people about this interaction in case it comes up again in the
future.
This commit is contained in:
Ignacio R. Morelle 2015-06-02 03:40:51 -03:00
parent a50252907a
commit dd36c4ed5f
4 changed files with 15 additions and 1 deletions

View file

@ -12,6 +12,9 @@ Version 1.12.2+dev:
to the player for the first time or some other unspecified thing happens.
* Hide mod options from the user command prompt dialog in the MP lobby when
not authenticated as a mod.
* Fixed unit bars, ellipses, and orbs disappearing for individual units in
replay mode when using Skip Animations/Quick Replays if they moved without
attacking or otherwise switching to a new animation.
* Miscellaneous and bug fixes:
* Fixed bug #23445: set default build type in cmake to "Release" to ensure
that the game is not unoptimized

View file

@ -10,6 +10,9 @@ Version 1.12.2+dev:
* Fixed minimap buttons appearing without contents or in the wrong state
during WML start events until they are interacted with or control is given
to the player for the first time or some other unspecified thing happens.
* Fixed unit bars, ellipses, and orbs disappearing for individual units in
replay mode when using Skip Animations/Quick Replays if they moved without
attacking or otherwise switching to a new animation.
Version 1.12.2:

View file

@ -505,6 +505,9 @@ namespace { // Private helpers for move_unit()
// Update the moving unit.
move_it_ = move_result.first;
move_it_->set_facing(step_from->get_relative_dir(*step_to));
// Disable bars. The expectation here is that the animation
// unit_mover::finish() will clean after us at a later point. Ugly,
// but it works.
move_it_->set_standing(false);
disp.invalidate_unit_after_move(*move_loc_, *step_to);
disp.invalidate(*step_to);

View file

@ -428,8 +428,13 @@ void unit_mover::wait_for_anims()
void unit_mover::finish(unit &u, map_location::DIRECTION dir)
{
// Nothing to do here if the display is not valid.
if ( !can_draw_ )
if ( !can_draw_ ) {
// Make sure to reset the unit's animation to deal with a quirk in the
// action engine where it leaves it to us to reenable bars even if the
// display is initially locked.
u.set_standing(true);
return;
}
const map_location & end_loc = path_[current_];
const map_location::DIRECTION final_dir = current_ == 0 ?