aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanasis Antoniou2019-03-05 11:19:55 +0200
committerThanasis Antoniou2019-03-05 11:26:20 +0200
commitddffce1dc547563a88388ee1bf681f2a748fb46b (patch)
tree84f08b2872f045a0a2a089610ae1e4aec4271f67
parent14349341a68bd5853173076e63ef5facc27e78b4 (diff)
downloadscummvm-rg350-ddffce1dc547563a88388ee1bf681f2a748fb46b.tar.gz
scummvm-rg350-ddffce1dc547563a88388ee1bf681f2a748fb46b.tar.bz2
scummvm-rg350-ddffce1dc547563a88388ee1bf681f2a748fb46b.zip
BLADERUNNER: Prevent assert fault when loading actor with bad frame value
Commented out assert fault in SliceAnimations::getFramePtr and sanitized the frame value instead Some actors (currently happened only with hawkers_barkeep) can have invalid frame value set when loading a save file which would cause and assert fault in the getFramePtr() assert check. This seems to be a combination of factors responsible: 1) The updateAnimation (called for an actor before drawing him into the world) has a switch clause based on animationState (not animationId) and 2) the ai_script vars for an actor are not re-initialized upon a LOAD (eg for hawkers_barkeep the _var2 value is problematic in this context because a non-zero value won't allow for sanitization of the existing / loaded frame value)
-rw-r--r--engines/bladerunner/slice_animations.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/engines/bladerunner/slice_animations.cpp b/engines/bladerunner/slice_animations.cpp
index b180e84ac0..078d51953a 100644
--- a/engines/bladerunner/slice_animations.cpp
+++ b/engines/bladerunner/slice_animations.cpp
@@ -168,7 +168,28 @@ void *SliceAnimations::PageFile::loadPage(uint32 pageNumber) {
}
void *SliceAnimations::getFramePtr(uint32 animation, uint32 frame) {
- assert(frame < _animations[animation].frameCount);
+#if BLADERUNNER_ORIGINAL_BUGS
+#else
+ // FIXME: Maybe there's a better way?
+ // Sanitize bad frame value
+ // For some actors (currently only happened with hawkers_barkeep) it is possible
+ // to SAVE a frame value (while saving a game)
+ // that in conjunction with other actor script vars not being re-initialized
+ // upon LOADING that game (for hawkers_barkeep this variable is "_var2")
+ // will lead to an invalid frame here and an assertion fault (now commented out).
+ // Example of faulty case:
+ // hawkers_barkeep was SAVED as:
+ // (animationState, animationFrame, animationStateNext, nextAnimation) = (0, 19, 0, 0)
+ // while his animationID was 705
+ // if _var1, _var2, _var3 == (0, 6, 1) when LOADING that save file,
+ // then animationFrame will remain 19, which is invalid for his 705 animation
+ // and the assert will produce a fault when trying to call drawInWorld for him.
+ if (frame >= _animations[animation].frameCount) {
+ debug("Bad frame: %u max: %u animation: %u", frame, _animations[animation].frameCount, animation);
+ frame = 0;
+ }
+// assert(frame < _animations[animation].frameCount);
+#endif // BLADERUNNER_ORIGINAL_BUGS
uint32 frameOffset = _animations[animation].offset + frame * _animations[animation].frameSize;
uint32 page = frameOffset / _pageSize;