|
|
@ -44,14 +44,15 @@ pub async fn create_room(id: ClientId, |
|
|
|
};
|
|
|
|
|
|
|
|
let area = client_location.get_area(id).await?;
|
|
|
|
let area_client = client_location.get_local_client(id).await?;
|
|
|
|
let old_area_client = client_location.get_local_client(id).await?;
|
|
|
|
let lobby_neighbors = client_location.get_client_neighbors(id).await?;
|
|
|
|
|
|
|
|
let room_id = client_location.create_new_room(id).await?;
|
|
|
|
let new_area_client = client_location.get_local_client(id).await?;
|
|
|
|
let room = clients.with(id, |client| {
|
|
|
|
let mut item_state = item_state.clone();
|
|
|
|
Box::pin(async move {
|
|
|
|
item_state.add_character_to_room(room_id, &client.character, area_client).await;
|
|
|
|
item_state.add_character_to_room(room_id, &client.character, new_area_client).await;
|
|
|
|
let mut room = RoomState::from_create_room(&create_room, map_builder, drop_table_builder, client.character.section_id, event)?;
|
|
|
|
room.bursting = true;
|
|
|
|
Ok::<_, anyhow::Error>(room)
|
|
|
@ -62,7 +63,7 @@ pub async fn create_room(id: ClientId, |
|
|
|
|
|
|
|
let mut result = vec![(id, SendShipPacket::JoinRoom(join_room))];
|
|
|
|
if let Ok(leader) = client_location.get_area_leader(area).await {
|
|
|
|
let leave_lobby = SendShipPacket::LeaveLobby(LeaveLobby::new(area_client.local_client.id(), leader.local_client.id()));
|
|
|
|
let leave_lobby = SendShipPacket::LeaveLobby(LeaveLobby::new(old_area_client.local_client.id(), leader.local_client.id()));
|
|
|
|
result.extend(lobby_neighbors
|
|
|
|
.into_iter()
|
|
|
|
.map(move |c| {
|
|
|
|