From 37367491da7c5d4b53ba23dd316cfefdcdf22510 Mon Sep 17 00:00:00 2001 From: timokoesters Date: Sun, 21 Apr 2019 20:46:07 +0200 Subject: [PATCH] Cleanup ClientStates Former-commit-id: 060cf9800dc6f09c58f41a4baaccb1a43bd97621 --- server/src/lib.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/server/src/lib.rs b/server/src/lib.rs index 1dd15e6f0b..5a7be9eec7 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -264,16 +264,16 @@ impl Server { ClientMsg::RequestState(requested_state) => match requested_state { ClientState::Connected => disconnect = true, // Default state ClientState::Registered => match client.client_state { - ClientState::Connected => {}, // Use ClientMsg::Connect instead + ClientState::Connected => disconnect = true, // Use ClientMsg::Register instead ClientState::Registered => client.error_state(RequestStateError::Already), - ClientState::Spectator => client.allow_state(ClientState::Registered), - ClientState::Character => client.allow_state(ClientState::Registered), + ClientState::Spectator | ClientState::Character + => client.allow_state(ClientState::Registered), }, ClientState::Spectator => match requested_state { - ClientState::Connected => disconnect = true, // Become Connected first - ClientState::Registered => client.allow_state(ClientState::Spectator), + ClientState::Connected => disconnect = true, // Become Registered first ClientState::Spectator => client.error_state(RequestStateError::Already), - ClientState::Character => client.allow_state(ClientState::Spectator), + ClientState::Registered | ClientState::Character + => client.allow_state(ClientState::Spectator), }, ClientState::Character => disconnect = true, // Use ClientMsg::Character instead }, @@ -282,16 +282,15 @@ impl Server { _ => disconnect = true, }, ClientMsg::Character(character) => match client.client_state { - ClientState::Connected => disconnect = true, // Become Connected first + ClientState::Connected => disconnect = true, // Become Registered first ClientState::Registered | ClientState::Spectator => Self::create_player_character(state, entity, client, character), ClientState::Character => client.error_state(RequestStateError::Already), }, ClientMsg::Chat(msg) => match client.client_state { ClientState::Connected => disconnect = true, - ClientState::Registered => new_chat_msgs.push((entity, msg)), - ClientState::Spectator => new_chat_msgs.push((entity, msg)), - ClientState::Character => new_chat_msgs.push((entity, msg)), + ClientState::Registered | ClientState::Spectator | ClientState::Character + => new_chat_msgs.push((entity, msg)), }, ClientMsg::PlayerAnimation(animation_history) => match client.client_state { ClientState::Character => state.write_component(entity, animation_history),