|
@ -236,6 +236,9 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
let room = self.rooms.get(pkt.item as usize)
|
|
|
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))?.as_ref()
|
|
|
.ok_or_else(|| ShipError::InvalidRoom(pkt.item))?;
|
|
|
.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 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)))?;
|
|
|
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
|
|
|
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())))
|
|
|
.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) {
|
|
|
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()));
|
|
|
let leave_lobby = SendShipPacket::LeaveLobby(LeaveLobby::new(area_client.local_client.id(), leader.local_client.id()));
|
|
|
Ok(result.chain(original_neighbors.into_iter()
|
|
|
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> {
|
|
|
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()
|
|
|
Box::new(self.client_location.get_client_neighbors(id).unwrap().into_iter()
|
|
|
.map(move |client| {
|
|
|
.map(move |client| {
|
|
|
vec![
|
|
|
vec![
|
|
@ -525,7 +535,8 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
let room_id = self.client_location.create_new_room(id).unwrap();
|
|
|
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 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 {
|
|
|
let players = [PlayerHeader {
|
|
|
tag: 0x10000,
|
|
|
tag: 0x10000,
|
|
|