From e53a2b18e93e17554416f7e974f462fb23898a50 Mon Sep 17 00:00:00 2001 From: athrxx Date: Mon, 17 Mar 2014 21:28:59 +0100 Subject: KYRA: (LOL) - fix LoLEngine::updateCompass() --- engines/kyra/scene_lol.cpp | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'engines') diff --git a/engines/kyra/scene_lol.cpp b/engines/kyra/scene_lol.cpp index 313386e86d..391de5e49c 100644 --- a/engines/kyra/scene_lol.cpp +++ b/engines/kyra/scene_lol.cpp @@ -620,14 +620,14 @@ void LoLEngine::updateCompass() { if (_compassStep) _compassStep -= (((ABS(_compassStep) >> 4) + 2) * dir); - int16 d = _compassBroken ? (int8(_rnd.getRandomNumber(255)) - _compassDirection) : (_currentDirection << 6) - _compassDirection; - if (d <= -128) - d += 256; - if (d >= 128) - d -= 256; - - d >>= 2; - _compassStep += d; + int16 diff = _compassBroken ? (int8(_rnd.getRandomNumber(255)) - _compassDirection) : (_currentDirection << 6) - _compassDirection; + if (diff <= -128) + diff += 256; + if (diff >= 128) + diff -= 256; + + diff >>= 2; + _compassStep += diff; _compassStep = CLIP(_compassStep, -24, 24); _compassDirection += _compassStep; @@ -636,14 +636,9 @@ void LoLEngine::updateCompass() { if (_compassDirection > 255) _compassDirection -= 256; - if ((_compassDirection >> 6) == _currentDirection && _compassStep < 2) { - int16 d2 = d >> 16; - d ^= d2; - d -= d2; - if (d < 4) { - _compassDirection = _currentDirection << 6; - _compassStep = 0; - } + if (((((_compassDirection + 3) & 0xFD) >> 6) == _currentDirection) && (_compassStep < 2) && (ABS(diff) < 4)) { + _compassDirection = _currentDirection << 6; + _compassStep = 0; } gui_drawCompass(); -- cgit v1.2.3