From 7c6cdd30cc78c2e0e561db65a367386074e51efa Mon Sep 17 00:00:00 2001 From: mht8355 Date: Tue, 28 Apr 2020 01:41:32 -0400 Subject: [PATCH] better code --- src/ship/packet/handler/lobby.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/ship/packet/handler/lobby.rs b/src/ship/packet/handler/lobby.rs index cc31ba1..5192646 100644 --- a/src/ship/packet/handler/lobby.rs +++ b/src/ship/packet/handler/lobby.rs @@ -70,10 +70,7 @@ pub fn change_lobby(id: ClientId, let leave_lobby = packet::builder::lobby::remove_from_lobby(id, client_location)?; let old_neighbors = client_location.get_client_neighbors(id).unwrap(); let mut lobby = LobbyId(requested_lobby as usize); - match client_location.add_client_to_lobby(id, lobby) { - Ok(lobby) => { - } - Err(err) => { + if let Err(_) = client_location.add_client_to_lobby(id, lobby) { match prev_area { RoomLobby::Lobby(lobby) => { let dialog = SmallDialog::new(String::from("Lobby is full.")); @@ -83,7 +80,6 @@ pub fn change_lobby(id: ClientId, lobby = client_location.add_client_to_next_available_lobby(id, lobby).map_err(|_| ShipError::TooManyClients)?; } } - } } let join_lobby = packet::builder::lobby::join_lobby(id, lobby, client_location, clients, level_table)?; let addto = packet::builder::lobby::add_to_lobby(id, lobby, client_location, clients, level_table)?;