|
|
@ -1,4 +1,16 @@ |
|
|
|
#![allow(dead_code, unused_must_use)]
|
|
|
|
#![allow(clippy::type_complexity)]
|
|
|
|
mod auth;
|
|
|
|
mod communication;
|
|
|
|
mod direct_message;
|
|
|
|
mod lobby;
|
|
|
|
mod message;
|
|
|
|
mod room;
|
|
|
|
mod settings;
|
|
|
|
mod quest;
|
|
|
|
mod ship;
|
|
|
|
pub mod trade;
|
|
|
|
mod chatcommand;
|
|
|
|
|
|
|
|
use std::net::Ipv4Addr;
|
|
|
|
|
|
|
|
use async_std::channel;
|
|
|
@ -22,18 +34,15 @@ use entity::character::SectionID; |
|
|
|
use entity::room::RoomNote;
|
|
|
|
use location::{ClientLocation, RoomLobby, ClientLocationError, RoomId};
|
|
|
|
use drops::{DropTable, StandardDropTable};
|
|
|
|
use items;
|
|
|
|
use room;
|
|
|
|
use ::room::{Rooms, RoomCreationError};
|
|
|
|
use maps::room::{RoomMode, Episode, Difficulty};
|
|
|
|
use quests::{load_standard_quests, load_government_quests};
|
|
|
|
use quests::{QuestList, QuestLoadError};
|
|
|
|
use maps::Holiday;
|
|
|
|
use maps::area::MapAreaError;
|
|
|
|
use maps::maps::{Maps, MapsError, generate_free_roam_maps};
|
|
|
|
use crate::ship::packet::handler;
|
|
|
|
use shops::{ItemShops, StandardItemShops};
|
|
|
|
use trade::TradeState;
|
|
|
|
use crate::ship::chatcommand;
|
|
|
|
use ::trade::{TradeState, TradeStateError};
|
|
|
|
use pktbuilder::quest::{QUEST_CATEGORY_MENU_ID, QUEST_SELECT_MENU_ID};
|
|
|
|
|
|
|
|
pub use client::{Clients, ClientState};
|
|
|
@ -98,13 +107,13 @@ pub enum ShipError { |
|
|
|
#[error("invalid item {0}")]
|
|
|
|
InvalidItem(items::ClientItemId),
|
|
|
|
#[error("trade error {0}")]
|
|
|
|
TradeError(#[from] crate::ship::packet::handler::trade::TradeError),
|
|
|
|
TradeError(#[from] trade::TradeError),
|
|
|
|
#[error("trade state error {0}")]
|
|
|
|
TradeStateError(#[from] trade::TradeStateError),
|
|
|
|
TradeStateError(#[from] TradeStateError),
|
|
|
|
#[error("message error {0}")]
|
|
|
|
MessageError(#[from] crate::ship::packet::handler::direct_message::MessageError),
|
|
|
|
MessageError(#[from] crate::direct_message::MessageError),
|
|
|
|
#[error("room creation error {0}")]
|
|
|
|
RoomCreationError(#[from] room::RoomCreationError),
|
|
|
|
RoomCreationError(#[from] RoomCreationError),
|
|
|
|
#[error("channel send error {0}")]
|
|
|
|
SendError(#[from] async_std::channel::SendError<ShipMessage>),
|
|
|
|
}
|
|
|
@ -432,7 +441,7 @@ impl<EG: EntityGateway + Clone + 'static> ShipServerStateBuilder<EG> { |
|
|
|
#[derive(Clone, Default)]
|
|
|
|
pub struct Block {
|
|
|
|
client_location: ClientLocation,
|
|
|
|
pub rooms: room::Rooms,
|
|
|
|
pub rooms: Rooms,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
@ -481,58 +490,58 @@ impl<EG: EntityGateway + Clone + 'static> ShipServerState<EG> { |
|
|
|
Ok(match msg.msg {
|
|
|
|
GameMessage::RequestExp(request_exp) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::message::request_exp(id, request_exp, &mut self.entity_gateway, &block.client_location, &self.clients, &block.rooms).await?
|
|
|
|
message::request_exp(id, request_exp, &mut self.entity_gateway, &block.client_location, &self.clients, &block.rooms).await?
|
|
|
|
},
|
|
|
|
GameMessage::PlayerDropItem(player_drop_item) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::message::player_drop_item(id, player_drop_item, &mut self.entity_gateway, &block.client_location, &self.clients, &block.rooms, &mut self.item_state).await?
|
|
|
|
message::player_drop_item(id, player_drop_item, &mut self.entity_gateway, &block.client_location, &self.clients, &block.rooms, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::DropCoordinates(drop_coordinates) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::message::drop_coordinates(id, drop_coordinates, &block.client_location, &self.clients, &block.rooms).await?
|
|
|
|
message::drop_coordinates(id, drop_coordinates, &block.client_location, &self.clients, &block.rooms).await?
|
|
|
|
},
|
|
|
|
GameMessage::PlayerNoLongerHasItem(no_longer_has_item) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::message::no_longer_has_item(id, no_longer_has_item, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
|
|
|
|
message::no_longer_has_item(id, no_longer_has_item, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::PlayerChangedMap(_) | GameMessage::PlayerChangedMap2(_) | GameMessage::TellOtherPlayerMyLocation(_) |
|
|
|
|
GameMessage::PlayerWarpingToFloor(_) | GameMessage::PlayerTeleported(_) | GameMessage::PlayerStopped(_) |
|
|
|
|
GameMessage::PlayerLoadedIn(_) | GameMessage::PlayerWalking(_) | GameMessage::PlayerRunning(_) |
|
|
|
|
GameMessage::PlayerWarped(_) | GameMessage::PlayerChangedFloor(_) | GameMessage::InitializeSpeechNpc(_) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::message::update_player_position(id, msg, &self.clients, &block.client_location, &block.rooms).await?
|
|
|
|
message::update_player_position(id, msg, &self.clients, &block.client_location, &block.rooms).await?
|
|
|
|
},
|
|
|
|
GameMessage::ChargeAttack(charge_attack) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::message::charge_attack(id, charge_attack, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
|
|
|
|
message::charge_attack(id, charge_attack, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::PlayerUseItem(player_use_item) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::message::player_uses_item(id, player_use_item, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
|
|
|
|
message::player_uses_item(id, player_use_item, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::PlayerUsedMedicalCenter(player_used_medical_center) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::message::player_used_medical_center(id, player_used_medical_center, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
|
|
|
|
message::player_used_medical_center(id, player_used_medical_center, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::PlayerFeedMag(player_feed_mag) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::message::player_feed_mag(id, player_feed_mag, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
|
|
|
|
message::player_feed_mag(id, player_feed_mag, &mut self.entity_gateway, &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?
|
|
|
|
message::player_equips_item(id, player_equip_item, &mut self.entity_gateway, &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?
|
|
|
|
message::player_unequips_item(id, player_unequip_item, &mut self.entity_gateway, &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?
|
|
|
|
message::player_sorts_items(id, sort_items, &mut self.entity_gateway, &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, &self.clients, &mut self.item_state).await?
|
|
|
|
message::player_sells_item(id, player_sold_item, &mut self.entity_gateway, &self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::FloorItemLimitItemDeletion(floor_item_limit_delete) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::message::floor_item_limit_deletion(id, floor_item_limit_delete, &mut self.entity_gateway, &block.client_location, &self.clients, &block.rooms, &mut self.item_state).await?
|
|
|
|
message::floor_item_limit_deletion(id, floor_item_limit_delete, &mut self.entity_gateway, &block.client_location, &self.clients, &block.rooms, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
_ => {
|
|
|
|
let cmsg = msg.clone();
|
|
|
@ -551,37 +560,37 @@ impl<EG: EntityGateway + Clone + 'static> ShipServerState<EG> { |
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
Ok(match msg.msg {
|
|
|
|
GameMessage::GuildcardSend(guildcard_send) => {
|
|
|
|
handler::direct_message::guildcard_send(id, guildcard_send, target, &block.client_location, &self.clients).await?
|
|
|
|
direct_message::guildcard_send(id, guildcard_send, target, &block.client_location, &self.clients).await?
|
|
|
|
},
|
|
|
|
GameMessage::RequestItem(request_item) => {
|
|
|
|
handler::direct_message::request_item(id, request_item, &mut self.entity_gateway, &block.client_location, &self.clients, &block.rooms, &mut self.item_state).await?
|
|
|
|
direct_message::request_item(id, request_item, &mut self.entity_gateway, &block.client_location, &self.clients, &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, &self.clients, &mut self.item_state).await?
|
|
|
|
direct_message::pickup_item(id, pickup_item, &mut self.entity_gateway, &block.client_location, &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, &self.clients, &block.rooms, &mut self.item_state).await?
|
|
|
|
direct_message::request_box_item(id, box_drop_request, &mut self.entity_gateway, &block.client_location, &self.clients, &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?
|
|
|
|
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, &self.clients, &mut self.item_state).await?
|
|
|
|
direct_message::bank_interaction(id, bank_interaction, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::ShopRequest(shop_request) => {
|
|
|
|
handler::direct_message::shop_request(id, shop_request, &block.client_location, &self.clients, &block.rooms, &self.shops).await?
|
|
|
|
direct_message::shop_request(id, shop_request, &block.client_location, &self.clients, &block.rooms, &self.shops).await?
|
|
|
|
},
|
|
|
|
GameMessage::BuyItem(buy_item) => {
|
|
|
|
handler::direct_message::buy_item(id, buy_item, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
|
|
|
|
direct_message::buy_item(id, buy_item, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::TekRequest(tek_request) => {
|
|
|
|
handler::direct_message::request_tek_item(id, tek_request, &mut self.entity_gateway, &self.clients, &mut self.item_state).await?
|
|
|
|
direct_message::request_tek_item(id, tek_request, &mut self.entity_gateway, &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, &self.clients, &mut self.item_state).await?
|
|
|
|
direct_message::accept_tek_item(id, tek_accept, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state).await?
|
|
|
|
},
|
|
|
|
GameMessage::TradeRequest(trade_request) => {
|
|
|
|
handler::trade::trade_request(id, trade_request, target, &block.client_location, &self.clients, &mut self.item_state, &mut self.trades).await?
|
|
|
|
trade::trade_request(id, trade_request, target, &block.client_location, &self.clients, &mut self.item_state, &mut self.trades).await?
|
|
|
|
},
|
|
|
|
_ => {
|
|
|
|
let cmsg = msg.clone();
|
|
|
@ -627,7 +636,7 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> { |
|
|
|
|
|
|
|
Ok(match pkt {
|
|
|
|
RecvShipPacket::Login(login) => {
|
|
|
|
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())
|
|
|
|
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())
|
|
|
|
.await?
|
|
|
|
.into_iter()
|
|
|
|
.map(move |pkt| (id, pkt))
|
|
|
@ -636,7 +645,7 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> { |
|
|
|
RecvShipPacket::QuestDetailRequest(questdetailrequest) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
match questdetailrequest.menu {
|
|
|
|
QUEST_SELECT_MENU_ID => handler::quest::quest_detail(id, questdetailrequest, &block.client_location, &block.rooms).await?,
|
|
|
|
QUEST_SELECT_MENU_ID => quest::quest_detail(id, questdetailrequest, &block.client_location, &block.rooms).await?,
|
|
|
|
_ => unreachable!(),
|
|
|
|
}
|
|
|
|
},
|
|
|
@ -644,27 +653,27 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> { |
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
match menuselect.menu {
|
|
|
|
SHIP_MENU_ID => {
|
|
|
|
let leave_lobby = handler::lobby::remove_from_lobby(id, &mut block.client_location).await.into_iter().flatten();
|
|
|
|
let select_ship = handler::ship::selected_ship(id, menuselect, &self.ship_list).await?;
|
|
|
|
let leave_lobby = lobby::remove_from_lobby(id, &mut block.client_location).await.into_iter().flatten();
|
|
|
|
let select_ship = ship::selected_ship(id, menuselect, &self.ship_list).await?;
|
|
|
|
leave_lobby.chain(select_ship).collect()
|
|
|
|
}
|
|
|
|
BLOCK_MENU_ID => {
|
|
|
|
let leave_lobby = handler::lobby::remove_from_lobby(id, &mut block.client_location).await.into_iter().flatten();
|
|
|
|
let select_block = handler::lobby::block_selected(id, menuselect, &self.clients, &self.item_state).await?.into_iter();
|
|
|
|
let leave_lobby = lobby::remove_from_lobby(id, &mut block.client_location).await.into_iter().flatten();
|
|
|
|
let select_block = lobby::block_selected(id, menuselect, &self.clients, &self.item_state).await?.into_iter();
|
|
|
|
leave_lobby.chain(select_block).collect()
|
|
|
|
}
|
|
|
|
ROOM_MENU_ID => handler::room::join_room(id, menuselect, &mut self.entity_gateway, &mut block.client_location, &self.clients, &mut self.item_state, &block.rooms, self.event).await?,
|
|
|
|
QUEST_CATEGORY_MENU_ID => handler::quest::select_quest_category(id, menuselect, &block.client_location, &block.rooms).await?,
|
|
|
|
ROOM_MENU_ID => room::join_room(id, menuselect, &mut self.entity_gateway, &mut block.client_location, &self.clients, &mut self.item_state, &block.rooms, self.event).await?,
|
|
|
|
QUEST_CATEGORY_MENU_ID => quest::select_quest_category(id, menuselect, &block.client_location, &block.rooms).await?,
|
|
|
|
_ => unreachable!(),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
RecvShipPacket::QuestMenuSelect(questmenuselect) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::quest::player_chose_quest(id, questmenuselect, &self.clients, &block.client_location, &block.rooms, self.event).await?
|
|
|
|
quest::player_chose_quest(id, questmenuselect, &self.clients, &block.client_location, &block.rooms, self.event).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::MenuDetail(menudetail) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::lobby::get_room_tab_info(id, menudetail, &mut block.client_location, &self.clients).await?
|
|
|
|
lobby::get_room_tab_info(id, menudetail, &mut block.client_location, &self.clients).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::RoomPasswordReq(room_password_req) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
@ -678,7 +687,7 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> { |
|
|
|
menu: room_password_req.menu,
|
|
|
|
item: room_password_req.item,
|
|
|
|
};
|
|
|
|
handler::room::join_room(id, menuselect, &mut self.entity_gateway, &mut block.client_location, &self.clients, &mut self.item_state, &block.rooms, self.event).await?
|
|
|
|
room::join_room(id, menuselect, &mut self.entity_gateway, &mut block.client_location, &self.clients, &mut self.item_state, &block.rooms, self.event).await?
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
vec![(id, SendShipPacket::SmallDialog(SmallDialog::new("Incorrect password".into())))]
|
|
|
@ -686,7 +695,7 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> { |
|
|
|
},
|
|
|
|
RecvShipPacket::CharData(chardata) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::lobby::send_player_to_lobby(id, chardata, &mut block.client_location, &self.clients, &self.item_state, self.event).await?
|
|
|
|
lobby::send_player_to_lobby(id, chardata, &mut block.client_location, &self.clients, &self.item_state, self.event).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::Message(msg) => {
|
|
|
|
self.message(id, msg).await?
|
|
|
@ -704,40 +713,40 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> { |
|
|
|
},
|
|
|
|
None => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::communication::player_chat(id, msg, &block.client_location, &self.clients).await?
|
|
|
|
communication::player_chat(id, msg, &block.client_location, &self.clients).await?
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
RecvShipPacket::CreateRoom(create_room) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::room::create_room(id, create_room, &mut self.entity_gateway, &mut block.client_location, &self.clients, &mut self.item_state,
|
|
|
|
room::create_room(id, create_room, &mut self.entity_gateway, &mut block.client_location, &self.clients, &mut self.item_state,
|
|
|
|
&block.rooms, self.map_builder.clone(), self.drop_table_builder.clone(),
|
|
|
|
self.standard_quest_builder.clone(), self.government_quest_builder.clone(), self.event).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::RoomNameRequest(_req) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::room::room_name_request(id, &block.client_location, &block.rooms).await?
|
|
|
|
room::room_name_request(id, &block.client_location, &block.rooms).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::UpdateTechMenu(pkt) => {
|
|
|
|
handler::settings::update_tech_menu(id, pkt, &self.clients, &mut self.entity_gateway).await?
|
|
|
|
settings::update_tech_menu(id, pkt, &self.clients, &mut self.entity_gateway).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::UpdateConfig(pkt) => {
|
|
|
|
handler::settings::update_config(id, pkt, &self.clients, &mut self.entity_gateway).await?
|
|
|
|
settings::update_config(id, pkt, &self.clients, &mut self.entity_gateway).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::ViewInfoboardRequest(_pkt) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::communication::request_infoboard(id, &block.client_location, &self.clients).await?
|
|
|
|
communication::request_infoboard(id, &block.client_location, &self.clients).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::WriteInfoboard(pkt) => {
|
|
|
|
handler::communication::write_infoboard(id, pkt, &self.clients, &mut self.entity_gateway).await?
|
|
|
|
communication::write_infoboard(id, pkt, &self.clients, &mut self.entity_gateway).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::RoomListRequest(_req) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::room::request_room_list(id, &block.client_location, &block.rooms).await
|
|
|
|
room::request_room_list(id, &block.client_location, &block.rooms).await
|
|
|
|
},
|
|
|
|
RecvShipPacket::Like62ButCooler(cool62) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::room::cool_62(id, cool62, &block.client_location).await?
|
|
|
|
room::cool_62(id, cool62, &block.client_location).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::ClientCharacterData(_) => {
|
|
|
|
// TOOD: validate this in some way?
|
|
|
@ -745,57 +754,57 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> { |
|
|
|
},
|
|
|
|
RecvShipPacket::DoneBursting(_) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::room::done_bursting(id, &block.client_location, &block.rooms).await?
|
|
|
|
room::done_bursting(id, &block.client_location, &block.rooms).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::DoneBursting2(_) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::room::done_bursting(id, &block.client_location, &block.rooms).await?
|
|
|
|
room::done_bursting(id, &block.client_location, &block.rooms).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::LobbySelect(pkt) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::lobby::change_lobby(id, pkt.lobby, &mut block.client_location, &self.clients, &mut self.item_state, &block.rooms, &mut self.entity_gateway, self.event).await?
|
|
|
|
lobby::change_lobby(id, pkt.lobby, &mut block.client_location, &self.clients, &mut self.item_state, &block.rooms, &mut self.entity_gateway, self.event).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::RequestQuestList(rql) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::quest::send_quest_category_list(id, rql, &block.client_location, &block.rooms).await?
|
|
|
|
quest::send_quest_category_list(id, rql, &block.client_location, &block.rooms).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::QuestFileRequest(quest_file_request) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::quest::quest_file_request(id, quest_file_request, &block.client_location, &mut block.rooms).await?
|
|
|
|
quest::quest_file_request(id, quest_file_request, &block.client_location, &mut block.rooms).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::QuestChunkAck(quest_chunk_ack) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::quest::quest_chunk_ack(id, quest_chunk_ack, &block.client_location, &block.rooms).await?
|
|
|
|
quest::quest_chunk_ack(id, quest_chunk_ack, &block.client_location, &block.rooms).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::DoneLoadingQuest(_) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::quest::done_loading_quest(id, &self.clients, &block.client_location).await?
|
|
|
|
quest::done_loading_quest(id, &self.clients, &block.client_location).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::FullCharacterData(_full_character_data) => {
|
|
|
|
Vec::new()
|
|
|
|
},
|
|
|
|
RecvShipPacket::SaveOptions(save_options) => {
|
|
|
|
handler::settings::save_options(id, save_options, &self.clients, &mut self.entity_gateway).await?
|
|
|
|
settings::save_options(id, save_options, &self.clients, &mut self.entity_gateway).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::RequestShipList(_) => {
|
|
|
|
handler::ship::ship_list(id, &self.ship_list).await
|
|
|
|
ship::ship_list(id, &self.ship_list).await
|
|
|
|
},
|
|
|
|
RecvShipPacket::RequestShipBlockList(_) => {
|
|
|
|
handler::ship::block_list(id, &self.name, self.blocks.0.len())
|
|
|
|
ship::block_list(id, &self.name, self.blocks.0.len())
|
|
|
|
},
|
|
|
|
RecvShipPacket::ItemsToTrade(items_to_trade) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::trade::items_to_trade(id, items_to_trade, &block.client_location, &self.clients, &mut self.item_state, &mut self.trades).await?
|
|
|
|
trade::items_to_trade(id, items_to_trade, &block.client_location, &self.clients, &mut self.item_state, &mut self.trades).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::TradeConfirmed(_) => {
|
|
|
|
let block = self.blocks.get_from_client(id, &self.clients).await?;
|
|
|
|
handler::trade::trade_confirmed(id, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state, &mut self.trades).await?
|
|
|
|
trade::trade_confirmed(id, &mut self.entity_gateway, &block.client_location, &self.clients, &mut self.item_state, &mut self.trades).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::KeyboardConfig(keyboard_config) => {
|
|
|
|
handler::settings::keyboard_config(id, keyboard_config, &self.clients, &mut self.entity_gateway).await?
|
|
|
|
settings::keyboard_config(id, keyboard_config, &self.clients, &mut self.entity_gateway).await?
|
|
|
|
},
|
|
|
|
RecvShipPacket::GamepadConfig(gamepad_config) => {
|
|
|
|
handler::settings::gamepad_config(id, gamepad_config, &self.clients, &mut self.entity_gateway).await?
|
|
|
|
settings::gamepad_config(id, gamepad_config, &self.clients, &mut self.entity_gateway).await?
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
@ -816,7 +825,7 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> { |
|
|
|
entity_gateway.add_room_note(room.room_id, RoomNote::PlayerJoin {
|
|
|
|
character_id,
|
|
|
|
}).await
|
|
|
|
})}).await;
|
|
|
|
})}).await??;
|
|
|
|
if neighbors.is_empty() {
|
|
|
|
block.rooms.remove(room).await;
|
|
|
|
}
|
|
|
@ -831,9 +840,9 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> { |
|
|
|
|
|
|
|
if let Some(mut client) = self.clients.remove(&id).await {
|
|
|
|
client.user.at_ship = false;
|
|
|
|
self.entity_gateway.save_user(&client.user).await;
|
|
|
|
self.entity_gateway.save_user(&client.user).await?;
|
|
|
|
if let Some(shipgate_sender) = self.shipgate_sender.as_ref() {
|
|
|
|
shipgate_sender.send(ShipMessage::RemoveUser(client.user.id)).await;
|
|
|
|
shipgate_sender.send(ShipMessage::RemoveUser(client.user.id)).await?;
|
|
|
|
}
|
|
|
|
self.item_state.remove_character_from_room(&client.character).await
|
|
|
|
}
|