mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-25 21:16:10 +00:00
grouping index,
more universal saving entries
This commit is contained in:
@@ -178,6 +178,11 @@ public class IggyFile implements StructureInterface {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
/*
|
||||
String indexFileName = "d:\\Dropbox\\jpexs-laptop\\iggi\\extraxtdir_orig\\index4_type0.bin";
|
||||
IggyIndexParser.parseIndex(true, new TemporaryDataStream(Helper.readFile(indexFileName)), new ArrayList<>(), new ArrayList<>());
|
||||
|
||||
System.exit(0);*/
|
||||
String inFileName = "d:\\Dropbox\\jpexs-laptop\\iggi\\lib_loc_english_font.iggy";
|
||||
String outFileName = "d:\\Dropbox\\jpexs-laptop\\iggi\\lib_loc_english_font2.iggy";
|
||||
|
||||
@@ -643,7 +648,25 @@ public class IggyFile implements StructureInterface {
|
||||
return iggySwfs.get(swfIndex).getHdr().getFrameRate();
|
||||
}
|
||||
|
||||
//WIP
|
||||
/**
|
||||
* Removes entries of type INDEX.There can be more than one INDEX,
|
||||
* continuous. This removes all ot them.
|
||||
*/
|
||||
public void removeIndexEntries() {
|
||||
long offsetsChange = 0;
|
||||
final int ENTRY_SIZE = 16;
|
||||
for (int i = 0; i < subFileEntries.size(); i++) {
|
||||
IggySubFileEntry entry = subFileEntries.get(i);
|
||||
entry.offset += offsetsChange;
|
||||
if (entry.type == IggySubFileEntry.TYPE_INDEX) {
|
||||
offsetsChange = offsetsChange - entry.size - ENTRY_SIZE;
|
||||
subFileEntriesData.remove(i);
|
||||
subFileEntries.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean replaceSwf(int targetSwfIndex, IggySwf iggySwf) throws IOException {
|
||||
|
||||
if (targetSwfIndex < 0 || targetSwfIndex >= getSwfCount()) {
|
||||
@@ -668,30 +691,22 @@ public class IggyFile implements StructureInterface {
|
||||
for (int i = 0; i < subFileEntries.size(); i++) {
|
||||
IggySubFileEntry entry = subFileEntries.get(i);
|
||||
entry.offset += offsetsChange;
|
||||
if (entry.type == IggySubFileEntry.TYPE_INDEX) {
|
||||
if (swfIndex == targetSwfIndex) {
|
||||
long oldSize = entry.size;
|
||||
long newSize = replacementIndexData.length;
|
||||
offsetsChange = offsetsChange + (newSize - oldSize);
|
||||
entry.size = newSize;
|
||||
entry.size2 = newSize;
|
||||
subFileEntriesData.set(i, replacementIndexData);
|
||||
}
|
||||
swfIndex++;
|
||||
}
|
||||
if (entry.type == IggySubFileEntry.TYPE_FLASH) {
|
||||
if (swfIndex == targetSwfIndex) {
|
||||
long oldSize = entry.size;
|
||||
long newSize = replacementData.length;
|
||||
offsetsChange = offsetsChange + (newSize - oldSize);
|
||||
entry.size = newSize;
|
||||
entry.size2 = newSize;
|
||||
//entries after this one will have modified offsets
|
||||
offsetsChange = offsetsChange + (newSize - oldSize); //entries after this one will have modified offsets
|
||||
subFileEntriesData.set(i, replacementData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
removeIndexEntries();
|
||||
IggySubFileEntry indexEntry = new IggySubFileEntry(IggySubFileEntry.TYPE_INDEX, replacementIndexData.length, replacementIndexData.length, 0 /*offset will be set automatically*/);
|
||||
subFileEntries.add(indexEntry);
|
||||
subFileEntriesData.add(replacementIndexData);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -724,15 +739,22 @@ public class IggyFile implements StructureInterface {
|
||||
@Override
|
||||
public void writeToDataStream(WriteDataStreamInterface stream) throws IOException {
|
||||
header.writeToDataStream(stream);
|
||||
for (IggySubFileEntry entry : subFileEntries) {
|
||||
entry.writeToDataStream(stream);
|
||||
}
|
||||
|
||||
long startOffset = IggyHeader.STRUCT_SIZE + IggySubFileEntry.STRUCTURE_SIZE * subFileEntries.size();
|
||||
long currentOffset = startOffset;
|
||||
|
||||
for (int i = 0; i < subFileEntries.size(); i++) {
|
||||
IggySubFileEntry entry = subFileEntries.get(i);
|
||||
entry.offset = currentOffset;
|
||||
currentOffset += entry.size;
|
||||
entry.writeToDataStream(stream);
|
||||
}
|
||||
|
||||
for (int i = 0; i < subFileEntries.size(); i++) {
|
||||
byte[] entryData = subFileEntriesData.get(i);
|
||||
stream.seek(entry.offset, SeekMode.SET);
|
||||
stream.writeBytes(entryData);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ import java.io.IOException;
|
||||
*/
|
||||
public class IggyHeader implements StructureInterface {
|
||||
|
||||
public static int STRUCT_SIZE = 32;
|
||||
|
||||
public static long MAGIC = 0xED0A6749;
|
||||
|
||||
//Must be 0xED0A6749
|
||||
|
||||
@@ -17,6 +17,8 @@ import java.util.List;
|
||||
*/
|
||||
public class IggySubFileEntry implements StructureInterface {
|
||||
|
||||
public static final int STRUCTURE_SIZE = 16;
|
||||
|
||||
public static final int TYPE_INDEX = 0;
|
||||
public static final int TYPE_FLASH = 1;
|
||||
|
||||
|
||||
@@ -34,8 +34,6 @@ public class IggySwf implements StructureInterface {
|
||||
|
||||
private IggyFlashHeader64 hdr;
|
||||
|
||||
private byte[] allFontBytes;
|
||||
|
||||
public IggySwf(ReadDataStreamInterface stream) throws IOException {
|
||||
readFromDataStream(stream);
|
||||
}
|
||||
@@ -92,10 +90,6 @@ public class IggySwf implements StructureInterface {
|
||||
public void readFromDataStream(ReadDataStreamInterface s) throws IOException {
|
||||
this.hdr = new IggyFlashHeader64(s);
|
||||
//Save all font bytes to buffer for later easy modification
|
||||
long curPos = s.position();
|
||||
long maxPos = hdr.getFontEndAddress();
|
||||
allFontBytes = s.readBytes((int) (maxPos - curPos));
|
||||
s.seek(curPos, SeekMode.SET);
|
||||
//here is offset[0] - 184
|
||||
name = s.readWChar();
|
||||
//here is offset[1] - 230
|
||||
|
||||
@@ -22,7 +22,7 @@ public class IggyIndexParser {
|
||||
|
||||
static {
|
||||
try {
|
||||
pw = new PrintWriter("d:\\Dropbox\\jpexs-laptop\\iggi\\extraxtdir_orig\\index2.txt");
|
||||
pw = new PrintWriter("d:\\Dropbox\\jpexs-laptop\\iggi\\extraxtdir_orig\\index2b.txt");
|
||||
} catch (FileNotFoundException ex) {
|
||||
Logger.getLogger(IggyIndexParser.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
@@ -43,7 +43,8 @@ public class IggyIndexParser {
|
||||
pw.close();
|
||||
}
|
||||
});
|
||||
}*/
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* Parser for index data. It creates table of indices and table of offsets
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user