From 99fcad7bc4133c32627fe2e4751faad05b9b4ef1 Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 4 Sep 2022 21:24:10 -0500 Subject: [PATCH] fix chunks not being able to be read --- Cargo.lock | 8 ++++---- azalea-buf/Cargo.toml | 2 +- azalea-buf/src/lib.rs | 3 +++ azalea-buf/src/read.rs | 10 +++++++--- azalea-client/Cargo.toml | 18 +++++++++--------- azalea-protocol/Cargo.toml | 2 +- azalea-world/Cargo.toml | 2 +- 7 files changed, 26 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e6a7d150..ed2026b2 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -1333,18 +1333,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.32" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994" +checksum = "8c1b05ca9d106ba7d2e31a9dab4a64e7be2cce415321966ea3132c49a656e252" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.32" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21" +checksum = "e8f2591983642de85c921015f3f070c665a197ed69e417af436115e3a1407487" dependencies = [ "proc-macro2", "quote", diff --git a/azalea-buf/Cargo.toml b/azalea-buf/Cargo.toml index 6f21e697..3bdb2477 100644 --- a/azalea-buf/Cargo.toml +++ b/azalea-buf/Cargo.toml @@ -11,7 +11,7 @@ version = "0.1.0" azalea-buf-macros = {path = "./azalea-buf-macros", version = "^0.1.0"} byteorder = "^1.4.3" 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"]} uuid = "^1.1.2" diff --git a/azalea-buf/src/lib.rs b/azalea-buf/src/lib.rs index 24392f6e..b8daa325 100644 --- a/azalea-buf/src/lib.rs +++ b/azalea-buf/src/lib.rs @@ -1,6 +1,9 @@ //! Utilities for reading and writing for the Minecraft protocol #![feature(min_specialization)] +// these two are necessary for thiserror backtraces +#![feature(error_generic_member_access)] +#![feature(provide_any)] mod definitions; mod read; diff --git a/azalea-buf/src/read.rs b/azalea-buf/src/read.rs index 82fd4f2f..4fea4b73 100644 --- a/azalea-buf/src/read.rs +++ b/azalea-buf/src/read.rs @@ -1,6 +1,6 @@ use super::{UnsizedByteArray, MAX_STRING_LENGTH}; 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 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})")] StringLengthTooLong { length: u32, max_length: u32 }, #[error("{0}")] - Io(#[from] std::io::Error), + Io( + #[from] + #[backtrace] + std::io::Error, + ), #[error("Invalid UTF-8")] InvalidUtf8, #[error("Unexpected enum variant {id}")] @@ -207,7 +211,7 @@ impl McBufVarReadable for u32 { impl McBufReadable for u16 { fn read_from(buf: &mut impl Read) -> Result { - i32::read_from(buf).map(|i| i as u16) + i16::read_from(buf).map(|i| i as u16) } } diff --git a/azalea-client/Cargo.toml b/azalea-client/Cargo.toml index 9fa32b75..8efa09b3 100755 --- a/azalea-client/Cargo.toml +++ b/azalea-client/Cargo.toml @@ -7,13 +7,13 @@ version = "0.1.0" [dependencies] anyhow = "1.0.59" -azalea-auth = { path = "../azalea-auth" } -azalea-core = { path = "../azalea-core" } -azalea-crypto = { path = "../azalea-crypto" } -azalea-physics = { path = "../azalea-physics" } -azalea-protocol = { path = "../azalea-protocol" } -azalea-world = { path = "../azalea-world" } -azalea-block = { path = "../azalea-block" } -thiserror = "^1.0.32" -tokio = { version = "^1.19.2", features = ["sync"] } +azalea-auth = {path = "../azalea-auth"} +azalea-block = {path = "../azalea-block"} +azalea-core = {path = "../azalea-core"} +azalea-crypto = {path = "../azalea-crypto"} +azalea-physics = {path = "../azalea-physics"} +azalea-protocol = {path = "../azalea-protocol"} +azalea-world = {path = "../azalea-world"} +thiserror = "^1.0.34" +tokio = {version = "^1.19.2", features = ["sync"]} uuid = "^1.1.2" diff --git a/azalea-protocol/Cargo.toml b/azalea-protocol/Cargo.toml index ab9b322f..f3e4cd74 100755 --- a/azalea-protocol/Cargo.toml +++ b/azalea-protocol/Cargo.toml @@ -22,7 +22,7 @@ flate2 = "1.0.23" packet-macros = {path = "./packet-macros"} serde = {version = "1.0.130", features = ["serde_derive"]} serde_json = "^1.0.72" -thiserror = "^1.0.32" +thiserror = "^1.0.34" tokio = {version = "^1.19.2", features = ["io-util", "net", "macros"]} tokio-util = "^0.6.9" trust-dns-resolver = "^0.20.3" diff --git a/azalea-world/Cargo.toml b/azalea-world/Cargo.toml index 524616e6..8f88757d 100644 --- a/azalea-world/Cargo.toml +++ b/azalea-world/Cargo.toml @@ -13,7 +13,7 @@ azalea-core = {path = "../azalea-core"} azalea-nbt = {path = "../azalea-nbt"} log = "0.4.17" nohash-hasher = "0.2.0" -thiserror = "1.0.32" +thiserror = "1.0.34" uuid = "1.1.2" [profile.release]