change server stuff

This commit is contained in:
griffi-gh 2023-03-08 17:27:53 +01:00
parent aeba49f03a
commit 56d9044203
8 changed files with 21 additions and 6 deletions

3
Cargo.lock generated
View file

@ -961,10 +961,13 @@ dependencies = [
"kubi-shared",
"log",
"nohash-hasher",
"postcard",
"rand",
"rayon",
"serde",
"shipyard",
"toml",
"uflow",
]
[[package]]

View file

@ -9,7 +9,7 @@ kubi-shared = { path = "../kubi-shared" }
kubi-logging = { path = "../kubi-logging" }
log = "*"
shipyard = { git = "https://github.com/leudz/shipyard", rev = "eb189f66" }
serde = "1.0"
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] }
toml = "0.7"
glam = { version = "0.23", features = ["debug-glam-assert", "fast-math"] }
hashbrown = "0.13"
@ -17,7 +17,10 @@ nohash-hasher = "0.2.0"
anyhow = "1.0"
rayon = "1.6"
flume = "0.10"
rand = "0.8"
uflow = "0.7"
postcard = { version = "1.0", features = ["alloc"] }
[features]
default = []
unstable = ["glam/core-simd"]
nightly = ["rand/nightly", "rand/simd_support", "serde/unstable", "glam/core-simd", "kubi-shared/nightly"]

View file

@ -1,11 +1,12 @@
use shipyard::{Component, EntityId};
use hashbrown::HashMap;
use nohash_hasher::BuildNoHashHasher;
use kubi_shared::networking::client::ClientId;
#[derive(Component)]
pub struct Client(ClientId);
pub struct ClientMap(HashMap<ClientId, EntityId, BuildNoHashHasher<ClientIdRepr>>);
pub struct ClientMap(HashMap<ClientId, EntityId, BuildNoHashHasher<ClientId>>);
impl ClientMap {
pub fn new() -> Self {
Self(HashMap::with_hasher(BuildNoHashHasher::default()))

View file

@ -1,5 +1,6 @@
use shipyard::{AllStoragesView, Unique, UniqueView, UniqueViewMut};
use kubi_shared::networking::messages::{ClientToServerMessage, ServerToClientMessage};
use uflow::server::Server;
use std::time::Duration;
use crate::config::ConfigTable;

View file

@ -1,7 +1,10 @@
use glam::IVec3;
use hashbrown::HashSet;
use nohash_hasher::BuildNoHashHasher;
use kubi_shared::chunk::BlockData;
use kubi_shared::{
chunk::BlockData,
networking::client::ClientId
};
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ChunkState {
@ -14,7 +17,7 @@ pub struct Chunk {
pub position: IVec3,
pub state: ChunkState,
pub blocks: Option<BlockData>,
pub subscriptions: HashSet<ClientId, BuildNoHashHasher<ClientIdRepr>>,
pub subscriptions: HashSet<ClientId, BuildNoHashHasher<ClientId>>,
}
impl Chunk {
pub fn new(position: IVec3) -> Self {

View file

@ -19,4 +19,4 @@ rand_xoshiro = "0.6"
[features]
default = []
nightly = ["rand/nightly", "rand/simd_support", "serde/unstable"]
nightly = ["rand/nightly", "rand/simd_support", "serde/unstable", "glam/core-simd"]

View file

@ -1,2 +1,3 @@
pub mod messages;
pub mod state;
pub mod client;

View file

@ -0,0 +1,3 @@
pub type ClientId = u16;
pub type ClientKey = u16;