Browse Source

show dialog when trying to join room with a bursting player

pbs
jake 5 years ago
parent
commit
28b7d89b42
  1. 2
      src/ship/room.rs
  2. 13
      src/ship/ship.rs

2
src/ship/room.rs

@ -129,6 +129,7 @@ pub struct RoomState {
pub drop_table: Box<DropTable<rand_chacha::ChaCha20Rng>>,
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,
})
}

13
src/ship/ship.rs

@ -236,6 +236,9 @@ impl<EG: EntityGateway> ShipServerState<EG> {
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<EG: EntityGateway> ShipServerState<EG> {
.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<EG: EntityGateway> ShipServerState<EG> {
}
fn done_bursting(&mut self, id: ClientId) -> Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + 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<EG: EntityGateway> ShipServerState<EG> {
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,

Loading…
Cancel
Save