From 777716f1b9961e2d33d83e575aa7f1024f088177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Mon, 12 Aug 2024 22:20:30 +0200 Subject: [PATCH] Fixed: #2266 StartSound/2 and VideoFrame tags, classNames not taken as dependencies (needed chars) --- CHANGELOG.md | 3 +++ .../decompiler/flash/tags/DefineSpriteTag.java | 16 +++++++++------- .../decompiler/flash/tags/PlaceObject3Tag.java | 6 ++++++ .../decompiler/flash/tags/PlaceObject4Tag.java | 6 ++++++ .../decompiler/flash/tags/StartSound2Tag.java | 7 +++++++ .../decompiler/flash/tags/StartSoundTag.java | 6 ++++++ 6 files changed, 37 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bf04a766..b958c8e5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Fixed +- [#2266] StartSound/2 and VideoFrame tags, classNames not taken as dependencies (needed chars) ## [21.0.2] - 2024-08-12 ### Added @@ -3495,6 +3497,7 @@ Major version of SWF to XML export changed to 2. [alpha 9]: https://github.com/jindrapetrik/jpexs-decompiler/compare/alpha8...alpha9 [alpha 8]: https://github.com/jindrapetrik/jpexs-decompiler/compare/alpha7...alpha8 [alpha 7]: https://github.com/jindrapetrik/jpexs-decompiler/releases/tag/alpha7 +[#2266]: https://www.free-decompiler.com/flash/issues/2266 [#2269]: https://www.free-decompiler.com/flash/issues/2269 [#2270]: https://www.free-decompiler.com/flash/issues/2270 [#2221]: https://www.free-decompiler.com/flash/issues/2221 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java index 703eb8a02..deeb2b0df 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java @@ -373,13 +373,15 @@ public class DefineSpriteTag extends DrawableTag implements Timelined { @Override public void getNeededCharacters(Set needed, SWF swf) { - for (Tag t : getTags()) { - if (t instanceof PlaceObjectTypeTag) { - int chId = ((PlaceObjectTypeTag) t).getCharacterId(); - if (chId != -1) { - needed.add(chId); - } - } + for (Tag t : getTags()) { + if ( + (t instanceof PlaceObjectTypeTag) + || (t instanceof StartSoundTag) + || (t instanceof StartSound2Tag) + || (t instanceof VideoFrameTag) + ) { + t.getNeededCharacters(needed, swf); + } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java index a91bb5d4b..9e664b34a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java @@ -482,6 +482,12 @@ public class PlaceObject3Tag extends PlaceObjectTypeTag implements ASMSourceCont if (placeFlagHasCharacter) { needed.add(characterId); } + if (placeFlagHasClassName) { + int chId = swf.getCharacterId(swf.getCharacterByClass(className)); + if (chId != -1) { + needed.add(chId); + } + } } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java index ce6c0d312..06a8349a2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java @@ -503,6 +503,12 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont if (placeFlagHasCharacter) { needed.add(characterId); } + if (placeFlagHasClassName) { + int chId = swf.getCharacterId(swf.getCharacterByClass(className)); + if (chId != -1) { + needed.add(chId); + } + } } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/StartSound2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/StartSound2Tag.java index 882929aa3..cc94a8ec2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/StartSound2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/StartSound2Tag.java @@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.types.annotations.SWFVersion; import com.jpexs.helpers.ByteArrayRange; import java.io.IOException; import java.util.Map; +import java.util.Set; /** * StartSound2 tag - starts a sound playing. Extends functionality of StartSound @@ -89,4 +90,10 @@ public class StartSound2Tag extends Tag { ret.put("cls", "" + soundClassName); return ret; } + + @Override + public void getNeededCharacters(Set needed, SWF swf) { + int characterId = swf.getCharacterId(swf.getCharacterByClass(soundClassName)); + needed.add(characterId); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/StartSoundTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/StartSoundTag.java index 8924cdae4..99802a2d3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/StartSoundTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/StartSoundTag.java @@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.types.annotations.SWFVersion; import com.jpexs.helpers.ByteArrayRange; import java.io.IOException; import java.util.Map; +import java.util.Set; /** * StartSound tag - starts a sound playing. @@ -101,4 +102,9 @@ public class StartSoundTag extends Tag implements CharacterIdTag { ret.put("cid", "" + soundId); return ret; } + + @Override + public void getNeededCharacters(Set needed, SWF swf) { + needed.add(soundId); + } }