[Scummvm-git-logs] scummvm master -> ddffce1dc547563a88388ee1bf681f2a748fb46b
antoniou79
antoniou at cti.gr
Tue Mar 5 10:29:41 CET 2019
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ddffce1dc5 BLADERUNNER: Prevent assert fault when loading actor with bad frame value
Commit: ddffce1dc547563a88388ee1bf681f2a748fb46b
https://github.com/scummvm/scummvm/commit/ddffce1dc547563a88388ee1bf681f2a748fb46b
Author: Thanasis Antoniou (a.antoniou79 at gmail.com)
Date: 2019-03-05T11:26:20+02:00
Commit Message:
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)
Changed paths:
engines/bladerunner/slice_animations.cpp
diff --git a/engines/bladerunner/slice_animations.cpp b/engines/bladerunner/slice_animations.cpp
index b180e84..078d519 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;
More information about the Scummvm-git-logs
mailing list