From bf595f969327b77ef38fb279f55ef582246c6d0b Mon Sep 17 00:00:00 2001 From: jake Date: Sun, 29 Mar 2020 12:43:20 -0700 Subject: [PATCH] Character -> CharacterEntity --- src/entity/character.rs | 8 ++++---- src/entity/gateway/entitygateway.rs | 12 ++++++------ src/entity/gateway/inmemory.rs | 16 ++++++++-------- src/login/character.rs | 10 +++++----- src/ship/character.rs | 10 +++++----- src/ship/items.rs | 4 ++-- src/ship/ship.rs | 6 +++--- 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/entity/character.rs b/src/entity/character.rs index 98da20b..1480016 100644 --- a/src/entity/character.rs +++ b/src/entity/character.rs @@ -225,7 +225,7 @@ impl CharacterInfoboard { #[derive(Clone)] -pub struct Character { +pub struct CharacterEntity { pub id: u32, pub user_id: u32, pub slot: u32, @@ -242,9 +242,9 @@ pub struct Character { pub info_board: CharacterInfoboard, } -impl std::default::Default for Character { - fn default() -> Character { - Character { +impl std::default::Default for CharacterEntity { + fn default() -> CharacterEntity { + CharacterEntity { id: 0, user_id: 0, slot: 0, diff --git a/src/entity/gateway/entitygateway.rs b/src/entity/gateway/entitygateway.rs index edcc45c..564d9b2 100644 --- a/src/entity/gateway/entitygateway.rs +++ b/src/entity/gateway/entitygateway.rs @@ -25,15 +25,15 @@ pub trait EntityGateway { unimplemented!(); } - fn get_characters_by_user(&self, _user: &UserAccount) -> [Option; 4] { + fn get_characters_by_user(&self, _user: &UserAccount) -> [Option; 4] { unimplemented!(); } - fn set_character(&mut self, _char: &Character) { + fn set_character(&mut self, _char: &CharacterEntity) { unimplemented!(); } - fn new_character_by_user(&mut self, _user: &UserAccount) -> Character { + fn new_character_by_user(&mut self, _user: &UserAccount) -> CharacterEntity { unimplemented!(); } @@ -49,15 +49,15 @@ pub trait EntityGateway { unimplemented!(); } - fn get_items_by_character(&self, _char: &Character) -> Vec { + fn get_items_by_character(&self, _char: &CharacterEntity) -> Vec { unimplemented!(); } - fn create_guild_card_by_character(&self, _character: &Character) -> GuildCard { + fn create_guild_card_by_character(&self, _character: &CharacterEntity) -> GuildCard { unimplemented!(); } - fn get_guild_card_by_character(&self, _character: &Character) -> Option { + fn get_guild_card_by_character(&self, _character: &CharacterEntity) -> Option { unimplemented!(); } } diff --git a/src/entity/gateway/inmemory.rs b/src/entity/gateway/inmemory.rs index a616ce4..708b6b4 100644 --- a/src/entity/gateway/inmemory.rs +++ b/src/entity/gateway/inmemory.rs @@ -16,7 +16,7 @@ pub struct InMemoryGateway { users: Arc>>, user_settings: Arc>>, guildcards: Arc>>, - characters: Arc>>, + characters: Arc>>, items: Arc>>, } @@ -74,7 +74,7 @@ impl EntityGateway for InMemoryGateway { new_settings } - fn get_characters_by_user(&self, user: &UserAccount) -> [Option; 4] { + fn get_characters_by_user(&self, user: &UserAccount) -> [Option; 4] { let characters = self.characters.lock().unwrap(); let mut chars = [None; 4]; characters @@ -84,21 +84,21 @@ impl EntityGateway for InMemoryGateway { chars } - fn new_character_by_user(&mut self, user: &UserAccount) -> Character { + fn new_character_by_user(&mut self, user: &UserAccount) -> CharacterEntity { let mut characters = self.characters.lock().unwrap(); let id = characters .iter() .fold(0, |sum, (i, _)| std::cmp::max(sum, *i)) + 1; - let mut c = Character::default(); + let mut c = CharacterEntity::default(); c.id = id; c.user_id = user.id; characters.insert(id, c.clone()); c } - fn set_character(&mut self, char: &Character) { + fn set_character(&mut self, char: &CharacterEntity) { let mut characters = self.characters.lock().unwrap(); characters.insert(char.id, char.clone()); } @@ -127,7 +127,7 @@ impl EntityGateway for InMemoryGateway { items.insert(item.id, item.clone()); } - fn get_items_by_character(&self, character: &Character) -> Vec { + fn get_items_by_character(&self, character: &CharacterEntity) -> Vec { let items = self.items.lock().unwrap(); items .iter() @@ -144,7 +144,7 @@ impl EntityGateway for InMemoryGateway { .collect() } - fn create_guild_card_by_character(&self, character: &Character) -> GuildCard { + fn create_guild_card_by_character(&self, character: &CharacterEntity) -> GuildCard { let mut guildcards = self.guildcards.lock().unwrap(); let user = self.get_user_by_id(character.user_id).unwrap(); let settings = self.get_user_settings_by_user(&user).unwrap(); @@ -172,7 +172,7 @@ impl EntityGateway for InMemoryGateway { new_guildcard } - fn get_guild_card_by_character(&self, character: &Character) -> Option { + fn get_guild_card_by_character(&self, character: &CharacterEntity) -> Option { let guildcards = self.guildcards.lock().unwrap(); guildcards .iter() diff --git a/src/login/character.rs b/src/login/character.rs index 818aeb1..4b9cf24 100644 --- a/src/login/character.rs +++ b/src/login/character.rs @@ -23,7 +23,7 @@ use crate::entity::item::armor::Armor; use crate::entity::item::tech::Technique; use crate::entity::item::tool::Tool; use crate::entity::item::mag::{Mag, MagType}; -use crate::entity::character::{Character, CharacterClass, TechLevel}; +use crate::entity::character::{CharacterEntity, CharacterClass, TechLevel}; use crate::login::login::get_login_status; @@ -143,7 +143,7 @@ fn generate_param_data(path: &str) -> (ParamDataHeader, Vec) { struct ClientState { param_index: usize, user: Option, - characters: Option<[Option; 4]>, + characters: Option<[Option; 4]>, guildcard_data_buffer: Option>, session: Session, } @@ -552,7 +552,7 @@ impl ServerState for CharacterServerState { } -fn new_character_from_preview(character: &mut Character, preview: &CharacterPreview) { +fn new_character_from_preview(character: &mut CharacterEntity, preview: &CharacterPreview) { character.slot = preview.slot; character.name = String::from_utf16_lossy(&preview.character.name).trim_matches(char::from(0)).into(); character.section_id = preview.character.section_id.into(); @@ -571,7 +571,7 @@ fn new_character_from_preview(character: &mut Character, preview: &CharacterPrev struct SelectScreenCharacterBuilder<'a> { - character: Option<&'a Character>, + character: Option<&'a CharacterEntity>, level: Option, } @@ -583,7 +583,7 @@ impl<'a> SelectScreenCharacterBuilder<'a> { } } - fn character(self, character: &'a Character) -> SelectScreenCharacterBuilder<'a> { + fn character(self, character: &'a CharacterEntity) -> SelectScreenCharacterBuilder<'a> { SelectScreenCharacterBuilder { character: Some(character), ..self diff --git a/src/ship/character.rs b/src/ship/character.rs index df38c37..8be687c 100644 --- a/src/ship/character.rs +++ b/src/ship/character.rs @@ -1,11 +1,11 @@ use libpso::character::character; use crate::common::leveltable::CharacterStats; -use crate::entity::character::Character; +use crate::entity::character::CharacterEntity; use crate::ship::items::ActiveInventory; // TODO: exp pub struct CharacterBytesBuilder<'a> { - character: Option<&'a Character>, + character: Option<&'a CharacterEntity>, stats: Option<&'a CharacterStats>, level: Option, } @@ -20,7 +20,7 @@ impl<'a> CharacterBytesBuilder<'a> { } } - pub fn character(self, character: &'a Character) -> CharacterBytesBuilder<'a> { + pub fn character(self, character: &'a CharacterEntity) -> CharacterBytesBuilder<'a> { CharacterBytesBuilder { character: Some(character), ..self @@ -76,7 +76,7 @@ impl<'a> CharacterBytesBuilder<'a> { pub struct FullCharacterBytesBuilder<'a> { - character: Option<&'a Character>, + character: Option<&'a CharacterEntity>, stats: Option<&'a CharacterStats>, level: Option, inventory: Option<&'a ActiveInventory>, @@ -97,7 +97,7 @@ impl<'a> FullCharacterBytesBuilder<'a> { } } - pub fn character(self, character: &'a Character) -> FullCharacterBytesBuilder<'a> { + pub fn character(self, character: &'a CharacterEntity) -> FullCharacterBytesBuilder<'a> { FullCharacterBytesBuilder { character: Some(character), ..self diff --git a/src/ship/items.rs b/src/ship/items.rs index 838ae66..6875d6d 100644 --- a/src/ship/items.rs +++ b/src/ship/items.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use libpso::character::character::InventoryItem; use crate::entity::gateway::EntityGateway; -use crate::entity::character::Character; +use crate::entity::character::CharacterEntity; use crate::entity::item::{Item, ItemId, ItemDetail, ItemLocation}; use crate::entity::item::weapon::Weapon; use crate::entity::item::armor::Armor; @@ -151,7 +151,7 @@ impl ActiveItemDatabase { // deactivate item - pub fn get_character_inventory(&mut self, entity_gateway: &mut EG, character: &Character) -> ActiveInventory { + pub fn get_character_inventory(&mut self, entity_gateway: &mut EG, character: &CharacterEntity) -> ActiveInventory { let items = entity_gateway.get_items_by_character(&character); let inventory_items = items.into_iter() .filter(|item| { diff --git a/src/ship/ship.rs b/src/ship/ship.rs index 6b44b19..80f0ccf 100644 --- a/src/ship/ship.rs +++ b/src/ship/ship.rs @@ -17,7 +17,7 @@ use crate::common::leveltable::CharacterLevelTable; use crate::entity::gateway::EntityGateway; use crate::entity::account::{UserAccount, UserSettings, USERFLAG_NEWCHAR, USERFLAG_DRESSINGROOM, GuildCard}; -use crate::entity::character::Character; +use crate::entity::character::CharacterEntity; use crate::entity::item::{ItemLocation, Item}; use crate::login::login::get_login_status; use crate::ship::location::{ClientLocation, LobbyId, RoomId, AreaType, MAX_ROOMS}; @@ -120,7 +120,7 @@ impl SendServerPacket for SendShipPacket { struct ClientState { user: UserAccount, settings: UserSettings, - character: Character, + character: CharacterEntity, session: Session, guildcard: GuildCard, inventory: items::ActiveInventory, @@ -129,7 +129,7 @@ struct ClientState { } impl ClientState { - fn new(user: UserAccount, settings: UserSettings, character: Character, 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, guildcard: GuildCard) -> ClientState { ClientState { user: user, settings: settings,