|
@ -23,6 +23,7 @@ use crate::login::character::SHIP_MENU_ID; |
|
|
use crate::entity::gateway::{EntityGateway, GatewayError};
|
|
|
use crate::entity::gateway::{EntityGateway, GatewayError};
|
|
|
use crate::entity::account::{UserAccountEntity, UserSettingsEntity};
|
|
|
use crate::entity::account::{UserAccountEntity, UserSettingsEntity};
|
|
|
use crate::entity::character::{CharacterEntity, SectionID};
|
|
|
use crate::entity::character::{CharacterEntity, SectionID};
|
|
|
|
|
|
use crate::entity::item;
|
|
|
|
|
|
|
|
|
use crate::ship::location::{ClientLocation, RoomLobby, MAX_ROOMS, ClientLocationError, GetNeighborError, GetClientsError, GetAreaError};
|
|
|
use crate::ship::location::{ClientLocation, RoomLobby, MAX_ROOMS, ClientLocationError, GetNeighborError, GetClientsError, GetAreaError};
|
|
|
|
|
|
|
|
@ -71,6 +72,7 @@ pub enum ShipError { |
|
|
UnknownMonster(crate::ship::monster::MonsterType),
|
|
|
UnknownMonster(crate::ship::monster::MonsterType),
|
|
|
InvalidShip(usize),
|
|
|
InvalidShip(usize),
|
|
|
InvalidBlock(usize),
|
|
|
InvalidBlock(usize),
|
|
|
|
|
|
InvalidItem(items::ClientItemId),
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
#[derive(Debug)]
|
|
@ -254,6 +256,7 @@ pub struct ClientState { |
|
|
pub weapon_shop: Vec<WeaponShopItem>,
|
|
|
pub weapon_shop: Vec<WeaponShopItem>,
|
|
|
pub tool_shop: Vec<ToolShopItem>,
|
|
|
pub tool_shop: Vec<ToolShopItem>,
|
|
|
pub armor_shop: Vec<ArmorShopItem>,
|
|
|
pub armor_shop: Vec<ArmorShopItem>,
|
|
|
|
|
|
pub tek: Option<(items::ClientItemId, item::weapon::TekSpecialModifier, item::weapon::TekPercentModifier, i32)>,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl ClientState {
|
|
|
impl ClientState {
|
|
@ -273,6 +276,7 @@ impl ClientState { |
|
|
weapon_shop: Vec::new(),
|
|
|
weapon_shop: Vec::new(),
|
|
|
tool_shop: Vec::new(),
|
|
|
tool_shop: Vec::new(),
|
|
|
armor_shop: Vec::new(),
|
|
|
armor_shop: Vec::new(),
|
|
|
|
|
|
tek: None,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@ -445,7 +449,7 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
},
|
|
|
},
|
|
|
GameMessage::PlayerNoLongerHasItem(no_longer_has_item) => {
|
|
|
GameMessage::PlayerNoLongerHasItem(no_longer_has_item) => {
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
handler::message::split_item_stack(id, no_longer_has_item, &mut self.entity_gateway, &mut block.client_location, &mut self.clients, &mut self.item_manager).await?
|
|
|
|
|
|
|
|
|
handler::message::no_longer_has_item(id, no_longer_has_item, &mut self.entity_gateway, &mut block.client_location, &mut self.clients, &mut self.item_manager).await?
|
|
|
},
|
|
|
},
|
|
|
GameMessage::PlayerChangedMap(_) | GameMessage::PlayerChangedMap2(_) | GameMessage::TellOtherPlayerMyLocation(_) |
|
|
|
GameMessage::PlayerChangedMap(_) | GameMessage::PlayerChangedMap2(_) | GameMessage::TellOtherPlayerMyLocation(_) |
|
|
|
GameMessage::PlayerWarpingToFloor(_) | GameMessage::PlayerTeleported(_) | GameMessage::PlayerStopped(_) |
|
|
|
GameMessage::PlayerWarpingToFloor(_) | GameMessage::PlayerTeleported(_) | GameMessage::PlayerStopped(_) |
|
|
@ -490,41 +494,40 @@ 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?
|
|
|
},
|
|
|
},
|
|
|
|
|
|
GameMessage::TekRequest(tek_request) => {
|
|
|
|
|
|
handler::direct_message::request_tek_item(id, tek_request, &mut self.entity_gateway, &mut self.clients, &mut self.item_manager).await?
|
|
|
|
|
|
},
|
|
|
|
|
|
GameMessage::TekAccept(tek_accept) => {
|
|
|
|
|
|
handler::direct_message::accept_tek_item(id, tek_accept, &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| {
|
|
|