From c16c2fd4b5171bff28515f56558eb0ad9e9293a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Wed, 15 Feb 2023 11:12:10 +0100 Subject: [PATCH] Fixed #1973 FLA export - improper calculation of shape instance count --- CHANGELOG.md | 2 + .../decompiler/flash/xfl/XFLConverter.java | 40 ++++++++++++------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2fb3e662..2b495b375 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file. - [#1972] AS3 Renaming invalid identifiers - various fixes - [#1972] AS3 imports taken only from packages, not package internal - Unresponsive status bar and its icon +- [#1973] FLA export - improper calculation of shape instance count ## [18.3.5] - 2023-02-12 ### Added @@ -2958,6 +2959,7 @@ All notable changes to this project will be documented in this file. [alpha 7]: https://github.com/jindrapetrik/jpexs-decompiler/releases/tag/alpha7 [#1970]: https://www.free-decompiler.com/flash/issues/1970 [#1972]: https://www.free-decompiler.com/flash/issues/1972 +[#1973]: https://www.free-decompiler.com/flash/issues/1973 [#1959]: https://www.free-decompiler.com/flash/issues/1959 [#1960]: https://www.free-decompiler.com/flash/issues/1960 [#1964]: https://www.free-decompiler.com/flash/issues/1964 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 8df2d7630..6e3622975 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 @@ -1035,36 +1035,48 @@ public class XFLConverter { } private static void walkShapeUsages(ReadOnlyTagList timeLineTags, HashMap characters, HashMap usages) { + Map depthMap = 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()); + } if (t instanceof PlaceObjectTypeTag) { PlaceObjectTypeTag po = (PlaceObjectTypeTag) t; - int ch = po.getCharacterId(); - if (ch > -1) { + int d = po.getDepth(); + if (po.flagMove() || !depthMap.containsKey(d)) { + int ch = po.getCharacterId(); + if (ch == -1) { + if (depthMap.containsKey(d)) { + ch = depthMap.get(d); + } + } else { + depthMap.put(d, ch); + } + if (ch == -1) { + continue; + } + if (!usages.containsKey(ch)) { usages.put(ch, 0); } int usageCount = usages.get(ch); + usageCount++; if (po.getInstanceName() != null) { usageCount++; - } - if (po.getColorTransform() != null) { + } else if (po.getColorTransform() != null) { + usageCount++; + } else if (po.cacheAsBitmap()) { + usageCount++; + } else if (po.getMatrix() != null && !po.getMatrix().isEmpty()){ usageCount++; } - if (po.cacheAsBitmap()) { - usageCount++; - } - MATRIX mat = po.getMatrix(); - if (mat != null) { - if (!mat.isEmpty()) { - usageCount++; - } - } - usages.put(ch, usageCount + 1); + usages.put(ch, usageCount); } + } } }