|
|
@ -373,7 +373,7 @@ impl Default for ItemShops { |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub struct ShipServerStateBuilder<EG: EntityGateway> {
|
|
|
|
pub struct ShipServerStateBuilder<EG: EntityGateway + Clone> {
|
|
|
|
entity_gateway: Option<EG>,
|
|
|
|
name: Option<String>,
|
|
|
|
ip: Option<Ipv4Addr>,
|
|
|
@ -382,7 +382,7 @@ pub struct ShipServerStateBuilder<EG: EntityGateway> { |
|
|
|
num_blocks: usize,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<EG: EntityGateway> Default for ShipServerStateBuilder<EG> {
|
|
|
|
impl<EG: EntityGateway + Clone> Default for ShipServerStateBuilder<EG> {
|
|
|
|
fn default() -> ShipServerStateBuilder<EG> {
|
|
|
|
ShipServerStateBuilder {
|
|
|
|
entity_gateway: None,
|
|
|
@ -395,7 +395,7 @@ impl<EG: EntityGateway> Default for ShipServerStateBuilder<EG> { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<EG: EntityGateway> ShipServerStateBuilder<EG> {
|
|
|
|
impl<EG: EntityGateway + Clone> ShipServerStateBuilder<EG> {
|
|
|
|
#[must_use]
|
|
|
|
pub fn gateway(mut self, entity_gateway: EG) -> ShipServerStateBuilder<EG> {
|
|
|
|
self.entity_gateway = Some(entity_gateway);
|
|
|
@ -478,7 +478,7 @@ impl Blocks { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct ShipServerState<EG: EntityGateway> {
|
|
|
|
pub struct ShipServerState<EG: EntityGateway + Clone> {
|
|
|
|
entity_gateway: EG,
|
|
|
|
pub clients: Clients,
|
|
|
|
level_table: CharacterLevelTable,
|
|
|
@ -496,7 +496,7 @@ pub struct ShipServerState<EG: EntityGateway> { |
|
|
|
trades: TradeState,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<EG: EntityGateway> ShipServerState<EG> {
|
|
|
|
impl<EG: EntityGateway + Clone> ShipServerState<EG> {
|
|
|
|
pub fn builder() -> ShipServerStateBuilder<EG> {
|
|
|
|
ShipServerStateBuilder::default()
|
|
|
|
}
|
|
|
@ -509,11 +509,11 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
|
Ok(match &msg.msg {
|
|
|
|
GameMessage::RequestExp(request_exp) => {
|
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|
handler::message::request_exp(id, request_exp, &mut self.entity_gateway, &block.client_location, &mut self.clients, &mut block.rooms, &self.level_table).await?
|
|
|
|
handler::message::request_exp(id, request_exp, self.entity_gateway.clone(), &block.client_location, &mut self.clients, &mut block.rooms, &self.level_table).await?
|
|
|
|
},
|
|
|
|
GameMessage::PlayerDropItem(player_drop_item) => {
|
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|
handler::message::player_drop_item(id, player_drop_item, &mut self.entity_gateway, &block.client_location, &mut self.clients, &mut block.rooms, &mut self.item_state).await?
|
|
|
|
handler::message::player_drop_item(id, player_drop_item, self.entity_gateway.clone(), &block.client_location, &mut self.clients, &mut block.rooms, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::DropCoordinates(drop_coordinates) => {
|
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
@ -521,7 +521,7 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
|
},
|
|
|
|
GameMessage::PlayerNoLongerHasItem(no_longer_has_item) => {
|
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|
handler::message::no_longer_has_item(id, no_longer_has_item, &mut self.entity_gateway, &block.client_location, &mut self.clients, &mut self.item_state).await?
|
|
|
|
handler::message::no_longer_has_item(id, no_longer_has_item, self.entity_gateway.clone(), &block.client_location, &mut self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::PlayerChangedMap(_) | GameMessage::PlayerChangedMap2(_) | GameMessage::TellOtherPlayerMyLocation(_) |
|
|
|
|
GameMessage::PlayerWarpingToFloor(_) | GameMessage::PlayerTeleported(_) | GameMessage::PlayerStopped(_) |
|
|
|
@ -532,31 +532,31 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
|
},
|
|
|
|
GameMessage::ChargeAttack(charge_attack) => {
|
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|
handler::message::charge_attack(id, charge_attack, &mut self.entity_gateway, &block.client_location, &mut self.clients, &mut self.item_state).await?
|
|
|
|
handler::message::charge_attack(id, charge_attack, self.entity_gateway.clone(), &block.client_location, &mut self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::PlayerUseItem(player_use_item) => {
|
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|
handler::message::player_uses_item(id, player_use_item, &mut self.entity_gateway, &block.client_location, &mut self.clients, &mut self.item_state).await?
|
|
|
|
handler::message::player_uses_item(id, player_use_item, self.entity_gateway.clone(), &block.client_location, &mut self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::PlayerUsedMedicalCenter(player_used_medical_center) => {
|
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|
handler::message::player_used_medical_center(id, player_used_medical_center, &mut self.entity_gateway, &block.client_location, &mut self.clients, &mut self.item_state).await?
|
|
|
|
handler::message::player_used_medical_center(id, player_used_medical_center, self.entity_gateway.clone(), &block.client_location, &mut self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::PlayerFeedMag(player_feed_mag) => {
|
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|
handler::message::player_feed_mag(id, player_feed_mag, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
|
|
|
|
handler::message::player_feed_mag(id, player_feed_mag, self.entity_gateway.clone(), &block.client_location, &self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::PlayerEquipItem(player_equip_item) => {
|
|
|
|
handler::message::player_equips_item(id, player_equip_item, &mut self.entity_gateway, &self.clients, &mut self.item_state).await?
|
|
|
|
handler::message::player_equips_item(id, player_equip_item, self.entity_gateway.clone(), &self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::PlayerUnequipItem(player_unequip_item) => {
|
|
|
|
handler::message::player_unequips_item(id, player_unequip_item, &mut self.entity_gateway, &self.clients, &mut self.item_state).await?
|
|
|
|
handler::message::player_unequips_item(id, player_unequip_item, self.entity_gateway.clone(), &self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::SortItems(sort_items) => {
|
|
|
|
handler::message::player_sorts_items(id, sort_items, &mut self.entity_gateway, &self.clients, &mut self.item_state).await?
|
|
|
|
handler::message::player_sorts_items(id, sort_items, self.entity_gateway.clone(), &self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::PlayerSoldItem(player_sold_item) => {
|
|
|
|
handler::message::player_sells_item(id, player_sold_item, &mut self.entity_gateway, &mut self.clients, &mut self.item_state).await?
|
|
|
|
handler::message::player_sells_item(id, player_sold_item, self.entity_gateway.clone(), &mut self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
_ => {
|
|
|
|
let cmsg = msg.clone();
|
|
|
@ -577,31 +577,31 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
|
handler::direct_message::guildcard_send(id, guildcard_send, target, &block.client_location, &self.clients)
|
|
|
|
},
|
|
|
|
GameMessage::RequestItem(request_item) => {
|
|
|
|
handler::direct_message::request_item(id, request_item, &mut self.entity_gateway, &block.client_location, &mut self.clients, &mut block.rooms, &mut self.item_state).await?
|
|
|
|
handler::direct_message::request_item(id, request_item, self.entity_gateway.clone(), &block.client_location, &mut self.clients, &mut block.rooms, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::PickupItem(pickup_item) => {
|
|
|
|
handler::direct_message::pickup_item(id, pickup_item, &mut self.entity_gateway, &block.client_location, &mut self.clients, &mut self.item_state).await?
|
|
|
|
handler::direct_message::pickup_item(id, pickup_item, self.entity_gateway.clone(), &block.client_location, &mut self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::BoxDropRequest(box_drop_request) => {
|
|
|
|
handler::direct_message::request_box_item(id, box_drop_request, &mut self.entity_gateway, &block.client_location, &mut self.clients, &mut block.rooms, &mut self.item_state).await?
|
|
|
|
handler::direct_message::request_box_item(id, box_drop_request, self.entity_gateway.clone(), &block.client_location, &mut self.clients, &mut block.rooms, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::BankRequest(_bank_request) => {
|
|
|
|
handler::direct_message::send_bank_list(id, &self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::BankInteraction(bank_interaction) => {
|
|
|
|
handler::direct_message::bank_interaction(id, bank_interaction, &mut self.entity_gateway, &block.client_location, &mut self.clients, &mut self.item_state).await?
|
|
|
|
handler::direct_message::bank_interaction(id, bank_interaction, self.entity_gateway.clone(), &block.client_location, &mut self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::ShopRequest(shop_request) => {
|
|
|
|
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) => {
|
|
|
|
handler::direct_message::buy_item(id, buy_item, &mut self.entity_gateway, &block.client_location, &mut self.clients, &mut self.item_state).await?
|
|
|
|
handler::direct_message::buy_item(id, buy_item, self.entity_gateway.clone(), &block.client_location, &mut self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::TekRequest(tek_request) => {
|
|
|
|
handler::direct_message::request_tek_item(id, tek_request, &mut self.entity_gateway, &mut self.clients, &mut self.item_state).await?
|
|
|
|
handler::direct_message::request_tek_item(id, tek_request, self.entity_gateway.clone(), &mut self.clients, &mut self.item_state).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_state).await?
|
|
|
|
handler::direct_message::accept_tek_item(id, tek_accept, self.entity_gateway.clone(), &block.client_location, &mut self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::TradeRequest(trade_request) => {
|
|
|
|
handler::trade::trade_request(id, trade_request, target, &block.client_location, &mut self.clients, &mut self.item_state, &mut self.trades).await?
|
|
|
@ -619,7 +619,7 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
|
}
|
|
|
|
|
|
|
|
#[async_trait::async_trait]
|
|
|
|
impl<EG: EntityGateway> ServerState for ShipServerState<EG> {
|
|
|
|
impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> {
|
|
|
|
type SendPacket = SendShipPacket;
|
|
|
|
type RecvPacket = RecvShipPacket;
|
|
|
|
type PacketError = anyhow::Error;
|
|
|
@ -647,7 +647,7 @@ impl<EG: EntityGateway> ServerState for ShipServerState<EG> { |
|
|
|
|
|
|
|
Ok(match pkt {
|
|
|
|
RecvShipPacket::Login(login) => {
|
|
|
|
Box::new(handler::auth::validate_login(id, login, &mut self.entity_gateway, &mut self.clients, &mut self.item_state, &self.shipgate_sender, &self.name, self.blocks.0.len())
|
|
|
|
Box::new(handler::auth::validate_login(id, login, self.entity_gateway.clone(), &mut self.clients, &mut self.item_state, &self.shipgate_sender, &self.name, self.blocks.0.len())
|
|
|
|
.await?.into_iter().map(move |pkt| (id, pkt)))
|
|
|
|
},
|
|
|
|
RecvShipPacket::QuestDetailRequest(questdetailrequest) => {
|
|
|
@ -721,14 +721,14 @@ impl<EG: EntityGateway> ServerState for ShipServerState<EG> { |
|
|
|
handler::room::room_name_request(id, &block.client_location, &block.rooms)
|
|
|
|
},
|
|
|
|
RecvShipPacket::UpdateConfig(pkt) => {
|
|
|
|
handler::settings::update_config(id, pkt, &mut self.clients, &mut self.entity_gateway).await
|
|
|
|
handler::settings::update_config(id, pkt, &mut self.clients, self.entity_gateway.clone()).await
|
|
|
|
},
|
|
|
|
RecvShipPacket::ViewInfoboardRequest(_pkt) => {
|
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|
handler::communication::request_infoboard(id, &block.client_location, &self.clients)
|
|
|
|
},
|
|
|
|
RecvShipPacket::WriteInfoboard(pkt) => {
|
|
|
|
handler::communication::write_infoboard(id, pkt, &mut self.clients, &mut self.entity_gateway).await
|
|
|
|
handler::communication::write_infoboard(id, pkt, &mut self.clients, self.entity_gateway.clone()).await
|
|
|
|
},
|
|
|
|
RecvShipPacket::RoomListRequest(_req) => {
|
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
@ -752,7 +752,7 @@ impl<EG: EntityGateway> ServerState for ShipServerState<EG> { |
|
|
|
},
|
|
|
|
RecvShipPacket::LobbySelect(pkt) => {
|
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|
Box::new(handler::lobby::change_lobby(id, pkt.lobby, &mut block.client_location, &self.clients, &mut self.item_state, &self.level_table, &mut block.rooms, &mut self.entity_gateway).await?.into_iter())
|
|
|
|
Box::new(handler::lobby::change_lobby(id, pkt.lobby, &mut block.client_location, &self.clients, &mut self.item_state, &self.level_table, &mut block.rooms, self.entity_gateway.clone()).await?.into_iter())
|
|
|
|
},
|
|
|
|
RecvShipPacket::RequestQuestList(rql) => {
|
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
@ -774,7 +774,7 @@ impl<EG: EntityGateway> ServerState for ShipServerState<EG> { |
|
|
|
Box::new(None.into_iter())
|
|
|
|
},
|
|
|
|
RecvShipPacket::SaveOptions(save_options) => {
|
|
|
|
handler::settings::save_options(id, save_options, &mut self.clients, &mut self.entity_gateway).await
|
|
|
|
handler::settings::save_options(id, save_options, &mut self.clients, self.entity_gateway.clone()).await
|
|
|
|
},
|
|
|
|
RecvShipPacket::RequestShipList(_) => {
|
|
|
|
handler::ship::ship_list(id, &self.ship_list)
|
|
|
@ -788,13 +788,13 @@ impl<EG: EntityGateway> ServerState for ShipServerState<EG> { |
|
|
|
},
|
|
|
|
RecvShipPacket::TradeConfirmed(_) => {
|
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|
handler::trade::trade_confirmed(id, &mut self.entity_gateway, &block.client_location, &mut self.clients, &mut self.item_state, &mut self.trades).await?
|
|
|
|
handler::trade::trade_confirmed(id, self.entity_gateway.clone(), &block.client_location, &mut self.clients, &mut self.item_state, &mut self.trades).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::KeyboardConfig(keyboard_config) => {
|
|
|
|
handler::settings::keyboard_config(id, keyboard_config, &mut self.clients, &mut self.entity_gateway).await
|
|
|
|
handler::settings::keyboard_config(id, keyboard_config, &mut self.clients, self.entity_gateway.clone()).await
|
|
|
|
},
|
|
|
|
RecvShipPacket::GamepadConfig(gamepad_config) => {
|
|
|
|
handler::settings::gamepad_config(id, gamepad_config, &mut self.clients, &mut self.entity_gateway).await
|
|
|
|
handler::settings::gamepad_config(id, gamepad_config, &mut self.clients, self.entity_gateway.clone()).await
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
@ -839,7 +839,7 @@ impl<EG: EntityGateway> ServerState for ShipServerState<EG> { |
|
|
|
|
|
|
|
|
|
|
|
#[async_trait::async_trait]
|
|
|
|
impl<EG: EntityGateway> InterserverActor for ShipServerState<EG> {
|
|
|
|
impl<EG: EntityGateway + Clone> InterserverActor for ShipServerState<EG> {
|
|
|
|
type SendMessage = ShipMessage;
|
|
|
|
type RecvMessage = LoginMessage;
|
|
|
|
type Error = ();
|
|
|
|