|
@ -490,41 +490,34 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
|
|
|
|
|
|
async fn direct_message(&mut self, id: ClientId, msg: &DirectMessage) -> Result<Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send>, anyhow::Error> {
|
|
|
async fn direct_message(&mut self, id: ClientId, msg: &DirectMessage) -> Result<Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send>, anyhow::Error> {
|
|
|
let target = msg.flag;
|
|
|
let target = msg.flag;
|
|
|
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
Ok(match &msg.msg {
|
|
|
Ok(match &msg.msg {
|
|
|
GameMessage::GuildcardSend(guildcard_send) => {
|
|
|
GameMessage::GuildcardSend(guildcard_send) => {
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|
|
|
handler::direct_message::guildcard_send(id, guildcard_send, target, &block.client_location, &self.clients)
|
|
|
handler::direct_message::guildcard_send(id, guildcard_send, target, &block.client_location, &self.clients)
|
|
|
},
|
|
|
},
|
|
|
GameMessage::RequestItem(request_item) => {
|
|
|
GameMessage::RequestItem(request_item) => {
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|
|
|
handler::direct_message::request_item(id, request_item, &mut self.entity_gateway, &mut block.client_location, &mut self.clients, &mut block.rooms, &mut self.item_manager).await?
|
|
|
handler::direct_message::request_item(id, request_item, &mut self.entity_gateway, &mut block.client_location, &mut self.clients, &mut block.rooms, &mut self.item_manager).await?
|
|
|
},
|
|
|
},
|
|
|
GameMessage::PickupItem(pickup_item) => {
|
|
|
GameMessage::PickupItem(pickup_item) => {
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|
|
|
handler::direct_message::pickup_item(id, pickup_item, &mut self.entity_gateway, &mut block.client_location, &mut self.clients, &mut self.item_manager).await?
|
|
|
handler::direct_message::pickup_item(id, pickup_item, &mut self.entity_gateway, &mut block.client_location, &mut self.clients, &mut self.item_manager).await?
|
|
|
},
|
|
|
},
|
|
|
GameMessage::BoxDropRequest(box_drop_request) => {
|
|
|
GameMessage::BoxDropRequest(box_drop_request) => {
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|
|
|
handler::direct_message::request_box_item(id, box_drop_request, &mut self.entity_gateway, &mut block.client_location, &mut self.clients, &mut block.rooms, &mut self.item_manager).await?
|
|
|
handler::direct_message::request_box_item(id, box_drop_request, &mut self.entity_gateway, &mut block.client_location, &mut self.clients, &mut block.rooms, &mut self.item_manager).await?
|
|
|
},
|
|
|
},
|
|
|
GameMessage::BankRequest(_bank_request) => {
|
|
|
GameMessage::BankRequest(_bank_request) => {
|
|
|
handler::direct_message::send_bank_list(id, &self.clients, &mut self.item_manager).await?
|
|
|
handler::direct_message::send_bank_list(id, &self.clients, &mut self.item_manager).await?
|
|
|
},
|
|
|
},
|
|
|
GameMessage::BankInteraction(bank_interaction) => {
|
|
|
GameMessage::BankInteraction(bank_interaction) => {
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|
|
|
handler::direct_message::bank_interaction(id, bank_interaction, &mut self.entity_gateway, &block.client_location, &mut self.clients, &mut self.item_manager).await?
|
|
|
handler::direct_message::bank_interaction(id, bank_interaction, &mut self.entity_gateway, &block.client_location, &mut self.clients, &mut self.item_manager).await?
|
|
|
},
|
|
|
},
|
|
|
GameMessage::ShopRequest(shop_request) => {
|
|
|
GameMessage::ShopRequest(shop_request) => {
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|
|
|
handler::direct_message::shop_request(id, shop_request, &block.client_location, &mut self.clients, &block.rooms, &self.level_table, &mut self.shops).await?
|
|
|
handler::direct_message::shop_request(id, shop_request, &block.client_location, &mut self.clients, &block.rooms, &self.level_table, &mut self.shops).await?
|
|
|
},
|
|
|
},
|
|
|
GameMessage::BuyItem(buy_item) => {
|
|
|
GameMessage::BuyItem(buy_item) => {
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|
|
|
handler::direct_message::buy_item(id, buy_item, &mut self.entity_gateway, &block.client_location, &mut self.clients, &mut self.item_manager).await?
|
|
|
handler::direct_message::buy_item(id, buy_item, &mut self.entity_gateway, &block.client_location, &mut self.clients, &mut self.item_manager).await?
|
|
|
},
|
|
|
},
|
|
|
_ => {
|
|
|
_ => {
|
|
|
let cmsg = msg.clone();
|
|
|
let cmsg = msg.clone();
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|
|
|
Box::new(block.client_location.get_all_clients_by_client(id).unwrap().into_iter()
|
|
|
Box::new(block.client_location.get_all_clients_by_client(id).unwrap().into_iter()
|
|
|
.filter(move |client| client.local_client.id() == target as u8)
|
|
|
.filter(move |client| client.local_client.id() == target as u8)
|
|
|
.map(move |client| {
|
|
|
.map(move |client| {
|
|
|