Added: FreeCharacter tag support, SyncFrame tag support

This commit is contained in:
Jindra Petřík
2025-08-29 09:53:41 +02:00
parent 1e9bf6be88
commit 1316c1e58b
19 changed files with 90 additions and 34 deletions

View File

@@ -32,6 +32,8 @@ All notable changes to this project will be documented in this file.
(CharacterSet, GenCommand, NameCharacter, DefineTextFormat, FontRef)
- DefineVideo tag support (Flash 4)
- SerialNumber tag support (before Flash 7)
- FreeCharacter tag support
- SyncFrame tag support
### Fixed
- [#2474] Gotos incorrectly decompiled

View File

@@ -16,9 +16,11 @@
*/
package com.jpexs.decompiler.flash;
import com.jpexs.decompiler.flash.tags.FreeCharacterTag;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.VideoFrameTag;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.CharacterModifier;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
import com.jpexs.decompiler.flash.tags.base.RemoveTag;
@@ -64,11 +66,8 @@ public class DefineBeforeUsageFixer {
int i = 0;
for (int j = 0; j < swf.getTags().size(); j++) {
Tag t2 = swf.getTags().get(j);
if ((t2 instanceof CharacterIdTag)
&& !(t2 instanceof PlaceObjectTypeTag)
&& !(t2 instanceof RemoveTag)
&& !(t2 instanceof VideoFrameTag)) {
CharacterIdTag chit = (CharacterIdTag) t2;
if (t2 instanceof CharacterModifier) {
CharacterModifier chit = (CharacterModifier) t2;
if (chit.getCharacterId() == characterId) {
swf.removeTag(j);
swf.addTag(usageIndex + i, (Tag) chit);

View File

@@ -19,7 +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.tags.base.CharacterModifier;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.CXFORM;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
@@ -35,7 +35,7 @@ import java.util.Set;
* @author JPEXS
*/
@SWFVersion(from = 2)
public class DefineButtonCxformTag extends Tag implements CharacterIdTag {
public class DefineButtonCxformTag extends Tag implements CharacterModifier {
public static final int ID = 23;

View File

@@ -19,7 +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.tags.base.CharacterModifier;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.SOUNDINFO;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
@@ -35,7 +35,7 @@ import java.util.Set;
* @author JPEXS
*/
@SWFVersion(from = 2)
public class DefineButtonSoundTag extends Tag implements CharacterIdTag {
public class DefineButtonSoundTag extends Tag implements CharacterModifier {
public static final int ID = 17;

View File

@@ -19,7 +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.tags.base.CharacterModifier;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.ZONERECORD;
import com.jpexs.decompiler.flash.types.annotations.EnumValue;
@@ -40,7 +40,7 @@ import java.util.Set;
* @author JPEXS
*/
@SWFVersion(from = 8)
public class DefineFontAlignZonesTag extends Tag implements CharacterIdTag {
public class DefineFontAlignZonesTag extends Tag implements CharacterModifier {
public static final int ID = 73;

View File

@@ -19,7 +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.tags.base.CharacterModifier;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.annotations.SWFVersion;
@@ -34,7 +34,7 @@ import java.util.Set;
* @author JPEXS
*/
@SWFVersion(from = 9)
public class DefineFontNameTag extends Tag implements CharacterIdTag {
public class DefineFontNameTag extends Tag implements CharacterModifier {
public static final int ID = 88;

View File

@@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle;
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
import com.jpexs.decompiler.flash.exporters.commonshape.Point;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.CharacterModifier;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
import com.jpexs.decompiler.flash.tags.base.RenderContext;
@@ -46,7 +46,7 @@ import java.util.Set;
* @author JPEXS
*/
@SWFVersion(from = 8)
public class DefineScalingGridTag extends Tag implements CharacterIdTag {
public class DefineScalingGridTag extends Tag implements CharacterModifier {
public static final int ID = 78;

View File

@@ -19,7 +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.tags.base.CharacterModifier;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.RECT;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
@@ -36,7 +36,7 @@ import java.util.List;
* @author JPEXS
*/
@SWFVersion(from = 3)
public class DefineTextFormatTag extends Tag implements CharacterIdTag {
public class DefineTextFormatTag extends Tag implements CharacterModifier {
public static final int ID = 42;

View File

@@ -24,7 +24,7 @@ import com.jpexs.helpers.ByteArrayRange;
import java.io.IOException;
/**
* FreeAll tag - undocumented.
* FreeAll tag - undocumented. Seems to do nothing.
*
* @author JPEXS
*/

View File

@@ -25,10 +25,11 @@ import com.jpexs.decompiler.flash.types.annotations.SWFType;
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;
/**
* FreeCharacter tag - undocumented.
* FreeCharacter tag - undocumented. Frees a character.
*
* @author JPEXS
*/
@@ -89,4 +90,13 @@ public class FreeCharacterTag extends Tag implements CharacterIdTag {
public void getNeededCharacters(Set<Integer> needed, SWF swf) {
needed.add(characterId);
}
@Override
public Map<String, String> getNameProperties() {
Map<String, String> ret = super.getNameProperties();
ret.put("chid", "" + characterId);
return ret;
}
}

View File

@@ -19,7 +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.tags.base.CharacterModifier;
import com.jpexs.decompiler.flash.types.BasicType;
import com.jpexs.decompiler.flash.types.annotations.SWFType;
import com.jpexs.decompiler.flash.types.annotations.SWFVersion;
@@ -34,7 +34,7 @@ import java.util.Set;
* @author JPEXS
*/
@SWFVersion(from = 3)
public class NameCharacterTag extends Tag implements CharacterIdTag {
public class NameCharacterTag extends Tag implements CharacterModifier {
public static final int ID = 40;

View File

@@ -53,6 +53,8 @@ public class ShowFrameTag extends Tag {
add(SoundStreamBlockTag.ID);
add(SetTabIndexTag.ID);
add(GenCommandTag.ID);
add(FreeCharacterTag.ID);
add(SyncFrameTag.ID);
/*add(SoundStreamHeadTag.ID);
add(SoundStreamHead2Tag.ID);*/
}

View File

@@ -413,6 +413,10 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable {
addTagInfo(map, map2, NameCharacterTag.ID, NameCharacterTag.class, NameCharacterTag.NAME);
addTagInfo(map, map2, CharacterSetTag.ID, CharacterSetTag.class, CharacterSetTag.NAME);
addTagInfo(map, map2, SerialNumberTag.ID, SerialNumberTag.class, SerialNumberTag.NAME);
addTagInfo(map, map2, FreeCharacterTag.ID, FreeCharacterTag.class, FreeCharacterTag.NAME);
addTagInfo(map, map2, SyncFrameTag.ID, SyncFrameTag.class, SyncFrameTag.NAME);
knownTagInfosById = map;
knownTagInfosByName = map2;
}

View File

@@ -0,0 +1,25 @@
/*
* Copyright (C) 2010-2025 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.tags.base;
/**
* A CharacterIdTag that modifies the character somehow
* @author JPEXS
*/
public interface CharacterModifier extends CharacterIdTag {
}

View File

@@ -29,7 +29,7 @@ import java.util.Map;
*
* @author JPEXS
*/
public abstract class FontInfoTag extends Tag implements CharacterIdTag {
public abstract class FontInfoTag extends Tag implements CharacterModifier {
/**
* Font ID

View File

@@ -54,7 +54,6 @@ import com.jpexs.decompiler.flash.tags.DefineSceneAndFrameLabelDataTag;
import com.jpexs.decompiler.flash.tags.DefineSoundTag;
import com.jpexs.decompiler.flash.tags.DefineSpriteTag;
import com.jpexs.decompiler.flash.tags.DefineTextFormatTag;
import com.jpexs.decompiler.flash.tags.DefineTextTag;
import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag;
import com.jpexs.decompiler.flash.tags.DoActionTag;
import com.jpexs.decompiler.flash.tags.DoInitActionTag;
@@ -65,6 +64,8 @@ import com.jpexs.decompiler.flash.tags.EndTag;
import com.jpexs.decompiler.flash.tags.ExportAssetsTag;
import com.jpexs.decompiler.flash.tags.FileAttributesTag;
import com.jpexs.decompiler.flash.tags.FrameLabelTag;
import com.jpexs.decompiler.flash.tags.FreeCharacterTag;
import com.jpexs.decompiler.flash.tags.GenCommandTag;
import com.jpexs.decompiler.flash.tags.ImportAssets2Tag;
import com.jpexs.decompiler.flash.tags.ImportAssetsTag;
import com.jpexs.decompiler.flash.tags.JPEGTablesTag;
@@ -89,6 +90,7 @@ import com.jpexs.decompiler.flash.tags.SoundStreamHeadTag;
import com.jpexs.decompiler.flash.tags.StartSound2Tag;
import com.jpexs.decompiler.flash.tags.StartSoundTag;
import com.jpexs.decompiler.flash.tags.SymbolClassTag;
import com.jpexs.decompiler.flash.tags.SyncFrameTag;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.TagStub;
import com.jpexs.decompiler.flash.tags.UnknownTag;
@@ -105,7 +107,6 @@ import com.jpexs.decompiler.flash.tags.base.RemoveTag;
import com.jpexs.decompiler.flash.tags.base.ShapeTag;
import com.jpexs.decompiler.flash.tags.base.SoundStreamHeadTypeTag;
import com.jpexs.decompiler.flash.tags.base.StaticTextTag;
import com.jpexs.decompiler.flash.tags.base.SymbolClassTypeTag;
import com.jpexs.decompiler.flash.tags.base.TextTag;
import com.jpexs.decompiler.flash.tags.gfx.DefineCompactedFont;
import com.jpexs.decompiler.flash.tags.gfx.DefineExternalSound;
@@ -877,7 +878,10 @@ public abstract class AbstractTagTree extends JTree {
RemoveObjectTag.ID, RemoveObject2Tag.ID, ShowFrameTag.ID, FrameLabelTag.ID,
StartSoundTag.ID, StartSound2Tag.ID, VideoFrameTag.ID,
SoundStreamBlockTag.ID, SoundStreamHeadTag.ID, SoundStreamHead2Tag.ID,
SetTabIndexTag.ID, PlaceImagePrivateTag.ID
SetTabIndexTag.ID, PlaceImagePrivateTag.ID,
GenCommandTag.ID,
FreeCharacterTag.ID,
SyncFrameTag.ID
);
}

View File

@@ -66,6 +66,7 @@ import com.jpexs.decompiler.flash.tags.ExportAssetsTag;
import com.jpexs.decompiler.flash.tags.FileAttributesTag;
import com.jpexs.decompiler.flash.tags.FontRefTag;
import com.jpexs.decompiler.flash.tags.FrameLabelTag;
import com.jpexs.decompiler.flash.tags.FreeCharacterTag;
import com.jpexs.decompiler.flash.tags.GenCommandTag;
import com.jpexs.decompiler.flash.tags.ImportAssets2Tag;
import com.jpexs.decompiler.flash.tags.ImportAssetsTag;
@@ -92,6 +93,7 @@ import com.jpexs.decompiler.flash.tags.SoundStreamHeadTag;
import com.jpexs.decompiler.flash.tags.StartSound2Tag;
import com.jpexs.decompiler.flash.tags.StartSoundTag;
import com.jpexs.decompiler.flash.tags.SymbolClassTag;
import com.jpexs.decompiler.flash.tags.SyncFrameTag;
import com.jpexs.decompiler.flash.tags.VideoFrameTag;
import com.jpexs.decompiler.flash.tags.gfx.DefineCompactedFont;
import com.jpexs.decompiler.flash.tags.gfx.DefineExternalGradient;
@@ -207,6 +209,9 @@ public class TagIdClassMap {
addTag(NameCharacterTag.ID, NameCharacterTag.class);
addTag(CharacterSetTag.ID, CharacterSetTag.class);
addTag(SerialNumberTag.ID, SerialNumberTag.class);
addTag(FreeCharacterTag.ID, FreeCharacterTag.class);
addTag(SyncFrameTag.ID, SyncFrameTag.class);
}
private static void addTag(int tagId, Class<?> cl) {

View File

@@ -47,7 +47,6 @@ import com.jpexs.decompiler.flash.tags.DefineShapeTag;
import com.jpexs.decompiler.flash.tags.DefineSoundTag;
import com.jpexs.decompiler.flash.tags.DefineSpriteTag;
import com.jpexs.decompiler.flash.tags.DefineText2Tag;
import com.jpexs.decompiler.flash.tags.DefineTextFormatTag;
import com.jpexs.decompiler.flash.tags.DefineTextTag;
import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag;
import com.jpexs.decompiler.flash.tags.DefineVideoTag;
@@ -62,12 +61,12 @@ import com.jpexs.decompiler.flash.tags.ExportAssetsTag;
import com.jpexs.decompiler.flash.tags.FileAttributesTag;
import com.jpexs.decompiler.flash.tags.FontRefTag;
import com.jpexs.decompiler.flash.tags.FrameLabelTag;
import com.jpexs.decompiler.flash.tags.FreeCharacterTag;
import com.jpexs.decompiler.flash.tags.GenCommandTag;
import com.jpexs.decompiler.flash.tags.ImportAssets2Tag;
import com.jpexs.decompiler.flash.tags.ImportAssetsTag;
import com.jpexs.decompiler.flash.tags.JPEGTablesTag;
import com.jpexs.decompiler.flash.tags.MetadataTag;
import com.jpexs.decompiler.flash.tags.NameCharacterTag;
import com.jpexs.decompiler.flash.tags.PlaceImagePrivateTag;
import com.jpexs.decompiler.flash.tags.PlaceObject2Tag;
import com.jpexs.decompiler.flash.tags.PlaceObject3Tag;
@@ -87,6 +86,7 @@ import com.jpexs.decompiler.flash.tags.SoundStreamHeadTag;
import com.jpexs.decompiler.flash.tags.StartSound2Tag;
import com.jpexs.decompiler.flash.tags.StartSoundTag;
import com.jpexs.decompiler.flash.tags.SymbolClassTag;
import com.jpexs.decompiler.flash.tags.SyncFrameTag;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.VideoFrameTag;
import com.jpexs.decompiler.flash.tags.gfx.DefineCompactedFont;
@@ -300,7 +300,10 @@ public class TagTree extends AbstractTagTree {
StartSoundTag.ID, StartSound2Tag.ID, VideoFrameTag.ID,
SoundStreamBlockTag.ID, SoundStreamHeadTag.ID, SoundStreamHead2Tag.ID,
SetTabIndexTag.ID, PlaceImagePrivateTag.ID,
GenCommandTag.ID);
GenCommandTag.ID,
FreeCharacterTag.ID,
SyncFrameTag.ID
);
break;
case TagTreeModel.FOLDER_OTHERS:
ret = Arrays.asList(

View File

@@ -80,6 +80,7 @@ import com.jpexs.decompiler.flash.tags.DoInitActionTag;
import com.jpexs.decompiler.flash.tags.ExportAssetsTag;
import com.jpexs.decompiler.flash.tags.FileAttributesTag;
import com.jpexs.decompiler.flash.tags.FrameLabelTag;
import com.jpexs.decompiler.flash.tags.FreeCharacterTag;
import com.jpexs.decompiler.flash.tags.MetadataTag;
import com.jpexs.decompiler.flash.tags.PlaceImagePrivateTag;
import com.jpexs.decompiler.flash.tags.PlaceObject2Tag;
@@ -93,6 +94,7 @@ import com.jpexs.decompiler.flash.tags.SoundStreamBlockTag;
import com.jpexs.decompiler.flash.tags.StartSound2Tag;
import com.jpexs.decompiler.flash.tags.StartSoundTag;
import com.jpexs.decompiler.flash.tags.SymbolClassTag;
import com.jpexs.decompiler.flash.tags.SyncFrameTag;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.decompiler.flash.tags.TagTypeInfo;
import com.jpexs.decompiler.flash.tags.UnknownTag;
@@ -101,6 +103,7 @@ import com.jpexs.decompiler.flash.tags.base.ASMSource;
import com.jpexs.decompiler.flash.tags.base.BinaryDataInterface;
import com.jpexs.decompiler.flash.tags.base.ButtonTag;
import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
import com.jpexs.decompiler.flash.tags.base.CharacterModifier;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.tags.base.DepthTag;
import com.jpexs.decompiler.flash.tags.base.DrawableTag;
@@ -5625,11 +5628,8 @@ public class TagTreeContextMenu extends JPopupMenu {
int i = 0;
for (int j = 0; j < swf.getTags().size(); j++) {
Tag t2 = swf.getTags().get(j);
if ((t2 instanceof CharacterIdTag)
&& !(t2 instanceof PlaceObjectTypeTag)
&& !(t2 instanceof RemoveTag)
&& !(t2 instanceof VideoFrameTag)) {
CharacterIdTag chit = (CharacterIdTag) t2;
if (t2 instanceof CharacterModifier) {
CharacterModifier chit = (CharacterModifier) t2;
if (chit.getCharacterId() == characterId) {
swf.removeTag(j);
swf.addTag(usageIndex + i, (Tag) chit);
@@ -5866,7 +5866,9 @@ public class TagTreeContextMenu extends JPopupMenu {
|| (tag instanceof StartSoundTag)
|| (tag instanceof StartSound2Tag)
|| (tag instanceof SoundStreamBlockTag)
|| (tag instanceof DoActionTag);
|| (tag instanceof DoActionTag)
|| (tag instanceof FreeCharacterTag)
|| (tag instanceof SyncFrameTag);
}
public void copyOrMoveTags(Set<TreeItem> items, boolean move, Timelined targetTimelined, Tag position) {