avm2: Movie clips not explicitly granted a `symbol_class` should be constructed using the `MovieClip` class directly

This commit is contained in:
David Wendt 2020-10-05 21:21:13 -04:00 committed by Mike Welsh
parent 12cf8022cd
commit ef665acaec
2 changed files with 16 additions and 4 deletions

View File

@ -54,6 +54,7 @@ pub struct SystemPrototypes<'gc> {
pub uint: Object<'gc>,
pub namespace: Object<'gc>,
pub array: Object<'gc>,
pub movieclip: Object<'gc>,
pub framelabel: Object<'gc>,
pub scene: Object<'gc>,
}
@ -83,6 +84,7 @@ impl<'gc> SystemPrototypes<'gc> {
uint: empty,
namespace: empty,
array: empty,
movieclip: empty,
framelabel: empty,
scene: empty,
}
@ -384,7 +386,13 @@ pub fn load_player_globals<'gc>(activation: &mut Activation<'_, 'gc, '_>) -> Res
flash::display::sprite::create_class(activation.context.gc_context),
implicit_deriver,
)?;
class(
activation
.context
.avm2
.system_prototypes
.as_mut()
.unwrap()
.movieclip = class(
activation,
gs,
flash::display::movieclip::create_class(activation.context.gc_context),

View File

@ -1497,8 +1497,12 @@ impl<'gc> MovieClip<'gc> {
context: &mut UpdateContext<'_, 'gc, '_>,
display_object: DisplayObject<'gc>,
) {
let constructor = self.0.read().avm_constructor;
if let Some(AvmObject::Avm2(mut constr)) = constructor {
let constructor = self
.0
.read()
.avm_constructor
.unwrap_or_else(|| context.avm2.prototypes().movieclip.into());
if let AvmObject::Avm2(mut constr) = constructor {
let mut constr_thing = || {
let mut activation = Avm2Activation::from_nothing(context.reborrow());
let proto = constr
@ -1527,7 +1531,7 @@ impl<'gc> MovieClip<'gc> {
log::error!("Got {} when constructing AVM2 side of display object", e);
}
} else {
log::error!("Attempted to construct AVM2 movieclip without constructor!");
log::error!("Attempted to construct AVM2 movieclip with AVM1 constructor!");
}
}