|
@ -6,7 +6,7 @@ use rand::Rng; |
|
|
use thiserror::Error;
|
|
|
use thiserror::Error;
|
|
|
|
|
|
|
|
|
use libpso::packet::ship::*;
|
|
|
use libpso::packet::ship::*;
|
|
|
use libpso::packet::login::{Login, LoginResponse, Session};
|
|
|
|
|
|
|
|
|
use libpso::packet::login::{RedirectClient, Login, LoginResponse, Session, ShipList};
|
|
|
use libpso::packet::messages::*;
|
|
|
use libpso::packet::messages::*;
|
|
|
use libpso::{PacketParseError, PSOPacket};
|
|
|
use libpso::{PacketParseError, PSOPacket};
|
|
|
use libpso::crypto::bb::PSOBBCipher;
|
|
|
use libpso::crypto::bb::PSOBBCipher;
|
|
@ -18,6 +18,8 @@ use crate::common::serverstate::{SendServerPacket, RecvServerPacket, ServerState |
|
|
use crate::common::leveltable::CharacterLevelTable;
|
|
|
use crate::common::leveltable::CharacterLevelTable;
|
|
|
use crate::common::interserver::{AuthToken, Ship, ServerId, InterserverActor, LoginMessage, ShipMessage};
|
|
|
use crate::common::interserver::{AuthToken, Ship, ServerId, InterserverActor, LoginMessage, ShipMessage};
|
|
|
|
|
|
|
|
|
|
|
|
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};
|
|
@ -67,6 +69,7 @@ pub enum ShipError { |
|
|
ShopError,
|
|
|
ShopError,
|
|
|
GatewayError(#[from] GatewayError),
|
|
|
GatewayError(#[from] GatewayError),
|
|
|
UnknownMonster(crate::ship::monster::MonsterType),
|
|
|
UnknownMonster(crate::ship::monster::MonsterType),
|
|
|
|
|
|
InvalidShip(usize),
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
#[derive(Debug)]
|
|
@ -98,6 +101,8 @@ pub enum RecvShipPacket { |
|
|
DoneLoadingQuest(DoneLoadingQuest),
|
|
|
DoneLoadingQuest(DoneLoadingQuest),
|
|
|
FullCharacterData(Box<FullCharacterData>),
|
|
|
FullCharacterData(Box<FullCharacterData>),
|
|
|
SaveOptions(SaveOptions),
|
|
|
SaveOptions(SaveOptions),
|
|
|
|
|
|
RequestShipList(RequestShipList),
|
|
|
|
|
|
RequestShipBlockList(RequestShipBlockList),
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl RecvServerPacket for RecvShipPacket {
|
|
|
impl RecvServerPacket for RecvShipPacket {
|
|
@ -131,6 +136,8 @@ impl RecvServerPacket for RecvShipPacket { |
|
|
0x6F => Ok(RecvShipPacket::DoneBursting(DoneBursting::from_bytes(data)?)),
|
|
|
0x6F => Ok(RecvShipPacket::DoneBursting(DoneBursting::from_bytes(data)?)),
|
|
|
0x16F => Ok(RecvShipPacket::DoneBursting2(DoneBursting2::from_bytes(data)?)),
|
|
|
0x16F => Ok(RecvShipPacket::DoneBursting2(DoneBursting2::from_bytes(data)?)),
|
|
|
0x84 => Ok(RecvShipPacket::LobbySelect(LobbySelect::from_bytes(data)?)),
|
|
|
0x84 => Ok(RecvShipPacket::LobbySelect(LobbySelect::from_bytes(data)?)),
|
|
|
|
|
|
0xA0 => Ok(RecvShipPacket::RequestShipList(RequestShipList::from_bytes(data)?)),
|
|
|
|
|
|
0xA1 => Ok(RecvShipPacket::RequestShipBlockList(RequestShipBlockList::from_bytes(data)?)),
|
|
|
0xA2 => Ok(RecvShipPacket::RequestQuestList(RequestQuestList::from_bytes(data)?)),
|
|
|
0xA2 => Ok(RecvShipPacket::RequestQuestList(RequestQuestList::from_bytes(data)?)),
|
|
|
0xAC => Ok(RecvShipPacket::DoneLoadingQuest(DoneLoadingQuest::from_bytes(data)?)),
|
|
|
0xAC => Ok(RecvShipPacket::DoneLoadingQuest(DoneLoadingQuest::from_bytes(data)?)),
|
|
|
0xE7 => Ok(RecvShipPacket::FullCharacterData(Box::new(FullCharacterData::from_bytes(data)?))),
|
|
|
0xE7 => Ok(RecvShipPacket::FullCharacterData(Box::new(FullCharacterData::from_bytes(data)?))),
|
|
@ -144,6 +151,7 @@ impl RecvServerPacket for RecvShipPacket { |
|
|
pub enum SendShipPacket {
|
|
|
pub enum SendShipPacket {
|
|
|
ShipWelcome(ShipWelcome),
|
|
|
ShipWelcome(ShipWelcome),
|
|
|
LoginResponse(LoginResponse),
|
|
|
LoginResponse(LoginResponse),
|
|
|
|
|
|
ShipList(ShipList),
|
|
|
ShipBlockList(ShipBlockList),
|
|
|
ShipBlockList(ShipBlockList),
|
|
|
FullCharacter(Box<FullCharacter>),
|
|
|
FullCharacter(Box<FullCharacter>),
|
|
|
CharDataRequest(CharDataRequest),
|
|
|
CharDataRequest(CharDataRequest),
|
|
@ -172,6 +180,7 @@ pub enum SendShipPacket { |
|
|
QuestChunk(QuestChunk),
|
|
|
QuestChunk(QuestChunk),
|
|
|
DoneLoadingQuest(DoneLoadingQuest),
|
|
|
DoneLoadingQuest(DoneLoadingQuest),
|
|
|
BankItemList(BankItemList),
|
|
|
BankItemList(BankItemList),
|
|
|
|
|
|
RedirectClient(RedirectClient),
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl SendServerPacket for SendShipPacket {
|
|
|
impl SendServerPacket for SendShipPacket {
|
|
@ -179,6 +188,7 @@ impl SendServerPacket for SendShipPacket { |
|
|
match self {
|
|
|
match self {
|
|
|
SendShipPacket::ShipWelcome(pkt) => pkt.as_bytes(),
|
|
|
SendShipPacket::ShipWelcome(pkt) => pkt.as_bytes(),
|
|
|
SendShipPacket::LoginResponse(pkt) => pkt.as_bytes(),
|
|
|
SendShipPacket::LoginResponse(pkt) => pkt.as_bytes(),
|
|
|
|
|
|
SendShipPacket::ShipList(pkt) => pkt.as_bytes(),
|
|
|
SendShipPacket::ShipBlockList(pkt) => pkt.as_bytes(),
|
|
|
SendShipPacket::ShipBlockList(pkt) => pkt.as_bytes(),
|
|
|
SendShipPacket::FullCharacter(pkt) => pkt.as_bytes(),
|
|
|
SendShipPacket::FullCharacter(pkt) => pkt.as_bytes(),
|
|
|
SendShipPacket::CharDataRequest(pkt) => pkt.as_bytes(),
|
|
|
SendShipPacket::CharDataRequest(pkt) => pkt.as_bytes(),
|
|
@ -207,6 +217,7 @@ impl SendServerPacket for SendShipPacket { |
|
|
SendShipPacket::QuestChunk(pkt) => pkt.as_bytes(),
|
|
|
SendShipPacket::QuestChunk(pkt) => pkt.as_bytes(),
|
|
|
SendShipPacket::DoneLoadingQuest(pkt) => pkt.as_bytes(),
|
|
|
SendShipPacket::DoneLoadingQuest(pkt) => pkt.as_bytes(),
|
|
|
SendShipPacket::BankItemList(pkt) => pkt.as_bytes(),
|
|
|
SendShipPacket::BankItemList(pkt) => pkt.as_bytes(),
|
|
|
|
|
|
SendShipPacket::RedirectClient(pkt) => pkt.as_bytes(),
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@ -508,6 +519,7 @@ impl<EG: EntityGateway> ServerState for ShipServerState<EG> { |
|
|
},
|
|
|
},
|
|
|
RecvShipPacket::MenuSelect(menuselect) => {
|
|
|
RecvShipPacket::MenuSelect(menuselect) => {
|
|
|
match menuselect.menu {
|
|
|
match menuselect.menu {
|
|
|
|
|
|
SHIP_MENU_ID => handler::ship::selected_ship(id, menuselect, &self.ship_list)?,
|
|
|
BLOCK_MENU_ID => Box::new(handler::lobby::block_selected(id, menuselect, &mut self.clients, &self.item_manager, &self.level_table)?.into_iter().map(move |pkt| (id, pkt))),
|
|
|
BLOCK_MENU_ID => Box::new(handler::lobby::block_selected(id, menuselect, &mut self.clients, &self.item_manager, &self.level_table)?.into_iter().map(move |pkt| (id, pkt))),
|
|
|
ROOM_MENU_ID => handler::room::join_room(id, menuselect, &mut self.client_location, &mut self.clients, &mut self.item_manager, &self.level_table, &mut self.rooms)?,
|
|
|
ROOM_MENU_ID => handler::room::join_room(id, menuselect, &mut self.client_location, &mut self.clients, &mut self.item_manager, &self.level_table, &mut self.rooms)?,
|
|
|
QUEST_CATEGORY_MENU_ID => handler::quest::select_quest_category(id, menuselect, &self.quests)?,
|
|
|
QUEST_CATEGORY_MENU_ID => handler::quest::select_quest_category(id, menuselect, &self.quests)?,
|
|
@ -599,6 +611,12 @@ impl<EG: EntityGateway> ServerState for ShipServerState<EG> { |
|
|
RecvShipPacket::SaveOptions(save_options) => {
|
|
|
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, &mut self.entity_gateway).await
|
|
|
},
|
|
|
},
|
|
|
|
|
|
RecvShipPacket::RequestShipList(_) => {
|
|
|
|
|
|
handler::ship::ship_list(id, &self.ship_list)
|
|
|
|
|
|
},
|
|
|
|
|
|
RecvShipPacket::RequestShipBlockList(_) => {
|
|
|
|
|
|
handler::ship::block_list(id, &self.name, 1)
|
|
|
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
@ -654,7 +672,9 @@ impl<EG: EntityGateway> InterserverActor for ShipServerState<EG> { |
|
|
ip: self.ip.clone(),
|
|
|
ip: self.ip.clone(),
|
|
|
port: self.port,
|
|
|
port: self.port,
|
|
|
block_count: 2,
|
|
|
block_count: 2,
|
|
|
})) ]
|
|
|
|
|
|
|
|
|
})),
|
|
|
|
|
|
(id, ShipMessage::RequestShipList)
|
|
|
|
|
|
]
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
async fn action(&mut self, id: ServerId, msg: Self::RecvMessage) -> Result<Vec<(ServerId, Self::SendMessage)>, Self::Error> {
|
|
|
async fn action(&mut self, id: ServerId, msg: Self::RecvMessage) -> Result<Vec<(ServerId, Self::SendMessage)>, Self::Error> {
|
|
|