fix naming, replace NotInGame with CharacterScreen

This commit is contained in:
Marcel Märtens 2020-10-06 13:15:20 +02:00
parent 8b40f81ee2
commit e8452fafc6
9 changed files with 86 additions and 80 deletions

View File

@ -25,11 +25,11 @@ use common::{
}, },
event::{EventBus, LocalEvent}, event::{EventBus, LocalEvent},
msg::{ msg::{
validate_chat_msg, ChatMsgValidationError, ClientGeneralMsg, ClientInGameMsg, ClientIngame, validate_chat_msg, ChatMsgValidationError, ClientCharacterScreenMsg, ClientGeneralMsg,
ClientNotInGameMsg, ClientRegisterMsg, ClientType, DisconnectReason, InviteAnswer, ClientInGameMsg, ClientIngame, ClientRegisterMsg, ClientType, DisconnectReason,
Notification, PingMsg, PlayerInfo, PlayerListUpdate, RegisterError, ServerGeneralMsg, InviteAnswer, Notification, PingMsg, PlayerInfo, PlayerListUpdate, RegisterError,
ServerInGameMsg, ServerInfo, ServerInitMsg, ServerNotInGameMsg, ServerRegisterAnswerMsg, ServerCharacterScreenMsg, ServerGeneralMsg, ServerInGameMsg, ServerInfo, ServerInitMsg,
MAX_BYTES_CHAT_MSG, ServerRegisterAnswerMsg, MAX_BYTES_CHAT_MSG,
}, },
outcome::Outcome, outcome::Outcome,
recipe::RecipeBook, recipe::RecipeBook,
@ -113,11 +113,11 @@ pub struct Client {
_network: Network, _network: Network,
participant: Option<Participant>, participant: Option<Participant>,
singleton_stream: Stream, general_stream: Stream,
ping_stream: Stream, ping_stream: Stream,
register_stream: Stream, register_stream: Stream,
character_screen_stream: Stream,
in_game_stream: Stream, in_game_stream: Stream,
not_in_game_stream: Stream,
client_timeout: Duration, client_timeout: Duration,
last_server_ping: f64, last_server_ping: f64,
@ -161,8 +161,8 @@ impl Client {
let stream = block_on(participant.opened())?; let stream = block_on(participant.opened())?;
let mut ping_stream = block_on(participant.opened())?; let mut ping_stream = block_on(participant.opened())?;
let mut register_stream = block_on(participant.opened())?; let mut register_stream = block_on(participant.opened())?;
let character_screen_stream = block_on(participant.opened())?;
let in_game_stream = block_on(participant.opened())?; let in_game_stream = block_on(participant.opened())?;
let not_in_game_stream = block_on(participant.opened())?;
register_stream.send(ClientType::Game)?; register_stream.send(ClientType::Game)?;
let server_info: ServerInfo = block_on(register_stream.recv())?; let server_info: ServerInfo = block_on(register_stream.recv())?;
@ -397,10 +397,10 @@ impl Client {
_network: network, _network: network,
participant: Some(participant), participant: Some(participant),
singleton_stream: stream, general_stream: stream,
ping_stream, ping_stream,
register_stream, register_stream,
not_in_game_stream, character_screen_stream,
in_game_stream, in_game_stream,
client_timeout, client_timeout,
@ -462,8 +462,8 @@ impl Client {
/// Request a state transition to `ClientState::Character`. /// Request a state transition to `ClientState::Character`.
pub fn request_character(&mut self, character_id: CharacterId) { pub fn request_character(&mut self, character_id: CharacterId) {
self.not_in_game_stream self.character_screen_stream
.send(ClientNotInGameMsg::Character(character_id)) .send(ClientCharacterScreenMsg::Character(character_id))
.unwrap(); .unwrap();
//Assume we are in_game unless server tells us otherwise //Assume we are in_game unless server tells us otherwise
@ -475,31 +475,31 @@ impl Client {
/// Load the current players character list /// Load the current players character list
pub fn load_character_list(&mut self) { pub fn load_character_list(&mut self) {
self.character_list.loading = true; self.character_list.loading = true;
self.not_in_game_stream self.character_screen_stream
.send(ClientNotInGameMsg::RequestCharacterList) .send(ClientCharacterScreenMsg::RequestCharacterList)
.unwrap(); .unwrap();
} }
/// New character creation /// New character creation
pub fn create_character(&mut self, alias: String, tool: Option<String>, body: comp::Body) { pub fn create_character(&mut self, alias: String, tool: Option<String>, body: comp::Body) {
self.character_list.loading = true; self.character_list.loading = true;
self.not_in_game_stream self.character_screen_stream
.send(ClientNotInGameMsg::CreateCharacter { alias, tool, body }) .send(ClientCharacterScreenMsg::CreateCharacter { alias, tool, body })
.unwrap(); .unwrap();
} }
/// Character deletion /// Character deletion
pub fn delete_character(&mut self, character_id: CharacterId) { pub fn delete_character(&mut self, character_id: CharacterId) {
self.character_list.loading = true; self.character_list.loading = true;
self.not_in_game_stream self.character_screen_stream
.send(ClientNotInGameMsg::DeleteCharacter(character_id)) .send(ClientCharacterScreenMsg::DeleteCharacter(character_id))
.unwrap(); .unwrap();
} }
/// Send disconnect message to the server /// Send disconnect message to the server
pub fn request_logout(&mut self) { pub fn request_logout(&mut self) {
debug!("Requesting logout from server"); debug!("Requesting logout from server");
if let Err(e) = self.singleton_stream.send(ClientGeneralMsg::Disconnect) { if let Err(e) = self.general_stream.send(ClientGeneralMsg::Disconnect) {
error!( error!(
?e, ?e,
"Couldn't send disconnect package to server, did server close already?" "Couldn't send disconnect package to server, did server close already?"
@ -840,7 +840,7 @@ impl Client {
pub fn send_chat(&mut self, message: String) { pub fn send_chat(&mut self, message: String) {
match validate_chat_msg(&message) { match validate_chat_msg(&message) {
Ok(()) => self Ok(()) => self
.singleton_stream .general_stream
.send(ClientGeneralMsg::ChatMsg(message)) .send(ClientGeneralMsg::ChatMsg(message))
.unwrap(), .unwrap(),
Err(ChatMsgValidationError::TooLong) => tracing::warn!( Err(ChatMsgValidationError::TooLong) => tracing::warn!(
@ -1116,12 +1116,12 @@ impl Client {
DisconnectReason::Requested => { DisconnectReason::Requested => {
debug!("finally sending ClientMsg::Terminate"); debug!("finally sending ClientMsg::Terminate");
frontend_events.push(Event::Disconnect); frontend_events.push(Event::Disconnect);
self.singleton_stream.send(ClientGeneralMsg::Terminate)?; self.general_stream.send(ClientGeneralMsg::Terminate)?;
}, },
DisconnectReason::Kicked(reason) => { DisconnectReason::Kicked(reason) => {
debug!("sending ClientMsg::Terminate because we got kicked"); debug!("sending ClientMsg::Terminate because we got kicked");
frontend_events.push(Event::Kicked(reason)); frontend_events.push(Event::Kicked(reason));
self.singleton_stream.send(ClientGeneralMsg::Terminate)?; self.general_stream.send(ClientGeneralMsg::Terminate)?;
}, },
}, },
ServerGeneralMsg::PlayerListUpdate(PlayerListUpdate::Init(list)) => { ServerGeneralMsg::PlayerListUpdate(PlayerListUpdate::Init(list)) => {
@ -1407,23 +1407,26 @@ impl Client {
Ok(()) Ok(())
} }
fn handle_server_not_in_game_msg(&mut self, msg: ServerNotInGameMsg) -> Result<(), Error> { fn handle_server_character_screen_msg(
&mut self,
msg: ServerCharacterScreenMsg,
) -> Result<(), Error> {
match msg { match msg {
ServerNotInGameMsg::CharacterListUpdate(character_list) => { ServerCharacterScreenMsg::CharacterListUpdate(character_list) => {
self.character_list.characters = character_list; self.character_list.characters = character_list;
self.character_list.loading = false; self.character_list.loading = false;
}, },
ServerNotInGameMsg::CharacterActionError(error) => { ServerCharacterScreenMsg::CharacterActionError(error) => {
warn!("CharacterActionError: {:?}.", error); warn!("CharacterActionError: {:?}.", error);
self.character_list.error = Some(error); self.character_list.error = Some(error);
}, },
ServerNotInGameMsg::CharacterDataLoadError(error) => { ServerCharacterScreenMsg::CharacterDataLoadError(error) => {
trace!("Handling join error by server"); trace!("Handling join error by server");
self.client_ingame = None; self.client_ingame = None;
self.clean_state(); self.clean_state();
self.character_list.error = Some(error); self.character_list.error = Some(error);
}, },
ServerNotInGameMsg::CharacterSuccess => { ServerCharacterScreenMsg::CharacterSuccess => {
debug!("client is now in ingame state on server"); debug!("client is now in ingame state on server");
if let Some(vd) = self.view_distance { if let Some(vd) = self.view_distance {
self.set_view_distance(vd); self.set_view_distance(vd);
@ -1461,9 +1464,9 @@ impl Client {
) -> Result<(), Error> { ) -> Result<(), Error> {
loop { loop {
let (m1, m2, m3, m4) = select!( let (m1, m2, m3, m4) = select!(
msg = self.singleton_stream.recv().fuse() => (Some(msg), None, None, None), msg = self.general_stream.recv().fuse() => (Some(msg), None, None, None),
msg = self.ping_stream.recv().fuse() => (None, Some(msg), None, None), msg = self.ping_stream.recv().fuse() => (None, Some(msg), None, None),
msg = self.not_in_game_stream.recv().fuse() => (None, None, Some(msg), None), msg = self.character_screen_stream.recv().fuse() => (None, None, Some(msg), None),
msg = self.in_game_stream.recv().fuse() => (None, None, None, Some(msg)), msg = self.in_game_stream.recv().fuse() => (None, None, None, Some(msg)),
); );
*cnt += 1; *cnt += 1;
@ -1474,7 +1477,7 @@ impl Client {
self.handle_ping_msg(msg?)?; self.handle_ping_msg(msg?)?;
} }
if let Some(msg) = m3 { if let Some(msg) = m3 {
self.handle_server_not_in_game_msg(msg?)?; self.handle_server_character_screen_msg(msg?)?;
} }
if let Some(msg) = m4 { if let Some(msg) = m4 {
self.handle_server_in_game_msg(frontend_events, msg?)?; self.handle_server_in_game_msg(frontend_events, msg?)?;
@ -1807,7 +1810,7 @@ impl Client {
impl Drop for Client { impl Drop for Client {
fn drop(&mut self) { fn drop(&mut self) {
trace!("Dropping client"); trace!("Dropping client");
if let Err(e) = self.singleton_stream.send(ClientGeneralMsg::Disconnect) { if let Err(e) = self.general_stream.send(ClientGeneralMsg::Disconnect) {
warn!( warn!(
?e, ?e,
"Error during drop of client, couldn't send disconnect package, is the connection \ "Error during drop of client, couldn't send disconnect package, is the connection \

View File

@ -23,9 +23,9 @@ pub struct ClientRegisterMsg {
pub token_or_username: String, pub token_or_username: String,
} }
//messages send by clients only valid when NOT ingame //messages send by clients only valid when in character screen
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum ClientNotInGameMsg { pub enum ClientCharacterScreenMsg {
RequestCharacterList, RequestCharacterList,
CreateCharacter { CreateCharacter {
alias: String, alias: String,
@ -37,7 +37,7 @@ pub enum ClientNotInGameMsg {
Spectate, Spectate,
} }
//messages send by clients only valid when ingame //messages send by clients only valid when in game (with a character)
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum ClientInGameMsg { pub enum ClientInGameMsg {
ControllerInputs(comp::ControllerInputs), ControllerInputs(comp::ControllerInputs),

View File

@ -5,13 +5,13 @@ pub mod server;
// Reexports // Reexports
pub use self::{ pub use self::{
client::{ client::{
ClientGeneralMsg, ClientInGameMsg, ClientNotInGameMsg, ClientRegisterMsg, ClientType, ClientCharacterScreenMsg, ClientGeneralMsg, ClientInGameMsg, ClientRegisterMsg, ClientType,
}, },
ecs_packet::EcsCompPacket, ecs_packet::EcsCompPacket,
server::{ server::{
CharacterInfo, DisconnectReason, InviteAnswer, Notification, PlayerInfo, PlayerListUpdate, CharacterInfo, DisconnectReason, InviteAnswer, Notification, PlayerInfo, PlayerListUpdate,
RegisterError, ServerGeneralMsg, ServerInGameMsg, ServerInfo, ServerInitMsg, RegisterError, ServerCharacterScreenMsg, ServerGeneralMsg, ServerInGameMsg, ServerInfo,
ServerNotInGameMsg, ServerRegisterAnswerMsg, ServerInitMsg, ServerRegisterAnswerMsg,
}, },
}; };
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -209,9 +209,9 @@ pub enum ServerInitMsg {
pub type ServerRegisterAnswerMsg = Result<(), RegisterError>; pub type ServerRegisterAnswerMsg = Result<(), RegisterError>;
//Messages only allowed while client ingame //Messages only allowed while client in character screen
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ServerNotInGameMsg { pub enum ServerCharacterScreenMsg {
/// An error occurred while loading character data /// An error occurred while loading character data
CharacterDataLoadError(String), CharacterDataLoadError(String),
/// A list of characters belonging to the a authenticated player was sent /// A list of characters belonging to the a authenticated player was sent
@ -221,7 +221,7 @@ pub enum ServerNotInGameMsg {
CharacterSuccess, CharacterSuccess,
} }
//Messages only allowed while client ingame //Messages only allowed while client is in game (with a character)
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ServerInGameMsg { pub enum ServerInGameMsg {
GroupUpdate(comp::group::ChangeNotification<sync::Uid>), GroupUpdate(comp::group::ChangeNotification<sync::Uid>),

View File

@ -1,7 +1,7 @@
use crate::error::Error; use crate::error::Error;
use common::msg::{ use common::msg::{
ClientGeneralMsg, ClientInGameMsg, ClientIngame, ClientNotInGameMsg, ClientType, PingMsg, ClientCharacterScreenMsg, ClientGeneralMsg, ClientInGameMsg, ClientIngame, ClientType, PingMsg,
ServerGeneralMsg, ServerInGameMsg, ServerInitMsg, ServerNotInGameMsg, ServerCharacterScreenMsg, ServerGeneralMsg, ServerInGameMsg, ServerInitMsg,
}; };
use hashbrown::HashSet; use hashbrown::HashSet;
use network::{MessageBuffer, Participant, Stream}; use network::{MessageBuffer, Participant, Stream};
@ -23,8 +23,8 @@ pub struct Client {
pub singleton_stream: Stream, pub singleton_stream: Stream,
pub ping_stream: Stream, pub ping_stream: Stream,
pub register_stream: Stream, pub register_stream: Stream,
pub character_screen_stream: Stream,
pub in_game_stream: Stream, pub in_game_stream: Stream,
pub not_in_game_stream: Stream,
pub network_error: AtomicBool, pub network_error: AtomicBool,
pub last_ping: f64, pub last_ping: f64,
pub login_msg_sent: bool, pub login_msg_sent: bool,
@ -65,8 +65,8 @@ impl Client {
Self::internal_send(&self.network_error, &mut self.in_game_stream, msg); Self::internal_send(&self.network_error, &mut self.in_game_stream, msg);
} }
pub fn send_not_in_game(&mut self, msg: ServerNotInGameMsg) { pub fn send_character_screen(&mut self, msg: ServerCharacterScreenMsg) {
Self::internal_send(&self.network_error, &mut self.not_in_game_stream, msg); Self::internal_send(&self.network_error, &mut self.character_screen_stream, msg);
} }
pub fn send_ping(&mut self, msg: PingMsg) { pub fn send_ping(&mut self, msg: PingMsg) {
@ -103,8 +103,8 @@ impl Client {
Self::internal_recv(&self.network_error, &mut self.in_game_stream).await Self::internal_recv(&self.network_error, &mut self.in_game_stream).await
} }
pub async fn recv_not_in_game_msg(&mut self) -> Result<ClientNotInGameMsg, Error> { pub async fn recv_character_screen_msg(&mut self) -> Result<ClientCharacterScreenMsg, Error> {
Self::internal_recv(&self.network_error, &mut self.not_in_game_stream).await Self::internal_recv(&self.network_error, &mut self.character_screen_stream).await
} }
pub async fn recv_ping_msg(&mut self) -> Result<PingMsg, Error> { pub async fn recv_ping_msg(&mut self) -> Result<PingMsg, Error> {

View File

@ -110,8 +110,8 @@ impl ConnectionHandler {
let general_stream = participant.open(10, reliablec).await?; let general_stream = participant.open(10, reliablec).await?;
let ping_stream = participant.open(5, reliable).await?; let ping_stream = participant.open(5, reliable).await?;
let mut register_stream = participant.open(10, reliablec).await?; let mut register_stream = participant.open(10, reliablec).await?;
let character_screen_stream = participant.open(10, reliablec).await?;
let in_game_stream = participant.open(10, reliablec).await?; let in_game_stream = participant.open(10, reliablec).await?;
let not_in_game_stream = participant.open(10, reliablec).await?;
let server_data = receiver.recv()?; let server_data = receiver.recv()?;
@ -138,7 +138,7 @@ impl ConnectionHandler {
ping_stream, ping_stream,
register_stream, register_stream,
in_game_stream, in_game_stream,
not_in_game_stream, character_screen_stream,
network_error: std::sync::atomic::AtomicBool::new(false), network_error: std::sync::atomic::AtomicBool::new(false),
last_ping: server_data.time, last_ping: server_data.time,
login_msg_sent: false, login_msg_sent: false,

View File

@ -47,8 +47,8 @@ use common::{
comp::{self, ChatType}, comp::{self, ChatType},
event::{EventBus, ServerEvent}, event::{EventBus, ServerEvent},
msg::{ msg::{
server::WorldMapMsg, ClientType, DisconnectReason, ServerGeneralMsg, ServerInGameMsg, server::WorldMapMsg, ClientType, DisconnectReason, ServerCharacterScreenMsg,
ServerInfo, ServerInitMsg, ServerNotInGameMsg, ServerGeneralMsg, ServerInGameMsg, ServerInfo, ServerInitMsg,
}, },
outcome::Outcome, outcome::Outcome,
recipe::default_recipe_book, recipe::default_recipe_book,
@ -525,13 +525,13 @@ impl Server {
.messages() .messages()
.for_each(|query_result| match query_result.result { .for_each(|query_result| match query_result.result {
CharacterLoaderResponseType::CharacterList(result) => match result { CharacterLoaderResponseType::CharacterList(result) => match result {
Ok(character_list_data) => self.notify_not_in_game_client( Ok(character_list_data) => self.notify_character_screen_client(
query_result.entity, query_result.entity,
ServerNotInGameMsg::CharacterListUpdate(character_list_data), ServerCharacterScreenMsg::CharacterListUpdate(character_list_data),
), ),
Err(error) => self.notify_not_in_game_client( Err(error) => self.notify_character_screen_client(
query_result.entity, query_result.entity,
ServerNotInGameMsg::CharacterActionError(error.to_string()), ServerCharacterScreenMsg::CharacterActionError(error.to_string()),
), ),
}, },
CharacterLoaderResponseType::CharacterData(result) => { CharacterLoaderResponseType::CharacterData(result) => {
@ -544,9 +544,9 @@ impl Server {
// We failed to load data for the character from the DB. Notify the // We failed to load data for the character from the DB. Notify the
// client to push the state back to character selection, with the error // client to push the state back to character selection, with the error
// to display // to display
self.notify_not_in_game_client( self.notify_character_screen_client(
query_result.entity, query_result.entity,
ServerNotInGameMsg::CharacterDataLoadError(error.to_string()), ServerCharacterScreenMsg::CharacterDataLoadError(error.to_string()),
); );
// Clean up the entity data on the server // Clean up the entity data on the server
@ -874,12 +874,12 @@ impl Server {
} }
} }
pub fn notify_not_in_game_client<S>(&self, entity: EcsEntity, msg: S) pub fn notify_character_screen_client<S>(&self, entity: EcsEntity, msg: S)
where where
S: Into<ServerNotInGameMsg>, S: Into<ServerCharacterScreenMsg>,
{ {
if let Some(client) = self.state.ecs().write_storage::<Client>().get_mut(entity) { if let Some(client) = self.state.ecs().write_storage::<Client>().get_mut(entity) {
client.send_not_in_game(msg.into()) client.send_character_screen(msg.into())
} }
} }

View File

@ -6,8 +6,8 @@ use common::{
comp, comp,
effect::Effect, effect::Effect,
msg::{ msg::{
CharacterInfo, ClientIngame, PlayerListUpdate, ServerGeneralMsg, ServerInGameMsg, CharacterInfo, ClientIngame, PlayerListUpdate, ServerCharacterScreenMsg, ServerGeneralMsg,
ServerNotInGameMsg, ServerInGameMsg,
}, },
state::State, state::State,
sync::{Uid, UidAllocator, WorldSyncExt}, sync::{Uid, UidAllocator, WorldSyncExt},
@ -220,7 +220,7 @@ impl StateExt for State {
// Tell the client its request was successful. // Tell the client its request was successful.
if let Some(client) = self.ecs().write_storage::<Client>().get_mut(entity) { if let Some(client) = self.ecs().write_storage::<Client>().get_mut(entity) {
client.in_game = Some(ClientIngame::Character); client.in_game = Some(ClientIngame::Character);
client.send_not_in_game(ServerNotInGameMsg::CharacterSuccess) client.send_character_screen(ServerCharacterScreenMsg::CharacterSuccess)
} }
} }

View File

@ -15,10 +15,10 @@ use common::{
}, },
event::{EventBus, ServerEvent}, event::{EventBus, ServerEvent},
msg::{ msg::{
validate_chat_msg, CharacterInfo, ChatMsgValidationError, ClientGeneralMsg, validate_chat_msg, CharacterInfo, ChatMsgValidationError, ClientCharacterScreenMsg,
ClientInGameMsg, ClientIngame, ClientNotInGameMsg, ClientRegisterMsg, DisconnectReason, ClientGeneralMsg, ClientInGameMsg, ClientIngame, ClientRegisterMsg, DisconnectReason,
PingMsg, PlayerInfo, PlayerListUpdate, RegisterError, ServerGeneralMsg, ServerInGameMsg, PingMsg, PlayerInfo, PlayerListUpdate, RegisterError, ServerCharacterScreenMsg,
ServerNotInGameMsg, ServerRegisterAnswerMsg, MAX_BYTES_CHAT_MSG, ServerGeneralMsg, ServerInGameMsg, ServerRegisterAnswerMsg, MAX_BYTES_CHAT_MSG,
}, },
span, span,
state::{BlockChange, Time}, state::{BlockChange, Time},
@ -237,7 +237,7 @@ impl Sys {
} }
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
fn handle_client_not_in_game_msg( fn handle_client_character_screen_msg(
server_emitter: &mut common::event::Emitter<'_, ServerEvent>, server_emitter: &mut common::event::Emitter<'_, ServerEvent>,
new_chat_msgs: &mut Vec<(Option<specs::Entity>, UnresolvedChatMsg)>, new_chat_msgs: &mut Vec<(Option<specs::Entity>, UnresolvedChatMsg)>,
entity: specs::Entity, entity: specs::Entity,
@ -247,18 +247,18 @@ impl Sys {
players: &mut WriteStorage<'_, Player>, players: &mut WriteStorage<'_, Player>,
editable_settings: &ReadExpect<'_, EditableSettings>, editable_settings: &ReadExpect<'_, EditableSettings>,
alias_validator: &ReadExpect<'_, AliasValidator>, alias_validator: &ReadExpect<'_, AliasValidator>,
msg: ClientNotInGameMsg, msg: ClientCharacterScreenMsg,
) -> Result<(), crate::error::Error> { ) -> Result<(), crate::error::Error> {
match msg { match msg {
// Request spectator state // Request spectator state
ClientNotInGameMsg::Spectate => { ClientCharacterScreenMsg::Spectate => {
if client.registered { if client.registered {
client.in_game = Some(ClientIngame::Spectator) client.in_game = Some(ClientIngame::Spectator)
} else { } else {
debug!("dropped Spectate msg from unregistered client"); debug!("dropped Spectate msg from unregistered client");
} }
}, },
ClientNotInGameMsg::Character(character_id) => { ClientCharacterScreenMsg::Character(character_id) => {
if client.registered && client.in_game.is_none() { if client.registered && client.in_game.is_none() {
// Only send login message if it wasn't already // Only send login message if it wasn't already
// sent previously // sent previously
@ -301,9 +301,11 @@ impl Sys {
} }
} }
} else { } else {
client.send_not_in_game(ServerNotInGameMsg::CharacterDataLoadError( client.send_character_screen(
String::from("Failed to fetch player entity"), ServerCharacterScreenMsg::CharacterDataLoadError(String::from(
)) "Failed to fetch player entity",
)),
)
} }
} else { } else {
let registered = client.registered; let registered = client.registered;
@ -311,15 +313,15 @@ impl Sys {
debug!(?registered, ?in_game, "dropped Character msg from client"); debug!(?registered, ?in_game, "dropped Character msg from client");
} }
}, },
ClientNotInGameMsg::RequestCharacterList => { ClientCharacterScreenMsg::RequestCharacterList => {
if let Some(player) = players.get(entity) { if let Some(player) = players.get(entity) {
character_loader.load_character_list(entity, player.uuid().to_string()) character_loader.load_character_list(entity, player.uuid().to_string())
} }
}, },
ClientNotInGameMsg::CreateCharacter { alias, tool, body } => { ClientCharacterScreenMsg::CreateCharacter { alias, tool, body } => {
if let Err(error) = alias_validator.validate(&alias) { if let Err(error) = alias_validator.validate(&alias) {
debug!(?error, ?alias, "denied alias as it contained a banned word"); debug!(?error, ?alias, "denied alias as it contained a banned word");
client.send_not_in_game(ServerNotInGameMsg::CharacterActionError( client.send_character_screen(ServerCharacterScreenMsg::CharacterActionError(
error.to_string(), error.to_string(),
)); ));
} else if let Some(player) = players.get(entity) { } else if let Some(player) = players.get(entity) {
@ -333,7 +335,7 @@ impl Sys {
); );
} }
}, },
ClientNotInGameMsg::DeleteCharacter(character_id) => { ClientCharacterScreenMsg::DeleteCharacter(character_id) => {
if let Some(player) = players.get(entity) { if let Some(player) = players.get(entity) {
character_loader.delete_character( character_loader.delete_character(
entity, entity,
@ -458,7 +460,8 @@ impl Sys {
loop { loop {
let q1 = Client::internal_recv(&client.network_error, &mut client.singleton_stream); let q1 = Client::internal_recv(&client.network_error, &mut client.singleton_stream);
let q2 = Client::internal_recv(&client.network_error, &mut client.in_game_stream); let q2 = Client::internal_recv(&client.network_error, &mut client.in_game_stream);
let q3 = Client::internal_recv(&client.network_error, &mut client.not_in_game_stream); let q3 =
Client::internal_recv(&client.network_error, &mut client.character_screen_stream);
let q4 = Client::internal_recv(&client.network_error, &mut client.ping_stream); let q4 = Client::internal_recv(&client.network_error, &mut client.ping_stream);
let q5 = Client::internal_recv(&client.network_error, &mut client.register_stream); let q5 = Client::internal_recv(&client.network_error, &mut client.register_stream);
@ -503,7 +506,7 @@ impl Sys {
)?; )?;
} }
if let Some(msg) = m3 { if let Some(msg) = m3 {
Self::handle_client_not_in_game_msg( Self::handle_client_character_screen_msg(
server_emitter, server_emitter,
new_chat_msgs, new_chat_msgs,
entity, entity,