remove unwraps

This commit is contained in:
Andy Newjack 2020-04-30 01:08:09 -03:00
parent 49aee7af26
commit c8a6823b82
2 changed files with 4 additions and 4 deletions

View File

@ -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;
}
},

View File

@ -336,9 +336,9 @@ impl<EG: EntityGateway> ServerState for ShipServerState<EG> {
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()))
},