Fixed an error in D2 file type

This commit is contained in:
Collin Smith 2019-12-06 23:47:57 -08:00
parent d3529540ca
commit d6c76d2add
2 changed files with 5 additions and 13 deletions

View File

@ -98,20 +98,15 @@ public class D2 {
public String cof;
public int framesPerDir;
public short speed;
public short unk1;
public short zero;
public int speed;
public byte data[];
Entry(InputStream in) throws IOException {
ByteBuffer buffer = ByteBuffer.wrap(IOUtils.readFully(in, SIZE)).order(ByteOrder.LITTLE_ENDIAN);
cof = BufferUtils.readString2(buffer, 8);
framesPerDir = buffer.getInt();
speed = (short) (buffer.get() & 0xFF);
unk1 = (short) (buffer.get() & 0xFF);
zero = buffer.getShort();
speed = buffer.getInt();
data = BufferUtils.readBytes(buffer, 144);
assert zero == 0;
assert !buffer.hasRemaining();
}
@ -121,8 +116,6 @@ public class D2 {
.append("cof", cof)
.append("framesPerDir", framesPerDir)
.append("speed", speed)
.append("unk1", unk1)
.append("zero", zero)
//.append("data", data)
.build();
}

View File

@ -13,6 +13,7 @@ import com.riiablo.mpq.MPQFileHandleResolver;
import com.riiablo.util.DebugUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.tuple.Pair;
import java.io.PrintWriter;
@ -79,7 +80,6 @@ public class D2Finder extends ApplicationAdapter {
writer.println("cof"
+ '\t' + "framesPerDir"
+ '\t' + "speed"
+ '\t' + "unk1"
+ '\t' + "data"
);
for (D2.Block block : lib.blocks) {
@ -87,9 +87,8 @@ public class D2Finder extends ApplicationAdapter {
for (D2.Entry entry : block.entries) {
writer.println(entry.cof
+ '\t' + entry.framesPerDir
+ '\t' + (entry.speed & 0xFF)
+ '\t' + (entry.unk1 & 0xFF)
+ '\t' + DebugUtils.toByteArray(entry.data)
+ '\t' + entry.speed
+ '\t' + (ArrayUtils.isSorted(entry.data) ? "" : DebugUtils.toByteArray(entry.data))
);
}
}