diff --git a/CHANGELOG.md b/CHANGELOG.md index 04c4932d6..5d20eb688 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Fixed +- [#1869] Replace references now replaces all references, not just PlaceObject +- Handle StartSound tag as CharacterIdTag ## [16.3.1] - 2022-11-14 ### Fixed @@ -2443,7 +2446,8 @@ All notable changes to this project will be documented in this file. ### Added - Initial public release -[Unreleased]: https://github.com/jindrapetrik/jpexs-decompiler/compare/version16.3.0...dev +[Unreleased]: https://github.com/jindrapetrik/jpexs-decompiler/compare/version16.3.1...dev +[16.3.1]: https://github.com/jindrapetrik/jpexs-decompiler/compare/version16.3.0...version16.3.1 [16.3.0]: https://github.com/jindrapetrik/jpexs-decompiler/compare/version16.2.0...version16.3.0 [16.2.0]: https://github.com/jindrapetrik/jpexs-decompiler/compare/version16.1.0...version16.2.0 [16.1.0]: https://github.com/jindrapetrik/jpexs-decompiler/compare/version16.0.4...version16.1.0 @@ -2572,6 +2576,7 @@ All notable changes to this project will be documented in this file. [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 +[#1869]: https://www.free-decompiler.com/flash/issues/1869 [#1867]: https://www.free-decompiler.com/flash/issues/1867 [#1868]: https://www.free-decompiler.com/flash/issues/1868 [#1649]: https://www.free-decompiler.com/flash/issues/1649 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 b0036d3a7..17ed2c5bc 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 @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.tags.base.CharacterIdTag; import com.jpexs.decompiler.flash.types.BasicType; import com.jpexs.decompiler.flash.types.SOUNDINFO; import com.jpexs.decompiler.flash.types.annotations.SWFType; @@ -31,7 +32,7 @@ import java.io.IOException; * @author JPEXS */ @SWFVersion(from = 1) -public class StartSoundTag extends Tag { +public class StartSoundTag extends Tag implements CharacterIdTag { public static final int ID = 15; @@ -80,5 +81,15 @@ public class StartSoundTag extends Tag { public void getData(SWFOutputStream sos) throws IOException { sos.writeUI16(soundId); sos.writeSOUNDINFO(soundInfo); + } + + @Override + public int getCharacterId() { + return soundId; } + + @Override + public void setCharacterId(int characterId) { + soundId = characterId; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundFormat.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundFormat.java index 454c29d91..238930ad8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundFormat.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundFormat.java @@ -227,10 +227,16 @@ public class SoundFormat { int inPointBytes = inPoint * 2 /*16bit*/ * (stereo ? 2 : 1); int outPointBytes = soundInfo.hasOutPoint ? outPoint * 2 /*16bit*/ * (stereo ? 2 : 1) : data.length; for (int i = inPointBytes; i < outPointBytes; i += (stereo ? 4 : 2)) { + if (i + 1 >= data.length) { + break; + } int left = ((data[i] & 0xff) + ((data[i + 1] & 0xff) << 8)) << 16 >> 16; int right = left; if (stereo) { - right = ((data[i + 2] & 0xff) + ((data[i + 3] & 0xff) << 8)) << 16 >> 16; + if (i + 3 >= data.length) { + break; + } + right = ((data[i + 2] & 0xff) + ((data[i + 3] & 0xff) << 8)) << 16 >> 16; } if (soundInfo.hasEnvelope) { diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java index c29f39d0b..13d210a1b 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java @@ -1472,13 +1472,14 @@ public class TagTreeContextMenu extends JPopupMenu { for (Tag tag : swf.getTags()) { replaceRef(tag, characterId, newCharacterId); } - + swf.assignExportNamesToSymbols(); swf.assignClassesToSymbols(); swf.clearImageCache(); swf.updateCharacters(); swf.computeDependentCharacters(); swf.computeDependentFrames(); + swf.resetTimeline(); mainPanel.refreshTree(swf); } } @@ -1489,19 +1490,19 @@ public class TagTreeContextMenu extends JPopupMenu { for (Tag subTag : sprite.getTags()) { replaceRef(subTag, characterId, newCharacterId); } + sprite.resetTimeline(); sprite.clearReadOnlyListCache(); + return; } - if (tag instanceof PlaceObjectTypeTag) { - PlaceObjectTypeTag placeTag = (PlaceObjectTypeTag) tag; - if (placeTag.getCharacterId() == characterId) { - placeTag.setCharacterId(newCharacterId); - placeTag.setModified(true); - Timelined tim = placeTag.getTimelined(); - if (tim != null) { - tim.resetTimeline(); - } - } + + if ((tag instanceof CharacterIdTag) && !(tag instanceof CharacterTag)) { + CharacterIdTag charIdTag = (CharacterIdTag) tag; + if (charIdTag.getCharacterId() == characterId) { + charIdTag.setCharacterId(newCharacterId); + tag.setModified(true); + } } + tag.replaceCharacter(characterId, newCharacterId); } private void rawEditActionPerformed(ActionEvent evt) {