mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-11-16 07:15:14 +01:00
337ca7f887
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing BungeeCord Changes: 70038c91 Revert "#2714: Remove unnecessary throws in ServerConnector" 39ef20b2 #2716: Don't attempt to send kick packet during handshake phase 74a6aa32 #2714: Remove unnecessary throws in ServerConnector c7984070 Misc dependency update
72 lines
2.8 KiB
Diff
72 lines
2.8 KiB
Diff
From 95eb27b9ffc5ed020a048f967eda6d224a4deb28 Mon Sep 17 00:00:00 2001
|
|
From: creeper123123321 <creeper123123321@gmail.com>
|
|
Date: Thu, 17 Jan 2019 03:25:59 +0000
|
|
Subject: [PATCH] Don't use a bytebuf for packet decoding
|
|
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java
|
|
index 25ee2027..743d65e4 100644
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java
|
|
@@ -17,8 +17,7 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
|
|
{
|
|
in.markReaderIndex();
|
|
|
|
- final byte[] buf = new byte[ 3 ];
|
|
- for ( int i = 0; i < buf.length; i++ )
|
|
+ for ( int i = 0; i < 3; i++ ) // Waterfall
|
|
{
|
|
if ( !in.isReadable() )
|
|
{
|
|
@@ -26,10 +25,13 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
|
|
return;
|
|
}
|
|
|
|
- buf[i] = in.readByte();
|
|
- if ( buf[i] >= 0 )
|
|
+ // Waterfall start
|
|
+ byte read = in.readByte();
|
|
+ if ( read >= 0 )
|
|
{
|
|
- int length = DefinedPacket.readVarInt( Unpooled.wrappedBuffer( buf ) );
|
|
+ in.resetReaderIndex();
|
|
+ int length = DefinedPacket.readVarInt( in );
|
|
+ // Waterfall end
|
|
if ( false && length == 0) // Waterfall - ignore
|
|
{
|
|
throw new CorruptedFrameException( "Empty Packet!" );
|
|
@@ -39,26 +41,11 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
|
|
{
|
|
in.resetReaderIndex();
|
|
return;
|
|
- } else
|
|
- {
|
|
- if ( in.hasMemoryAddress() )
|
|
- {
|
|
- out.add( in.slice( in.readerIndex(), length ).retain() );
|
|
- in.skipBytes( length );
|
|
- } else
|
|
- {
|
|
- if ( !DIRECT_WARNING )
|
|
- {
|
|
- DIRECT_WARNING = true;
|
|
- System.out.println( "Netty is not using direct IO buffers." );
|
|
- }
|
|
-
|
|
- // See https://github.com/SpigotMC/BungeeCord/issues/1717
|
|
- ByteBuf dst = ctx.alloc().directBuffer( length );
|
|
- in.readBytes( dst );
|
|
- out.add( dst );
|
|
- }
|
|
+ // Waterfall start
|
|
+ } else {
|
|
+ out.add(in.readRetainedSlice(length));
|
|
return;
|
|
+ // Waterfall end
|
|
}
|
|
}
|
|
}
|
|
--
|
|
2.24.0
|
|
|