diff options
author | Thanasis Antoniou | 2019-07-11 07:25:39 +0300 |
---|---|---|
committer | Thanasis Antoniou | 2019-07-11 07:26:33 +0300 |
commit | c9baa9867c31e5d60e5a7691ed3e3aa5102a5baa (patch) | |
tree | e5062934ef2e5d72c86cc22ebf00621443ba2234 | |
parent | 9f89ade437021e5f22fd9dd3087e3da3151c5e58 (diff) | |
download | scummvm-rg350-c9baa9867c31e5d60e5a7691ed3e3aa5102a5baa.tar.gz scummvm-rg350-c9baa9867c31e5d60e5a7691ed3e3aa5102a5baa.tar.bz2 scummvm-rg350-c9baa9867c31e5d60e5a7691ed3e3aa5102a5baa.zip |
BLADERUNNER: Possible fix for facing angle assertion fault
-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); |