mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-03-06 07:30:41 +07:00
Removed readU8 and replaced with equivalent appropriate substitutions
This commit is contained in:
parent
0050720249
commit
65a8dee1eb
@ -401,7 +401,7 @@ public class DCC extends com.riiablo.codec.DC {
|
||||
}
|
||||
|
||||
if (tmp == 0) {
|
||||
pixelMask = dir.pixelMaskBitStream.readU8(4);
|
||||
pixelMask = dir.pixelMaskBitStream.readU7(4);
|
||||
assert pixelMask >= 0;
|
||||
} else {
|
||||
nextCell = true;
|
||||
@ -424,11 +424,11 @@ public class DCC extends com.riiablo.codec.DC {
|
||||
decodedPixels = 0;
|
||||
for (int i = 0; i < pixels; i++) {
|
||||
if (encodingType > 0) {
|
||||
readPixel[i] = dir.rawPixelCodesBitStream.readU8(8);
|
||||
readPixel[i] = dir.rawPixelCodesBitStream.readU31(8);
|
||||
} else {
|
||||
readPixel[i] = lastPixel;
|
||||
do {
|
||||
pixelDisplacement = dir.pixelCodeAndDisplacementBitStream.readU8(4);
|
||||
pixelDisplacement = dir.pixelCodeAndDisplacementBitStream.readU7(4);
|
||||
readPixel[i] += pixelDisplacement;
|
||||
} while (pixelDisplacement == 0xF);
|
||||
}
|
||||
@ -651,7 +651,7 @@ public class DCC extends com.riiablo.codec.DC {
|
||||
|
||||
for (int y = 0; y < cell.h; y++) {
|
||||
for (int x = 0; x < cell.w; x++) {
|
||||
int pix = dir.pixelCodeAndDisplacementBitStream.readU8(bits);
|
||||
int pix = dir.pixelCodeAndDisplacementBitStream.readU7(bits);
|
||||
cell.bmp.setPixel(x, y, pbe.val[pix]);
|
||||
}
|
||||
}
|
||||
@ -755,14 +755,14 @@ public class DCC extends com.riiablo.codec.DC {
|
||||
Direction read(InputStream in, int size, Frame[] frames) throws IOException {
|
||||
BitStream bitStream = new BitStream(IOUtils.readFully(in, size), size * Byte.SIZE);
|
||||
outsizeCoded = bitStream.readUnsigned(32);
|
||||
compressionFlags = (byte) bitStream.readU8(2);
|
||||
variable0Bits = (byte) bitStream.readU8(4);
|
||||
widthBits = (byte) bitStream.readU8(4);
|
||||
heightBits = (byte) bitStream.readU8(4);
|
||||
xOffsetBits = (byte) bitStream.readU8(4);
|
||||
yOffsetBits = (byte) bitStream.readU8(4);
|
||||
optionalBytesBits = (byte) bitStream.readU8(4);
|
||||
codedBytesBits = (byte) bitStream.readU8(4);
|
||||
compressionFlags = (byte) bitStream.readRaw(2);
|
||||
variable0Bits = bitStream.readU7(4);
|
||||
widthBits = bitStream.readU7(4);
|
||||
heightBits = bitStream.readU7(4);
|
||||
xOffsetBits = bitStream.readU7(4);
|
||||
yOffsetBits = bitStream.readU7(4);
|
||||
optionalBytesBits = bitStream.readU7(4);
|
||||
codedBytesBits = bitStream.readU7(4);
|
||||
|
||||
box = new BBox();
|
||||
box.xMin = box.yMin = Integer.MAX_VALUE;
|
||||
|
@ -159,11 +159,6 @@ public class BitStream {
|
||||
return readUnsigned(bits);
|
||||
}
|
||||
|
||||
public int readU8(int bits) {
|
||||
assert bits <= Byte.SIZE;
|
||||
return (int) readUnsigned(bits);
|
||||
}
|
||||
|
||||
public long readSigned(int bits) {
|
||||
if (bits == Long.SIZE) {
|
||||
return readRaw(bits);
|
||||
@ -199,7 +194,7 @@ public class BitStream {
|
||||
assert bitsPerChar <= Byte.SIZE;
|
||||
byte[] b = new byte[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
b[i] = (byte) readU8(bitsPerChar);
|
||||
b[i] = (byte) readUnsigned(bitsPerChar);
|
||||
}
|
||||
return BufferUtils.readString(ByteBuffer.wrap(b), len);
|
||||
}
|
||||
@ -207,7 +202,7 @@ public class BitStream {
|
||||
public String readString2(int len, int bitsPerChar) {
|
||||
assert bitsPerChar <= Byte.SIZE;
|
||||
byte[] b = new byte[len];
|
||||
for (int i = 0; i < len && (b[i] = (byte) readU8(bitsPerChar)) != '\0'; i++);
|
||||
for (int i = 0; i < len && (b[i] = (byte) readUnsigned(bitsPerChar)) != '\0'; i++);
|
||||
return BufferUtils.readString(ByteBuffer.wrap(b), len);
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class ItemSerializer {
|
||||
item.reset();
|
||||
item.flags = (int) bitStream.readRaw(32);
|
||||
Log.tracef(log, "flags: 0x%08X [%s]", item.flags, item.getFlagsString());
|
||||
item.version = bitStream.readU8(Byte.SIZE);
|
||||
item.version = bitStream.readU31(8);
|
||||
log.trace("version: {}", item.version);
|
||||
bitStream.skip(2); // Unknown use -- safe to skip
|
||||
item.location = Location.valueOf(bitStream.readU7(3));
|
||||
|
Loading…
Reference in New Issue
Block a user