diff --git a/client/src/lib.rs b/client/src/lib.rs index 96f269bb68..1fb2903464 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -132,9 +132,10 @@ impl Client { } /// Request a state transition to `ClientState::Registered`. - pub fn register(&mut self, player: comp::Player, password: String) -> Result<(), Error> { + pub fn register(&mut self, player: comp::Player, password: String) /*-> Result<(), Error>*/ { self.postbox.send_message(ClientMsg::Register { player, password }); - loop { + self.client_state = ClientState::Pending; + /*loop { match self.postbox.next_message() { Some(ServerMsg::StateAnswer(Err((RequestStateError::Denied, _)))) => { println!("Got a bad"); @@ -150,7 +151,7 @@ impl Client { None => { println!("Got nothing?"); }, } - } + }*/ } /// Request a state transition to `ClientState::Character`. @@ -470,6 +471,10 @@ impl Client { self.client_state = state; } ServerMsg::StateAnswer(Err((error, state))) => { + if error == RequestStateError::Denied { + warn!("Connection denied!"); + return Err(Error::InvalidAuth); + } warn!( "StateAnswer: {:?}. Server thinks client is in state {:?}.", error, state diff --git a/common/src/msg/server.rs b/common/src/msg/server.rs index 5d5b8a83a3..8e92e0d2be 100644 --- a/common/src/msg/server.rs +++ b/common/src/msg/server.rs @@ -7,7 +7,7 @@ use crate::{ use fxhash::FxHashMap; use vek::*; -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub enum RequestStateError { Denied, Already, diff --git a/voxygen/src/menu/main/client_init.rs b/voxygen/src/menu/main/client_init.rs index a0a0362d8d..8896f62095 100644 --- a/voxygen/src/menu/main/client_init.rs +++ b/voxygen/src/menu/main/client_init.rs @@ -57,14 +57,15 @@ impl ClientInit { for socket_addr in first_addrs.into_iter().chain(second_addrs) { match Client::new(socket_addr, player.view_distance) { Ok(mut client) => { - match client.register(player, password) { + /*match client.register(player, password) { Err(ClientError::InvalidAuth) => { last_err = Some(Error::InvalidAuth); break; } _ => {} } - println!("Auth success"); + println!("Auth success");*/ + client.register(player, password); let _ = tx.send(Ok(client)); #[cfg(feature = "discord")]