using swf.version instead of SWF.DEFAULT_VERSION where available

This commit is contained in:
Honfika
2014-02-25 20:35:41 +01:00
parent 4859d3b2d2
commit d5e23423db
95 changed files with 289 additions and 341 deletions
+14 -13
View File
@@ -345,6 +345,7 @@ public final class SWF implements TreeItem {
* @param listener
* @param parallelRead Use parallel threads?
* @param checkOnly Check only file validity
* @param skipTagReading
* @throws IOException
* @throws java.lang.InterruptedException
*/
@@ -439,7 +440,7 @@ public final class SWF implements TreeItem {
} else {
boolean hasNonUnknownTag = false;
for (Tag tag : tags) {
if (tag.getData(version).length > 0 && Tag.getRequiredTags().contains(tag.getId())) {
if (tag.getData().length > 0 && Tag.getRequiredTags().contains(tag.getId())) {
hasNonUnknownTag = true;
}
}
@@ -1110,13 +1111,13 @@ public final class SWF implements TreeItem {
if ((shead.getSoundFormat() == DefineSoundTag.FORMAT_ADPCM) && wave) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
for (int b = 0; b < blocks.size(); b++) {
byte[] data = blocks.get(b).getData(SWF.DEFAULT_VERSION);
byte[] data = blocks.get(b).getData();
baos.write(data);
}
createWavFromAdpcm(fos, shead.getSoundRate(), shead.getSoundSize(), shead.getSoundType(), baos.toByteArray());
} else if ((shead.getSoundFormat() == DefineSoundTag.FORMAT_MP3) && mp3) {
for (int b = 0; b < blocks.size(); b++) {
byte[] data = blocks.get(b).getData(SWF.DEFAULT_VERSION);
byte[] data = blocks.get(b).getData();
fos.write(data, 4, data.length - 4);
}
} else {
@@ -1125,7 +1126,7 @@ public final class SWF implements TreeItem {
int ms = (int) (1000.0f / ((float) frameRate));
for (int b = 0; b < blocks.size(); b++) {
byte[] data = blocks.get(b).getData(SWF.DEFAULT_VERSION);
byte[] data = blocks.get(b).getData();
if (shead.getSoundFormat() == 2) { //MP3
data = Arrays.copyOfRange(data, 4, data.length);
}
@@ -1249,7 +1250,7 @@ public final class SWF implements TreeItem {
if ((shead.getSoundFormat() == DefineSoundTag.FORMAT_ADPCM) && wave) {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
for (int b = 0; b < blocks.size(); b++) {
byte data[] = blocks.get(b).getData(SWF.DEFAULT_VERSION);
byte data[] = blocks.get(b).getData();
baos.write(data);
}
final File file = new File(outdir + File.separator + id + ".wav");
@@ -1270,7 +1271,7 @@ public final class SWF implements TreeItem {
public void run() throws IOException {
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(file))) {
for (int b = 0; b < blocks.size(); b++) {
byte data[] = blocks.get(b).getData(SWF.DEFAULT_VERSION);
byte data[] = blocks.get(b).getData();
os.write(data, 2, data.length - 2);
}
}
@@ -1288,7 +1289,7 @@ public final class SWF implements TreeItem {
int ms = (int) (1000.0f / ((float) frameRate));
for (int b = 0; b < blocks.size(); b++) {
byte data[] = blocks.get(b).getData(SWF.DEFAULT_VERSION);
byte data[] = blocks.get(b).getData();
if (shead.getSoundFormat() == 2) { //MP3
data = Arrays.copyOfRange(data, 4, data.length);
}
@@ -1330,7 +1331,7 @@ public final class SWF implements TreeItem {
if ((videoStream.codecID == DefineVideoStreamTag.CODEC_VP6)
|| (videoStream.codecID == DefineVideoStreamTag.CODEC_VP6_ALPHA)) {
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(tag.videoData), SWF.DEFAULT_VERSION);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(tag.videoData), version);
if (videoStream.codecID == DefineVideoStreamTag.CODEC_VP6_ALPHA) {
sis.readUI24(); //offsetToAlpha
}
@@ -1359,12 +1360,12 @@ public final class SWF implements TreeItem {
}
SWFOutputStream sos = new SWFOutputStream(baos, SWF.DEFAULT_VERSION);
SWFOutputStream sos = new SWFOutputStream(baos, version);
sos.writeUB(4, horizontalAdjustment);
sos.writeUB(4, verticalAdjustment);
}
if (videoStream.codecID == DefineVideoStreamTag.CODEC_SORENSON_H263) {
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(tag.videoData), SWF.DEFAULT_VERSION);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(tag.videoData), version);
sis.readUB(17);//pictureStartCode
sis.readUB(5); //version
sis.readUB(8); //temporalReference
@@ -1751,7 +1752,7 @@ public final class SWF implements TreeItem {
private List<MyEntry<DirectValueActionItem, ConstantPool>> getVariables(List<MyEntry<DirectValueActionItem, ConstantPool>> variables, List<GraphSourceItem> functions, HashMap<DirectValueActionItem, ConstantPool> strings, HashMap<DirectValueActionItem, String> usageType, ASMSource src, String path) throws InterruptedException {
List<MyEntry<DirectValueActionItem, ConstantPool>> ret = new ArrayList<>();
List<Action> actions = src.getActions(version);
List<Action> actions = src.getActions();
actionsMap.put(src, actions);
getVariables(variables, functions, strings, usageType, new ActionGraphSource(actions, version, new HashMap<Integer, String>(), new HashMap<String, GraphTargetItem>(), new HashMap<String, GraphTargetItem>()), 0, path);
return ret;
@@ -1875,7 +1876,7 @@ public final class SWF implements TreeItem {
int staticOperation = Graph.SOP_USE_STATIC; //(Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC;
List<GraphTargetItem> dec;
try {
dec = Action.actionsToTree(dia.getActions(version), version, staticOperation, ""/*FIXME*/);
dec = Action.actionsToTree(dia.getActions(), version, staticOperation, ""/*FIXME*/);
} catch (EmptyStackException ex) {
continue;
}
@@ -2059,7 +2060,7 @@ public final class SWF implements TreeItem {
}
for (ASMSource src : actionsMap.keySet()) {
actionsMap.put(src, Action.removeNops(0, actionsMap.get(src), version, 0, ""/*FIXME path*/));
src.setActions(actionsMap.get(src), version);
src.setActions(actionsMap.get(src));
}
deobfuscation.deobfuscateInstanceNames(deobfuscated, renameType, tags, selected);
return ret;
@@ -790,7 +790,7 @@ public class SWFInputStream extends InputStream {
sb.append(" len=");
sb.append(Helper.formatInt((int) tag.getOrigDataLength(), 8));
sb.append(" ");
sb.append(Helper.bytesToHexString(64, tag.getData(version), 0));
sb.append(Helper.bytesToHexString(64, tag.getData(), 0));
out.println(sb.toString());
// out.println(Utils.formatHex((int)tag.getPos(), 8) + ": " + Utils.indent(level, "") + Utils.format(tag.toString(), 25 - 2*level) + " tagId="+tag.getId()+" len="+tag.getOrigDataLength()+": "+Utils.bytesToHexString(64, tag.getData(version), 0));
if (tag.hasSubTags()) {
@@ -951,7 +951,7 @@ public class SWFInputStream extends InputStream {
public static Tag resolveTag(SWF swf, Tag tag, int version, int level, boolean parallel, boolean skipUnusualTags, boolean gfx) throws InterruptedException {
Tag ret;
byte[] data = tag.getData(version);
byte[] data = tag.getData();
long pos = tag.getPos();
try {
switch (tag.getId()) {
@@ -1265,7 +1265,7 @@ public class SWFInputStream extends InputStream {
byte[] data = readBytes((int) tagLength);
Tag ret = new Tag(swf, tagID, "Unresolved", data, pos);
ret.forceWriteAsLong = readLong;
byte[] dataNew = ret.getData(version);
byte[] dataNew = ret.getData();
int ignoreFirst = 0;
for (int i = 0; i < data.length; i++) {
@@ -454,7 +454,7 @@ public class SWFOutputStream extends OutputStream {
* @throws IOException
*/
public void writeTag(Tag tag) throws IOException {
byte[] data = tag.getData(version);
byte[] data = tag.getData();
write(getTagHeader(tag, data, version));
write(data);
}
@@ -34,7 +34,7 @@ import java.util.Set;
public class SWFSearch {
protected Searchable s;
private boolean noCheck;
private final boolean noCheck;
private boolean processed = false;
private final Set<ProgressListener> listeners = new HashSet<>();
private final Map<Long, MemoryInputStream> swfStreams = new HashMap<>();
@@ -52,7 +52,6 @@ import com.jpexs.decompiler.flash.abc.usages.MethodParamsMultinameUsage;
import com.jpexs.decompiler.flash.abc.usages.MethodReturnTypeMultinameUsage;
import com.jpexs.decompiler.flash.abc.usages.MultinameUsage;
import com.jpexs.decompiler.flash.abc.usages.TypeNameMultinameUsage;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.collections.MyEntry;
import com.jpexs.helpers.utf8.Utf8PrintWriter;
import java.io.ByteArrayInputStream;
@@ -710,12 +710,11 @@ public class Action implements GraphSourceItem {
*
* @param asm
* @param actions List of actions
* @param version SWF version
* @param path
* @param writer
* @throws java.lang.InterruptedException
*/
public static void actionsToSource(ASMSource asm, final List<Action> actions, final int version, final String path, GraphTextWriter writer) throws InterruptedException {
public static void actionsToSource(final ASMSource asm, final List<Action> actions, final String path, GraphTextWriter writer) throws InterruptedException {
writer.suspendMeasure();
List<GraphTargetItem> tree = null;
Throwable convertException = null;
@@ -725,7 +724,7 @@ public class Action implements GraphSourceItem {
@Override
public List<GraphTargetItem> call() throws Exception {
int staticOperation = Graph.SOP_USE_STATIC; //(Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC;
List<GraphTargetItem> tree = actionsToTree(new HashMap<Integer, String>(), new HashMap<String, GraphTargetItem>(), new HashMap<String, GraphTargetItem>(), actions, version, staticOperation, path);
List<GraphTargetItem> tree = actionsToTree(new HashMap<Integer, String>(), new HashMap<String, GraphTargetItem>(), new HashMap<String, GraphTargetItem>(), actions, asm.getSwf().version, staticOperation, path);
Graph.graphToString(tree, new NulWriter(), new LocalData());
return tree;
}
@@ -24,7 +24,6 @@ import com.jpexs.decompiler.flash.action.model.CallFunctionActionItem;
import com.jpexs.decompiler.flash.action.model.CallMethodActionItem;
import com.jpexs.decompiler.flash.action.model.CharToAsciiActionItem;
import com.jpexs.decompiler.flash.action.model.CloneSpriteActionItem;
import com.jpexs.decompiler.flash.action.model.ConstantPool;
import com.jpexs.decompiler.flash.action.model.DefineLocalActionItem;
import com.jpexs.decompiler.flash.action.model.DeleteActionItem;
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
@@ -42,7 +42,6 @@ import java.awt.Stroke;
import java.awt.TexturePaint;
import java.awt.geom.AffineTransform;
import java.awt.geom.GeneralPath;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.List;
@@ -2718,7 +2718,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
List<Action> actions;
DoActionTag doa;
doa = new DoActionTag(null, new byte[]{}, SWF.DEFAULT_VERSION, 0);
doa = new DoActionTag(null, new byte[]{}, swf.version, 0);
actions = ASMParser.parse(0, 0, false,
"ConstantPool \"_root\" \"my_sound\" \"Sound\" \"my_define_sound\" \"attachSound\"\n"
+ "Push \"_root\"\n"
@@ -2733,8 +2733,8 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
+ "Push \"attachSound\"\n"
+ "CallMethod\n"
+ "Pop\n"
+ "Stop", SWF.DEFAULT_VERSION, false);
doa.setActions(actions, SWF.DEFAULT_VERSION);
+ "Stop", swf.version, false);
doa.setActions(actions);
sos2.writeTag(doa);
sos2.writeTag(new ShowFrameTag(null));
@@ -2760,8 +2760,8 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
+ "Push \"start\"\n"
+ "CallMethod\n"
+ "Pop\n"
+ "Stop", SWF.DEFAULT_VERSION, false);
doa.setActions(actions, SWF.DEFAULT_VERSION);
+ "Stop", swf.version, false);
doa.setActions(actions);
sos2.writeTag(doa);
sos2.writeTag(new ShowFrameTag(null));
@@ -2804,15 +2804,15 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
+ "Push \"start\"\n"
+ "CallMethod\n"
+ "Pop\n"
+ "Stop", SWF.DEFAULT_VERSION, false);
doa.setActions(actions, SWF.DEFAULT_VERSION);
+ "Stop", swf.version, false);
doa.setActions(actions);
sos2.writeTag(doa);
sos2.writeTag(new ShowFrameTag(null));
actions = ASMParser.parse(0, 0, false,
"StopSounds\n"
+ "Stop", SWF.DEFAULT_VERSION, false);
doa.setActions(actions, SWF.DEFAULT_VERSION);
+ "Stop", swf.version, false);
doa.setActions(actions);
sos2.writeTag(doa);
sos2.writeTag(new ShowFrameTag(null));
@@ -187,10 +187,10 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene
private void cacheScript(ASMSource src, List<Action> actions) throws InterruptedException {
if (!cache.contains(src)) {
if (actions == null) {
actions = src.getActions(SWF.DEFAULT_VERSION);
actions = src.getActions();
}
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true);
Action.actionsToSource(src, actions, SWF.DEFAULT_VERSION, src.toString()/*FIXME?*/, writer);
Action.actionsToSource(src, actions, src.toString()/*FIXME?*/, writer);
List<Highlighting> hilights = writer.instructionHilights;
String srcNoHex = writer.toString();
cache.put(src, new CachedScript(srcNoHex, hilights));
@@ -311,7 +311,7 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene
asm.addDisassemblyListener(listener);
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true);
try {
asm.getASMSource(SWF.DEFAULT_VERSION, exportMode, writer, lastCode);
asm.getASMSource(exportMode, writer, lastCode);
} catch (InterruptedException ex) {
Logger.getLogger(ActionPanel.class.getName()).log(Level.SEVERE, null, ex);
}
@@ -382,7 +382,7 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene
}
DisassemblyListener listener = getDisassemblyListener();
asm.addDisassemblyListener(listener);
List<Action> actions = asm.getActions(SWF.DEFAULT_VERSION);
List<Action> actions = asm.getActions();
lastCode = actions;
asm.removeDisassemblyListener(listener);
srcWithHex = null;
@@ -725,7 +725,7 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene
if (text.trim().startsWith("#hexdata")) {
src.setActionBytes(Helper.getBytesFromHexaText(text));
} else {
src.setActions(ASMParser.parse(0, src.getPos(), true, text, SWF.DEFAULT_VERSION, false), SWF.DEFAULT_VERSION);
src.setActions(ASMParser.parse(0, src.getPos(), true, text, src.getSwf().version, false));
}
setSource(this.src, false);
View.showMessageDialog(this, AppStrings.translate("message.action.saved"));
@@ -748,8 +748,8 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene
case ACTION_SAVE_DECOMPILED:
try {
ActionScriptParser par = new ActionScriptParser();
src.setActions(par.actionsFromString(decompiledEditor.getText()), SWF.DEFAULT_VERSION);
setSource(this.src, false);
src.setActions(par.actionsFromString(decompiledEditor.getText()));
setSource(src, false);
View.showMessageDialog(this, AppStrings.translate("message.action.saved"));
setDecompiledEditMode(false);
@@ -62,14 +62,13 @@ public class CSMTextSettingsTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(textID);
sos.writeUB(2, useFlashType);
@@ -41,14 +41,13 @@ public class DebugIDTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.write(debugId);
} catch (IOException e) {
@@ -44,14 +44,13 @@ public class DefineBinaryDataTag extends CharacterTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(tag);
sos.writeUI32(reserved);
@@ -88,10 +88,10 @@ public class DefineBitsJPEG2Tag extends ImageTag implements AloneTag {
}
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterID);
sos.write(imageData);
@@ -119,14 +119,13 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterID);
sos.writeUI32(imageData.length);
@@ -113,14 +113,13 @@ public class DefineBitsJPEG4Tag extends ImageTag implements AloneTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterID);
sos.writeUI32(imageData.length);
@@ -98,10 +98,10 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag {
}
}
ByteArrayOutputStream bitmapDataOS = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(bitmapDataOS, SWF.DEFAULT_VERSION);
SWFOutputStream sos = new SWFOutputStream(bitmapDataOS, getVersion());
sos.writeALPHABITMAPDATA(bitmapData, bitmapFormat, bitmapWidth, bitmapHeight);
ByteArrayOutputStream zlibOS = new ByteArrayOutputStream();
SWFOutputStream sos2 = new SWFOutputStream(zlibOS, SWF.DEFAULT_VERSION);
SWFOutputStream sos2 = new SWFOutputStream(zlibOS, getVersion());
sos2.writeBytesZlib(bitmapDataOS.toByteArray());
zlibBitmapData = zlibOS.toByteArray();
decompressed = false;
@@ -154,14 +154,13 @@ public class DefineBitsLossless2Tag extends ImageTag implements AloneTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterID);
sos.writeUI8(bitmapFormat);
@@ -97,10 +97,10 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag {
}
}
ByteArrayOutputStream bitmapDataOS = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(bitmapDataOS, SWF.DEFAULT_VERSION);
SWFOutputStream sos = new SWFOutputStream(bitmapDataOS, getVersion());
sos.writeBITMAPDATA(bitmapData, bitmapFormat, bitmapWidth, bitmapHeight);
ByteArrayOutputStream zlibOS = new ByteArrayOutputStream();
SWFOutputStream sos2 = new SWFOutputStream(zlibOS, SWF.DEFAULT_VERSION);
SWFOutputStream sos2 = new SWFOutputStream(zlibOS, getVersion());
sos2.writeBytesZlib(bitmapDataOS.toByteArray());
zlibBitmapData = zlibOS.toByteArray();
decompressed = false;
@@ -197,14 +197,13 @@ public class DefineBitsLosslessTag extends ImageTag implements AloneTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterID);
sos.writeUI8(bitmapFormat);
@@ -83,7 +83,7 @@ public class DefineBitsTag extends ImageTag {
getJPEGTables(tags);
if ((jtt != null)) {
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
byte[] jttdata = jtt.getData(swf.version);
byte[] jttdata = jtt.getData();
if (jttdata.length != 0) {
baos.write(jttdata, SWF.hasErrorHeader(jttdata) ? 4 : 0, jttdata.length - (SWF.hasErrorHeader(jttdata) ? 6 : 2));
baos.write(jpegData, SWF.hasErrorHeader(jpegData) ? 6 : 2, jpegData.length - (SWF.hasErrorHeader(jttdata) ? 6 : 2));
@@ -101,14 +101,13 @@ public class DefineBitsTag extends ImageTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterID);
sos.write(jpegData);
@@ -120,13 +120,12 @@ public class DefineButton2Tag extends CharacterTag implements Container, Bounded
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
if (Configuration.disableDangerous.get()) {
return super.getData(version);
return super.getData();
}
ByteArrayInputStream bais = new ByteArrayInputStream(super.data);
@@ -136,7 +135,7 @@ public class DefineButton2Tag extends CharacterTag implements Container, Bounded
if (Configuration.debugCopy.get()) {
os = new CopyOutputStream(os, bais);
}
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(buttonId);
sos.writeUB(7, reserved);
@@ -146,14 +145,14 @@ public class DefineButton2Tag extends CharacterTag implements Container, Bounded
OutputStream os2 = baos2;
byte[] origbrdata = null;
if (Configuration.debugCopy.get()) {
SWFInputStream sis = new SWFInputStream(bais, version);
SWFInputStream sis = new SWFInputStream(bais, getVersion());
int len = sis.readUI16();
if (len != 0) {
origbrdata = sis.readBytesEx(len - 2);
os2 = new CopyOutputStream(os2, new ByteArrayInputStream(origbrdata));
}
}
try (SWFOutputStream sos2 = new SWFOutputStream(os2, version)) {
try (SWFOutputStream sos2 = new SWFOutputStream(os2, getVersion())) {
sos2.writeBUTTONRECORDList(characters, true);
}
byte[] brdata = baos2.toByteArray();
@@ -165,7 +164,7 @@ public class DefineButton2Tag extends CharacterTag implements Container, Bounded
}
}
if (Configuration.debugCopy.get()) {
sos = new SWFOutputStream(baos, version);
sos = new SWFOutputStream(baos, getVersion());
}
if ((actions == null) || (actions.isEmpty())) {
sos.writeUI16(0);
@@ -174,7 +173,7 @@ public class DefineButton2Tag extends CharacterTag implements Container, Bounded
}
sos.write(brdata);
if (Configuration.debugCopy.get()) {
sos = new SWFOutputStream(new CopyOutputStream(baos, bais), version);
sos = new SWFOutputStream(new CopyOutputStream(baos, bais), getVersion());
}
sos.writeBUTTONCONDACTIONList(actions);
sos.close();
@@ -42,14 +42,13 @@ public class DefineButtonCxformTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(buttonId);
sos.writeCXFORM(buttonColorTransform);
@@ -67,14 +67,13 @@ public class DefineButtonSoundTag extends CharacterIdTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(buttonId);
sos.writeUI16(buttonSoundChar0);
@@ -115,20 +115,19 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
if (Configuration.disableDangerous.get()) {
return super.getData(version);
return super.getData();
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
if (Configuration.debugCopy.get()) {
os = new CopyOutputStream(os, new ByteArrayInputStream(super.data));
}
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(buttonId);
sos.writeBUTTONRECORDList(characters, false);
@@ -143,18 +142,17 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT
/**
* Converts actions to ASM source
*
* @param version SWF version
* @param actions
* @param writer
* @return ASM source
* @throws java.lang.InterruptedException
*/
@Override
public GraphTextWriter getASMSource(int version, ExportMode exportMode, GraphTextWriter writer, List<Action> actions) throws InterruptedException {
public GraphTextWriter getASMSource(ExportMode exportMode, GraphTextWriter writer, List<Action> actions) throws InterruptedException {
if (actions == null) {
actions = getActions(version);
actions = getActions();
}
return Action.actionsToString(listeners, 0, actions, null, version, exportMode, writer, getPos() + hdrSize, toString()/*FIXME?*/);
return Action.actionsToString(listeners, 0, actions, null, swf.version, exportMode, writer, getPos() + hdrSize, toString()/*FIXME?*/);
}
/**
@@ -170,17 +168,16 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT
/**
* Returns actions associated with this object
*
* @param version Version
* @return List of actions
* @throws java.lang.InterruptedException
*/
@Override
public List<Action> getActions(int version) throws InterruptedException {
public List<Action> getActions() throws InterruptedException {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int prevLength = 0;
if (previousTag != null) {
byte[] prevData = previousTag.getData(version);
byte[] prevData = previousTag.getData();
baos.write(prevData);
prevLength = prevData.length;
}
@@ -188,7 +185,7 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT
MemoryInputStream rri = new MemoryInputStream(baos.toByteArray());
rri.seek(prevLength);
List<Action> list = ActionListReader.readActionListTimeout(listeners, getPos() + hdrSize - prevLength, rri, version, prevLength, -1, toString()/*FIXME?*/);
List<Action> list = ActionListReader.readActionListTimeout(listeners, getPos() + hdrSize - prevLength, rri, getVersion(), prevLength, -1, toString()/*FIXME?*/);
return list;
} catch (InterruptedException ex) {
throw ex;
@@ -199,8 +196,8 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT
}
@Override
public void setActions(List<Action> actions, int version) {
actionBytes = Action.actionsToBytes(actions, true, version);
public void setActions(List<Action> actions) {
actionBytes = Action.actionsToBytes(actions, true, swf.version);
}
@Override
@@ -488,14 +488,13 @@ public class DefineEditTextTag extends TextTag implements DrawableTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterID);
sos.writeRECT(bounds);
@@ -109,13 +109,12 @@ public class DefineFont2Tag extends FontTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
SWFOutputStream sos = new SWFOutputStream(baos, getVersion());
try {
sos.writeUI16(fontId);
sos.writeUB(1, fontFlagsHasLayout ? 1 : 0);
@@ -135,7 +134,7 @@ public class DefineFont2Tag extends FontTag {
List<Long> offsetTable = new ArrayList<>();
ByteArrayOutputStream baosGlyphShapes = new ByteArrayOutputStream();
SWFOutputStream sos3 = new SWFOutputStream(baosGlyphShapes, version);
SWFOutputStream sos3 = new SWFOutputStream(baosGlyphShapes, getVersion());
for (int i = 0; i < numGlyphs; i++) {
offsetTable.add((glyphShapeTable.size() + 1/*CodeTableOffset*/) * (fontFlagsWideOffsets ? 4 : 2) + sos3.getPos());
sos3.writeSHAPE(glyphShapeTable.get(i), 1);
@@ -179,14 +179,13 @@ public class DefineFont3Tag extends FontTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
if (Configuration.debugCopy.get()) {
sos = new SWFOutputStream(new CopyOutputStream(sos, new ByteArrayInputStream(data)), 10);
}
@@ -209,7 +208,7 @@ public class DefineFont3Tag extends FontTag {
List<Long> offsetTable = new ArrayList<>();
ByteArrayOutputStream baosGlyphShapes = new ByteArrayOutputStream();
SWFOutputStream sos3 = new SWFOutputStream(baosGlyphShapes, version);
SWFOutputStream sos3 = new SWFOutputStream(baosGlyphShapes, getVersion());
for (int i = 0; i < numGlyphs; i++) {
offsetTable.add((glyphShapeTable.size() + 1/*CodeTableOffset*/) * (fontFlagsWideOffsets ? 4 : 2) + sos3.getPos());
sos3.writeSHAPE(glyphShapeTable.get(i), 1);
@@ -63,14 +63,13 @@ public class DefineFont4Tag extends CharacterTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(fontID);
sos.writeUB(5, reserved);
@@ -60,14 +60,13 @@ public class DefineFontAlignZonesTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(fontID);
sos.writeUB(2, CSMTableHint);
@@ -58,14 +58,13 @@ public class DefineFontInfo2Tag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(fontID);
byte[] fontNameBytes = Utf8Helper.getBytes(fontName);
@@ -56,14 +56,13 @@ public class DefineFontInfoTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(fontId);
byte[] fontNameBytes = Utf8Helper.getBytes(fontName);
@@ -109,19 +109,18 @@ public class DefineFontTag extends FontTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(fontId);
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
List<Integer> offsetTable = new ArrayList<>();
SWFOutputStream sos2 = new SWFOutputStream(baos2, version);
SWFOutputStream sos2 = new SWFOutputStream(baos2, getVersion());
for (SHAPE shape : glyphShapeTable) {
offsetTable.add(glyphShapeTable.size() * 2 + (int) sos2.getPos());
sos2.writeSHAPE(shape, 1);
@@ -104,14 +104,13 @@ public class DefineMorphShape2Tag extends CharacterTag implements BoundedTag, Mo
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterId);
sos.writeRECT(startBounds);
@@ -122,7 +121,7 @@ public class DefineMorphShape2Tag extends CharacterTag implements BoundedTag, Mo
sos.writeUB(1, usesNonScalingStrokes ? 1 : 0);
sos.writeUB(1, usesScalingStrokes ? 1 : 0);
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
SWFOutputStream sos2 = new SWFOutputStream(baos2, version);
SWFOutputStream sos2 = new SWFOutputStream(baos2, getVersion());
sos2.writeMORPHFILLSTYLEARRAY(morphFillStyles, 2);
sos2.writeMORPHLINESTYLEARRAY(morphLineStyles, 2);
sos2.writeSHAPE(startEdges, 1);
@@ -86,20 +86,19 @@ public class DefineMorphShapeTag extends CharacterTag implements BoundedTag, Mor
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterId);
sos.writeRECT(startBounds);
sos.writeRECT(endBounds);
ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
SWFOutputStream sos2 = new SWFOutputStream(baos2, version);
SWFOutputStream sos2 = new SWFOutputStream(baos2, getVersion());
sos2.writeMORPHFILLSTYLEARRAY(morphFillStyles, 1);
sos2.writeMORPHLINESTYLEARRAY(morphLineStyles, 1);
sos2.writeSHAPE(startEdges, 1);
@@ -47,14 +47,13 @@ public class DefineScalingGridTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterId);
sos.writeRECT(splitter);
@@ -51,14 +51,13 @@ public class DefineSceneAndFrameLabelDataTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
int sceneCount = sceneOffsets.length;
sos.writeEncodedU32(sceneCount);
@@ -77,13 +77,12 @@ public class DefineShapeTag extends CharacterTag implements ShapeTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
SWFOutputStream sos = new SWFOutputStream(baos, getVersion());
try {
sos.writeUI16(shapeId);
sos.writeRECT(shapeBounds);
@@ -68,14 +68,13 @@ public class DefineSoundTag extends CharacterTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(soundId);
sos.writeUB(4, soundFormat);
@@ -211,20 +211,19 @@ public class DefineSpriteTag extends CharacterTag implements Container, BoundedT
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
if (Configuration.disableDangerous.get()) {
return super.getData(version);
return super.getData();
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
if (Configuration.debugCopy.get()) {
os = new CopyOutputStream(os, new ByteArrayInputStream(super.data));
}
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(spriteId);
sos.writeUI16(frameCount);
@@ -424,14 +424,13 @@ public class DefineText2Tag extends TextTag implements DrawableTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterID);
sos.writeRECT(textBounds);
@@ -434,14 +434,13 @@ public class DefineTextTag extends TextTag implements DrawableTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterID);
sos.writeRECT(textBounds);
@@ -77,14 +77,13 @@ public class DefineVideoStreamTag extends CharacterTag implements BoundedTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterID);
sos.writeUI16(numFrames);
@@ -85,18 +85,17 @@ public class DoABCDefineTag extends Tag implements ABCContainerTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
OutputStream os = bos;
if (Configuration.debugCopy.get()) {
os = new CopyOutputStream(os, new ByteArrayInputStream(super.data));
}
try (SWFOutputStream sos = new SWFOutputStream(os, version)) {
try (SWFOutputStream sos = new SWFOutputStream(os, getVersion())) {
sos.writeUI32(flags);
sos.writeString(name);
abc.saveToStream(sos);
@@ -68,18 +68,17 @@ public class DoABCTag extends Tag implements ABCContainerTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
OutputStream os = bos;
if (Configuration.debugCopy.get()) {
os = new CopyOutputStream(os, new ByteArrayInputStream(super.data));
}
try (SWFOutputStream sos = new SWFOutputStream(os, version)) {
try (SWFOutputStream sos = new SWFOutputStream(os, getVersion())) {
abc.saveToStream(sos);
}
return bos.toByteArray();
@@ -63,29 +63,27 @@ public class DoActionTag extends Tag implements ASMSource {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
return actionBytes;//Action.actionsToBytes(actions, true, version);
}
/**
* Converts actions to ASM source
*
* @param version SWF version
* @param actions
* @param writer
* @return ASM source
* @throws java.lang.InterruptedException
*/
@Override
public GraphTextWriter getASMSource(int version, ExportMode exportMode, GraphTextWriter writer, List<Action> actions) throws InterruptedException {
public GraphTextWriter getASMSource(ExportMode exportMode, GraphTextWriter writer, List<Action> actions) throws InterruptedException {
if (actions == null) {
actions = getActions(version);
actions = getActions();
}
return Action.actionsToString(listeners, 0, actions, null, version, exportMode, writer, getPos(), toString()/*FIXME?*/);
return Action.actionsToString(listeners, 0, actions, null, swf.version, exportMode, writer, getPos(), toString()/*FIXME?*/);
}
/**
@@ -109,22 +107,22 @@ public class DoActionTag extends Tag implements ASMSource {
}
@Override
public List<Action> getActions(int version) throws InterruptedException {
public List<Action> getActions() throws InterruptedException {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int prevLength = 0;
if (previousTag != null) {
byte[] prevData = previousTag.getData(version);
byte[] prevData = previousTag.getData();
baos.write(prevData);
prevLength = prevData.length;
byte[] header = SWFOutputStream.getTagHeader(this, data, version);
byte[] header = SWFOutputStream.getTagHeader(this, data, getVersion());
baos.write(header);
prevLength += header.length;
}
baos.write(actionBytes);
MemoryInputStream rri = new MemoryInputStream(baos.toByteArray());
rri.seek(prevLength);
List<Action> list = ActionListReader.readActionListTimeout(listeners, getPos() - prevLength, rri, version, prevLength, -1, toString()/*FIXME?*/);
List<Action> list = ActionListReader.readActionListTimeout(listeners, getPos() - prevLength, rri, getVersion(), prevLength, -1, toString()/*FIXME?*/);
return list;
} catch (InterruptedException ex) {
throw ex;
@@ -135,8 +133,8 @@ public class DoActionTag extends Tag implements ASMSource {
}
@Override
public void setActions(List<Action> actions, int version) {
actionBytes = Action.actionsToBytes(actions, true, version);
public void setActions(List<Action> actions) {
actionBytes = Action.actionsToBytes(actions, true, swf.version);
}
@Override
@@ -74,13 +74,12 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
SWFOutputStream sos = new SWFOutputStream(baos, getVersion());
try {
sos.writeUI16(spriteId);
sos.write(actionBytes);
@@ -104,40 +103,39 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource {
/**
* Converts actions to ASM source
*
* @param version SWF version
* @param actions
* @param writer
* @return ASM source
* @throws java.lang.InterruptedException
*/
@Override
public GraphTextWriter getASMSource(int version, ExportMode exportMode, GraphTextWriter writer, List<Action> actions) throws InterruptedException {
public GraphTextWriter getASMSource(ExportMode exportMode, GraphTextWriter writer, List<Action> actions) throws InterruptedException {
if (actions == null) {
actions = getActions(version);
actions = getActions();
}
return Action.actionsToString(listeners, 0, actions, null, version, exportMode, writer, getPos() + 2, toString()/*FIXME?*/);
return Action.actionsToString(listeners, 0, actions, null, swf.version, exportMode, writer, getPos() + 2, toString()/*FIXME?*/);
}
@Override
public List<Action> getActions(int version) throws InterruptedException {
public List<Action> getActions() throws InterruptedException {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int prevLength = 0;
if (previousTag != null) {
byte[] prevData = previousTag.getData(version);
byte[] prevData = previousTag.getData();
baos.write(prevData);
prevLength = prevData.length;
baos.write(0);
baos.write(0);
prevLength += 2;
byte[] header = SWFOutputStream.getTagHeader(this, data, version);
byte[] header = SWFOutputStream.getTagHeader(this, data, getVersion());
baos.write(header);
prevLength += header.length;
}
baos.write(actionBytes);
MemoryInputStream rri = new MemoryInputStream(baos.toByteArray());
rri.seek(prevLength);
List<Action> list = ActionListReader.readActionListTimeout(listeners, getPos() + 2 - prevLength, rri, version, prevLength, -1, toString()/*FIXME?*/);
List<Action> list = ActionListReader.readActionListTimeout(listeners, getPos() + 2 - prevLength, rri, getVersion(), prevLength, -1, toString()/*FIXME?*/);
return list;
} catch (InterruptedException ex) {
throw ex;
@@ -148,8 +146,8 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource {
}
@Override
public void setActions(List<Action> actions, int version) {
actionBytes = Action.actionsToBytes(actions, true, version);
public void setActions(List<Action> actions) {
actionBytes = Action.actionsToBytes(actions, true, swf.version);
}
@Override
@@ -46,14 +46,13 @@ public class EnableDebugger2Tag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(reserved);
sos.writeString(passwordHash);
@@ -40,14 +40,13 @@ public class EnableDebuggerTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
if (passwordHash != null) {
sos.writeString(passwordHash);
@@ -48,14 +48,13 @@ public class EnableTelemetryTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUB(16, reserved);
if (passwordHash != null) {
@@ -29,11 +29,10 @@ public class EndTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
return new byte[0];
}
public static final int ID = 0;
@@ -79,14 +79,13 @@ public class ExportAssetsTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(tags.size());
for (int i = 0; i < tags.size(); i++) {
@@ -68,14 +68,13 @@ public class FileAttributesTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUB(1, reserved1 ? 1 : 0); //reserved
sos.writeUB(1, useDirectBlit ? 1 : 0);
@@ -52,14 +52,13 @@ public class FrameLabelTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeString(name);
if (namedAnchor) {
@@ -86,14 +86,13 @@ public class ImportAssets2Tag extends Tag implements ImportTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeString(url);
sos.writeUI8(reserved1);
@@ -77,14 +77,13 @@ public class ImportAssetsTag extends Tag implements ImportTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeString(url);
sos.writeUI16(tags.size());
@@ -43,14 +43,13 @@ public class MetadataTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeString(xmlMetadata);
} catch (IOException e) {
@@ -142,20 +142,19 @@ public class PlaceObject2Tag extends CharacterIdTag implements Container, PlaceO
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
if (Configuration.disableDangerous.get()) {
return super.getData(version);
return super.getData();
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
if (Configuration.debugCopy.get()) {
os = new CopyOutputStream(os, new ByteArrayInputStream(super.data));
}
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUB(1, placeFlagHasClipActions ? 1 : 0);
sos.writeUB(1, placeFlagHasClipDepth ? 1 : 0);
@@ -219,20 +219,19 @@ public class PlaceObject3Tag extends CharacterIdTag implements Container, PlaceO
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
if (Configuration.disableDangerous.get()) {
return super.getData(version);
return super.getData();
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
if (Configuration.debugCopy.get()) {
os = new CopyOutputStream(os, new ByteArrayInputStream(super.data));
}
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUB(1, placeFlagHasClipActions ? 1 : 0);
sos.writeUB(1, placeFlagHasClipDepth ? 1 : 0);
@@ -221,20 +221,19 @@ public class PlaceObject4Tag extends CharacterIdTag implements Container, PlaceO
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
if (Configuration.disableDangerous.get()) {
return super.getData(version);
return super.getData();
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
if (Configuration.debugCopy.get()) {
os = new CopyOutputStream(os, new ByteArrayInputStream(super.data));
}
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUB(1, placeFlagHasClipActions ? 1 : 0);
sos.writeUB(1, placeFlagHasClipDepth ? 1 : 0);
@@ -79,14 +79,13 @@ public class PlaceObjectTag extends CharacterIdTag implements PlaceObjectTypeTag
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterId);
sos.writeUI16(depth);
@@ -76,10 +76,10 @@ public class ProductInfoTag extends Tag {
}
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI32(productID);
sos.writeUI32(edition);
@@ -40,14 +40,13 @@ public class ProtectTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
if (!"".equals(passwordHash)) {
sos.writeString(passwordHash);
@@ -50,14 +50,13 @@ public class RemoveObjectTag extends CharacterIdTag implements RemoveTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterId);
sos.writeUI16(depth);
@@ -46,14 +46,13 @@ public class ScriptLimitsTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(maxRecursionDepth);
sos.writeUI16(scriptTimeoutSeconds);
@@ -41,9 +41,9 @@ public class SetBackgroundColorTag extends Tag {
}
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SWFOutputStream sos = new SWFOutputStream(baos, version);
SWFOutputStream sos = new SWFOutputStream(baos, getVersion());
try {
sos.writeRGB(backgroundColor);
} catch (IOException e) {
@@ -48,14 +48,13 @@ public class SetTabIndexTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(depth);
sos.writeUI16(tabIndex);
@@ -65,12 +65,11 @@ public class ShowFrameTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
return super.getData(version);
public byte[] getData() {
return super.getData();
}
public static boolean isNestedTagType(int tagTypeId) {
@@ -97,14 +97,13 @@ public class SoundStreamHead2Tag extends CharacterIdTag implements SoundStreamHe
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUB(4, reserved);
sos.writeUB(2, playBackSoundRate);
@@ -88,14 +88,13 @@ public class SoundStreamHeadTag extends CharacterIdTag implements SoundStreamHea
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUB(4, reserved);
sos.writeUB(2, playBackSoundRate);
@@ -39,14 +39,13 @@ public class StartSound2Tag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
/*try {
//sos.write
} catch (IOException e) {
@@ -42,14 +42,13 @@ public class StartSoundTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(soundId);
sos.writeSOUNDINFO(soundInfo);
@@ -53,14 +53,13 @@ public class SymbolClassTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
int numSymbols = tags.length;
sos.writeUI16(numSymbols);
@@ -261,12 +261,18 @@ public class Tag implements NeedsCharacters, Exportable, ContainerItem, Serializ
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
public byte[] getData(int version) {
public byte[] getData() {
return data;
}
public int getVersion() {
if (swf == null) {
return SWF.DEFAULT_VERSION;
}
return swf.version;
}
/**
* Gets original read data
@@ -36,14 +36,13 @@ public class TagStub extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
/*try {
//sos.write
} catch (IOException e) {
@@ -43,14 +43,13 @@ public class VideoFrameTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(streamID);
sos.writeUI16(frameNum);
@@ -33,14 +33,13 @@ public interface ASMSource extends TreeItem {
/**
* Converts actions to ASM source
*
* @param version SWF version
* @param exportMode PCode or hex?
* @param writer
* @param actions
* @return ASM source
* @throws java.lang.InterruptedException
*/
public GraphTextWriter getASMSource(int version, ExportMode exportMode, GraphTextWriter writer, List<Action> actions) throws InterruptedException;
public GraphTextWriter getASMSource(ExportMode exportMode, GraphTextWriter writer, List<Action> actions) throws InterruptedException;
/**
* Whether or not this object contains ASM source
@@ -52,11 +51,10 @@ public interface ASMSource extends TreeItem {
/**
* Returns actions associated with this object
*
* @param version Version
* @return List of actions
* @throws java.lang.InterruptedException
*/
public List<Action> getActions(int version) throws InterruptedException;
public List<Action> getActions() throws InterruptedException;
/**
* Sets actions associated with this object
@@ -64,7 +62,7 @@ public interface ASMSource extends TreeItem {
* @param version Version
* @param actions Action list
*/
public void setActions(List<Action> actions, int version);
public void setActions(List<Action> actions);
public byte[] getActionBytes();
@@ -71,14 +71,13 @@ public final class DefineCompactedFont extends FontTag implements DrawableTag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(fontId);
for (FontType ft : fonts) {
@@ -44,14 +44,13 @@ public class DefineExternalGradient extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(gradientId);
sos.writeUI16(bitmapsFormat);
@@ -45,14 +45,13 @@ public class DefineExternalImage extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterId);
sos.writeUI16(bitmapFormat);
@@ -47,14 +47,13 @@ public class DefineExternalImage2 extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI32(characterId);
sos.writeUI16(bitmapFormat);
@@ -47,14 +47,13 @@ public class DefineExternalSound extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterId);
sos.writeUI16(soundFormat);
@@ -47,14 +47,13 @@ public class DefineExternalStreamSound extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(soundFormat);
sos.writeUI16(bits);
@@ -38,14 +38,13 @@ public class DefineGradientMap extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(indices.length);
for (int i = 0; i < indices.length; i++) {
@@ -43,14 +43,13 @@ public class DefineSubImage extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI16(characterId);
sos.writeUI16(imageCharacterId);
@@ -52,11 +52,10 @@ public class ExporterInfoTag extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
@@ -53,14 +53,13 @@ public class FontTextureInfo extends Tag {
/**
* Gets data bytes
*
* @param version SWF version
* @return Bytes of data
*/
@Override
public byte[] getData(int version) {
public byte[] getData() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStream os = baos;
SWFOutputStream sos = new SWFOutputStream(os, version);
SWFOutputStream sos = new SWFOutputStream(os, getVersion());
try {
sos.writeUI32(textureID);
sos.writeUI16(textureFormat);
@@ -145,12 +145,12 @@ public class TagNode extends ContainerNode {
asm.getActionSourceSuffix(writer);
} else if (exportMode != ExportMode.SOURCE) {
asm.getActionSourcePrefix(writer);
asm.getASMSource(SWF.DEFAULT_VERSION, exportMode, writer, null);
asm.getASMSource(exportMode, writer, null);
asm.getActionSourceSuffix(writer);
} else {
List<Action> as = asm.getActions(SWF.DEFAULT_VERSION);
Action.setActionsAddresses(as, 0, SWF.DEFAULT_VERSION);
Action.actionsToSource(asm, as, SWF.DEFAULT_VERSION, ""/*FIXME*/, writer);
List<Action> as = asm.getActions();
Action.setActionsAddresses(as, 0, asm.getSwf().version);
Action.actionsToSource(asm, as, ""/*FIXME*/, writer);
}
}
@@ -159,18 +159,17 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem, S
/**
* Converts actions to ASM source
*
* @param version SWF version
* @param actions
* @param writer
* @return ASM source
* @throws java.lang.InterruptedException
*/
@Override
public GraphTextWriter getASMSource(int version, ExportMode exportMode, GraphTextWriter writer, List<Action> actions) throws InterruptedException {
public GraphTextWriter getASMSource(ExportMode exportMode, GraphTextWriter writer, List<Action> actions) throws InterruptedException {
if (actions == null) {
actions = getActions(version);
actions = getActions();
}
return Action.actionsToString(listeners, 0, actions, null, version, exportMode, writer, getPos() + 4, toString()/*FIXME?*/);
return Action.actionsToString(listeners, 0, actions, null, swf.version, exportMode, writer, getPos() + 4, toString()/*FIXME?*/);
}
/**
@@ -186,14 +185,13 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem, S
/**
* Returns actions associated with this object
*
* @param version Version
* @return List of actions
* @throws java.lang.InterruptedException
*/
@Override
public List<Action> getActions(int version) throws InterruptedException {
public List<Action> getActions() throws InterruptedException {
try {
List<Action> list = ActionListReader.readActionListTimeout(listeners, getPos() + 4, new MemoryInputStream(actionBytes), version, 0, -1, toString()/*FIXME?*/);
List<Action> list = ActionListReader.readActionListTimeout(listeners, getPos() + 4, new MemoryInputStream(actionBytes), swf.version, 0, -1, toString()/*FIXME?*/);
return list;
} catch (InterruptedException ex) {
@@ -205,8 +203,8 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem, S
}
@Override
public void setActions(List<Action> actions, int version) {
actionBytes = Action.actionsToBytes(actions, true, version);
public void setActions(List<Action> actions) {
actionBytes = Action.actionsToBytes(actions, true, swf.version);
}
@Override
@@ -165,18 +165,17 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem, S
/**
* Converts actions to ASM source
*
* @param version SWF version
* @param actions
* @param writer
* @return ASM source
* @throws java.lang.InterruptedException
*/
@Override
public GraphTextWriter getASMSource(int version, ExportMode exportMode, GraphTextWriter writer, List<Action> actions) throws InterruptedException {
public GraphTextWriter getASMSource(ExportMode exportMode, GraphTextWriter writer, List<Action> actions) throws InterruptedException {
if (actions == null) {
actions = getActions(version);
actions = getActions();
}
return Action.actionsToString(listeners, 0, actions, null, version, exportMode, writer, getPos() + hdrPos, toString()/*FIXME?*/);
return Action.actionsToString(listeners, 0, actions, null, swf.version, exportMode, writer, getPos() + hdrPos, toString()/*FIXME?*/);
}
/**
@@ -190,9 +189,9 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem, S
}
@Override
public List<Action> getActions(int version) throws InterruptedException {
public List<Action> getActions() throws InterruptedException {
try {
List<Action> list = ActionListReader.readActionListTimeout(listeners, getPos() + hdrPos, new MemoryInputStream(actionBytes), version, 0, -1, toString()/*FIXME?*/);
List<Action> list = ActionListReader.readActionListTimeout(listeners, getPos() + hdrPos, new MemoryInputStream(actionBytes), swf.version, 0, -1, toString()/*FIXME?*/);
return list;
} catch (InterruptedException ex) {
throw ex;
@@ -203,8 +202,8 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem, S
}
@Override
public void setActions(List<Action> actions, int version) {
actionBytes = Action.actionsToBytes(actions, true, version);
public void setActions(List<Action> actions) {
actionBytes = Action.actionsToBytes(actions, true, swf.version);
}
@Override
@@ -1155,7 +1155,7 @@ public class XFLConverter {
private static String convertActionScript(ASMSource as) {
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false);
try {
Action.actionsToSource(as, as.getActions(SWF.DEFAULT_VERSION), SWF.DEFAULT_VERSION, as.toString(), writer);
Action.actionsToSource(as, as.getActions(), as.toString(), writer);
} catch (InterruptedException ex) {
Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, null, ex);
}
@@ -1382,7 +1382,7 @@ public class XFLConverter {
for (Tag t : tags) {
if (found && (t instanceof SoundStreamBlockTag)) {
SoundStreamBlockTag bl = (SoundStreamBlockTag) t;
soundData = bl.getData(SWF.DEFAULT_VERSION);
soundData = bl.getData();
break;
}
if (t == symbol) {
@@ -1425,7 +1425,7 @@ public class XFLConverter {
bits = 18;
}
if (soundFormat == DefineSoundTag.FORMAT_ADPCM) {
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(soundData), SWF.DEFAULT_VERSION);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(soundData), swf.version);
exportFormat = "wav";
try {
int adpcmCodeSize = (int) sis.readUB(2);
@@ -1440,7 +1440,7 @@ public class XFLConverter {
format += 1;
}
format += 4; //quality best
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(soundData), SWF.DEFAULT_VERSION);
SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(soundData), swf.version);
try {
sis.readSI16();
MP3FRAME frame = new MP3FRAME(sis);
@@ -21,7 +21,6 @@ import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.IndexColorModel;
import java.awt.image.WritableRaster;
import java.io.File;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;