Browse Source

UserAccount/UserSettings/GuildCardData -> *Entities

pbs
jake 5 years ago
parent
commit
6b1ef41bd0
  1. 24
      src/entity/account.rs
  2. 5
      src/entity/character.rs
  3. 16
      src/entity/gateway/entitygateway.rs
  4. 32
      src/entity/gateway/inmemory.rs
  5. 12
      src/login/character.rs
  6. 18
      src/login/login.rs
  7. 18
      src/main.rs
  8. 20
      src/ship/ship.rs

24
src/entity/account.rs

@ -6,9 +6,17 @@ use libpso::character::guildcard;
pub const USERFLAG_NEWCHAR: u32 = 0x00000001; pub const USERFLAG_NEWCHAR: u32 = 0x00000001;
pub const USERFLAG_DRESSINGROOM: u32 = 0x00000002; pub const USERFLAG_DRESSINGROOM: u32 = 0x00000002;
// TOOD: these should not derive default
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, Default)]
pub struct UserAccountId(pub u32);
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, Default)]
pub struct UserSettingsId(pub u32);
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, Default)]
pub struct GuildCardDataId(pub u32);
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct UserAccount {
pub id: u32,
pub struct UserAccountEntity {
pub id: UserAccountId,
pub username: String, pub username: String,
pub password: String, pub password: String,
pub guildcard: u32, pub guildcard: u32,
@ -20,15 +28,15 @@ pub struct UserAccount {
} }
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
pub struct UserSettings {
pub id: u32,
pub user_id: u32,
pub struct UserSettingsEntity {
pub id: UserSettingsId,
pub user_id: UserAccountId,
pub settings: settings::UserSettings, pub settings: settings::UserSettings,
} }
#[derive(Clone, Default)] #[derive(Clone, Default)]
pub struct GuildCardData {
pub id: u32,
pub user_id: u32,
pub struct GuildCardDataEntity {
pub id: GuildCardDataId,
pub user_id: UserAccountId,
pub guildcard: guildcard::GuildCardData, pub guildcard: guildcard::GuildCardData,
} }

5
src/entity/character.rs

@ -3,6 +3,7 @@ use std::collections::HashMap;
use libpso::packet::ship::{UpdateConfig, WriteInfoboard}; use libpso::packet::ship::{UpdateConfig, WriteInfoboard};
use crate::entity::item::tech::Technique; use crate::entity::item::tech::Technique;
use crate::entity::account::UserAccountId;
#[derive(Copy, Clone, Hash, PartialEq, Eq)] #[derive(Copy, Clone, Hash, PartialEq, Eq)]
pub enum CharacterClass { pub enum CharacterClass {
@ -234,7 +235,7 @@ pub struct CharacterEntityId(pub u32);
#[derive(Clone)] #[derive(Clone)]
pub struct CharacterEntity { pub struct CharacterEntity {
pub id: CharacterEntityId, pub id: CharacterEntityId,
pub user_id: u32,
pub user_id: UserAccountId,
pub slot: u32, pub slot: u32,
pub name: String, pub name: String,
@ -254,7 +255,7 @@ impl std::default::Default for CharacterEntity {
fn default() -> CharacterEntity { fn default() -> CharacterEntity {
CharacterEntity { CharacterEntity {
id: CharacterEntityId(0), id: CharacterEntityId(0),
user_id: 0,
user_id: UserAccountId(0),
slot: 0, slot: 0,
name: "".into(), name: "".into(),
exp: 0, exp: 0,

16
src/entity/gateway/entitygateway.rs

@ -5,27 +5,27 @@ use crate::entity::item::*;
use libpso::item; use libpso::item;
pub trait EntityGateway { pub trait EntityGateway {
fn get_user_by_id(&self, _id: u32) -> Option<UserAccount> {
fn get_user_by_id(&self, _id: UserAccountId) -> Option<UserAccountEntity> {
unimplemented!(); unimplemented!();
} }
fn get_user_by_name(&self, _username: String) -> Option<UserAccount> {
fn get_user_by_name(&self, _username: String) -> Option<UserAccountEntity> {
unimplemented!(); unimplemented!();
} }
fn set_user(&mut self, _user: &UserAccount) {
fn set_user(&mut self, _user: &UserAccountEntity) {
unimplemented!(); unimplemented!();
} }
fn get_user_settings_by_user(&self, _user: &UserAccount) -> Option<UserSettings> {
fn get_user_settings_by_user(&self, _user: &UserAccountEntity) -> Option<UserSettingsEntity> {
unimplemented!(); unimplemented!();
} }
fn create_user_settings_by_user(&self, _user: &UserAccount) -> UserSettings {
fn create_user_settings_by_user(&self, _user: &UserAccountEntity) -> UserSettingsEntity {
unimplemented!(); unimplemented!();
} }
fn get_characters_by_user(&self, _user: &UserAccount) -> [Option<CharacterEntity>; 4] {
fn get_characters_by_user(&self, _user: &UserAccountEntity) -> [Option<CharacterEntity>; 4] {
unimplemented!(); unimplemented!();
} }
@ -33,11 +33,11 @@ pub trait EntityGateway {
unimplemented!(); unimplemented!();
} }
fn new_character_by_user(&mut self, _user: &UserAccount) -> CharacterEntity {
fn new_character_by_user(&mut self, _user: &UserAccountEntity) -> CharacterEntity {
unimplemented!(); unimplemented!();
} }
fn get_guild_card_data_by_user(&self, _user: &UserAccount) -> GuildCardData {
fn get_guild_card_data_by_user(&self, _user: &UserAccountEntity) -> GuildCardDataEntity {
unimplemented!(); unimplemented!();
} }

32
src/entity/gateway/inmemory.rs

@ -13,8 +13,8 @@ use std::sync::{Arc, Mutex};
#[derive(Clone)] #[derive(Clone)]
pub struct InMemoryGateway { pub struct InMemoryGateway {
users: Arc<Mutex<HashMap<u32, UserAccount>>>,
user_settings: Arc<Mutex<HashMap<u32, UserSettings>>>,
users: Arc<Mutex<HashMap<UserAccountId, UserAccountEntity>>>,
user_settings: Arc<Mutex<HashMap<UserSettingsId, UserSettingsEntity>>>,
characters: Arc<Mutex<HashMap<CharacterEntityId, CharacterEntity>>>, characters: Arc<Mutex<HashMap<CharacterEntityId, CharacterEntity>>>,
items: Arc<Mutex<HashMap<ItemEntityId, ItemEntity>>>, items: Arc<Mutex<HashMap<ItemEntityId, ItemEntity>>>,
} }
@ -31,12 +31,12 @@ impl InMemoryGateway {
} }
impl EntityGateway for InMemoryGateway { impl EntityGateway for InMemoryGateway {
fn get_user_by_id(&self, id: u32) -> Option<UserAccount> {
fn get_user_by_id(&self, id: UserAccountId) -> Option<UserAccountEntity> {
let users = self.users.lock().unwrap(); let users = self.users.lock().unwrap();
users.get(&id).map(|k| k.clone()) users.get(&id).map(|k| k.clone())
} }
fn get_user_by_name(&self, username: String) -> Option<UserAccount> {
fn get_user_by_name(&self, username: String) -> Option<UserAccountEntity> {
let users = self.users.lock().unwrap(); let users = self.users.lock().unwrap();
users users
.iter() .iter()
@ -44,35 +44,35 @@ impl EntityGateway for InMemoryGateway {
.map(|(_, k)| k.clone()) .map(|(_, k)| k.clone())
} }
fn set_user(&mut self, user: &UserAccount) {
fn set_user(&mut self, user: &UserAccountEntity) {
let mut users = self.users.lock().unwrap(); let mut users = self.users.lock().unwrap();
users.insert(user.id, user.clone()); users.insert(user.id, user.clone());
} }
fn get_user_settings_by_user(&self, user: &UserAccount) -> Option<UserSettings> {
fn get_user_settings_by_user(&self, user: &UserAccountEntity) -> Option<UserSettingsEntity> {
let user_settings = self.user_settings.lock().unwrap(); let user_settings = self.user_settings.lock().unwrap();
user_settings user_settings
.iter() .iter()
.find(|(_, k)| k.id == user.id)
.find(|(_, k)| k.user_id == user.id)
.map(|(_, k)| k.clone()) .map(|(_, k)| k.clone())
} }
fn create_user_settings_by_user(&self, user: &UserAccount) -> UserSettings {
fn create_user_settings_by_user(&self, user: &UserAccountEntity) -> UserSettingsEntity {
let mut user_settings = self.user_settings.lock().unwrap(); let mut user_settings = self.user_settings.lock().unwrap();
let id = user_settings let id = user_settings
.iter() .iter()
.fold(0, |sum, (i, _)| std::cmp::max(sum, *i))
.fold(0, |sum, (i, _)| std::cmp::max(sum, i.0))
+ 1; + 1;
let new_settings = UserSettings {
id: id,
let new_settings = UserSettingsEntity {
id: UserSettingsId(id),
user_id: user.id, user_id: user.id,
settings: settings::UserSettings::default(), settings: settings::UserSettings::default(),
}; };
user_settings.insert(id, new_settings.clone());
user_settings.insert(new_settings.id, new_settings.clone());
new_settings new_settings
} }
fn get_characters_by_user(&self, user: &UserAccount) -> [Option<CharacterEntity>; 4] {
fn get_characters_by_user(&self, user: &UserAccountEntity) -> [Option<CharacterEntity>; 4] {
let characters = self.characters.lock().unwrap(); let characters = self.characters.lock().unwrap();
let mut chars = [None; 4]; let mut chars = [None; 4];
characters characters
@ -82,7 +82,7 @@ impl EntityGateway for InMemoryGateway {
chars chars
} }
fn new_character_by_user(&mut self, user: &UserAccount) -> CharacterEntity {
fn new_character_by_user(&mut self, user: &UserAccountEntity) -> CharacterEntity {
let mut characters = self.characters.lock().unwrap(); let mut characters = self.characters.lock().unwrap();
let id = characters let id = characters
.iter() .iter()
@ -101,8 +101,8 @@ impl EntityGateway for InMemoryGateway {
characters.insert(char.id, char.clone()); characters.insert(char.id, char.clone());
} }
fn get_guild_card_data_by_user(&self, _user: &UserAccount) -> GuildCardData {
GuildCardData::default()
fn get_guild_card_data_by_user(&self, _user: &UserAccountEntity) -> GuildCardDataEntity {
GuildCardDataEntity::default()
} }
fn new_item(&mut self, item: ItemDetail, location: ItemLocation) -> ItemEntity { fn new_item(&mut self, item: ItemDetail, location: ItemLocation) -> ItemEntity {

12
src/login/character.rs

@ -16,7 +16,7 @@ use crate::common::leveltable::CharacterLevelTable;
use libpso::{utf8_to_array, utf8_to_utf16_array}; use libpso::{utf8_to_array, utf8_to_utf16_array};
use crate::entity::gateway::EntityGateway; use crate::entity::gateway::EntityGateway;
use crate::entity::account::{UserAccount, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM};
use crate::entity::account::{UserAccountEntity, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM};
use crate::entity::item::{ItemDetail, ItemLocation}; use crate::entity::item::{ItemDetail, ItemLocation};
use crate::entity::item::weapon::Weapon; use crate::entity::item::weapon::Weapon;
use crate::entity::item::armor::Armor; use crate::entity::item::armor::Armor;
@ -142,7 +142,7 @@ fn generate_param_data(path: &str) -> (ParamDataHeader, Vec<u8>) {
#[derive(Clone)] #[derive(Clone)]
struct ClientState { struct ClientState {
param_index: usize, param_index: usize,
user: Option<UserAccount>,
user: Option<UserAccountEntity>,
characters: Option<[Option<CharacterEntity>; 4]>, characters: Option<[Option<CharacterEntity>; 4]>,
guildcard_data_buffer: Option<Vec<u8>>, guildcard_data_buffer: Option<Vec<u8>>,
session: Session, session: Session,
@ -189,7 +189,7 @@ pub struct CharacterServerState<EG: EntityGateway> {
} }
fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAccount, preview: &CharacterPreview) {
fn new_character<EG: EntityGateway>(entity_gateway: &mut EG, user: &UserAccountEntity, preview: &CharacterPreview) {
let mut char = entity_gateway.new_character_by_user(&user); let mut char = entity_gateway.new_character_by_user(&user);
new_character_from_preview(&mut char, preview); new_character_from_preview(&mut char, preview);
match char.char_class { match char.char_class {
@ -647,7 +647,7 @@ mod test {
} }
impl EntityGateway for TestData { impl EntityGateway for TestData {
fn get_user_settings_by_user(&self, _user: &UserAccount) -> Option<UserSettings> {
fn get_user_settings_by_user(&self, _user: &UserAccountEntity) -> Option<UserSettings> {
Some(UserSettings { Some(UserSettings {
id: 0, id: 0,
user_id: 0, user_id: 0,
@ -658,7 +658,7 @@ mod test {
let mut server = CharacterServerState::new(TestData {}); let mut server = CharacterServerState::new(TestData {});
let mut clientstate = ClientState::new(); let mut clientstate = ClientState::new();
clientstate.user = Some(UserAccount {
clientstate.user = Some(UserAccountEntity {
id: 1, id: 1,
username: "testuser".to_owned(), username: "testuser".to_owned(),
password: bcrypt::hash("mypassword", 5).unwrap(), password: bcrypt::hash("mypassword", 5).unwrap(),
@ -700,7 +700,7 @@ mod test {
fn test_character_create() { fn test_character_create() {
let TestData = InMemoryGateway::new(); let TestData = InMemoryGateway::new();
let mut fake_user = ClientState::new(); let mut fake_user = ClientState::new();
fake_user.user = Some(UserAccount {
fake_user.user = Some(UserAccountEntity {
id: 3, id: 3,
username: "hi3".to_string(), username: "hi3".to_string(),
password: bcrypt::hash("qwer", 5).unwrap(), password: bcrypt::hash("qwer", 5).unwrap(),

18
src/login/login.rs

@ -14,7 +14,7 @@ use crate::common::cipherkeys::{ELSEWHERE_PRIVATE_KEY, ELSEWHERE_PARRAY};
use crate::common::serverstate::{SendServerPacket, RecvServerPacket, ServerState, OnConnect, ClientId}; use crate::common::serverstate::{SendServerPacket, RecvServerPacket, ServerState, OnConnect, ClientId};
use crate::entity::gateway::EntityGateway; use crate::entity::gateway::EntityGateway;
use crate::entity::account::UserAccount;
use crate::entity::account::UserAccountEntity;
pub const LOGIN_PORT: u16 = 12000; pub const LOGIN_PORT: u16 = 12000;
@ -56,7 +56,7 @@ impl SendServerPacket for SendLoginPacket {
} }
pub fn get_login_status(entity_gateway: &impl EntityGateway, pkt: &Login) -> Result<UserAccount, AccountStatus> {
pub fn get_login_status(entity_gateway: &impl EntityGateway, pkt: &Login) -> Result<UserAccountEntity, AccountStatus> {
let username = array_to_utf8(pkt.username).map_err(|_err| AccountStatus::Error)?; let username = array_to_utf8(pkt.username).map_err(|_err| AccountStatus::Error)?;
let password = array_to_utf8(pkt.password).map_err(|_err| AccountStatus::Error)?; let password = array_to_utf8(pkt.password).map_err(|_err| AccountStatus::Error)?;
let user = entity_gateway.get_user_by_name(username).ok_or(AccountStatus::InvalidUser)?; let user = entity_gateway.get_user_by_name(username).ok_or(AccountStatus::InvalidUser)?;
@ -172,9 +172,9 @@ mod test {
} }
impl EntityGateway for TestData { impl EntityGateway for TestData {
fn get_user_by_name(&self, name: String) -> Option<UserAccount> {
fn get_user_by_name(&self, name: String) -> Option<UserAccountEntity> {
assert!(name == "testuser"); assert!(name == "testuser");
Some(UserAccount {
Some(UserAccountEntity {
id: 1, id: 1,
username: "testuser".to_owned(), username: "testuser".to_owned(),
password: bcrypt::hash("mypassword", 5).unwrap(), password: bcrypt::hash("mypassword", 5).unwrap(),
@ -220,7 +220,7 @@ mod test {
} }
impl EntityGateway for TestData { impl EntityGateway for TestData {
fn get_user_by_name(&self, _name: String) -> Option<UserAccount> {
fn get_user_by_name(&self, _name: String) -> Option<UserAccountEntity> {
None None
} }
} }
@ -252,9 +252,9 @@ mod test {
} }
impl EntityGateway for TestData { impl EntityGateway for TestData {
fn get_user_by_name(&self, name: String) -> Option<UserAccount> {
fn get_user_by_name(&self, name: String) -> Option<UserAccountEntity> {
assert!(name == "testuser"); assert!(name == "testuser");
Some(UserAccount {
Some(UserAccountEntity {
id: 1, id: 1,
username: "testuser".to_owned(), username: "testuser".to_owned(),
password: bcrypt::hash("notpassword", 5).unwrap(), password: bcrypt::hash("notpassword", 5).unwrap(),
@ -295,9 +295,9 @@ mod test {
} }
impl EntityGateway for TestData { impl EntityGateway for TestData {
fn get_user_by_name(&self, name: String) -> Option<UserAccount> {
fn get_user_by_name(&self, name: String) -> Option<UserAccountEntity> {
assert!(name == "testuser"); assert!(name == "testuser");
Some(UserAccount {
Some(UserAccountEntity {
id: 1, id: 1,
username: "testuser".to_owned(), username: "testuser".to_owned(),
password: bcrypt::hash("mypassword", 5).unwrap(), password: bcrypt::hash("mypassword", 5).unwrap(),

18
src/main.rs

@ -18,7 +18,7 @@ use patch::patch::{PatchServerState, generate_patch_tree, load_config, load_motd
use login::login::LoginServerState; use login::login::LoginServerState;
use login::character::CharacterServerState; use login::character::CharacterServerState;
use ship::ship::ShipServerState; use ship::ship::ShipServerState;
use entity::account::UserAccount;
use entity::account::{UserAccountEntity, UserAccountId};
use entity::gateway::{EntityGateway, InMemoryGateway}; use entity::gateway::{EntityGateway, InMemoryGateway};
use entity::item::ItemLocation; use entity::item::ItemLocation;
@ -58,8 +58,8 @@ fn main() {
setup_logger(); setup_logger();
let mut entity_gateway = InMemoryGateway::new(); let mut entity_gateway = InMemoryGateway::new();
let fake_user = UserAccount {
id: 1,
let fake_user = UserAccountEntity {
id: UserAccountId(1),
username: "hi".to_string(), username: "hi".to_string(),
password: bcrypt::hash("qwer", 5).unwrap(), password: bcrypt::hash("qwer", 5).unwrap(),
guildcard: 1u32, guildcard: 1u32,
@ -98,8 +98,8 @@ fn main() {
); );
let fake_user2 = UserAccount {
id: 2,
let fake_user2 = UserAccountEntity {
id: UserAccountId(2),
username: "hi2".to_string(), username: "hi2".to_string(),
password: bcrypt::hash("qwer", 5).unwrap(), password: bcrypt::hash("qwer", 5).unwrap(),
guildcard: 2u32, guildcard: 2u32,
@ -119,8 +119,8 @@ fn main() {
character.name = "Test Char 4".into(); character.name = "Test Char 4".into();
entity_gateway.set_character(&character); entity_gateway.set_character(&character);
let fake_user3 = UserAccount {
id: 3,
let fake_user3 = UserAccountEntity {
id: UserAccountId(3),
username: "hi3".to_string(), username: "hi3".to_string(),
password: bcrypt::hash("qwer", 5).unwrap(), password: bcrypt::hash("qwer", 5).unwrap(),
guildcard: 3u32, guildcard: 3u32,
@ -140,8 +140,8 @@ fn main() {
character.name = "Test Char 6".into(); character.name = "Test Char 6".into();
entity_gateway.set_character(&character); entity_gateway.set_character(&character);
let fake_user4 = UserAccount {
id: 4,
let fake_user4 = UserAccountEntity {
id: UserAccountId(4),
username: "hi4".to_string(), username: "hi4".to_string(),
password: bcrypt::hash("qwer", 5).unwrap(), password: bcrypt::hash("qwer", 5).unwrap(),
guildcard: 4u32, guildcard: 4u32,

20
src/ship/ship.rs

@ -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),

Loading…
Cancel
Save