mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 00:38:21 +00:00
Merge pull request #284 from CharlesVaneenoo/remove_useless_if
Remove useless if in GamePacketencoder
This commit is contained in:
@@ -31,14 +31,11 @@ public final class GamePacketEncoder extends MessageToByteEncoder<GamePacket> {
|
|||||||
protected void encode(ChannelHandlerContext ctx, GamePacket packet, ByteBuf out) throws Exception {
|
protected void encode(ChannelHandlerContext ctx, GamePacket packet, ByteBuf out) throws Exception {
|
||||||
PacketType type = packet.getType();
|
PacketType type = packet.getType();
|
||||||
int payloadLength = packet.getLength();
|
int payloadLength = packet.getLength();
|
||||||
if (type == PacketType.VARIABLE_BYTE) {
|
|
||||||
if (payloadLength >= 256) {
|
if (type == PacketType.VARIABLE_BYTE && payloadLength >= 256) {
|
||||||
throw new Exception("Payload too long for variable byte packet.");
|
throw new Exception("Payload too long for variable byte packet.");
|
||||||
}
|
} else if (type == PacketType.VARIABLE_SHORT && payloadLength >= 65_536) {
|
||||||
} else if (type == PacketType.VARIABLE_SHORT) {
|
throw new Exception("Payload too long for variable short packet.");
|
||||||
if (payloadLength >= 65_536) {
|
|
||||||
throw new Exception("Payload too long for variable short packet.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out.writeByte(packet.getOpcode() + random.nextInt() & 0xFF);
|
out.writeByte(packet.getOpcode() + random.nextInt() & 0xFF);
|
||||||
|
|||||||
Reference in New Issue
Block a user