mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-04 16:49:11 +00:00
Fix bug with reading longs.
This commit is contained in:
@@ -74,32 +74,32 @@ public final class GamePacketReader {
|
||||
for (int i = length - 1; i >= 0; i--) {
|
||||
if (i == 0 && transformation != DataTransformation.NONE) {
|
||||
if (transformation == DataTransformation.ADD) {
|
||||
longValue |= buffer.readByte() - 128 & 0xFF;
|
||||
longValue |= buffer.readByte() - 128 & 0xFFL;
|
||||
} else if (transformation == DataTransformation.NEGATE) {
|
||||
longValue |= -buffer.readByte() & 0xFF;
|
||||
longValue |= -buffer.readByte() & 0xFFL;
|
||||
} else if (transformation == DataTransformation.SUBTRACT) {
|
||||
longValue |= 128 - buffer.readByte() & 0xFF;
|
||||
longValue |= 128 - buffer.readByte() & 0xFFL;
|
||||
} else {
|
||||
throw new IllegalArgumentException("unknown transformation");
|
||||
}
|
||||
} else {
|
||||
longValue |= (buffer.readByte() & 0xFF) << i * 8;
|
||||
longValue |= (buffer.readByte() & 0xFFL) << i * 8;
|
||||
}
|
||||
}
|
||||
} else if (order == DataOrder.LITTLE) {
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (i == 0 && transformation != DataTransformation.NONE) {
|
||||
if (transformation == DataTransformation.ADD) {
|
||||
longValue |= buffer.readByte() - 128 & 0xFF;
|
||||
longValue |= buffer.readByte() - 128 & 0xFFL;
|
||||
} else if (transformation == DataTransformation.NEGATE) {
|
||||
longValue |= -buffer.readByte() & 0xFF;
|
||||
longValue |= -buffer.readByte() & 0xFFL;
|
||||
} else if (transformation == DataTransformation.SUBTRACT) {
|
||||
longValue |= 128 - buffer.readByte() & 0xFF;
|
||||
longValue |= 128 - buffer.readByte() & 0xFFL;
|
||||
} else {
|
||||
throw new IllegalArgumentException("unknown transformation");
|
||||
}
|
||||
} else {
|
||||
longValue |= (buffer.readByte() & 0xFF) << i * 8;
|
||||
longValue |= (buffer.readByte() & 0xFFL) << i * 8;
|
||||
}
|
||||
}
|
||||
} else if (order == DataOrder.MIDDLE) {
|
||||
|
||||
Reference in New Issue
Block a user