Skip to content

Commit

Permalink
KYRA: (LOL) - fix LoLEngine::updateCompass()
Browse files Browse the repository at this point in the history
  • Loading branch information
athrxx committed Mar 17, 2014
1 parent 2e8f2ba commit e53a2b1
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions engines/kyra/scene_lol.cpp
Expand Up @@ -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;

Expand All @@ -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();
Expand Down

0 comments on commit e53a2b1

Please sign in to comment.