From 9e02ee6d3015f63d795c1e0db689db90d6986e32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 23 Dec 2023 16:00:40 +0100 Subject: [PATCH] Fixed #2152 FLA Export - wrong nonlibrary shapes detection --- CHANGELOG.md | 2 + .../decompiler/flash/xfl/XFLConverter.java | 40 +++++++++++++++---- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f50672d73..17aa70749 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -88,6 +88,7 @@ All notable changes to this project will be documented in this file. - AS3 - extra newlines on methods which use activation - [#2162] AS3 switch inside foreach - [#2162] AS3 try inside foreach +- [#2152] FLA Export - wrong nonlibrary shapes detection ### Changed - [#2120] Exported assets no longer take names from assigned classes if there is more than 1 assigned class @@ -3371,6 +3372,7 @@ Major version of SWF to XML export changed to 2. [#2153]: https://www.free-decompiler.com/flash/issues/2153 [#2163]: https://www.free-decompiler.com/flash/issues/2163 [#2162]: https://www.free-decompiler.com/flash/issues/2162 +[#2152]: https://www.free-decompiler.com/flash/issues/2152 [#2120]: https://www.free-decompiler.com/flash/issues/2120 [#1130]: https://www.free-decompiler.com/flash/issues/1130 [#1220]: https://www.free-decompiler.com/flash/issues/1220 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index 23ebfd0c0..32c5bfdcb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -1153,18 +1153,45 @@ public class XFLConverter { private static void walkShapeUsages(ReadOnlyTagList timeLineTags, HashMap characters, HashMap usages) { Map depthMap = new HashMap<>(); + Map depthHasInstanceName = new HashMap<>(); + Map depthHasColorTransform = new HashMap<>(); + Map depthCacheAsBitmap = new HashMap<>(); + Map depthHasNonemptyMatrix = new HashMap<>(); for (Tag t : timeLineTags) { if (t instanceof DefineSpriteTag) { DefineSpriteTag sprite = (DefineSpriteTag) t; walkShapeUsages(sprite.getTags(), characters, usages); } if (t instanceof RemoveTag) { - depthMap.remove(((RemoveTag) t).getDepth()); + int d = ((RemoveTag) t).getDepth(); + depthMap.remove(d); + depthHasInstanceName.remove(d); + depthHasColorTransform.remove(d); + depthCacheAsBitmap.remove(d); + depthHasNonemptyMatrix.remove(d); } - if (t instanceof PlaceObjectTypeTag) { + if (t instanceof PlaceObjectTypeTag) { PlaceObjectTypeTag po = (PlaceObjectTypeTag) t; int d = po.getDepth(); + if (po.flagMove() || !depthMap.containsKey(d)) { + if (!po.flagMove()) { + depthHasInstanceName.put(d, false); + depthHasColorTransform.put(d, false); + depthCacheAsBitmap.put(d, false); + depthHasNonemptyMatrix.put(d, false); + } + + if (po.getInstanceName() != null) { + depthHasInstanceName.put(d, true); + } else if (po.getColorTransform() != null) { + depthHasColorTransform.put(d, true); + } else if (po.cacheAsBitmap()) { + depthCacheAsBitmap.put(d, true); + } else if (po.getMatrix() != null && !po.getMatrix().isEmpty()) { + depthHasNonemptyMatrix.put(d, true); + } + int ch = po.getCharacterId(); if (ch == -1) { if (depthMap.containsKey(d)) { @@ -1182,18 +1209,17 @@ public class XFLConverter { } int usageCount = usages.get(ch); usageCount++; - if (po.getInstanceName() != null) { + if (depthHasInstanceName.get(d)) { usageCount++; - } else if (po.getColorTransform() != null) { + } else if (depthHasColorTransform.get(d)) { usageCount++; - } else if (po.cacheAsBitmap()) { + } else if (depthCacheAsBitmap.get(d)) { usageCount++; - } else if (po.getMatrix() != null && !po.getMatrix().isEmpty()) { + } else if (depthHasNonemptyMatrix.get(d)) { usageCount++; } usages.put(ch, usageCount); } - } } }