residualvm/residualvm — pull request #1121 by chkr-private (2014-11-19 17:31:08+00:00)
Title: EMI: Fix stucked dart players

TurnActorTo is mapped to Actor::singleTurnTo() which only
turns the actor according to its turn rate a small amount.

If the the turn could not be completed, TurnActorTo returns
false.

In EMI, all LUA calls to TurnActorTo are repeated until the
actor does eventually look into the correct direction.

However, for parallel running LUA threads calls to IsActorTurning
would return false during such a "LUA-controlled" turn.

In the scene with the dart players, the LUA code for the dialog
waits for the dart player to stop moving (and turning) by repeatedly
calling IsActorTurning. Since that function returns false
even if the players are still turning towards the dart board, the
dialog code starts and starts a parallel LUA thread to use
TurnActorTo to make the dart players looking at Guybrush.

This means, that eventually for each dart player, two LUA
threads with contradicting TurnActorTo directions will run forever
since in none of the threads the final direction is ever reached.

To fix that, a new actor state variable _singleTurning is introduced.
It is set to true if an Actior::singleTurnTo() call indicates that
the turn is not complete. It is set to false once the turning has
fininshed.

Since all TurnActorTo calls EMI are repeated until the function returns
false, it is safe to use that variable to indicate a "LUA-controlled"
turning is in progress.

In GRIM, that's not the case and so isTurning() is only changed for EMI.

This fixes issue #1034.