From d04c366497108a63f726205be88c81d06c8981b2 Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Tue, 10 Aug 2021 23:36:39 +0000 Subject: [PATCH] Fix edge case where bytecode tried to rewind an animation entirely and failed due to being outside of the frame boundary instead of starting from the first frame. --- bemani/format/afp/render.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/bemani/format/afp/render.py b/bemani/format/afp/render.py index 1d8094f..cb0b79f 100644 --- a/bemani/format/afp/render.py +++ b/bemani/format/afp/render.py @@ -235,8 +235,10 @@ class PlacedClip(PlacedObject): if actual_frame is None: print(f"WARNING: Unrecognized frame {frame} to gotoAndStop function!") return - if actual_frame <= 0 or actual_frame > len(self.source.frames): - return + if actual_frame <= 0: + actual_frame = 1 + if actual_frame > len(self.source.frames): + actual_frame = len(self.source.frames) self.requested_frame = actual_frame self.playing = False @@ -245,8 +247,10 @@ class PlacedClip(PlacedObject): if actual_frame is None: print(f"WARNING: Non-integer frame {frame} to gotoAndPlay function!") return - if actual_frame <= 0 or actual_frame > len(self.source.frames): - return + if actual_frame <= 0: + actual_frame = 1 + if actual_frame > len(self.source.frames): + actual_frame = len(self.source.frames) self.requested_frame = actual_frame self.playing = True @@ -262,8 +266,10 @@ class PlacedClip(PlacedObject): print(f"WARNING: Non-integer frame {frame} to setInvisibleUntil function!") return self.visible = False - if actual_frame <= 0 or actual_frame > len(self.source.frames): - return + if actual_frame <= 0: + actual_frame = 1 + if actual_frame > len(self.source.frames): + actual_frame = len(self.source.frames) self.visible_frame = actual_frame @property @@ -276,8 +282,10 @@ class PlacedClip(PlacedObject): if actual_frame is None: print(f"WARNING: Non-integer frameOffset {val} to frameOffset attribute!") return - if actual_frame < 0 or actual_frame >= len(self.source.frames): - return + if actual_frame < 0: + actual_frame = 0 + if actual_frame >= len(self.source.frames): + actual_frame = len(self.source.frames) - 1 self.requested_frame = actual_frame + 1