#3527: Switching between servers causes a decoding error
This commit is contained in:
parent
f3397b3003
commit
3cb7a12738
@ -31,12 +31,12 @@ public class LegacyDecoder extends ByteToMessageDecoder
|
||||
|
||||
if ( packetID == 0xFE )
|
||||
{
|
||||
out.add( new PacketWrapper( new LegacyPing( in.isReadable() && in.readUnsignedByte() == 0x01 ), Unpooled.EMPTY_BUFFER ) );
|
||||
out.add( new PacketWrapper( new LegacyPing( in.isReadable() && in.readUnsignedByte() == 0x01 ), Unpooled.EMPTY_BUFFER, Protocol.STATUS ) );
|
||||
return;
|
||||
} else if ( packetID == 0x02 && in.isReadable() )
|
||||
{
|
||||
in.skipBytes( in.readableBytes() );
|
||||
out.add( new PacketWrapper( new LegacyHandshake(), Unpooled.EMPTY_BUFFER ) );
|
||||
out.add( new PacketWrapper( new LegacyHandshake(), Unpooled.EMPTY_BUFFER, Protocol.STATUS ) );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
|
||||
in.skipBytes( in.readableBytes() );
|
||||
}
|
||||
|
||||
out.add( new PacketWrapper( packet, slice ) );
|
||||
out.add( new PacketWrapper( packet, slice, protocol ) );
|
||||
slice = null;
|
||||
} finally
|
||||
{
|
||||
|
@ -10,6 +10,7 @@ public class PacketWrapper
|
||||
|
||||
public final DefinedPacket packet;
|
||||
public final ByteBuf buf;
|
||||
public final Protocol protocol;
|
||||
@Setter
|
||||
private boolean released;
|
||||
|
||||
|
@ -136,8 +136,15 @@ public class UpstreamBridge extends PacketHandler
|
||||
{
|
||||
if ( con.getServer() != null )
|
||||
{
|
||||
Protocol serverEncode = con.getServer().getCh().getEncodeProtocol();
|
||||
// #3527: May still have old packets from client in game state when switching server to configuration state - discard those
|
||||
if ( packet.protocol != serverEncode )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityMap rewrite = con.getEntityRewrite();
|
||||
if ( rewrite != null && con.getServer().getCh().getEncodeProtocol() == Protocol.GAME )
|
||||
if ( rewrite != null && serverEncode == Protocol.GAME )
|
||||
{
|
||||
rewrite.rewriteServerbound( packet.buf, con.getClientEntityId(), con.getServerEntityId(), con.getPendingConnection().getVersion() );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user