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

View File

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