From ec0d890fd23bfa09a94cd1bd0e906c5b31d0b950 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Wed, 3 Mar 2021 18:00:55 +0100 Subject: [PATCH] Fixed: Flash viewer- cyclic DefineSprite usage --- CHANGELOG.md | 1 + .../decompiler/flash/timeline/Timeline.java | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab94bf09a..07ed16187 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ All notable changes to this project will be documented in this file. - Copying to clipboard does not support transparency - #1634 AS3 slot/const editor loses focus on edit button press - #1636 Exception after search - traitslist with not properly set abc, other ui exception +- Flash viewer- cyclic DefineSprite usage ### Removed - #1631 ActiveX Flash component download in windows installer diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java index f65b007df..a656b32cf 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java @@ -306,6 +306,13 @@ public class Timeline { if (characterId != -1) { fl.characterId = characterId; } + CharacterTag character = swf.getCharacter(characterId); + if (character instanceof DefineSpriteTag) { + Stack cyStack = new Stack<>(); + if (isCyclic(timelined, cyStack)) { + fl.characterId = -1; + } + } if (po.flagMove()) { MATRIX matrix2 = po.getMatrix(); if (matrix2 != null) { @@ -1215,4 +1222,28 @@ public class Timeline { return false; } + + private boolean isCyclic(Timelined tim, Stack walked) { + for (Tag t : tim.getTags()) { + if (t instanceof PlaceObjectTypeTag) { + PlaceObjectTypeTag p = (PlaceObjectTypeTag) t; + int chid = p.getCharacterId(); + if (chid != -1) { + if (walked.contains(chid)) { + return true; + } + CharacterTag character = swf.getCharacter(chid); + if (character instanceof DefineSpriteTag) { + walked.push(chid); + if (isCyclic((DefineSpriteTag) character, walked)) { + walked.pop(); + return true; + } + walked.pop(); + } + } + } + } + return false; + } }