|
|
@ -10,13 +10,14 @@ use libpso::{PacketParseError, PSOPacket}; |
|
|
|
use libpso::crypto::bb::PSOBBCipher;
|
|
|
|
use libpso::character::character;
|
|
|
|
use libpso::packet::ship::{ROOM_MENU_ID};
|
|
|
|
use libpso::{utf8_to_array, utf8_to_utf16_array};
|
|
|
|
|
|
|
|
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::entity::gateway::EntityGateway;
|
|
|
|
use crate::entity::account::{UserAccount, UserSettings, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM, GuildCard};
|
|
|
|
use crate::entity::account::{UserAccount, UserSettings, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM};
|
|
|
|
use crate::entity::character::CharacterEntity;
|
|
|
|
use crate::entity::item::{ItemLocation, Item};
|
|
|
|
use crate::login::login::get_login_status;
|
|
|
@ -122,21 +123,20 @@ struct ClientState { |
|
|
|
settings: UserSettings,
|
|
|
|
character: CharacterEntity,
|
|
|
|
session: Session,
|
|
|
|
guildcard: GuildCard,
|
|
|
|
//guildcard: GuildCard,
|
|
|
|
inventory: items::ActiveInventory,
|
|
|
|
//bank: Bank,
|
|
|
|
block: u32,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ClientState {
|
|
|
|
fn new(user: UserAccount, settings: UserSettings, character: CharacterEntity, inventory: items::ActiveInventory, /*bank: Bank,*/ session: Session, guildcard: GuildCard) -> ClientState {
|
|
|
|
fn new(user: UserAccount, settings: UserSettings, character: CharacterEntity, inventory: items::ActiveInventory, /*bank: Bank,*/ session: Session) -> ClientState {
|
|
|
|
ClientState {
|
|
|
|
user: user,
|
|
|
|
settings: settings,
|
|
|
|
character: character,
|
|
|
|
session: session,
|
|
|
|
inventory: inventory,
|
|
|
|
guildcard: guildcard,
|
|
|
|
//bank: bank,
|
|
|
|
block: 1,
|
|
|
|
}
|
|
|
@ -181,11 +181,9 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
|
.clone();
|
|
|
|
let settings = self.entity_gateway.get_user_settings_by_user(&user)
|
|
|
|
.ok_or(ShipError::ClientNotFound(id))?;
|
|
|
|
let guildcard = self.entity_gateway.get_guild_card_by_character(&character)
|
|
|
|
.ok_or(ShipError::ClientNotFound(id))?;
|
|
|
|
let inventory = self.item_database.get_character_inventory(&mut self.entity_gateway, &character);
|
|
|
|
|
|
|
|
self.clients.insert(id, ClientState::new(user, settings, character, inventory, pkt.session, guildcard));
|
|
|
|
self.clients.insert(id, ClientState::new(user, settings, character, inventory, pkt.session));
|
|
|
|
vec![SendShipPacket::LoginResponse(response), SendShipPacket::ShipBlockList(ShipBlockList::new(&self.name, 3))]
|
|
|
|
},
|
|
|
|
Err(err) => {
|
|
|
@ -331,22 +329,21 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
|
fn direct_message(&mut self, id: ClientId, msg: &DirectMessage) -> Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send> {
|
|
|
|
let cmsg = msg.clone();
|
|
|
|
let client = self.clients.get_mut(&id).unwrap();
|
|
|
|
let gc = self.entity_gateway.get_guild_card_by_character(&client.character).unwrap();
|
|
|
|
match &cmsg.msg {
|
|
|
|
GameMessage::GuildcardSend(GuildcardSend) => {
|
|
|
|
GameMessage::GuildcardSend(guildcard_send) => {
|
|
|
|
let out_msg = DirectMessage{
|
|
|
|
flag: cmsg.flag,
|
|
|
|
msg: GameMessage::GuildcardRecv(GuildcardRecv {
|
|
|
|
client: 141,
|
|
|
|
target: 8,
|
|
|
|
guildcard: gc.guildcard.guildcard,
|
|
|
|
name: gc.guildcard.name,
|
|
|
|
team: gc.guildcard.team,
|
|
|
|
desc: gc.guildcard.desc,
|
|
|
|
client: guildcard_send.client,
|
|
|
|
target: guildcard_send.target,
|
|
|
|
guildcard: client.user.id,
|
|
|
|
name: utf8_to_utf16_array!(client.character.name, 0x18),
|
|
|
|
team: [0; 0x10], // TODO: teams not yet implemented
|
|
|
|
desc: utf8_to_utf16_array!(client.character.guildcard.description, 0x58),
|
|
|
|
one: 1,
|
|
|
|
language: gc.guildcard.language,
|
|
|
|
section_id: gc.guildcard.section_id,
|
|
|
|
class: gc.guildcard.class,
|
|
|
|
language: 0, // TODO: add language flag to character
|
|
|
|
section_id: client.character.section_id.into(),
|
|
|
|
class: client.character.char_class.into(),
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
Box::new(self.client_location.get_area_by_user(id).clients().iter()
|
|
|
|