From 153b5b45e42a031e9ee7dd2764840b07ce1cb47b Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 30 Apr 2022 02:10:21 -0500 Subject: misc fixes --- .../game/clientbound_declare_commands_packet.rs | 2 +- azalea-protocol/src/read.rs | 24 ++++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'azalea-protocol/src') diff --git a/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs b/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs index 33b710d5..afaa7fdd 100755 --- a/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs +++ b/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs @@ -76,7 +76,7 @@ impl McBufWritable for BrigadierNumber { if self.max.is_some() { flags |= 0x02; } - buf.write_i8(flags); + buf.write_byte(flags)?; if let Some(min) = &self.min { min.write_into(buf)?; } diff --git a/azalea-protocol/src/read.rs b/azalea-protocol/src/read.rs index b249e3d7..51224499 100755 --- a/azalea-protocol/src/read.rs +++ b/azalea-protocol/src/read.rs @@ -1,4 +1,8 @@ -use std::{cell::Cell, pin::Pin}; +use std::{ + cell::Cell, + pin::Pin, + task::{Context, Poll}, +}; use crate::{connect::PacketFlow, mc_buf::Readable, packets::ProtocolPacket}; use async_compression::tokio::bufread::ZlibDecoder; @@ -35,13 +39,13 @@ where { // Packet ID let packet_id = stream.read_varint().await?; - Ok(P::read(packet_id.try_into().unwrap(), flow, stream).await?) + P::read(packet_id.try_into().unwrap(), flow, stream).await } // this is always true in multiplayer, false in singleplayer static VALIDATE_DECOMPRESSED: bool = true; -pub static MAXIMUM_UNCOMPRESSED_LENGTH: u32 = 8388608; +pub static MAXIMUM_UNCOMPRESSED_LENGTH: u32 = 2097152; async fn compression_decoder( stream: &mut R, @@ -103,28 +107,26 @@ where impl AsyncRead for EncryptedStream<'_, R> where - R: AsyncRead + std::marker::Unpin + std::marker::Send, + R: AsyncRead + Unpin + Send, { fn poll_read( mut self: Pin<&mut Self>, - cx: &mut std::task::Context<'_>, + cx: &mut Context<'_>, buf: &mut tokio::io::ReadBuf<'_>, - ) -> std::task::Poll> { + ) -> Poll> { // i hate this let polled = self.as_mut().stream.as_mut().poll_read(cx, buf); match polled { - std::task::Poll::Ready(r) => { + Poll::Ready(r) => { if let Some(cipher) = self.as_mut().cipher.get_mut() { azalea_auth::encryption::decrypt_packet(cipher, buf.initialized_mut()); } match r { - Ok(()) => std::task::Poll::Ready(Ok(())), + Ok(()) => Poll::Ready(Ok(())), Err(e) => panic!("{:?}", e), } } - std::task::Poll::Pending => { - return std::task::Poll::Pending; - } + Poll::Pending => Poll::Pending, } } } -- cgit v1.2.3