From 4a7c985ba117aa5e28074a1d99bceec655e98c77 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Tue, 14 Feb 2023 04:52:11 +0100 Subject: [PATCH] wip --- kubi-server/src/auth.rs | 6 ++++-- kubi-shared/src/networking/messages.rs | 13 ++++++++++++- kubi-udp/src/lib.rs | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/kubi-server/src/auth.rs b/kubi-server/src/auth.rs index eb2b634..5a376a0 100644 --- a/kubi-server/src/auth.rs +++ b/kubi-server/src/auth.rs @@ -35,10 +35,12 @@ pub fn authenticate_players( //Spawn the user // TODO - + //Approve the user server.0.send_message(*from, ServerToClientMessage::ServerHello { - init: InitData {} + init: InitData { + users: todo!() + } }).map_err(log_error).ok(); } } diff --git a/kubi-shared/src/networking/messages.rs b/kubi-shared/src/networking/messages.rs index 95b7b16..0b553c6 100644 --- a/kubi-shared/src/networking/messages.rs +++ b/kubi-shared/src/networking/messages.rs @@ -1,3 +1,5 @@ +use std::num::NonZeroUsize; + use bincode::{Encode, Decode}; use crate::chunk::BlockData; @@ -23,9 +25,18 @@ pub enum ClientToServerMessage { }, } +#[derive(Encode, Decode, Clone)] +pub struct UserInitData { + pub client_id: NonZeroUsize, //maybe use the proper type instead + pub username: String, + pub position: Vec3Arr, + pub velocity: Vec3Arr, + pub direction: QuatArr, +} + #[derive(Encode, Decode, Clone)] pub struct InitData { - + pub users: Vec } #[derive(Encode, Decode, Clone)] diff --git a/kubi-udp/src/lib.rs b/kubi-udp/src/lib.rs index ae5678c..82588e3 100644 --- a/kubi-udp/src/lib.rs +++ b/kubi-udp/src/lib.rs @@ -4,6 +4,7 @@ pub(crate) mod packet; pub(crate) mod common; pub use common::ClientId; pub use common::ClientIdRepr; +pub use common::MAX_CLIENTS; //pub(crate) trait Serializable: bincode::Encode + bincode::Decode {} pub(crate) const BINCODE_CONFIG: bincode::config::Configuration = bincode::config::standard()