|
|
@ -15,7 +15,6 @@ use libpso::packet::ship::{BLOCK_MENU_ID, ROOM_MENU_ID}; |
|
|
|
|
|
|
|
use crate::common::cipherkeys::{ELSEWHERE_PRIVATE_KEY, ELSEWHERE_PARRAY};
|
|
|
|
use crate::common::serverstate::{SendServerPacket, RecvServerPacket, ServerState, OnConnect, ClientId};
|
|
|
|
use crate::common::leveltable::CharacterLevelTable;
|
|
|
|
use crate::common::interserver::{AuthToken, Ship, ServerId, InterserverActor, LoginMessage, ShipMessage};
|
|
|
|
|
|
|
|
use crate::login::character::SHIP_MENU_ID;
|
|
|
@ -437,7 +436,6 @@ impl<EG: EntityGateway + Clone> ShipServerStateBuilder<EG> { |
|
|
|
ShipServerState {
|
|
|
|
entity_gateway: self.entity_gateway.unwrap(),
|
|
|
|
clients: HashMap::new(),
|
|
|
|
level_table: CharacterLevelTable::default(),
|
|
|
|
name: self.name.unwrap_or_else(|| "NAMENOTSET".into()),
|
|
|
|
item_state: items::state::ItemState::default(),
|
|
|
|
ip: self.ip.unwrap_or_else(|| Ipv4Addr::new(127,0,0,1)),
|
|
|
@ -481,7 +479,6 @@ impl Blocks { |
|
|
|
pub struct ShipServerState<EG: EntityGateway + Clone> {
|
|
|
|
entity_gateway: EG,
|
|
|
|
pub clients: Clients,
|
|
|
|
level_table: CharacterLevelTable,
|
|
|
|
name: String,
|
|
|
|
item_state: items::state::ItemState,
|
|
|
|
shops: Box<ItemShops>,
|
|
|
@ -509,7 +506,7 @@ impl<EG: EntityGateway + Clone> 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, self.entity_gateway.clone(), &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).await?
|
|
|
|
},
|
|
|
|
GameMessage::PlayerDropItem(player_drop_item) => {
|
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
@ -592,7 +589,7 @@ impl<EG: EntityGateway + Clone> ShipServerState<EG> { |
|
|
|
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?
|
|
|
|
handler::direct_message::shop_request(id, shop_request, &block.client_location, &mut self.clients, &block.rooms, &mut self.shops).await?
|
|
|
|
},
|
|
|
|
GameMessage::BuyItem(buy_item) => {
|
|
|
|
handler::direct_message::buy_item(id, buy_item, self.entity_gateway.clone(), &block.client_location, &mut self.clients, &mut self.item_state).await?
|
|
|
@ -667,10 +664,10 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> { |
|
|
|
}
|
|
|
|
BLOCK_MENU_ID => {
|
|
|
|
let leave_lobby = handler::lobby::remove_from_lobby(id, &mut block.client_location).into_iter().into_iter().flatten();
|
|
|
|
let select_block = handler::lobby::block_selected(id, menuselect, &mut self.clients, &self.item_state, &self.level_table)?.into_iter();
|
|
|
|
let select_block = handler::lobby::block_selected(id, menuselect, &mut self.clients, &self.item_state)?.into_iter();
|
|
|
|
Box::new(leave_lobby.chain(select_block))
|
|
|
|
}
|
|
|
|
ROOM_MENU_ID => handler::room::join_room(id, menuselect, &mut block.client_location, &mut self.clients, &mut self.item_state, &self.level_table, &mut block.rooms)?,
|
|
|
|
ROOM_MENU_ID => handler::room::join_room(id, menuselect, &mut block.client_location, &mut self.clients, &mut self.item_state, &mut block.rooms)?,
|
|
|
|
QUEST_CATEGORY_MENU_ID => handler::quest::select_quest_category(id, menuselect, &block.client_location, &mut block.rooms)?,
|
|
|
|
_ => unreachable!(),
|
|
|
|
}
|
|
|
@ -692,7 +689,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 block.client_location, &mut self.clients, &mut self.item_state, &self.level_table, &mut block.rooms)?
|
|
|
|
handler::room::join_room(id, &menuselect, &mut block.client_location, &mut self.clients, &mut self.item_state, &mut block.rooms)?
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Box::new(vec![(id, SendShipPacket::SmallDialog(SmallDialog::new("Incorrect password".into())))].into_iter())
|
|
|
@ -700,7 +697,7 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> { |
|
|
|
},
|
|
|
|
RecvShipPacket::CharData(chardata) => {
|
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|
Box::new(handler::lobby::send_player_to_lobby(id, chardata, &mut block.client_location, &self.clients, &self.item_state, &self.level_table)?.into_iter())
|
|
|
|
Box::new(handler::lobby::send_player_to_lobby(id, chardata, &mut block.client_location, &self.clients, &self.item_state)?.into_iter())
|
|
|
|
},
|
|
|
|
RecvShipPacket::Message(msg) => {
|
|
|
|
self.message(id, msg).await?
|
|
|
@ -714,7 +711,7 @@ impl<EG: EntityGateway + Clone> ServerState for ShipServerState<EG> { |
|
|
|
},
|
|
|
|
RecvShipPacket::CreateRoom(create_room) => {
|
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|
handler::room::create_room(id, create_room, &mut block.client_location, &mut self.clients, &mut self.item_state, &self.level_table, &mut block.rooms)?
|
|
|
|
handler::room::create_room(id, create_room, &mut block.client_location, &mut self.clients, &mut self.item_state, &mut block.rooms)?
|
|
|
|
},
|
|
|
|
RecvShipPacket::RoomNameRequest(_req) => {
|
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
@ -752,7 +749,7 @@ impl<EG: EntityGateway + Clone> 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, self.entity_gateway.clone()).await?.into_iter())
|
|
|
|
Box::new(handler::lobby::change_lobby(id, pkt.lobby, &mut block.client_location, &self.clients, &mut self.item_state, &mut block.rooms, self.entity_gateway.clone()).await?.into_iter())
|
|
|
|
},
|
|
|
|
RecvShipPacket::RequestQuestList(rql) => {
|
|
|
|
let block = self.blocks.with_client(id, &self.clients)?;
|
|
|
|