|
@ -17,7 +17,7 @@ use crate::common::serverstate::{SendServerPacket, RecvServerPacket, ServerState |
|
|
use crate::common::leveltable::CharacterLevelTable;
|
|
|
use crate::common::leveltable::CharacterLevelTable;
|
|
|
|
|
|
|
|
|
use crate::entity::gateway::EntityGateway;
|
|
|
use crate::entity::gateway::EntityGateway;
|
|
|
use crate::entity::account::{UserAccount, UserSettings, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM};
|
|
|
|
|
|
|
|
|
use crate::entity::account::{UserAccountEntity, UserSettingsEntity, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM};
|
|
|
use crate::entity::character::CharacterEntity;
|
|
|
use crate::entity::character::CharacterEntity;
|
|
|
use crate::entity::item::{ItemLocation, ItemEntity};
|
|
|
use crate::entity::item::{ItemLocation, ItemEntity};
|
|
|
use crate::login::login::get_login_status;
|
|
|
use crate::login::login::get_login_status;
|
|
@ -119,8 +119,8 @@ impl SendServerPacket for SendShipPacket { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
struct ClientState {
|
|
|
struct ClientState {
|
|
|
user: UserAccount,
|
|
|
|
|
|
settings: UserSettings,
|
|
|
|
|
|
|
|
|
user: UserAccountEntity,
|
|
|
|
|
|
settings: UserSettingsEntity,
|
|
|
character: CharacterEntity,
|
|
|
character: CharacterEntity,
|
|
|
session: Session,
|
|
|
session: Session,
|
|
|
//guildcard: GuildCard,
|
|
|
//guildcard: GuildCard,
|
|
@ -130,7 +130,7 @@ struct ClientState { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl ClientState {
|
|
|
impl ClientState {
|
|
|
fn new(user: UserAccount, settings: UserSettings, character: CharacterEntity, inventory: items::ActiveInventory, /*bank: Bank,*/ session: Session) -> ClientState {
|
|
|
|
|
|
|
|
|
fn new(user: UserAccountEntity, settings: UserSettingsEntity, character: CharacterEntity, inventory: items::ActiveInventory, /*bank: Bank,*/ session: Session) -> ClientState {
|
|
|
ClientState {
|
|
|
ClientState {
|
|
|
user: user,
|
|
|
user: user,
|
|
|
settings: settings,
|
|
|
settings: settings,
|
|
@ -171,7 +171,7 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
Ok(match get_login_status(&self.entity_gateway, pkt) {
|
|
|
Ok(match get_login_status(&self.entity_gateway, pkt) {
|
|
|
Ok(user) => {
|
|
|
Ok(user) => {
|
|
|
let mut response = LoginResponse::by_status(AccountStatus::Ok, Session::new());
|
|
|
let mut response = LoginResponse::by_status(AccountStatus::Ok, Session::new());
|
|
|
response.guildcard = user.id as u32;
|
|
|
|
|
|
|
|
|
response.guildcard = user.id.0 as u32;
|
|
|
response.team_id = user.team_id.map_or(31, |ti| ti) as u32;
|
|
|
response.team_id = user.team_id.map_or(31, |ti| ti) as u32;
|
|
|
let characters = self.entity_gateway.get_characters_by_user(&user);
|
|
|
let characters = self.entity_gateway.get_characters_by_user(&user);
|
|
|
let character = characters
|
|
|
let character = characters
|
|
@ -233,7 +233,7 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
PlayerInfo {
|
|
|
PlayerInfo {
|
|
|
header: PlayerHeader {
|
|
|
header: PlayerHeader {
|
|
|
tag: 0x100,
|
|
|
tag: 0x100,
|
|
|
guildcard: client.user.id,
|
|
|
|
|
|
|
|
|
guildcard: client.user.id.0,
|
|
|
_unknown1: [0; 5],
|
|
|
_unknown1: [0; 5],
|
|
|
client_id: room_client.index as u32,
|
|
|
client_id: room_client.index as u32,
|
|
|
name: c.name,
|
|
|
name: c.name,
|
|
@ -289,7 +289,7 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
playerinfo: PlayerInfo {
|
|
|
playerinfo: PlayerInfo {
|
|
|
header: PlayerHeader {
|
|
|
header: PlayerHeader {
|
|
|
tag: 0x100,
|
|
|
tag: 0x100,
|
|
|
guildcard: client.user.id,
|
|
|
|
|
|
|
|
|
guildcard: client.user.id.0,
|
|
|
_unknown1: [0; 5],
|
|
|
_unknown1: [0; 5],
|
|
|
client_id: client_id as u32,
|
|
|
client_id: client_id as u32,
|
|
|
name: c.name,
|
|
|
name: c.name,
|
|
@ -336,7 +336,7 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
msg: GameMessage::GuildcardRecv(GuildcardRecv {
|
|
|
msg: GameMessage::GuildcardRecv(GuildcardRecv {
|
|
|
client: guildcard_send.client,
|
|
|
client: guildcard_send.client,
|
|
|
target: guildcard_send.target,
|
|
|
target: guildcard_send.target,
|
|
|
guildcard: client.user.id,
|
|
|
|
|
|
|
|
|
guildcard: client.user.id.0,
|
|
|
name: utf8_to_utf16_array!(client.character.name, 0x18),
|
|
|
name: utf8_to_utf16_array!(client.character.name, 0x18),
|
|
|
team: [0; 0x10], // TODO: teams not yet implemented
|
|
|
team: [0; 0x10], // TODO: teams not yet implemented
|
|
|
desc: utf8_to_utf16_array!(client.character.guildcard.description, 0x58),
|
|
|
desc: utf8_to_utf16_array!(client.character.guildcard.description, 0x58),
|
|
@ -365,7 +365,7 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
|
|
|
|
|
|
fn player_chat(&mut self, id: ClientId, msg: &PlayerChat) -> Result<Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send>, ShipError> {
|
|
|
fn player_chat(&mut self, id: ClientId, msg: &PlayerChat) -> Result<Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send>, ShipError> {
|
|
|
let client = self.clients.get_mut(&id).ok_or(ShipError::ClientNotFound(id))?;
|
|
|
let client = self.clients.get_mut(&id).ok_or(ShipError::ClientNotFound(id))?;
|
|
|
let cmsg = PlayerChat::new(client.user.id, msg.message.clone());
|
|
|
|
|
|
|
|
|
let cmsg = PlayerChat::new(client.user.id.0, msg.message.clone());
|
|
|
|
|
|
|
|
|
Ok(Box::new(self.client_location.get_area_by_user(id).clients().iter()
|
|
|
Ok(Box::new(self.client_location.get_area_by_user(id).clients().iter()
|
|
|
.map(move |client| {
|
|
|
.map(move |client| {
|
|
@ -392,7 +392,7 @@ impl<EG: EntityGateway> ShipServerState<EG> { |
|
|
let client = self.clients.get_mut(&id).unwrap();//.ok_or(ShipError::ClientNotFound(id)).unwrap();
|
|
|
let client = self.clients.get_mut(&id).unwrap();//.ok_or(ShipError::ClientNotFound(id)).unwrap();
|
|
|
let players = [PlayerHeader {
|
|
|
let players = [PlayerHeader {
|
|
|
tag: 0x00010000,
|
|
|
tag: 0x00010000,
|
|
|
guildcard: client.user.id,
|
|
|
|
|
|
|
|
|
guildcard: client.user.id.0,
|
|
|
_unknown1: [0; 5],
|
|
|
_unknown1: [0; 5],
|
|
|
client_id: 0,
|
|
|
client_id: 0,
|
|
|
name: libpso::utf8_to_utf16_array!(client.character.name, 16),
|
|
|
name: libpso::utf8_to_utf16_array!(client.character.name, 16),
|
|
|