diff --git a/src/ship/packet/handler/lobby.rs b/src/ship/packet/handler/lobby.rs index 3f22c69..25066ea 100644 --- a/src/ship/packet/handler/lobby.rs +++ b/src/ship/packet/handler/lobby.rs @@ -71,7 +71,7 @@ pub fn change_lobby(id: ClientId, } }, RoomLobby::Room(old_room) => { - if client_location.get_client_neighbors(id).unwrap().len() == 0 { + if client_location.get_client_neighbors(id).map_err(|err| -> ClientLocationError {err.into()})?.len() == 0 { ship_rooms[old_room.0] = None; } }, diff --git a/src/ship/ship.rs b/src/ship/ship.rs index 3c3fad2..e1c61a6 100644 --- a/src/ship/ship.rs +++ b/src/ship/ship.rs @@ -336,9 +336,9 @@ impl ServerState for ShipServerState { let pkt = match self.client_location.get_area(id).unwrap() { RoomLobby::Room(room) => { - if self.client_location.get_client_neighbors(id).unwrap().len() == 0 { - self.rooms[room.0] = None; - } + self.client_location.get_client_neighbors(id).map(|x| if x.len() == 0 { + self.rooms[room.0] = None + }); let leader = self.client_location.get_room_leader(room).unwrap(); SendShipPacket::LeaveRoom(LeaveRoom::new(client.local_client.id(), leader.local_client.id())) },