diff options
-rw-r--r-- | engines/bladerunner/actor.cpp | 8 | ||||
-rw-r--r-- | engines/bladerunner/actor_walk.cpp | 12 |
2 files changed, 20 insertions, 0 deletions
diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp index 5a464394f8..62ffd6f3a1 100644 --- a/engines/bladerunner/actor.cpp +++ b/engines/bladerunner/actor.cpp @@ -1298,9 +1298,17 @@ bool Actor::findEmptyPositionAround(const Vector3 &startPosition, const Vector3 } } else { // looks like a bug as it might not find anything when there is no walkbox at this angle facingLeft += 20; +#if BLADERUNNER_ORIGINAL_BUGS if (facingLeft > 1024) { facingLeft -= 1024; } +#else + // if facingLeft + 20 == 1024 then it could cause the assertion fault + // in common/sinetables.cpp for SineTable::at(int index) -> assert((index >= 0) && (index < _nPoints)) + if (facingLeft >= 1024) { + facingLeft -= 1024; + } +#endif facingLeftCounter += 20; } diff --git a/engines/bladerunner/actor_walk.cpp b/engines/bladerunner/actor_walk.cpp index 1c91ce0155..536893ce7c 100644 --- a/engines/bladerunner/actor_walk.cpp +++ b/engines/bladerunner/actor_walk.cpp @@ -211,6 +211,18 @@ bool ActorWalk::tick(int actorId, float stepDistance, bool mustReachWalkDestinat } } +#if !BLADERUNNER_ORIGINAL_BUGS + // safety-guard / validator check + if (_facing >= 1024) { + _facing = (_facing % 1024); + } else if (_facing < 0) { + _facing = (-1) * _facing; + _facing = (_facing % 1024); + if (_facing > 0) { + _facing = 1024 - _facing; // this will always be in [1, 1023] + } + } +#endif _current.x += stepDistance * _vm->_sinTable1024->at(_facing); _current.z -= stepDistance * _vm->_cosTable1024->at(_facing); _current.y = _vm->_scene->_set->getAltitudeAtXZ(_current.x, _current.z, &walkboxFound); |