diff --git a/core/src/avm1/activation.rs b/core/src/avm1/activation.rs index b4f6ee547..8f17e9f33 100644 --- a/core/src/avm1/activation.rs +++ b/core/src/avm1/activation.rs @@ -647,11 +647,10 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { // AS1 logical and let a = self.context.avm1.pop(); let b = self.context.avm1.pop(); - let version = self.current_swf_version(); - let result = b.as_bool(version) && a.as_bool(version); + let result = b.as_bool(self.swf_version()) && a.as_bool(self.swf_version()); self.context .avm1 - .push(Value::from_bool(result, self.current_swf_version())); + .push(Value::from_bool(result, self.swf_version())); Ok(FrameControl::Continue) } @@ -790,7 +789,7 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { let _ = self.run_child_frame_for_action( "[Frame Call]", clip.into(), - self.current_swf_version(), + self.swf_version(), action, )?; } @@ -1112,7 +1111,7 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { let result = b.into_number_v1() == a.into_number_v1(); self.context .avm1 - .push(Value::from_bool(result, self.current_swf_version())); + .push(Value::from_bool(result, self.swf_version())); Ok(FrameControl::Continue) } @@ -1461,7 +1460,7 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { data: &'b SwfSlice, ) -> Result, Error<'gc>> { let val = self.context.avm1.pop(); - if val.as_bool(self.current_swf_version()) { + if val.as_bool(self.swf_version()) { reader.seek(data.movie.data(), jump_offset); } Ok(FrameControl::Continue) @@ -1556,7 +1555,7 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { let result = b.into_number_v1() < a.into_number_v1(); self.context .avm1 - .push(Value::from_bool(result, self.current_swf_version())); + .push(Value::from_bool(result, self.swf_version())); Ok(FrameControl::Continue) } @@ -1664,9 +1663,10 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { } fn action_not(&mut self) -> Result, Error<'gc>> { - let version = self.current_swf_version(); - let val = !self.context.avm1.pop().as_bool(version); - self.context.avm1.push(Value::from_bool(val, version)); + let val = !self.context.avm1.pop().as_bool(self.swf_version()); + self.context + .avm1 + .push(Value::from_bool(val, self.swf_version())); Ok(FrameControl::Continue) } @@ -1737,9 +1737,10 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { // AS1 logical or let a = self.context.avm1.pop(); let b = self.context.avm1.pop(); - let version = self.current_swf_version(); - let result = b.as_bool(version) || a.as_bool(version); - self.context.avm1.push(Value::from_bool(result, version)); + let result = b.as_bool(self.swf_version()) || a.as_bool(self.swf_version()); + self.context + .avm1 + .push(Value::from_bool(result, self.swf_version())); Ok(FrameControl::Continue) } @@ -1993,7 +1994,7 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { let display_object = self.resolve_target_display_object(start_clip, target, true)?; if let Some(display_object) = display_object { let lock_center = self.context.avm1.pop(); - let constrain = self.context.avm1.pop().as_bool(self.current_swf_version()); + let constrain = self.context.avm1.pop().as_bool(self.swf_version()); if constrain { let y2 = self.context.avm1.pop(); let x2 = self.context.avm1.pop(); @@ -2055,7 +2056,7 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { let result = b.coerce_to_string(self)? == a.coerce_to_string(self)?; self.context .avm1 - .push(Value::from_bool(result, self.current_swf_version())); + .push(Value::from_bool(result, self.swf_version())); Ok(FrameControl::Continue) } @@ -2097,7 +2098,7 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { .gt(a.coerce_to_string(self)?.bytes()); self.context .avm1 - .push(Value::from_bool(result, self.current_swf_version())); + .push(Value::from_bool(result, self.swf_version())); Ok(FrameControl::Continue) } @@ -2122,7 +2123,7 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { .lt(a.coerce_to_string(self)?.bytes()); self.context .avm1 - .push(Value::from_bool(result, self.current_swf_version())); + .push(Value::from_bool(result, self.swf_version())); Ok(FrameControl::Continue) } @@ -2845,14 +2846,9 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { Ok(self.base_clip().avm1_root(&self.context)?.object()) } - /// Get the currently executing SWF version. - pub fn current_swf_version(&self) -> u8 { - self.swf_version() - } - /// Returns whether property keys should be case sensitive based on the current SWF version. pub fn is_case_sensitive(&self) -> bool { - self.current_swf_version() > 6 + self.swf_version() > 6 } /// Resolve a particular named local variable within this activation. diff --git a/core/src/avm1/function.rs b/core/src/avm1/function.rs index 818c1f57a..aaf6402c8 100644 --- a/core/src/avm1/function.rs +++ b/core/src/avm1/function.rs @@ -302,7 +302,7 @@ impl<'gc> Executable<'gc> { None }; - let effective_ver = if activation.current_swf_version() > 5 { + let effective_ver = if activation.swf_version() > 5 { af.swf_version() } else { this.as_display_object() @@ -604,7 +604,7 @@ impl<'gc> TObject<'gc> for FunctionObject<'gc> { Attribute::DONT_ENUM, Attribute::empty(), ); - if activation.current_swf_version() < 7 { + if activation.swf_version() < 7 { this.set("constructor", (*self).into(), activation)?; this.set_attributes( activation.context.gc_context, @@ -646,7 +646,7 @@ impl<'gc> TObject<'gc> for FunctionObject<'gc> { Attribute::DONT_ENUM, Attribute::empty(), ); - if activation.current_swf_version() < 7 { + if activation.swf_version() < 7 { this.set("constructor", (*self).into(), activation)?; this.set_attributes( activation.context.gc_context, diff --git a/core/src/avm1/globals.rs b/core/src/avm1/globals.rs index 1d7a70ab6..827cf8804 100644 --- a/core/src/avm1/globals.rs +++ b/core/src/avm1/globals.rs @@ -204,7 +204,7 @@ pub fn get_infinity<'gc>( _this: Object<'gc>, _args: &[Value<'gc>], ) -> Result, Error<'gc>> { - if activation.current_swf_version() > 4 { + if activation.swf_version() > 4 { Ok(f64::INFINITY.into()) } else { Ok(Value::Undefined) @@ -216,7 +216,7 @@ pub fn get_nan<'gc>( _this: Object<'gc>, _args: &[Value<'gc>], ) -> Result, Error<'gc>> { - if activation.current_swf_version() > 4 { + if activation.swf_version() > 4 { Ok(f64::NAN.into()) } else { Ok(Value::Undefined) diff --git a/core/src/avm1/globals/bevel_filter.rs b/core/src/avm1/globals/bevel_filter.rs index 6a7c3f137..69541336f 100644 --- a/core/src/avm1/globals/bevel_filter.rs +++ b/core/src/avm1/globals/bevel_filter.rs @@ -291,7 +291,7 @@ pub fn set_knockout<'gc>( let knockout = args .get(0) .unwrap_or(&false.into()) - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); if let Some(filter) = this.as_bevel_filter_object() { filter.set_knockout(activation.context.gc_context, knockout); diff --git a/core/src/avm1/globals/bitmap_data.rs b/core/src/avm1/globals/bitmap_data.rs index 7b49c7f34..f2963cd18 100644 --- a/core/src/avm1/globals/bitmap_data.rs +++ b/core/src/avm1/globals/bitmap_data.rs @@ -59,7 +59,7 @@ pub fn constructor<'gc>( let transparency = args .get(2) .unwrap_or(&Value::Bool(true)) - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); let fill_color = args .get(3) @@ -464,7 +464,7 @@ pub fn noise<'gc>( let gray_scale = args .get(4) .unwrap_or(&Value::Bool(false)) - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); if let Some(bitmap_data) = this.as_bitmap_data_object() { if !bitmap_data.disposed() { @@ -583,7 +583,7 @@ pub fn get_color_bounds_rect<'gc>( let find_color = args .get(2) .unwrap_or(&Value::Bool(true)) - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); if let (Some(mask_val), Some(color_val)) = (args.get(0), args.get(1)) { let mask = mask_val.coerce_to_i32(activation)?; diff --git a/core/src/avm1/globals/boolean.rs b/core/src/avm1/globals/boolean.rs index 26ee071bc..cbfa27cfa 100644 --- a/core/src/avm1/globals/boolean.rs +++ b/core/src/avm1/globals/boolean.rs @@ -15,7 +15,7 @@ pub fn constructor<'gc>( args: &[Value<'gc>], ) -> Result, Error<'gc>> { let cons_value = if let Some(val) = args.get(0) { - Value::Bool(val.as_bool(activation.current_swf_version())) + Value::Bool(val.as_bool(activation.swf_version())) } else { Value::Bool(false) }; @@ -35,7 +35,7 @@ pub fn boolean_function<'gc>( args: &[Value<'gc>], ) -> Result, Error<'gc>> { let ret_value = if let Some(val) = args.get(0) { - Value::Bool(val.as_bool(activation.current_swf_version())) + Value::Bool(val.as_bool(activation.swf_version())) } else { Value::Undefined }; diff --git a/core/src/avm1/globals/button.rs b/core/src/avm1/globals/button.rs index f0df307f4..0877efba1 100644 --- a/core/src/avm1/globals/button.rs +++ b/core/src/avm1/globals/button.rs @@ -106,7 +106,7 @@ fn set_enabled<'gc>( activation: &mut Activation<'_, 'gc, '_>, value: Value<'gc>, ) -> Result<(), Error<'gc>> { - let enabled = value.as_bool(activation.current_swf_version()); + let enabled = value.as_bool(activation.swf_version()); this.set_enabled(&mut activation.context, enabled); Ok(()) } @@ -123,7 +123,7 @@ fn set_use_hand_cursor<'gc>( activation: &mut Activation<'_, 'gc, '_>, value: Value<'gc>, ) -> Result<(), Error<'gc>> { - let use_hand_cursor = value.as_bool(activation.current_swf_version()); + let use_hand_cursor = value.as_bool(activation.swf_version()); this.set_use_hand_cursor(&mut activation.context, use_hand_cursor); Ok(()) } diff --git a/core/src/avm1/globals/context_menu.rs b/core/src/avm1/globals/context_menu.rs index 1b23f4457..a8abd07d3 100644 --- a/core/src/avm1/globals/context_menu.rs +++ b/core/src/avm1/globals/context_menu.rs @@ -65,28 +65,28 @@ pub fn copy<'gc>( let save = built_in .get("save", activation)? - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); let zoom = built_in .get("zoom", activation)? - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); let quality = built_in .get("quality", activation)? - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); let play = built_in .get("play", activation)? - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); let loop_ = built_in .get("loop", activation)? - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); let rewind = built_in .get("rewind", activation)? - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); let forward_back = built_in .get("forward_back", activation)? - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); let print = built_in .get("print", activation)? - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); copy_built_in.set("save", save.into(), activation)?; copy_built_in.set("zoom", zoom.into(), activation)?; diff --git a/core/src/avm1/globals/convolution_filter.rs b/core/src/avm1/globals/convolution_filter.rs index 3188ac62a..5242328cf 100644 --- a/core/src/avm1/globals/convolution_filter.rs +++ b/core/src/avm1/globals/convolution_filter.rs @@ -105,7 +105,7 @@ pub fn set_clamp<'gc>( let clamp = args .get(0) .unwrap_or(&true.into()) - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); if let Some(filter) = this.as_convolution_filter_object() { filter.set_clamp(activation.context.gc_context, clamp); @@ -305,7 +305,7 @@ pub fn set_preserve_alpha<'gc>( let preserve_alpha = args .get(0) .unwrap_or(&true.into()) - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); if let Some(filter) = this.as_convolution_filter_object() { filter.set_preserve_alpha(activation.context.gc_context, preserve_alpha); diff --git a/core/src/avm1/globals/display_object.rs b/core/src/avm1/globals/display_object.rs index ed83a7af2..ee7d503e1 100644 --- a/core/src/avm1/globals/display_object.rs +++ b/core/src/avm1/globals/display_object.rs @@ -130,7 +130,7 @@ pub fn get_depth<'gc>( activation: &mut Activation<'_, 'gc, '_>, _args: &[Value<'gc>], ) -> Result, Error<'gc>> { - if activation.current_swf_version() >= 6 { + if activation.swf_version() >= 6 { let depth = display_object.depth().wrapping_sub(AVM_DEPTH_BIAS); Ok(depth.into()) } else { diff --git a/core/src/avm1/globals/drop_shadow_filter.rs b/core/src/avm1/globals/drop_shadow_filter.rs index 841bbb6c2..3054fbb87 100644 --- a/core/src/avm1/globals/drop_shadow_filter.rs +++ b/core/src/avm1/globals/drop_shadow_filter.rs @@ -231,7 +231,7 @@ pub fn set_hide_object<'gc>( let hide_object = args .get(0) .unwrap_or(&false.into()) - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); if let Some(object) = this.as_drop_shadow_filter_object() { object.set_hide_object(activation.context.gc_context, hide_object); @@ -260,7 +260,7 @@ pub fn set_inner<'gc>( let inner = args .get(0) .unwrap_or(&false.into()) - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); if let Some(object) = this.as_drop_shadow_filter_object() { object.set_inner(activation.context.gc_context, inner); @@ -289,7 +289,7 @@ pub fn set_knockout<'gc>( let knockout = args .get(0) .unwrap_or(&false.into()) - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); if let Some(object) = this.as_drop_shadow_filter_object() { object.set_knockout(activation.context.gc_context, knockout); diff --git a/core/src/avm1/globals/glow_filter.rs b/core/src/avm1/globals/glow_filter.rs index 9795f9c92..80293db47 100644 --- a/core/src/avm1/globals/glow_filter.rs +++ b/core/src/avm1/globals/glow_filter.rs @@ -163,7 +163,7 @@ pub fn set_inner<'gc>( let inner = args .get(0) .unwrap_or(&Value::Undefined) - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); if let Some(filter) = this.as_glow_filter_object() { filter.set_inner(activation.context.gc_context, inner); @@ -192,7 +192,7 @@ pub fn set_knockout<'gc>( let knockout = args .get(0) .unwrap_or(&Value::Undefined) - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); if let Some(filter) = this.as_glow_filter_object() { filter.set_knockout(activation.context.gc_context, knockout); diff --git a/core/src/avm1/globals/gradient_bevel_filter.rs b/core/src/avm1/globals/gradient_bevel_filter.rs index ebefdfe27..60ed1ddc3 100644 --- a/core/src/avm1/globals/gradient_bevel_filter.rs +++ b/core/src/avm1/globals/gradient_bevel_filter.rs @@ -445,7 +445,7 @@ pub fn set_knockout<'gc>( let knockout = args .get(0) .unwrap_or(&false.into()) - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); if let Some(object) = this.as_gradient_bevel_filter_object() { object.set_knockout(activation.context.gc_context, knockout); diff --git a/core/src/avm1/globals/gradient_glow_filter.rs b/core/src/avm1/globals/gradient_glow_filter.rs index 39776f0cc..0a511559c 100644 --- a/core/src/avm1/globals/gradient_glow_filter.rs +++ b/core/src/avm1/globals/gradient_glow_filter.rs @@ -445,7 +445,7 @@ pub fn set_knockout<'gc>( let knockout = args .get(0) .unwrap_or(&false.into()) - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); if let Some(object) = this.as_gradient_glow_filter_object() { object.set_knockout(activation.context.gc_context, knockout); diff --git a/core/src/avm1/globals/movie_clip.rs b/core/src/avm1/globals/movie_clip.rs index 9739d248f..d8b836c57 100644 --- a/core/src/avm1/globals/movie_clip.rs +++ b/core/src/avm1/globals/movie_clip.rs @@ -124,7 +124,7 @@ pub fn hit_test<'gc>( let y = args.get(1).unwrap().coerce_to_f64(activation)?; let shape = args .get(2) - .map(|v| v.as_bool(activation.current_swf_version())) + .map(|v| v.as_bool(activation.swf_version())) .unwrap_or(false); if x.is_finite() && y.is_finite() { // The docs say the point is in "Stage coordinates", but actually they are in root coordinates. @@ -255,12 +255,12 @@ fn attach_bitmap<'gc>( let _pixel_snapping = args .get(2) .unwrap_or(&Value::Undefined) - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); let smoothing = args .get(3) .unwrap_or(&Value::Undefined) - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); if let Some(bitmap_handle) = bitmap_handle { //TODO: do attached BitmapDatas have character ids? @@ -308,7 +308,7 @@ fn line_style<'gc>( }; let is_pixel_hinted = args .get(3) - .map_or(false, |v| v.as_bool(activation.current_swf_version())); + .map_or(false, |v| v.as_bool(activation.swf_version())); let (allow_scale_x, allow_scale_y) = match args .get(4) .and_then(|v| v.coerce_to_string(activation).ok()) @@ -724,7 +724,7 @@ fn create_text_field<'gc>( false, ); - if activation.current_swf_version() >= 8 { + if activation.swf_version() >= 8 { //SWF8+ returns the `TextField` instance here Ok(text_field.object()) } else { @@ -858,7 +858,7 @@ fn get_instance_at_depth<'gc>( activation: &mut Activation<'_, 'gc, '_>, args: &[Value<'gc>], ) -> Result, Error<'gc>> { - if activation.current_swf_version() >= 7 { + if activation.swf_version() >= 7 { let depth = if let Some(depth) = args.get(0) { depth .coerce_to_i32(activation)? @@ -893,7 +893,7 @@ fn get_next_highest_depth<'gc>( activation: &mut Activation<'_, 'gc, '_>, _args: &[Value<'gc>], ) -> Result, Error<'gc>> { - if activation.current_swf_version() >= 7 { + if activation.swf_version() >= 7 { let depth = std::cmp::max( movie_clip .highest_depth(Depth::MAX) @@ -1370,7 +1370,7 @@ fn set_enabled<'gc>( activation: &mut Activation<'_, 'gc, '_>, value: Value<'gc>, ) -> Result<(), Error<'gc>> { - let enabled = value.as_bool(activation.current_swf_version()); + let enabled = value.as_bool(activation.swf_version()); this.set_enabled(&mut activation.context, enabled); Ok(()) } @@ -1388,7 +1388,7 @@ fn set_focus_enabled<'gc>( value: Value<'gc>, ) -> Result<(), Error<'gc>> { this.set_focusable( - value.as_bool(activation.current_swf_version()), + value.as_bool(activation.swf_version()), &mut activation.context, ); Ok(()) @@ -1406,7 +1406,7 @@ fn set_lock_root<'gc>( activation: &mut Activation<'_, 'gc, '_>, value: Value<'gc>, ) -> Result<(), Error<'gc>> { - let lock_root = value.as_bool(activation.current_swf_version()); + let lock_root = value.as_bool(activation.swf_version()); this.set_lock_root(activation.context.gc_context, lock_root); Ok(()) } @@ -1423,7 +1423,7 @@ fn set_use_hand_cursor<'gc>( activation: &mut Activation<'_, 'gc, '_>, value: Value<'gc>, ) -> Result<(), Error<'gc>> { - let use_hand_cursor = value.as_bool(activation.current_swf_version()); + let use_hand_cursor = value.as_bool(activation.swf_version()); this.set_use_hand_cursor(&mut activation.context, use_hand_cursor); Ok(()) } diff --git a/core/src/avm1/globals/shared_object.rs b/core/src/avm1/globals/shared_object.rs index 4e4f8e78b..86ca8f4ed 100644 --- a/core/src/avm1/globals/shared_object.rs +++ b/core/src/avm1/globals/shared_object.rs @@ -193,7 +193,7 @@ pub fn get_local<'gc>( let secure = args .get(2) .unwrap_or(&Value::Undefined) - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); // Secure parameter disallows using the shared object from non-HTTPS. if secure && movie_url.scheme() != "https" { diff --git a/core/src/avm1/globals/sound.rs b/core/src/avm1/globals/sound.rs index 355024aa3..4a7d8e31c 100644 --- a/core/src/avm1/globals/sound.rs +++ b/core/src/avm1/globals/sound.rs @@ -240,7 +240,7 @@ fn duration<'gc>( this: Object<'gc>, _args: &[Value<'gc>], ) -> Result, Error<'gc>> { - if activation.current_swf_version() >= 6 { + if activation.swf_version() >= 6 { if let Some(sound_object) = this.as_sound_object() { return Ok(sound_object .duration() @@ -258,7 +258,7 @@ fn get_bytes_loaded<'gc>( _this: Object<'gc>, _args: &[Value<'gc>], ) -> Result, Error<'gc>> { - if activation.current_swf_version() >= 6 { + if activation.swf_version() >= 6 { avm_warn!(activation, "Sound.getBytesLoaded: Unimplemented"); Ok(1.into()) } else { @@ -271,7 +271,7 @@ fn get_bytes_total<'gc>( _this: Object<'gc>, _args: &[Value<'gc>], ) -> Result, Error<'gc>> { - if activation.current_swf_version() >= 6 { + if activation.swf_version() >= 6 { avm_warn!(activation, "Sound.getBytesTotal: Unimplemented"); Ok(1.into()) } else { @@ -350,7 +350,7 @@ fn id3<'gc>( _this: Object<'gc>, _args: &[Value<'gc>], ) -> Result, Error<'gc>> { - if activation.current_swf_version() >= 6 { + if activation.swf_version() >= 6 { avm_warn!(activation, "Sound.id3: Unimplemented"); } Ok(Value::Undefined) @@ -361,7 +361,7 @@ fn load_sound<'gc>( _this: Object<'gc>, _args: &[Value<'gc>], ) -> Result, Error<'gc>> { - if activation.current_swf_version() >= 6 { + if activation.swf_version() >= 6 { avm_warn!(activation, "Sound.loadSound: Unimplemented"); } Ok(Value::Undefined) @@ -372,7 +372,7 @@ fn position<'gc>( this: Object<'gc>, _args: &[Value<'gc>], ) -> Result, Error<'gc>> { - if activation.current_swf_version() >= 6 { + if activation.swf_version() >= 6 { if let Some(sound_object) = this.as_sound_object() { // TODO: The position is "sticky"; even if the sound is no longer playing, it should return // the previous valid position. diff --git a/core/src/avm1/globals/system.rs b/core/src/avm1/globals/system.rs index e28cc116b..eeb54fc26 100644 --- a/core/src/avm1/globals/system.rs +++ b/core/src/avm1/globals/system.rs @@ -448,7 +448,7 @@ pub fn set_use_code_page<'gc>( .get(0) .unwrap_or(&Value::Undefined) .to_owned() - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); activation.context.system.use_codepage = value; @@ -472,7 +472,7 @@ pub fn set_exact_settings<'gc>( .get(0) .unwrap_or(&Value::Undefined) .to_owned() - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); activation.context.system.exact_settings = value; diff --git a/core/src/avm1/globals/text_field.rs b/core/src/avm1/globals/text_field.rs index 4d502430c..d5508645e 100644 --- a/core/src/avm1/globals/text_field.rs +++ b/core/src/avm1/globals/text_field.rs @@ -157,8 +157,10 @@ pub fn set_password<'gc>( activation: &mut Activation<'_, 'gc, '_>, value: Value<'gc>, ) -> Result<(), Error<'gc>> { - let current_swf_version = activation.current_swf_version(); - this.set_password(value.as_bool(current_swf_version), &mut activation.context); + this.set_password( + value.as_bool(activation.swf_version()), + &mut activation.context, + ); Ok(()) } @@ -341,8 +343,8 @@ pub fn set_html<'gc>( activation: &mut Activation<'_, 'gc, '_>, value: Value<'gc>, ) -> Result<(), Error<'gc>> { - let current_swf_version = activation.current_swf_version(); - this.set_is_html(&mut activation.context, value.as_bool(current_swf_version)); + let value = value.as_bool(activation.swf_version()); + this.set_is_html(&mut activation.context, value); Ok(()) } @@ -405,7 +407,7 @@ pub fn set_background<'gc>( activation: &mut Activation<'_, 'gc, '_>, value: Value<'gc>, ) -> Result<(), Error<'gc>> { - let has_background = value.as_bool(activation.current_swf_version()); + let has_background = value.as_bool(activation.swf_version()); this.set_has_background(activation.context.gc_context, has_background); Ok(()) } @@ -439,7 +441,7 @@ pub fn set_border<'gc>( activation: &mut Activation<'_, 'gc, '_>, value: Value<'gc>, ) -> Result<(), Error<'gc>> { - let has_border = value.as_bool(activation.current_swf_version()); + let has_border = value.as_bool(activation.swf_version()); this.set_has_border(activation.context.gc_context, has_border); Ok(()) } @@ -473,7 +475,7 @@ pub fn set_embed_fonts<'gc>( activation: &mut Activation<'_, 'gc, '_>, value: Value<'gc>, ) -> Result<(), Error<'gc>> { - let embed_fonts = value.as_bool(activation.current_swf_version()); + let embed_fonts = value.as_bool(activation.swf_version()); this.set_is_device_font(&mut activation.context, !embed_fonts); Ok(()) } @@ -513,7 +515,7 @@ pub fn set_multiline<'gc>( activation: &mut Activation<'_, 'gc, '_>, value: Value<'gc>, ) -> Result<(), Error<'gc>> { - let is_multiline = value.as_bool(activation.current_swf_version()); + let is_multiline = value.as_bool(activation.swf_version()); this.set_multiline(is_multiline, &mut activation.context); Ok(()) } @@ -530,7 +532,7 @@ pub fn set_selectable<'gc>( activation: &mut Activation<'_, 'gc, '_>, value: Value<'gc>, ) -> Result<(), Error<'gc>> { - let set_selectable = value.as_bool(activation.current_swf_version()); + let set_selectable = value.as_bool(activation.swf_version()); this.set_selectable(set_selectable, &mut activation.context); Ok(()) } @@ -572,7 +574,7 @@ pub fn set_word_wrap<'gc>( activation: &mut Activation<'_, 'gc, '_>, value: Value<'gc>, ) -> Result<(), Error<'gc>> { - let is_word_wrap = value.as_bool(activation.current_swf_version()); + let is_word_wrap = value.as_bool(activation.swf_version()); this.set_word_wrap(is_word_wrap, &mut activation.context); Ok(()) } diff --git a/core/src/avm1/globals/text_format.rs b/core/src/avm1/globals/text_format.rs index 6ba45ede8..7e4b54247 100644 --- a/core/src/avm1/globals/text_format.rs +++ b/core/src/avm1/globals/text_format.rs @@ -55,7 +55,7 @@ fn map_defined_to_bool<'gc>( Some(Value::Undefined) => Value::Null, Some(Value::Null) => Value::Null, None => Value::Null, - Some(v) => v.as_bool(activation.current_swf_version()).into(), + Some(v) => v.as_bool(activation.swf_version()).into(), }; this.set(name, val, activation)?; diff --git a/core/src/avm1/globals/xml.rs b/core/src/avm1/globals/xml.rs index a4723c5f4..0c2f48ab4 100644 --- a/core/src/avm1/globals/xml.rs +++ b/core/src/avm1/globals/xml.rs @@ -137,7 +137,7 @@ pub fn xmlnode_clone_node<'gc>( if let (Some(xmlnode), deep) = ( this.as_xml_node(), args.get(0) - .map(|v| v.as_bool(activation.current_swf_version())) + .map(|v| v.as_bool(activation.swf_version())) .unwrap_or(false), ) { let mut clone_node = xmlnode.duplicate(activation.context.gc_context, deep); @@ -792,7 +792,7 @@ pub fn xml_constructor<'gc>( this_node.swap(activation.context.gc_context, xmlnode); let ignore_whitespace = this .get("ignoreWhite", activation)? - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); if let Err(e) = this_node.replace_with_str( activation.context.gc_context, @@ -901,7 +901,7 @@ pub fn xml_parse_xml<'gc>( let ignore_whitespace = this .get("ignoreWhite", activation)? - .as_bool(activation.current_swf_version()); + .as_bool(activation.swf_version()); let result = node.replace_with_str( activation.context.gc_context, diff --git a/core/src/avm1/object.rs b/core/src/avm1/object.rs index ca0d8e1c7..5efe972ba 100644 --- a/core/src/avm1/object.rs +++ b/core/src/avm1/object.rs @@ -390,7 +390,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into> + Clone + Copy proto_stack.push(p); } - if activation.current_swf_version() >= 7 { + if activation.swf_version() >= 7 { for interface in this_proto.interfaces() { if Object::ptr_eq(interface, constructor) { return Ok(true); diff --git a/core/src/avm1/value.rs b/core/src/avm1/value.rs index 3a9161997..a124db2f6 100644 --- a/core/src/avm1/value.rs +++ b/core/src/avm1/value.rs @@ -139,15 +139,15 @@ impl<'gc> Value<'gc> { /// * In SWF5 and lower, hexadecimal is unsupported. fn primitive_as_number(&self, activation: &mut Activation<'_, 'gc, '_>) -> f64 { match self { - Value::Undefined if activation.current_swf_version() < 7 => 0.0, - Value::Null if activation.current_swf_version() < 7 => 0.0, + Value::Undefined if activation.swf_version() < 7 => 0.0, + Value::Null if activation.swf_version() < 7 => 0.0, Value::Undefined => f64::NAN, Value::Null => f64::NAN, Value::Bool(false) => 0.0, Value::Bool(true) => 1.0, Value::Number(v) => *v, Value::String(v) => match v.as_str() { - v if activation.current_swf_version() >= 6 && v.starts_with("0x") => { + v if activation.swf_version() >= 6 && v.starts_with("0x") => { let mut n: u32 = 0; for c in v[2..].bytes() { n = n.wrapping_shl(4); @@ -173,7 +173,7 @@ impl<'gc> Value<'gc> { } f64::from(n as i32) } - v if activation.current_swf_version() >= 6 + v if activation.swf_version() >= 6 && (v.starts_with('0') || v.starts_with("+0") || v.starts_with("-0")) && v[1..].bytes().all(|c| c >= b'0' && c <= b'7') => { @@ -441,7 +441,7 @@ impl<'gc> Value<'gc> { _ => "[type Object]".into(), }, Value::Undefined => { - if activation.current_swf_version() >= 7 { + if activation.swf_version() >= 7 { "undefined".into() } else { "".into() diff --git a/core/src/html/text_format.rs b/core/src/html/text_format.rs index b1004b6d5..c6e3869c4 100644 --- a/core/src/html/text_format.rs +++ b/core/src/html/text_format.rs @@ -166,7 +166,7 @@ fn getbool_from_avm1_object<'gc>( Ok(match object.get(name, activation)? { Avm1Value::Undefined => None, Avm1Value::Null => None, - v => Some(v.as_bool(activation.current_swf_version())), + v => Some(v.as_bool(activation.swf_version())), }) }