mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-27 01:45:36 +00:00
tag writing fixes + test
This commit is contained in:
@@ -1441,7 +1441,7 @@ public class SWFInputStream implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.SEVERE, "Error during tag reading", ex);
|
||||
logger.log(Level.SEVERE, "Error during tag reading. ID: " + tag.getId() + " name: " + tag.getName() + " pos: " + data.getPos(), ex);
|
||||
ret = new TagStub(swf, tag.getId(), "ErrorTag", data, null);
|
||||
}
|
||||
ret.forceWriteAsLong = tag.forceWriteAsLong;
|
||||
@@ -2631,7 +2631,7 @@ public class SWFInputStream implements AutoCloseable {
|
||||
}
|
||||
if (stateNewStyles) {
|
||||
if (morphShape) {
|
||||
// This should never happen
|
||||
// This should never happen in a valid SWF
|
||||
throw new IOException("MorphShape should not have new styles.");
|
||||
} else {
|
||||
scr.fillStyles = readFILLSTYLEARRAY(shapeNum, "fillStyles");
|
||||
|
||||
@@ -1376,7 +1376,7 @@ public class SWFOutputStream extends OutputStream {
|
||||
scr.numFillBits = getNeededBitsU(scr.fillStyles.fillStyles.length);
|
||||
scr.numLineBits = getNeededBitsU(scr.lineStyles.lineStyles.length);
|
||||
fillBits = scr.numFillBits;
|
||||
fillBits = scr.numLineBits;
|
||||
lineBits = scr.numLineBits;
|
||||
writeUB(4, scr.numFillBits);
|
||||
writeUB(4, scr.numLineBits);
|
||||
}
|
||||
@@ -1501,7 +1501,8 @@ public class SWFOutputStream extends OutputStream {
|
||||
writeRGBA(value.endColor);
|
||||
}
|
||||
if ((value.fillStyleType == MORPHFILLSTYLE.LINEAR_GRADIENT)
|
||||
|| (value.fillStyleType == MORPHFILLSTYLE.RADIAL_GRADIENT)) {
|
||||
|| (value.fillStyleType == MORPHFILLSTYLE.RADIAL_GRADIENT)
|
||||
|| (value.fillStyleType == MORPHFILLSTYLE.FOCAL_RADIAL_GRADIENT)) {
|
||||
writeMatrix(value.startGradientMatrix);
|
||||
writeMatrix(value.endGradientMatrix);
|
||||
}
|
||||
@@ -1509,6 +1510,9 @@ public class SWFOutputStream extends OutputStream {
|
||||
|| (value.fillStyleType == MORPHFILLSTYLE.RADIAL_GRADIENT)) {
|
||||
writeMORPHGRADIENT(value.gradient, shapeNum);
|
||||
}
|
||||
if (value.fillStyleType == MORPHFILLSTYLE.FOCAL_RADIAL_GRADIENT) {
|
||||
writeMORPHFOCALGRADIENT((MORPHFOCALGRADIENT) value.gradient, shapeNum);
|
||||
}
|
||||
|
||||
if ((value.fillStyleType == MORPHFILLSTYLE.REPEATING_BITMAP)
|
||||
|| (value.fillStyleType == MORPHFILLSTYLE.CLIPPED_BITMAP)
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash;
|
||||
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
@@ -67,18 +68,20 @@ public class ExportTest {
|
||||
@DataProvider(name = "swfFiles")
|
||||
public Object[][] createData() {
|
||||
File dir = new File(TESTDATADIR);
|
||||
File dir = new File(TESTDATADIR);
|
||||
if (!dir.exists()) {
|
||||
File[] files = new File[0];
|
||||
if (dir.exists()) {
|
||||
files = dir.listFiles(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.toLowerCase().endsWith(".swf");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
File[] files = dir.listFiles(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.toLowerCase().endsWith(".swf");
|
||||
}
|
||||
});
|
||||
Object[][] ret = new Object[files.length][1];
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
Object[][] ret = new Object[files.length + 2][1];
|
||||
ret[0][0] = new File(TESTDATADIR + File.separator + "../as2/as2.swf");
|
||||
ret[1][0] = new File(TESTDATADIR + File.separator + "../as3/as3.swf");
|
||||
for (int f = 0; f < files.length; f++) {
|
||||
ret[f + 2][0] = files[f];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ import com.jpexs.decompiler.flash.helpers.CodeFormatting;
|
||||
import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.collections.MyEntry;
|
||||
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.TagStub;
|
||||
import com.jpexs.decompiler.flash.tags.base.ASMSource;
|
||||
import com.jpexs.decompiler.graph.CompilationException;
|
||||
import com.jpexs.decompiler.graph.TranslateException;
|
||||
@@ -148,6 +150,27 @@ public class RecompileTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "provideFiles")
|
||||
public void testTagEditing(String filename) throws IOException, InterruptedException {
|
||||
try {
|
||||
SWF swf = new SWF(new BufferedInputStream(new FileInputStream(TESTDATADIR + File.separator + filename)), false);
|
||||
for (Tag tag : swf.tags) {
|
||||
if (!(tag instanceof TagStub)) {
|
||||
byte[] data = tag.getData();
|
||||
SWFInputStream tagDataStream = new SWFInputStream(swf, data, tag.getDataPos(), data.length);
|
||||
TagStub copy = new TagStub(swf, tag.getId(), "Unresolved", tag.getOriginalRange(), tagDataStream);
|
||||
copy.forceWriteAsLong = tag.forceWriteAsLong;
|
||||
Tag tag2 = SWFInputStream.resolveTag(copy, 0, false, true, false);
|
||||
if (tag2 instanceof TagStub) {
|
||||
fail("Recompile failed. Tag: " + tag.getId() + " " + tag.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
@DataProvider(name = "provideFiles")
|
||||
public Object[][] provideFiles() {
|
||||
File dir = new File(TESTDATADIR);
|
||||
|
||||
Reference in New Issue
Block a user