From 30416adf58be6391ac6dec8645831a8a303c61c0 Mon Sep 17 00:00:00 2001 From: Lord-McSweeney Date: Sat, 2 Dec 2023 11:33:42 -0800 Subject: [PATCH] core: More mixed AVM fixes, improve test This commit breaks mixed AVM without #13889. --- core/src/display_object/container.rs | 11 +++++++---- core/src/loader.rs | 9 +++++++-- tests/tests/swfs/avm2/mixed_avm/avm1.swf | Bin 137 -> 269 bytes tests/tests/swfs/avm2/mixed_avm/output.txt | 6 ++++++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/core/src/display_object/container.rs b/core/src/display_object/container.rs index 7c152937ef8b..03b58c950235 100644 --- a/core/src/display_object/container.rs +++ b/core/src/display_object/container.rs @@ -381,15 +381,18 @@ pub trait TDisplayObjectContainer<'gc>: /// Insert a child directly into this container's depth list. fn insert_child_into_depth_list( &mut self, - gc_context: &Mutation<'gc>, + context: &mut UpdateContext<'_, 'gc>, depth: Depth, child: DisplayObject<'gc>, ) { - self.raw_container_mut(gc_context) + let this: DisplayObject<'_> = (*self).into(); + + child.set_depth(context.gc_context, depth); + child.set_parent(context, Some(this)); + self.raw_container_mut(context.gc_context) .insert_child_into_depth_list(depth, child); - let this: DisplayObject<'_> = (*self).into(); - this.invalidate_cached_bitmap(gc_context); + this.invalidate_cached_bitmap(context.gc_context); } /// Removes (without unloading) a child display object from this container's depth list. diff --git a/core/src/loader.rs b/core/src/loader.rs index da79051d692d..6dab6934fac7 100644 --- a/core/src/loader.rs +++ b/core/src/loader.rs @@ -42,6 +42,9 @@ use url::{form_urlencoded, ParseError, Url}; pub type Handle = Index; +/// The depth of AVM1 movies that AVM2 loads. +const LOADER_INSERTED_AVM1_DEPTH: i32 = -0xF000; + /// How Ruffle should load movies. #[cfg_attr(feature = "clap", derive(clap::ValueEnum))] #[derive(Debug, Clone, Copy, PartialEq)] @@ -1730,6 +1733,8 @@ impl<'gc> Loader<'gc> { { // When an AVM2 movie loads an AVM1 movie, we need to call `post_instantiation` here. mc.post_instantiation(uc, None, Instantiator::Movie, false); + + mc.set_depth(uc.gc_context, LOADER_INSERTED_AVM1_DEPTH); } } @@ -2007,8 +2012,8 @@ impl<'gc> Loader<'gc> { if !movie.unwrap().is_action_script_3() { loader.insert_child_into_depth_list( - activation.context.gc_context, - 0, + &mut activation.context, + LOADER_INSERTED_AVM1_DEPTH, dobj.unwrap(), ); } diff --git a/tests/tests/swfs/avm2/mixed_avm/avm1.swf b/tests/tests/swfs/avm2/mixed_avm/avm1.swf index 373d6d365b1cea833faea3b4a1f7bcbdc2ea0244..ca42f8796d1f26d93638c1c00566d578f347cedd 100644 GIT binary patch literal 269 zcmV+o0rLJsS5py;0RRAaoL!DRPQySDg`e##NdST9D2y~|Tv0$9DFTFrm4e0>u#B@L zmeyVrFCmBv4Uqw-U%l`)%8P4?TuFt@yTX*Z9@Ad|mRcK{$rrO2BV&WPG%dZ7z` zv=!*{T6RIm+Djwc1V8p~^MPY5q*9umm%5^SRb7ve?&j0~1-gFJuZ@iLTWz^wo>`{c z*wVH0xU~4*;i&7U$%HZ`S5jT^$d2}p-9OTIM+Rx)QoT>X334gHau6mQ`c4O(879#M T$HU!#qi~u;xV62%CdOS%U0H&$ literal 137 zcmV;40CxXFS5pzD0001ZoU349jb~usU%8i-_^%?h$Y0W8D>BA8{|K@