avm2: Remove old hack now that DOs use an instance allocator

This commit is contained in:
Lord-McSweeney 2023-07-07 13:14:14 -07:00 committed by Adrian Wielgosik
parent e9f4a92073
commit 5337975cba
2 changed files with 3 additions and 26 deletions

View File

@ -3,7 +3,6 @@
use crate::avm2::activation::Activation;
use crate::avm2::error::argument_error;
use crate::avm2::error::range_error;
use crate::avm2::globals::flash::display::sprite::init_empty_sprite;
use crate::avm2::object::{Object, TObject};
use crate::avm2::parameters::ParametersExt;
use crate::avm2::value::Value;
@ -174,18 +173,11 @@ pub fn add_child<'gc>(
) -> Result<Value<'gc>, Error<'gc>> {
if let Some(parent) = this.as_display_object() {
if let Some(ctr) = parent.as_container() {
let child = args.get_object(activation, 0, "child")?;
if child.as_display_object().is_none() {
let sprite = activation.avm2().classes().sprite.inner_class_definition();
if child.is_of_type(sprite, &mut activation.context) {
// [NA] Hack to make Haxe work - they call addChild before super()
// This will create an empty sprite the same way sprite's constructor will.
init_empty_sprite(activation, child)?;
}
}
let child = child
let child = args
.get_object(activation, 0, "child")?
.as_display_object()
.ok_or("ArgumentError: Child not a valid display object")?;
let target_index = ctr.num_children();
validate_add_operation(activation, parent, child, target_index)?;

View File

@ -44,21 +44,6 @@ pub fn sprite_allocator<'gc>(
unreachable!("A Sprite subclass should have Sprite in superclass chain");
}
pub fn init_empty_sprite<'gc>(
activation: &mut Activation<'_, 'gc>,
this: Object<'gc>,
) -> Result<(), Error<'gc>> {
let class_object = this
.instance_of()
.ok_or("Attempted to construct Sprite on a bare object")?;
let movie = activation.context.swf.clone();
let new_do = MovieClip::new_with_avm2(movie, this, class_object, activation.context.gc_context);
this.init_display_object(&mut activation.context, new_do.into());
Ok(())
}
/// Implements `dropTarget`'s getter
pub fn get_drop_target<'gc>(
_activation: &mut Activation<'_, 'gc>,