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 80b22f2b18
commit e249945b36
4 changed files with 15 additions and 1 deletions

View file

@ -31,6 +31,9 @@ Version 1.13.0+dev:
(bug #20337).
* 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.
* WML engine:
* Added support for [object] duration=turn end
* New or updated image path functions:

View file

@ -25,6 +25,9 @@ Version 1.13.0+dev:
* Force uniform font rendering settings across X11 and Apple OS X, avoiding
color glitches resulting from incorrect applications of subpixel hinting
(bug #20337).
* 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 a segfault in [move_units_fake]

View file

@ -504,6 +504,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_->anim_comp().set_standing(false);
disp.invalidate_unit_after_move(*move_loc_, *step_to);
disp.invalidate(*step_to);

View file

@ -415,8 +415,13 @@ void unit_mover::wait_for_anims()
void unit_mover::finish(unit_ptr 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->anim_comp().set_standing(true);
return;
}
const map_location & end_loc = path_[current_];
const map_location::DIRECTION final_dir = current_ == 0 ?