fix chunks not being able to be read

This commit is contained in:
mat 2022-09-04 21:24:10 -05:00
parent 2557d70576
commit 99fcad7bc4
7 changed files with 26 additions and 19 deletions

8
Cargo.lock generated
View file

@ -1333,18 +1333,18 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.32" version = "1.0.34"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994" checksum = "8c1b05ca9d106ba7d2e31a9dab4a64e7be2cce415321966ea3132c49a656e252"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.32" version = "1.0.34"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21" checksum = "e8f2591983642de85c921015f3f070c665a197ed69e417af436115e3a1407487"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View file

@ -11,7 +11,7 @@ version = "0.1.0"
azalea-buf-macros = {path = "./azalea-buf-macros", version = "^0.1.0"} azalea-buf-macros = {path = "./azalea-buf-macros", version = "^0.1.0"}
byteorder = "^1.4.3" byteorder = "^1.4.3"
serde_json = {version = "^1.0", optional = true} serde_json = {version = "^1.0", optional = true}
thiserror = "^1.0.31" thiserror = "^1.0.34"
tokio = {version = "^1.19.2", features = ["io-util", "net", "macros"]} tokio = {version = "^1.19.2", features = ["io-util", "net", "macros"]}
uuid = "^1.1.2" uuid = "^1.1.2"

View file

@ -1,6 +1,9 @@
//! Utilities for reading and writing for the Minecraft protocol //! Utilities for reading and writing for the Minecraft protocol
#![feature(min_specialization)] #![feature(min_specialization)]
// these two are necessary for thiserror backtraces
#![feature(error_generic_member_access)]
#![feature(provide_any)]
mod definitions; mod definitions;
mod read; mod read;

View file

@ -1,6 +1,6 @@
use super::{UnsizedByteArray, MAX_STRING_LENGTH}; use super::{UnsizedByteArray, MAX_STRING_LENGTH};
use byteorder::{ReadBytesExt, BE}; use byteorder::{ReadBytesExt, BE};
use std::{collections::HashMap, hash::Hash, io::Read}; use std::{backtrace::Backtrace, collections::HashMap, hash::Hash, io::Read};
use thiserror::Error; use thiserror::Error;
use tokio::io::{AsyncRead, AsyncReadExt}; use tokio::io::{AsyncRead, AsyncReadExt};
@ -15,7 +15,11 @@ pub enum BufReadError {
#[error("The received encoded string buffer length is longer than maximum allowed ({length} > {max_length})")] #[error("The received encoded string buffer length is longer than maximum allowed ({length} > {max_length})")]
StringLengthTooLong { length: u32, max_length: u32 }, StringLengthTooLong { length: u32, max_length: u32 },
#[error("{0}")] #[error("{0}")]
Io(#[from] std::io::Error), Io(
#[from]
#[backtrace]
std::io::Error,
),
#[error("Invalid UTF-8")] #[error("Invalid UTF-8")]
InvalidUtf8, InvalidUtf8,
#[error("Unexpected enum variant {id}")] #[error("Unexpected enum variant {id}")]
@ -207,7 +211,7 @@ impl McBufVarReadable for u32 {
impl McBufReadable for u16 { impl McBufReadable for u16 {
fn read_from(buf: &mut impl Read) -> Result<Self, BufReadError> { fn read_from(buf: &mut impl Read) -> Result<Self, BufReadError> {
i32::read_from(buf).map(|i| i as u16) i16::read_from(buf).map(|i| i as u16)
} }
} }

View file

@ -7,13 +7,13 @@ version = "0.1.0"
[dependencies] [dependencies]
anyhow = "1.0.59" anyhow = "1.0.59"
azalea-auth = { path = "../azalea-auth" } azalea-auth = {path = "../azalea-auth"}
azalea-core = { path = "../azalea-core" } azalea-block = {path = "../azalea-block"}
azalea-crypto = { path = "../azalea-crypto" } azalea-core = {path = "../azalea-core"}
azalea-physics = { path = "../azalea-physics" } azalea-crypto = {path = "../azalea-crypto"}
azalea-protocol = { path = "../azalea-protocol" } azalea-physics = {path = "../azalea-physics"}
azalea-world = { path = "../azalea-world" } azalea-protocol = {path = "../azalea-protocol"}
azalea-block = { path = "../azalea-block" } azalea-world = {path = "../azalea-world"}
thiserror = "^1.0.32" thiserror = "^1.0.34"
tokio = { version = "^1.19.2", features = ["sync"] } tokio = {version = "^1.19.2", features = ["sync"]}
uuid = "^1.1.2" uuid = "^1.1.2"

View file

@ -22,7 +22,7 @@ flate2 = "1.0.23"
packet-macros = {path = "./packet-macros"} packet-macros = {path = "./packet-macros"}
serde = {version = "1.0.130", features = ["serde_derive"]} serde = {version = "1.0.130", features = ["serde_derive"]}
serde_json = "^1.0.72" serde_json = "^1.0.72"
thiserror = "^1.0.32" thiserror = "^1.0.34"
tokio = {version = "^1.19.2", features = ["io-util", "net", "macros"]} tokio = {version = "^1.19.2", features = ["io-util", "net", "macros"]}
tokio-util = "^0.6.9" tokio-util = "^0.6.9"
trust-dns-resolver = "^0.20.3" trust-dns-resolver = "^0.20.3"

View file

@ -13,7 +13,7 @@ azalea-core = {path = "../azalea-core"}
azalea-nbt = {path = "../azalea-nbt"} azalea-nbt = {path = "../azalea-nbt"}
log = "0.4.17" log = "0.4.17"
nohash-hasher = "0.2.0" nohash-hasher = "0.2.0"
thiserror = "1.0.32" thiserror = "1.0.34"
uuid = "1.1.2" uuid = "1.1.2"
[profile.release] [profile.release]