|
@ -61,18 +61,26 @@ pub fn change_lobby(id: ClientId, |
|
|
clients: &Clients,
|
|
|
clients: &Clients,
|
|
|
level_table: &CharacterLevelTable)
|
|
|
level_table: &CharacterLevelTable)
|
|
|
-> Result<Vec<(ClientId, SendShipPacket)>, ShipError> {
|
|
|
-> Result<Vec<(ClientId, SendShipPacket)>, ShipError> {
|
|
|
|
|
|
let prev_area = client_location.get_area(id).unwrap();
|
|
|
let leave_lobby = packet::builder::lobby::remove_from_lobby(id, client_location).unwrap();
|
|
|
let leave_lobby = packet::builder::lobby::remove_from_lobby(id, client_location).unwrap();
|
|
|
let old_neighbors = client_location.get_client_neighbors(id).unwrap();
|
|
|
let old_neighbors = client_location.get_client_neighbors(id).unwrap();
|
|
|
let lobby = LobbyId(requested_lobby as usize);
|
|
|
|
|
|
|
|
|
let mut lobby = LobbyId(requested_lobby as usize);
|
|
|
match client_location.add_client_to_lobby(id, lobby) {
|
|
|
match client_location.add_client_to_lobby(id, lobby) {
|
|
|
Ok(lobby) => {
|
|
|
Ok(lobby) => {
|
|
|
}
|
|
|
}
|
|
|
Err(err) => {
|
|
|
Err(err) => {
|
|
|
let dialog = SmallDialog {
|
|
|
|
|
|
padding: [0, 0],
|
|
|
|
|
|
msg: String::from("Lobby is full."),
|
|
|
|
|
|
};
|
|
|
|
|
|
return Ok(vec![(id, SendShipPacket::SmallDialog(dialog))])
|
|
|
|
|
|
|
|
|
match prev_area {
|
|
|
|
|
|
RoomLobby::Lobby(lobby) => {
|
|
|
|
|
|
let dialog = SmallDialog {
|
|
|
|
|
|
padding: [0, 0],
|
|
|
|
|
|
msg: String::from("Lobby is full."),
|
|
|
|
|
|
};
|
|
|
|
|
|
return Ok(vec![(id, SendShipPacket::SmallDialog(dialog))])
|
|
|
|
|
|
}
|
|
|
|
|
|
RoomLobby::Room(room) => {
|
|
|
|
|
|
lobby = client_location.add_client_to_next_available_lobby(id, lobby).unwrap();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
let join_lobby = packet::builder::lobby::join_lobby(id, lobby, client_location, clients, level_table)?;
|
|
|
let join_lobby = packet::builder::lobby::join_lobby(id, lobby, client_location, clients, level_table)?;
|
|
|