From c8a6823b82f35f17068c74f48bb8febd18489cec Mon Sep 17 00:00:00 2001 From: Andy Newjack Date: Thu, 30 Apr 2020 01:08:09 -0300 Subject: [PATCH] remove unwraps --- src/ship/packet/handler/lobby.rs | 2 +- src/ship/ship.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) 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())) },