avm1: Clamp `WaitForFrame` ops to the total frame count of the movie clip being tested.

This commit is contained in:
David Wendt 2022-09-22 11:06:02 -04:00 committed by kmeisthax
parent 1954f6162f
commit aca1c0fb50
1 changed files with 3 additions and 2 deletions

View File

@ -22,6 +22,7 @@ use ruffle_render::bounding_box::BoundingBox;
use smallvec::SmallVec;
use std::borrow::Cow;
use std::cell::{Ref, RefMut};
use std::cmp::min;
use std::fmt;
use swf::avm1::read::Reader;
use swf::avm1::types::*;
@ -2183,7 +2184,7 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
let loaded = self
.target_clip()
.and_then(|dobj| dobj.as_movie_clip())
.map(|mc| mc.frames_loaded() > action.frame)
.map(|mc| mc.frames_loaded() > min(action.frame, mc.frames_loaded() - 1))
.unwrap_or(true);
if !loaded {
// Note that the offset is given in # of actions, NOT in bytes.
@ -2202,7 +2203,7 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> {
let loaded = self
.target_clip()
.and_then(|dobj| dobj.as_movie_clip())
.map(|mc| mc.frames_loaded() > frame_num)
.map(|mc| mc.frames_loaded() > min(frame_num, mc.frames_loaded() - 1))
.unwrap_or(true);
if !loaded {
// Note that the offset is given in # of actions, NOT in bytes.