Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Store MovieClip avm2_class in MovieClipStatic #16433

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions core/src/display_object/movie_clip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ pub struct MovieClipData<'gc> {
frame_scripts: Vec<Option<Avm2Object<'gc>>>,
#[collect(require_static)]
flags: MovieClipFlags,
avm2_class: Option<Avm2ClassObject<'gc>>,
#[collect(require_static)]
drawing: Drawing,
avm2_enabled: bool,
Expand Down Expand Up @@ -209,7 +208,6 @@ impl<'gc> MovieClip<'gc> {
clip_event_flags: ClipEventFlag::empty(),
frame_scripts: Vec::new(),
flags: MovieClipFlags::empty(),
avm2_class: None,
drawing: Drawing::new(),
avm2_enabled: true,
avm2_use_hand_cursor: true,
Expand All @@ -234,7 +232,7 @@ impl<'gc> MovieClip<'gc> {
class: Avm2ClassObject<'gc>,
gc_context: &Mutation<'gc>,
) -> Self {
MovieClip(GcCell::new(
let clip = MovieClip(GcCell::new(
gc_context,
MovieClipData {
base: Default::default(),
Expand All @@ -251,7 +249,6 @@ impl<'gc> MovieClip<'gc> {
clip_event_flags: ClipEventFlag::empty(),
frame_scripts: Vec::new(),
flags: MovieClipFlags::empty(),
avm2_class: Some(class),
drawing: Drawing::new(),
avm2_enabled: true,
avm2_use_hand_cursor: true,
Expand All @@ -267,7 +264,9 @@ impl<'gc> MovieClip<'gc> {
queued_tags: HashMap::new(),
attached_audio: None,
},
))
));
clip.set_avm2_class(gc_context, Some(class));
clip
}

/// Constructs a non-root movie
Expand All @@ -294,7 +293,6 @@ impl<'gc> MovieClip<'gc> {
clip_event_flags: ClipEventFlag::empty(),
frame_scripts: Vec::new(),
flags: MovieClipFlags::PLAYING,
avm2_class: None,
drawing: Drawing::new(),
avm2_enabled: true,
avm2_use_hand_cursor: true,
Expand Down Expand Up @@ -362,7 +360,6 @@ impl<'gc> MovieClip<'gc> {
clip_event_flags: ClipEventFlag::empty(),
frame_scripts: Vec::new(),
flags: MovieClipFlags::PLAYING,
avm2_class: None,
drawing: Drawing::new(),
avm2_enabled: true,
avm2_use_hand_cursor: true,
Expand Down Expand Up @@ -1370,8 +1367,7 @@ impl<'gc> MovieClip<'gc> {
}

pub fn set_avm2_class(self, gc_context: &Mutation<'gc>, constr: Option<Avm2ClassObject<'gc>>) {
let mut write = self.0.write(gc_context);
write.avm2_class = constr;
*self.0.read().static_data.avm2_class.write(gc_context) = constr;
}

pub fn frame_label_to_number(
Expand Down Expand Up @@ -2192,7 +2188,9 @@ impl<'gc> MovieClip<'gc> {
let class_object = self
.0
.read()
.static_data
.avm2_class
.read()
.unwrap_or_else(|| context.avm2.classes().movieclip);

let mut constr_thing = || {
Expand Down Expand Up @@ -2222,7 +2220,9 @@ impl<'gc> MovieClip<'gc> {
let class_object = self
.0
.read()
.static_data
.avm2_class
.read()
.unwrap_or_else(|| context.avm2.classes().movieclip);

if let Avm2Value::Object(object) = self.object2() {
Expand Down Expand Up @@ -4611,6 +4611,7 @@ struct MovieClipStatic<'gc> {
/// The last known symbol name under which this movie clip was exported.
/// Used for looking up constructors registered with `Object.registerClass`.
exported_name: GcCell<'gc, Option<AvmString<'gc>>>,
avm2_class: GcCell<'gc, Option<Avm2ClassObject<'gc>>>,
Aaron1011 marked this conversation as resolved.
Show resolved Hide resolved
/// Only set if this MovieClip is the root movie in an SWF
/// (either the root SWF initially loaded by the player,
/// or an SWF dynamically loaded by `Loader`)
Expand Down Expand Up @@ -4657,6 +4658,7 @@ impl<'gc> MovieClipStatic<'gc> {
audio_stream_info: None,
audio_stream_handle: None,
exported_name: GcCell::new(gc_context, None),
avm2_class: GcCell::new(gc_context, None),
loader_info,
preload_progress: GcCell::new(gc_context, Default::default()),
processed_bytecode_tags_pos: GcCell::new(gc_context, -1),
Expand Down