mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-22 11:58:21 -06:00
use bincode derive instead of serde due to potential issues
This commit is contained in:
parent
5c3062d13f
commit
1c0409a9cf
|
@ -8,8 +8,7 @@ edition = "2021"
|
|||
[dependencies]
|
||||
glam = { version = "0.22", features = ["debug-glam-assert", "fast-math", "serde"] }
|
||||
strum = { version = "0.24", features = ["derive"] }
|
||||
bincode = { version = "2.0.0-rc", default_features = false, features = ["std", "serde"] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
bincode = "2.0.0-rc"
|
||||
anyhow = "1.0"
|
||||
bracket-noise = "0.8"
|
||||
#laminar = "0.5.0"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use bincode::{Encode, Decode};
|
||||
use strum::EnumIter;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, EnumIter)]
|
||||
#[derive(Encode, Decode, Clone, Copy, Debug, PartialEq, Eq, EnumIter)]
|
||||
#[repr(u8)]
|
||||
pub enum Block {
|
||||
Air,
|
||||
|
|
|
@ -16,7 +16,7 @@ impl Client {
|
|||
})
|
||||
}
|
||||
pub fn send(&self, message: ClientToServerMessage) -> anyhow::Result<()> {
|
||||
let bytes = bincode::serde::encode_to_vec(message, BINCODE_CONFIG)?;
|
||||
let bytes = bincode::encode_to_vec(message, BINCODE_CONFIG)?;
|
||||
self.socket.send(&bytes)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
use glam::{Vec3, Quat};
|
||||
use serde::{Serialize, Deserialize};
|
||||
use bincode::{Encode, Decode};
|
||||
use crate::chunk::BlockData;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
type IVec3Arr = [i32; 3];
|
||||
type Vec3Arr = [f32; 3];
|
||||
type QuatArr = [f32; 3];
|
||||
|
||||
#[derive(Encode, Decode)]
|
||||
pub enum ClientToServerMessage {
|
||||
ClientHello {
|
||||
username: String,
|
||||
|
@ -10,12 +14,17 @@ pub enum ClientToServerMessage {
|
|||
PositionChanged {
|
||||
client_id: u8,
|
||||
secret: u32,
|
||||
position: Vec3,
|
||||
direction: Quat
|
||||
}
|
||||
position: Vec3Arr,
|
||||
direction: QuatArr,
|
||||
},
|
||||
ChunkRequest {
|
||||
client_id: u8,
|
||||
secret: u32,
|
||||
chunk: IVec3Arr,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Encode, Decode)]
|
||||
pub enum ServerToClientMessage {
|
||||
ServerHello {
|
||||
client_id: u8,
|
||||
|
@ -25,6 +34,12 @@ pub enum ServerToClientMessage {
|
|||
reason: String,
|
||||
},
|
||||
PlayerPositionChanged {
|
||||
|
||||
client_id: u8,
|
||||
position: Vec3Arr,
|
||||
direction: QuatArr,
|
||||
},
|
||||
ChunkResponse {
|
||||
chunk: IVec3Arr,
|
||||
data: BlockData
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue