|
|
@ -23,22 +23,22 @@ pub struct PgUserAccount { |
|
|
|
at_ship: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<UserAccountEntity> for PgUserAccount {
|
|
|
|
fn into(self) -> UserAccountEntity {
|
|
|
|
impl From<PgUserAccount> for UserAccountEntity {
|
|
|
|
fn from(other: PgUserAccount) -> UserAccountEntity {
|
|
|
|
UserAccountEntity {
|
|
|
|
id: UserAccountId(self.id as u32),
|
|
|
|
username: self.username,
|
|
|
|
password: self.password,
|
|
|
|
banned_until: self.banned,
|
|
|
|
muted_until: self.muted,
|
|
|
|
created_at: self.created_at,
|
|
|
|
flags: self.flags as u32,
|
|
|
|
guildcard: self.id as u32 + 1,
|
|
|
|
id: UserAccountId(other.id as u32),
|
|
|
|
username: other.username,
|
|
|
|
password: other.password,
|
|
|
|
banned_until: other.banned,
|
|
|
|
muted_until: other.muted,
|
|
|
|
created_at: other.created_at,
|
|
|
|
flags: other.flags as u32,
|
|
|
|
guildcard: other.id as u32 + 1,
|
|
|
|
team_id: None,
|
|
|
|
activated: self.activated,
|
|
|
|
at_login: self.at_login,
|
|
|
|
at_character: self.at_character,
|
|
|
|
at_ship: self.at_ship,
|
|
|
|
activated: other.activated,
|
|
|
|
at_login: other.at_login,
|
|
|
|
at_character: other.at_character,
|
|
|
|
at_ship: other.at_ship,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -56,19 +56,19 @@ pub struct PgUserSettings { |
|
|
|
team_name: Vec<u8>, //[u16; 0x10],
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<UserSettingsEntity> for PgUserSettings {
|
|
|
|
fn into(self) -> UserSettingsEntity {
|
|
|
|
impl From<PgUserSettings> for UserSettingsEntity {
|
|
|
|
fn from(other: PgUserSettings) -> UserSettingsEntity {
|
|
|
|
UserSettingsEntity {
|
|
|
|
id: UserSettingsId(self.id as u32),
|
|
|
|
user_id: UserAccountId(self.user_account as u32),
|
|
|
|
id: UserSettingsId(other.id as u32),
|
|
|
|
user_id: UserAccountId(other.user_account as u32),
|
|
|
|
settings: settings::UserSettings {
|
|
|
|
blocked_users: vec_to_array(self.blocked_users.chunks(4).map(|b| u32::from_le_bytes([b[0], b[1], b[2], b[3]])).collect()),
|
|
|
|
key_config: vec_to_array(self.key_config),
|
|
|
|
joystick_config: vec_to_array(self.joystick_config),
|
|
|
|
option_flags: self.option_flags as u32,
|
|
|
|
shortcuts: vec_to_array(self.shortcuts),
|
|
|
|
symbol_chats: vec_to_array(self.symbol_chats),
|
|
|
|
team_name: vec_to_array(self.team_name.chunks(2).map(|b| u16::from_le_bytes([b[0], b[1]])).collect()),
|
|
|
|
blocked_users: vec_to_array(other.blocked_users.chunks(4).map(|b| u32::from_le_bytes([b[0], b[1], b[2], b[3]])).collect()),
|
|
|
|
key_config: vec_to_array(other.key_config),
|
|
|
|
joystick_config: vec_to_array(other.joystick_config),
|
|
|
|
option_flags: other.option_flags as u32,
|
|
|
|
shortcuts: vec_to_array(other.shortcuts),
|
|
|
|
symbol_chats: vec_to_array(other.symbol_chats),
|
|
|
|
team_name: vec_to_array(other.team_name.chunks(2).map(|b| u16::from_le_bytes([b[0], b[1]])).collect()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -91,9 +91,9 @@ pub enum PgCharacterClass { |
|
|
|
FOnewearl,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<CharacterClass> for PgCharacterClass {
|
|
|
|
fn into(self) -> CharacterClass {
|
|
|
|
match self {
|
|
|
|
impl From<PgCharacterClass> for CharacterClass {
|
|
|
|
fn from(other: PgCharacterClass) -> CharacterClass {
|
|
|
|
match other{
|
|
|
|
PgCharacterClass::HUmar => CharacterClass::HUmar,
|
|
|
|
PgCharacterClass::HUnewearl => CharacterClass::HUnewearl,
|
|
|
|
PgCharacterClass::HUcast => CharacterClass::HUcast,
|
|
|
@ -144,9 +144,9 @@ pub enum PgSectionId { |
|
|
|
Whitill,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<SectionID> for PgSectionId {
|
|
|
|
fn into(self) -> SectionID {
|
|
|
|
match self {
|
|
|
|
impl From<PgSectionId> for SectionID {
|
|
|
|
fn from(other: PgSectionId) -> SectionID {
|
|
|
|
match other {
|
|
|
|
PgSectionId::Viridia => SectionID::Viridia,
|
|
|
|
PgSectionId::Greenill => SectionID::Greenill,
|
|
|
|
PgSectionId::Skyly => SectionID::Skyly,
|
|
|
@ -220,55 +220,55 @@ pub struct PgCharacter { |
|
|
|
bank_meseta: i32,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<CharacterEntity> for PgCharacter {
|
|
|
|
fn into(self) -> CharacterEntity {
|
|
|
|
impl From<PgCharacter> for CharacterEntity {
|
|
|
|
fn from(other: PgCharacter) -> CharacterEntity {
|
|
|
|
CharacterEntity {
|
|
|
|
id: CharacterEntityId(self.id as u32),
|
|
|
|
user_id: UserAccountId(self.user_account as u32),
|
|
|
|
slot: self.slot as u32,
|
|
|
|
name: self.name,
|
|
|
|
exp: self.exp as u32,
|
|
|
|
char_class: self.class.parse().unwrap(),
|
|
|
|
section_id: self.section_id.parse().unwrap(),
|
|
|
|
id: CharacterEntityId(other.id as u32),
|
|
|
|
user_id: UserAccountId(other.user_account as u32),
|
|
|
|
slot: other.slot as u32,
|
|
|
|
name: other.name,
|
|
|
|
exp: other.exp as u32,
|
|
|
|
char_class: other.class.parse().unwrap(),
|
|
|
|
section_id: other.section_id.parse().unwrap(),
|
|
|
|
appearance: CharacterAppearance {
|
|
|
|
costume: self.costume as u16,
|
|
|
|
skin: self.skin as u16,
|
|
|
|
face: self.face as u16,
|
|
|
|
head: self.head as u16,
|
|
|
|
hair: self.hair as u16,
|
|
|
|
hair_r: self.hair_r as u16,
|
|
|
|
hair_g: self.hair_g as u16,
|
|
|
|
hair_b: self.hair_b as u16,
|
|
|
|
prop_x: self.prop_x,
|
|
|
|
prop_y: self.prop_y,
|
|
|
|
costume: other.costume as u16,
|
|
|
|
skin: other.skin as u16,
|
|
|
|
face: other.face as u16,
|
|
|
|
head: other.head as u16,
|
|
|
|
hair: other.hair as u16,
|
|
|
|
hair_r: other.hair_r as u16,
|
|
|
|
hair_g: other.hair_g as u16,
|
|
|
|
hair_b: other.hair_b as u16,
|
|
|
|
prop_x: other.prop_x,
|
|
|
|
prop_y: other.prop_y,
|
|
|
|
},
|
|
|
|
techs: CharacterTechniques {
|
|
|
|
techs: self.techs.iter().enumerate().take(19).filter(|(_, t)| **t != 0xFF).map(|(i, t)| (tech::Technique::from_value(i as u8), TechLevel(*t)) ).collect()
|
|
|
|
techs: other.techs.iter().enumerate().take(19).filter(|(_, t)| **t != 0xFF).map(|(i, t)| (tech::Technique::from_value(i as u8), TechLevel(*t)) ).collect()
|
|
|
|
},
|
|
|
|
config: CharacterConfig {
|
|
|
|
raw_data: vec_to_array(self.config)
|
|
|
|
raw_data: vec_to_array(other.config)
|
|
|
|
},
|
|
|
|
info_board: CharacterInfoboard {
|
|
|
|
board: libpso::utf8_to_utf16_array!(self.infoboard, 172),
|
|
|
|
board: libpso::utf8_to_utf16_array!(other.infoboard, 172),
|
|
|
|
},
|
|
|
|
guildcard: CharacterGuildCard {
|
|
|
|
description: self.guildcard,
|
|
|
|
description: other.guildcard,
|
|
|
|
},
|
|
|
|
option_flags: self.option_flags as u32,
|
|
|
|
option_flags: other.option_flags as u32,
|
|
|
|
materials: CharacterMaterials {
|
|
|
|
power: self.power as u32,
|
|
|
|
mind: self.mind as u32,
|
|
|
|
def: self.def as u32,
|
|
|
|
evade: self.evade as u32,
|
|
|
|
luck: self.luck as u32,
|
|
|
|
hp: self.hp as u32,
|
|
|
|
tp: self.tp as u32,
|
|
|
|
power: other.power as u32,
|
|
|
|
mind: other.mind as u32,
|
|
|
|
def: other.def as u32,
|
|
|
|
evade: other.evade as u32,
|
|
|
|
luck: other.luck as u32,
|
|
|
|
hp: other.hp as u32,
|
|
|
|
tp: other.tp as u32,
|
|
|
|
},
|
|
|
|
tech_menu: CharacterTechMenu {
|
|
|
|
tech_menu: vec_to_array(self.tech_menu)
|
|
|
|
tech_menu: vec_to_array(other.tech_menu)
|
|
|
|
},
|
|
|
|
meseta: self.meseta as u32,
|
|
|
|
bank_meseta: self.bank_meseta as u32,
|
|
|
|
meseta: other.meseta as u32,
|
|
|
|
bank_meseta: other.bank_meseta as u32,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -300,10 +300,10 @@ impl From<weapon::Weapon> for PgWeapon { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<weapon::Weapon> for PgWeapon {
|
|
|
|
fn into(self) -> weapon::Weapon {
|
|
|
|
impl From<PgWeapon> for weapon::Weapon {
|
|
|
|
fn from(other: PgWeapon) -> weapon::Weapon {
|
|
|
|
let mut attrs: [Option<weapon::WeaponAttribute>; 3] = [None; 3];
|
|
|
|
for (attr, (atype, value)) in attrs.iter_mut().zip(self.attrs.iter()) {
|
|
|
|
for (attr, (atype, value)) in attrs.iter_mut().zip(other.attrs.iter()) {
|
|
|
|
*attr = Some(weapon::WeaponAttribute {
|
|
|
|
attr: *atype,
|
|
|
|
value: *value
|
|
|
@ -311,11 +311,11 @@ impl Into<weapon::Weapon> for PgWeapon { |
|
|
|
}
|
|
|
|
|
|
|
|
weapon::Weapon {
|
|
|
|
weapon: self.weapon,
|
|
|
|
special: self.special,
|
|
|
|
grind: self.grind,
|
|
|
|
attrs: attrs,
|
|
|
|
tekked: self.tekked,
|
|
|
|
weapon: other.weapon,
|
|
|
|
special: other.special,
|
|
|
|
grind: other.grind,
|
|
|
|
attrs,
|
|
|
|
tekked: other.tekked,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -345,13 +345,13 @@ impl From<armor::Armor> for PgArmor { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<armor::Armor> for PgArmor {
|
|
|
|
fn into(self) -> armor::Armor {
|
|
|
|
impl From<PgArmor> for armor::Armor {
|
|
|
|
fn from(other: PgArmor) -> armor::Armor {
|
|
|
|
armor::Armor {
|
|
|
|
armor: self.armor,
|
|
|
|
dfp: self.dfp,
|
|
|
|
evp: self.evp,
|
|
|
|
slots: self.slots,
|
|
|
|
armor: other.armor,
|
|
|
|
dfp: other.dfp,
|
|
|
|
evp: other.evp,
|
|
|
|
slots: other.slots,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -373,12 +373,12 @@ impl From<shield::Shield> for PgShield { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<shield::Shield> for PgShield {
|
|
|
|
fn into(self) -> shield::Shield {
|
|
|
|
impl From<PgShield> for shield::Shield {
|
|
|
|
fn from(other: PgShield) -> shield::Shield {
|
|
|
|
shield::Shield {
|
|
|
|
shield: self.shield,
|
|
|
|
dfp: self.dfp,
|
|
|
|
evp: self.evp,
|
|
|
|
shield: other.shield,
|
|
|
|
dfp: other.dfp,
|
|
|
|
evp: other.evp,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -398,11 +398,11 @@ impl From<unit::Unit> for PgUnit { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<unit::Unit> for PgUnit {
|
|
|
|
fn into(self) -> unit::Unit {
|
|
|
|
impl From<PgUnit> for unit::Unit {
|
|
|
|
fn from(other: PgUnit) -> unit::Unit {
|
|
|
|
unit::Unit {
|
|
|
|
unit: self.unit,
|
|
|
|
modifier: self.modifier,
|
|
|
|
unit: other.unit,
|
|
|
|
modifier: other.modifier,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -420,10 +420,10 @@ impl From<tool::Tool> for PgTool { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<tool::Tool> for PgTool {
|
|
|
|
fn into(self) -> tool::Tool {
|
|
|
|
impl From<PgTool> for tool::Tool {
|
|
|
|
fn from(other: PgTool) -> tool::Tool {
|
|
|
|
tool::Tool {
|
|
|
|
tool: self.tool,
|
|
|
|
tool: other.tool,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -443,11 +443,11 @@ impl From<tech::TechniqueDisk> for PgTechDisk { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<tech::TechniqueDisk> for PgTechDisk {
|
|
|
|
fn into(self) -> tech::TechniqueDisk {
|
|
|
|
impl From<PgTechDisk> for tech::TechniqueDisk {
|
|
|
|
fn from(other: PgTechDisk) -> tech::TechniqueDisk {
|
|
|
|
tech::TechniqueDisk {
|
|
|
|
tech: self.tech,
|
|
|
|
level: self.level
|
|
|
|
tech: other.tech,
|
|
|
|
level: other.level
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -469,8 +469,8 @@ impl From<mag::Mag> for PgMag { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<mag::Mag> for PgMag {
|
|
|
|
fn into(self) -> mag::Mag {
|
|
|
|
impl From<PgMag> for mag::Mag {
|
|
|
|
fn from(other: PgMag) -> mag::Mag {
|
|
|
|
/*mag::Mag {
|
|
|
|
mag: self.mag,
|
|
|
|
synchro: self.synchro,
|
|
|
@ -484,9 +484,9 @@ impl Into<mag::Mag> for PgMag { |
|
|
|
class: CharacterClass::HUmar,
|
|
|
|
id: SectionID::Viridia,
|
|
|
|
}*/
|
|
|
|
let mut mag = mag::Mag::baby_mag(self.color as u16);
|
|
|
|
mag.mag = self.mag;
|
|
|
|
mag.synchro = self.synchro;
|
|
|
|
let mut mag = mag::Mag::baby_mag(other.color as u16);
|
|
|
|
mag.mag = other.mag;
|
|
|
|
mag.synchro = other.synchro;
|
|
|
|
mag
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -510,13 +510,13 @@ impl From<esweapon::ESWeapon> for PgESWeapon { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<esweapon::ESWeapon> for PgESWeapon {
|
|
|
|
fn into(self) -> esweapon::ESWeapon {
|
|
|
|
impl From<PgESWeapon> for esweapon::ESWeapon {
|
|
|
|
fn from(other: PgESWeapon) -> esweapon::ESWeapon {
|
|
|
|
esweapon::ESWeapon {
|
|
|
|
esweapon: self.esweapon,
|
|
|
|
special: self.special,
|
|
|
|
name: self.name,
|
|
|
|
grind: self.grind,
|
|
|
|
esweapon: other.esweapon,
|
|
|
|
special: other.special,
|
|
|
|
name: other.name,
|
|
|
|
grind: other.grind,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -548,9 +548,9 @@ impl From<ItemDetail> for PgItemDetail { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<ItemDetail> for PgItemDetail {
|
|
|
|
fn into(self) -> ItemDetail {
|
|
|
|
match self {
|
|
|
|
impl From<PgItemDetail> for ItemDetail {
|
|
|
|
fn from(other: PgItemDetail) -> ItemDetail {
|
|
|
|
match other {
|
|
|
|
PgItemDetail::Weapon(weapon) => ItemDetail::Weapon(weapon.into()),
|
|
|
|
PgItemDetail::Armor(armor) => ItemDetail::Armor(armor.into()),
|
|
|
|
PgItemDetail::Shield(shield) => ItemDetail::Shield(shield.into()),
|
|
|
@ -613,9 +613,9 @@ impl From<ItemLocation> for PgItemLocationDetail { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<ItemLocation> for PgItemLocationDetail {
|
|
|
|
fn into(self) -> ItemLocation {
|
|
|
|
match self {
|
|
|
|
impl From<PgItemLocationDetail> for ItemLocation {
|
|
|
|
fn from(other: PgItemLocationDetail) -> ItemLocation {
|
|
|
|
match other{
|
|
|
|
PgItemLocationDetail::Inventory{character_id} => ItemLocation::Inventory{character_id: CharacterEntityId(character_id)},
|
|
|
|
PgItemLocationDetail::Bank{character_id, name} => ItemLocation::Bank{character_id: CharacterEntityId(character_id), name: BankName(name)},
|
|
|
|
PgItemLocationDetail::LocalFloor{character_id, map_area, x,y,z} => ItemLocation::LocalFloor{character_id: CharacterEntityId(character_id), map_area, x,y,z},
|
|
|
@ -655,9 +655,9 @@ impl From<mag::MagModifier> for PgMagModifierDetail { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<mag::MagModifier> for PgMagModifierDetail {
|
|
|
|
fn into(self) -> mag::MagModifier {
|
|
|
|
match self {
|
|
|
|
impl From<PgMagModifierDetail> for mag::MagModifier {
|
|
|
|
fn from(other: PgMagModifierDetail) -> mag::MagModifier {
|
|
|
|
match other {
|
|
|
|
PgMagModifierDetail::FeedMag(food) => mag::MagModifier::FeedMag{food: ItemEntityId(food as u32)},
|
|
|
|
PgMagModifierDetail::BankMag => mag::MagModifier::BankMag,
|
|
|
|
PgMagModifierDetail::MagCell(cell) => mag::MagModifier::MagCell(ItemEntityId(cell as u32)),
|
|
|
@ -687,12 +687,12 @@ pub struct PgItemWithLocation { |
|
|
|
pub location: sqlx::types::Json<PgItemLocationDetail>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<ItemEntity> for PgItemWithLocation {
|
|
|
|
fn into(self) -> ItemEntity {
|
|
|
|
impl From<PgItemWithLocation> for ItemEntity {
|
|
|
|
fn from(other: PgItemWithLocation) -> ItemEntity {
|
|
|
|
ItemEntity {
|
|
|
|
id: ItemEntityId(self.id as u32),
|
|
|
|
item: self.item.0.into(),
|
|
|
|
location: self.location.0.into(),
|
|
|
|
id: ItemEntityId(other.id as u32),
|
|
|
|
item: other.item.0.into(),
|
|
|
|
location: other.location.0.into(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -740,18 +740,18 @@ pub struct PgEquipped { |
|
|
|
mag: Option<i32>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<EquippedEntity> for PgEquipped {
|
|
|
|
fn into(self) -> EquippedEntity {
|
|
|
|
impl From<PgEquipped> for EquippedEntity{
|
|
|
|
fn from(other: PgEquipped) -> EquippedEntity {
|
|
|
|
EquippedEntity {
|
|
|
|
weapon: self.weapon.map(|i| ItemEntityId(i as u32)),
|
|
|
|
armor: self.armor.map(|i| ItemEntityId(i as u32)),
|
|
|
|
shield: self.shield.map(|i| ItemEntityId(i as u32)),
|
|
|
|
unit: [self.unit0.map(|i| ItemEntityId(i as u32)),
|
|
|
|
self.unit1.map(|i| ItemEntityId(i as u32)),
|
|
|
|
self.unit2.map(|i| ItemEntityId(i as u32)),
|
|
|
|
self.unit3.map(|i| ItemEntityId(i as u32)),
|
|
|
|
weapon: other.weapon.map(|i| ItemEntityId(i as u32)),
|
|
|
|
armor: other.armor.map(|i| ItemEntityId(i as u32)),
|
|
|
|
shield: other.shield.map(|i| ItemEntityId(i as u32)),
|
|
|
|
unit: [other.unit0.map(|i| ItemEntityId(i as u32)),
|
|
|
|
other.unit1.map(|i| ItemEntityId(i as u32)),
|
|
|
|
other.unit2.map(|i| ItemEntityId(i as u32)),
|
|
|
|
other.unit3.map(|i| ItemEntityId(i as u32)),
|
|
|
|
],
|
|
|
|
mag: self.mag.map(|i| ItemEntityId(i as u32)),
|
|
|
|
mag: other.mag.map(|i| ItemEntityId(i as u32)),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|