This commit is contained in:
Garen Tyler 2022-04-19 08:27:22 -06:00
parent 9b760eb58f
commit 144ebbba1d
No known key found for this signature in database
GPG Key ID: E3BF83D66394FD92
4 changed files with 6 additions and 6 deletions

View File

@ -60,7 +60,7 @@ pub fn parse_varint(data: &[u8]) -> ParseResult<i32> {
return Err(ParseError::NotEnoughData);
}
output |= (((data[offset] & 0x7f) as i32) << bytes_read * 7) as i32;
output |= (((data[offset] & 0x7f) as i32) << (bytes_read * 7)) as i32;
bytes_read += 1;
if data[offset] & 0x80 != 0x80 {
break;

View File

@ -2,7 +2,7 @@ pub mod packets;
use crate::prelude::*;
pub use packets::Packet;
use std::time::{Duration, Instant};
use std::time::Instant;
use tokio::net::TcpStream;
#[derive(PartialEq, Copy, Clone, Debug)]
@ -49,7 +49,7 @@ impl NetworkClient {
}
Err(ref e) if e.kind() == tokio::io::ErrorKind::WouldBlock => break,
Err(e) => {
return Err(e.into());
return Err(e);
}
}
}

View File

@ -32,7 +32,7 @@ pub enum Packet {
impl Packet {
pub fn parse_body(
data: &[u8],
length: usize,
_length: usize,
id: usize,
state: NetworkClientState,
serverbound: bool,
@ -119,7 +119,7 @@ impl Packet {
"favicon": format!("data:image/png;base64,{}", radix64::STD_NO_PAD.encode(FAVICON.as_ref().unwrap())),
})),
),
CS01Pong { payload } => (0x01, serialize_long(payload.clone()).to_vec()),
CS01Pong { payload } => (0x01, serialize_long(*payload).to_vec()),
_ => unimplemented!(),
};
let mut id_and_body = serialize_varint(id as i32);

View File

@ -66,7 +66,7 @@ impl Server {
match client.read_packet() {
Ok(_) => {}
Err(ParseError::NotEnoughData) => break 'packet,
Err(e) => {}
Err(_) => {}
}
}
}