Skip to content

Commit b33e449

Browse files
kjaroshtorokati44
authored andcommitted
core: Move rewind-related logic to survives_rewind
1 parent cc33a6a commit b33e449

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

core/src/display_object/movie_clip.rs

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,22 +1569,7 @@ impl<'gc> MovieClip<'gc> {
15691569

15701570
let children: SmallVec<[_; 16]> = self
15711571
.iter_render_list()
1572-
.filter(|child| {
1573-
let is_candidate_for_removal = if self.movie().is_action_script_3() {
1574-
child.place_frame() > frame || child.placed_by_script()
1575-
} else {
1576-
child.depth() < AVM_DEPTH_BIAS
1577-
};
1578-
1579-
if !is_candidate_for_removal && child.as_morph_shape().is_none() {
1580-
return false;
1581-
}
1582-
if let Some(final_placement) = final_placements.get(&child.depth()) {
1583-
!self.survives_rewind(*child, &final_placement.place_object)
1584-
} else {
1585-
true
1586-
}
1587-
})
1572+
.filter(|child| !self.survives_rewind(*child, &final_placements, frame))
15881573
.collect();
15891574

15901575
for child in children {
@@ -1711,22 +1696,44 @@ impl<'gc> MovieClip<'gc> {
17111696
self.assert_expected_tag_end(hit_target_frame);
17121697
}
17131698

1714-
fn survives_rewind(self, old_object: DisplayObject<'_>, new_params: &swf::PlaceObject) -> bool {
1699+
fn survives_rewind(
1700+
self,
1701+
old_object: DisplayObject<'_>,
1702+
final_placements: &HashMap<Depth, &GotoPlaceObject<'_>>,
1703+
frame: FrameNumber,
1704+
) -> bool {
17151705
// TODO [KJ] This logic is not 100% tested. It's possible it's a bit
17161706
// different in reality, but the spirit is there :)
17171707

1708+
let is_candidate_for_removal = if self.movie().is_action_script_3() {
1709+
old_object.place_frame() > frame || old_object.placed_by_script()
1710+
} else {
1711+
old_object.depth() < AVM_DEPTH_BIAS
1712+
};
1713+
1714+
if !is_candidate_for_removal && old_object.as_morph_shape().is_none() {
1715+
return true;
1716+
}
1717+
let Some(final_placement) = final_placements.get(&old_object.depth()) else {
1718+
return false;
1719+
};
1720+
1721+
let new_params = &final_placement.place_object;
1722+
17181723
if !old_object.movie().is_action_script_3()
17191724
&& old_object.placed_by_avm1_script()
17201725
&& old_object.depth() < AVM_DEPTH_BIAS
17211726
{
17221727
return false;
17231728
}
1729+
17241730
let id_equals = match new_params.action {
17251731
swf::PlaceObjectAction::Place(id) | swf::PlaceObjectAction::Replace(id) => {
17261732
old_object.id() == id
17271733
}
17281734
_ => false,
17291735
};
1736+
17301737
let ratio_equals = match new_params.ratio {
17311738
Some(ratio) => old_object.ratio() == ratio,
17321739
None => true,

0 commit comments

Comments
 (0)