From 28b7d89b426ed9001473b821cad3b05c70f682ed Mon Sep 17 00:00:00 2001 From: jake Date: Tue, 21 Apr 2020 08:51:06 -0600 Subject: [PATCH] show dialog when trying to join room with a bursting player --- src/ship/room.rs | 2 ++ src/ship/ship.rs | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/ship/room.rs b/src/ship/room.rs index 9354239..b91c790 100644 --- a/src/ship/room.rs +++ b/src/ship/room.rs @@ -129,6 +129,7 @@ pub struct RoomState { pub drop_table: Box>, pub section_id: SectionID, pub random_seed: u32, + pub bursting: bool, // items on ground // enemy info } @@ -207,6 +208,7 @@ impl RoomState { maps: Maps::new(room_mode.episode()), section_id: section_id, drop_table: Box::new(DropTable::new(room_mode.episode(), room_mode.difficulty(), section_id)), + bursting: false, }) } diff --git a/src/ship/ship.rs b/src/ship/ship.rs index 580f271..3ed4285 100644 --- a/src/ship/ship.rs +++ b/src/ship/ship.rs @@ -236,6 +236,9 @@ impl ShipServerState { let room = self.rooms.get(pkt.item as usize) .ok_or_else(|| ShipError::InvalidRoom(pkt.item))?.as_ref() .ok_or_else(|| ShipError::InvalidRoom(pkt.item))?; + if room.bursting { + return Ok(vec![(id, SendShipPacket::SmallDialog(SmallDialog::new("player is bursting\nplease wait".into())))]) + } let room_id = RoomId(pkt.item as usize); let original_room_clients = self.client_location.get_clients_in_room(room_id).map_err(|err| ShipError::ClientError(format!("{:?}", err)))?; self.client_location.add_client_to_room(id, room_id).unwrap(); // TODO: show room full error or whatever @@ -320,6 +323,8 @@ impl ShipServerState { .map(|c| (c.client, SendShipPacket::AddToRoom(add_to.clone()))) ); + let room = self.rooms.get_mut(room_id.0).unwrap().as_mut().unwrap(); + room.bursting = true; if let Ok(leader) = self.client_location.get_area_leader(original_area) { let leave_lobby = SendShipPacket::LeaveLobby(LeaveLobby::new(area_client.local_client.id(), leader.local_client.id())); Ok(result.chain(original_neighbors.into_iter() @@ -419,6 +424,11 @@ impl ShipServerState { } fn done_bursting(&mut self, id: ClientId) -> Box + Send> { + let area = self.client_location.get_area(id).unwrap(); + if let RoomLobby::Room(room_id) = area { + let room = self.rooms.get_mut(room_id.0).unwrap().as_mut().unwrap(); + room.bursting = false; + } Box::new(self.client_location.get_client_neighbors(id).unwrap().into_iter() .map(move |client| { vec![ @@ -525,7 +535,8 @@ impl ShipServerState { let room_id = self.client_location.create_new_room(id).unwrap(); let client = self.clients.get_mut(&id).unwrap();//.ok_or(ShipError::ClientNotFound(id)).unwrap(); - let room = room::RoomState::from_create_room(create_room, client.character.section_id).unwrap(); + let mut room = room::RoomState::from_create_room(create_room, client.character.section_id).unwrap(); + room.bursting = true; let players = [PlayerHeader { tag: 0x10000,