2020-10-16 19:37:28 +00:00
|
|
|
use common::msg::{ClientInGame, ClientType};
|
2019-10-15 04:06:14 +00:00
|
|
|
use hashbrown::HashSet;
|
2020-10-17 09:36:44 +00:00
|
|
|
use network::Participant;
|
2019-10-06 17:35:47 +00:00
|
|
|
use specs::{Component, FlaggedStorage};
|
2020-07-06 05:56:02 +00:00
|
|
|
use specs_idvs::IdvStorage;
|
2019-10-06 17:35:47 +00:00
|
|
|
use vek::*;
|
2019-03-03 22:02:38 +00:00
|
|
|
|
|
|
|
pub struct Client {
|
Redo Network Frontend.
Rather than having a single Stream to handle ALL data, seperate into multiple streams:
- Ping Stream, for seperate PINGS
- Register Stream, only used till the client is registered, then no longer used!
- General Stream, used for msg that can occur always
- NotInGame Stream, used for everything NOT ingame, e.g. Character Screen
- InGame Stream, used for all GAME data, players, terrain, entities, etc...
This version does compile, and gets the client registered (with auth too) but doesnt get to the char screen yet.
This fixes also the ignoring messages problem we had, as we are not sending data to the register stream!
This fixes also the problem that the server had to sleep for the Stream Creation, as the Server is now creating the streams and client has to sleep.
2020-10-04 18:20:18 +00:00
|
|
|
pub registered: bool,
|
|
|
|
pub client_type: ClientType,
|
2020-10-12 08:18:28 +00:00
|
|
|
pub in_game: Option<ClientInGame>,
|
2020-10-07 11:59:14 +00:00
|
|
|
pub participant: Option<Participant>,
|
2019-03-03 22:02:38 +00:00
|
|
|
pub last_ping: f64,
|
2019-12-31 08:10:51 +00:00
|
|
|
pub login_msg_sent: bool,
|
2020-10-22 23:45:19 +00:00
|
|
|
pub terminate_msg_recv: bool,
|
2019-03-03 22:02:38 +00:00
|
|
|
}
|
2019-03-04 19:50:26 +00:00
|
|
|
|
2019-10-15 04:06:14 +00:00
|
|
|
impl Component for Client {
|
2020-07-06 05:56:02 +00:00
|
|
|
type Storage = FlaggedStorage<Self, IdvStorage<Self>>;
|
2019-10-15 04:06:14 +00:00
|
|
|
}
|
|
|
|
|
2019-10-06 17:35:47 +00:00
|
|
|
// Distance from fuzzy_chunk before snapping to current chunk
|
|
|
|
pub const CHUNK_FUZZ: u32 = 2;
|
|
|
|
// Distance out of the range of a region before removing it from subscriptions
|
|
|
|
pub const REGION_FUZZ: u32 = 16;
|
|
|
|
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
pub struct RegionSubscription {
|
|
|
|
pub fuzzy_chunk: Vec2<i32>,
|
|
|
|
pub regions: HashSet<Vec2<i32>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Component for RegionSubscription {
|
2020-07-06 05:56:02 +00:00
|
|
|
type Storage = FlaggedStorage<Self, IdvStorage<Self>>;
|
2019-10-06 17:35:47 +00:00
|
|
|
}
|