Browse Source

remove unwraps

pbs
Andy Newjack 5 years ago
parent
commit
c8a6823b82
  1. 2
      src/ship/packet/handler/lobby.rs
  2. 6
      src/ship/ship.rs

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

6
src/ship/ship.rs

@ -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()))
},

Loading…
Cancel
Save