diff --git a/protocol/src/main/kotlin/org/openrs2/protocol/js5/Js5ResponseDecoder.kt b/protocol/src/main/kotlin/org/openrs2/protocol/js5/Js5ResponseDecoder.kt index 888eb07c..19b06c40 100644 --- a/protocol/src/main/kotlin/org/openrs2/protocol/js5/Js5ResponseDecoder.kt +++ b/protocol/src/main/kotlin/org/openrs2/protocol/js5/Js5ResponseDecoder.kt @@ -62,7 +62,7 @@ public class Js5ResponseDecoder : ByteToMessageDecoder() { if (state == State.READ_DATA) { while (data.isWritable) { - val blockLen = min(511 - ((data.readableBytes() + 3) % 511), data.writableBytes()) + val blockLen = min(511 - ((data.readableBytes() + 2) % 511), data.writableBytes()) val last = data.writableBytes() <= blockLen val blockLenIncludingTrailer = if (last) { diff --git a/protocol/src/main/kotlin/org/openrs2/protocol/js5/Js5ResponseEncoder.kt b/protocol/src/main/kotlin/org/openrs2/protocol/js5/Js5ResponseEncoder.kt index d2650ef1..be7342e9 100644 --- a/protocol/src/main/kotlin/org/openrs2/protocol/js5/Js5ResponseEncoder.kt +++ b/protocol/src/main/kotlin/org/openrs2/protocol/js5/Js5ResponseEncoder.kt @@ -24,7 +24,7 @@ public object Js5ResponseEncoder : MessageToByteEncoder(Js5Response } out.writeByte(compression) - out.writeBytes(msg.data, min(msg.data.readableBytes(), 507)) + out.writeBytes(msg.data, min(msg.data.readableBytes(), 508)) while (msg.data.isReadable) { out.writeByte(0xFF) @@ -34,7 +34,7 @@ public object Js5ResponseEncoder : MessageToByteEncoder(Js5Response override fun allocateBuffer(ctx: ChannelHandlerContext, msg: Js5Response, preferDirect: Boolean): ByteBuf { val dataLen = msg.data.readableBytes() - val len = 3 + dataLen + (3 + dataLen) / 511 + val len = 3 + dataLen + (2 + dataLen) / 511 return if (preferDirect) { ctx.alloc().ioBuffer(len, len) diff --git a/protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5ResponseDecoderTest.kt b/protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5ResponseDecoderTest.kt index 007d42f8..3301b2a5 100644 --- a/protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5ResponseDecoderTest.kt +++ b/protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5ResponseDecoderTest.kt @@ -14,23 +14,23 @@ import kotlin.test.assertEquals object Js5ResponseDecoderTest { @Test fun testDecode() { - testDecode("508.dat", "508-prefetch.dat", true) - testDecode("508.dat", "508-urgent.dat", false) - testDecode("509.dat", "509-prefetch.dat", true) testDecode("509.dat", "509-urgent.dat", false) - testDecode("1019.dat", "1019-prefetch.dat", true) - testDecode("1019.dat", "1019-urgent.dat", false) + testDecode("510.dat", "510-prefetch.dat", true) + testDecode("510.dat", "510-urgent.dat", false) testDecode("1020.dat", "1020-prefetch.dat", true) testDecode("1020.dat", "1020-urgent.dat", false) - testDecode("1530.dat", "1530-prefetch.dat", true) - testDecode("1530.dat", "1530-urgent.dat", false) + testDecode("1021.dat", "1021-prefetch.dat", true) + testDecode("1021.dat", "1021-urgent.dat", false) testDecode("1531.dat", "1531-prefetch.dat", true) testDecode("1531.dat", "1531-urgent.dat", false) + + testDecode("1532.dat", "1532-prefetch.dat", true) + testDecode("1532.dat", "1532-urgent.dat", false) } @Test diff --git a/protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5ResponseEncoderTest.kt b/protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5ResponseEncoderTest.kt index 45671736..f559c98c 100644 --- a/protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5ResponseEncoderTest.kt +++ b/protocol/src/test/kotlin/org/openrs2/protocol/js5/Js5ResponseEncoderTest.kt @@ -12,23 +12,23 @@ import kotlin.test.assertEquals object Js5ResponseEncoderTest { @Test fun testEncode() { - testEncode("508.dat", "508-prefetch.dat", true) - testEncode("508.dat", "508-urgent.dat", false) - testEncode("509.dat", "509-prefetch.dat", true) testEncode("509.dat", "509-urgent.dat", false) - testEncode("1019.dat", "1019-prefetch.dat", true) - testEncode("1019.dat", "1019-urgent.dat", false) + testEncode("510.dat", "510-prefetch.dat", true) + testEncode("510.dat", "510-urgent.dat", false) testEncode("1020.dat", "1020-prefetch.dat", true) testEncode("1020.dat", "1020-urgent.dat", false) - testEncode("1530.dat", "1530-prefetch.dat", true) - testEncode("1530.dat", "1530-urgent.dat", false) + testEncode("1021.dat", "1021-prefetch.dat", true) + testEncode("1021.dat", "1021-urgent.dat", false) testEncode("1531.dat", "1531-prefetch.dat", true) testEncode("1531.dat", "1531-urgent.dat", false) + + testEncode("1532.dat", "1532-prefetch.dat", true) + testEncode("1532.dat", "1532-urgent.dat", false) } @Test diff --git a/protocol/src/test/resources/org/openrs2/protocol/js5/1020-prefetch.dat b/protocol/src/test/resources/org/openrs2/protocol/js5/1020-prefetch.dat index 7afdc6b3..1c134669 100644 Binary files a/protocol/src/test/resources/org/openrs2/protocol/js5/1020-prefetch.dat and b/protocol/src/test/resources/org/openrs2/protocol/js5/1020-prefetch.dat differ diff --git a/protocol/src/test/resources/org/openrs2/protocol/js5/1020-urgent.dat b/protocol/src/test/resources/org/openrs2/protocol/js5/1020-urgent.dat index 57aa6a81..5126a2fd 100644 Binary files a/protocol/src/test/resources/org/openrs2/protocol/js5/1020-urgent.dat and b/protocol/src/test/resources/org/openrs2/protocol/js5/1020-urgent.dat differ diff --git a/protocol/src/test/resources/org/openrs2/protocol/js5/1019-prefetch.dat b/protocol/src/test/resources/org/openrs2/protocol/js5/1021-prefetch.dat similarity index 81% rename from protocol/src/test/resources/org/openrs2/protocol/js5/1019-prefetch.dat rename to protocol/src/test/resources/org/openrs2/protocol/js5/1021-prefetch.dat index 5d2ee5ce..b1730c54 100644 Binary files a/protocol/src/test/resources/org/openrs2/protocol/js5/1019-prefetch.dat and b/protocol/src/test/resources/org/openrs2/protocol/js5/1021-prefetch.dat differ diff --git a/protocol/src/test/resources/org/openrs2/protocol/js5/1019-urgent.dat b/protocol/src/test/resources/org/openrs2/protocol/js5/1021-urgent.dat similarity index 81% rename from protocol/src/test/resources/org/openrs2/protocol/js5/1019-urgent.dat rename to protocol/src/test/resources/org/openrs2/protocol/js5/1021-urgent.dat index 5efce678..102e9283 100644 Binary files a/protocol/src/test/resources/org/openrs2/protocol/js5/1019-urgent.dat and b/protocol/src/test/resources/org/openrs2/protocol/js5/1021-urgent.dat differ diff --git a/protocol/src/test/resources/org/openrs2/protocol/js5/1019.dat b/protocol/src/test/resources/org/openrs2/protocol/js5/1021.dat similarity index 87% rename from protocol/src/test/resources/org/openrs2/protocol/js5/1019.dat rename to protocol/src/test/resources/org/openrs2/protocol/js5/1021.dat index a8a624b6..5c9754df 100644 Binary files a/protocol/src/test/resources/org/openrs2/protocol/js5/1019.dat and b/protocol/src/test/resources/org/openrs2/protocol/js5/1021.dat differ diff --git a/protocol/src/test/resources/org/openrs2/protocol/js5/1531-prefetch.dat b/protocol/src/test/resources/org/openrs2/protocol/js5/1531-prefetch.dat index fe8e66b4..0113c1a7 100644 Binary files a/protocol/src/test/resources/org/openrs2/protocol/js5/1531-prefetch.dat and b/protocol/src/test/resources/org/openrs2/protocol/js5/1531-prefetch.dat differ diff --git a/protocol/src/test/resources/org/openrs2/protocol/js5/1531-urgent.dat b/protocol/src/test/resources/org/openrs2/protocol/js5/1531-urgent.dat index 09993f12..7778ed81 100644 Binary files a/protocol/src/test/resources/org/openrs2/protocol/js5/1531-urgent.dat and b/protocol/src/test/resources/org/openrs2/protocol/js5/1531-urgent.dat differ diff --git a/protocol/src/test/resources/org/openrs2/protocol/js5/1530-urgent.dat b/protocol/src/test/resources/org/openrs2/protocol/js5/1532-prefetch.dat similarity index 83% rename from protocol/src/test/resources/org/openrs2/protocol/js5/1530-urgent.dat rename to protocol/src/test/resources/org/openrs2/protocol/js5/1532-prefetch.dat index 22c4d38a..323db5b1 100644 Binary files a/protocol/src/test/resources/org/openrs2/protocol/js5/1530-urgent.dat and b/protocol/src/test/resources/org/openrs2/protocol/js5/1532-prefetch.dat differ diff --git a/protocol/src/test/resources/org/openrs2/protocol/js5/1530-prefetch.dat b/protocol/src/test/resources/org/openrs2/protocol/js5/1532-urgent.dat similarity index 83% rename from protocol/src/test/resources/org/openrs2/protocol/js5/1530-prefetch.dat rename to protocol/src/test/resources/org/openrs2/protocol/js5/1532-urgent.dat index eee39ab8..77ea56c5 100644 Binary files a/protocol/src/test/resources/org/openrs2/protocol/js5/1530-prefetch.dat and b/protocol/src/test/resources/org/openrs2/protocol/js5/1532-urgent.dat differ diff --git a/protocol/src/test/resources/org/openrs2/protocol/js5/1530.dat b/protocol/src/test/resources/org/openrs2/protocol/js5/1532.dat similarity index 91% rename from protocol/src/test/resources/org/openrs2/protocol/js5/1530.dat rename to protocol/src/test/resources/org/openrs2/protocol/js5/1532.dat index af31cb74..0b2b379c 100644 Binary files a/protocol/src/test/resources/org/openrs2/protocol/js5/1530.dat and b/protocol/src/test/resources/org/openrs2/protocol/js5/1532.dat differ diff --git a/protocol/src/test/resources/org/openrs2/protocol/js5/509-prefetch.dat b/protocol/src/test/resources/org/openrs2/protocol/js5/509-prefetch.dat index 8b7b5f6e..bc2732b2 100644 Binary files a/protocol/src/test/resources/org/openrs2/protocol/js5/509-prefetch.dat and b/protocol/src/test/resources/org/openrs2/protocol/js5/509-prefetch.dat differ diff --git a/protocol/src/test/resources/org/openrs2/protocol/js5/509-urgent.dat b/protocol/src/test/resources/org/openrs2/protocol/js5/509-urgent.dat index d97c7967..aa4e75b7 100644 Binary files a/protocol/src/test/resources/org/openrs2/protocol/js5/509-urgent.dat and b/protocol/src/test/resources/org/openrs2/protocol/js5/509-urgent.dat differ diff --git a/protocol/src/test/resources/org/openrs2/protocol/js5/508-urgent.dat b/protocol/src/test/resources/org/openrs2/protocol/js5/510-prefetch.dat similarity index 74% rename from protocol/src/test/resources/org/openrs2/protocol/js5/508-urgent.dat rename to protocol/src/test/resources/org/openrs2/protocol/js5/510-prefetch.dat index 040ac8bd..d98054b5 100644 Binary files a/protocol/src/test/resources/org/openrs2/protocol/js5/508-urgent.dat and b/protocol/src/test/resources/org/openrs2/protocol/js5/510-prefetch.dat differ diff --git a/protocol/src/test/resources/org/openrs2/protocol/js5/508-prefetch.dat b/protocol/src/test/resources/org/openrs2/protocol/js5/510-urgent.dat similarity index 74% rename from protocol/src/test/resources/org/openrs2/protocol/js5/508-prefetch.dat rename to protocol/src/test/resources/org/openrs2/protocol/js5/510-urgent.dat index baed755c..0e93725c 100644 Binary files a/protocol/src/test/resources/org/openrs2/protocol/js5/508-prefetch.dat and b/protocol/src/test/resources/org/openrs2/protocol/js5/510-urgent.dat differ diff --git a/protocol/src/test/resources/org/openrs2/protocol/js5/508.dat b/protocol/src/test/resources/org/openrs2/protocol/js5/510.dat similarity index 75% rename from protocol/src/test/resources/org/openrs2/protocol/js5/508.dat rename to protocol/src/test/resources/org/openrs2/protocol/js5/510.dat index 6500e76c..592509f2 100644 Binary files a/protocol/src/test/resources/org/openrs2/protocol/js5/508.dat and b/protocol/src/test/resources/org/openrs2/protocol/js5/510.dat differ diff --git a/protocol/src/test/resources/org/openrs2/protocol/js5/invalid-block-trailer.dat b/protocol/src/test/resources/org/openrs2/protocol/js5/invalid-block-trailer.dat index 2450d775..85b0c15d 100644 Binary files a/protocol/src/test/resources/org/openrs2/protocol/js5/invalid-block-trailer.dat and b/protocol/src/test/resources/org/openrs2/protocol/js5/invalid-block-trailer.dat differ