Browse Source

added some error handling

pbs
mht8355 5 years ago
parent
commit
880bfc620a
  1. 6
      src/ship/packet/builder/lobby.rs

6
src/ship/packet/builder/lobby.rs

@ -65,8 +65,10 @@ pub fn add_to_lobby(id: ClientId,
pub fn remove_from_lobby(id: ClientId, pub fn remove_from_lobby(id: ClientId,
client_location: &ClientLocation) client_location: &ClientLocation)
-> Result<LeaveLobby, ShipError> { -> Result<LeaveLobby, ShipError> {
let prev_area_index = client_location.get_local_client(id).unwrap().local_client.id();
let prev_area_leader_index = client_location.get_area_leader(client_location.get_area(id).unwrap()).unwrap().local_client.id();
let prev_area_index = client_location.get_local_client(id).map_err(|err| -> ClientLocationError { err.into() })?.local_client.id();
let prev_area_leader_index = client_location.get_area_leader(client_location.get_area(id)
.map_err(|err| -> ClientLocationError { err.into() })?)
.map_err(|err| -> ClientLocationError { err.into() })?.local_client.id();
Ok(LeaveLobby { Ok(LeaveLobby {
client: prev_area_index, client: prev_area_index,
leader: prev_area_leader_index, leader: prev_area_leader_index,

Loading…
Cancel
Save