This commit is contained in:
griffi-gh 2023-03-09 04:29:21 +01:00
parent 321e69f976
commit 9cf4e81818
3 changed files with 5 additions and 4 deletions

View file

@ -20,7 +20,7 @@ flume = "0.10"
rand = "0.8"
uflow = "0.7"
postcard = { version = "1.0", features = ["alloc"] }
lz4_flex = { version = "0.10", default-features = false, features = ["checked-decode"] }
lz4_flex = { version = "0.10", default-features = false, features = ["checked-decode", "std"] }
[features]
default = []

View file

@ -22,7 +22,7 @@ gilrs = { version = "0.10", default_features = false, features = ["xinput"] }
uflow = "0.7"
postcard = { version = "1.0", features = ["alloc"] }
serde_json = { version = "1.0", optional = true }
lz4_flex = { version = "0.10", default-features = false, features = ["checked-decode"] }
lz4_flex = { version = "0.10", default-features = false, features = ["checked-decode", "std"] }
[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3" }

View file

@ -113,7 +113,7 @@ fn check_server_hello_response(
//TODO multithreaded decompression
fn decompress_chunk_packet(data: &Box<[u8]>) -> Result<ServerToClientMessage> {
let data_ref = &data[1..];
let decompressed = decompress_size_prepended(data_ref).map_err(|x| println!("{x}")).ok().context("Decompress failed")?;
let decompressed = decompress_size_prepended(data_ref)?;
let deserialized = postcard::from_bytes(&decompressed).ok().context("Deserialization failed")?;
Ok(deserialized)
}
@ -126,9 +126,10 @@ fn inject_network_responses_into_manager_queue(
for event in events.iter() {
if event.is_message_of_type::<S_CHUNK_RESPONSE>() {
let NetworkEvent(ClientEvent::Receive(data)) = &event else { unreachable!() };
let packet = decompress_chunk_packet(data).expect("Chunk decode failed");
let ServerToClientMessage::ChunkResponse {
chunk, data, queued
} = decompress_chunk_packet(data).expect("Chunk decode failed") else { unreachable!() };
} = packet else { unreachable!() };
manager.add_sussy_response(ChunkTaskResponse::LoadedChunk {
position: chunk,
chunk_data: data,