|
|
@ -1,12 +1,12 @@ |
|
|
|
// TODO: ch_class to CharacterClass enum
|
|
|
|
// TODO: section_id to SectionId enum
|
|
|
|
// TODO: techniques to enum
|
|
|
|
use psopacket::PSOPacketData;
|
|
|
|
use crate::{PSOPacketData, PacketParseError};
|
|
|
|
use serde::{Serialize, Deserialize};
|
|
|
|
|
|
|
|
#[repr(u32)]
|
|
|
|
#[derive(Copy, Clone, Hash, PartialEq, Eq)]
|
|
|
|
pub enum Class {
|
|
|
|
|
|
|
|
#[repr(u8)]
|
|
|
|
#[derive(PSOPacketData, Debug, Copy, Clone, Hash, PartialEq, Eq, strum::Display, strum::EnumString, Serialize, Deserialize)]
|
|
|
|
pub enum CharacterClass {
|
|
|
|
HUmar,
|
|
|
|
HUnewearl,
|
|
|
|
HUcast,
|
|
|
@ -21,28 +21,82 @@ pub enum Class { |
|
|
|
FOnewearl,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::convert::From<u8> for Class {
|
|
|
|
fn from(f: u8) -> Class {
|
|
|
|
impl Default for CharacterClass {
|
|
|
|
fn default() -> CharacterClass {
|
|
|
|
CharacterClass::HUmar
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: TryFrom
|
|
|
|
impl std::convert::From<u8> for CharacterClass {
|
|
|
|
fn from(f: u8) -> CharacterClass {
|
|
|
|
match f {
|
|
|
|
0 => Class::HUmar,
|
|
|
|
1 => Class::HUnewearl,
|
|
|
|
2 => Class::HUcast,
|
|
|
|
3 => Class::RAmar,
|
|
|
|
4 => Class::RAcast,
|
|
|
|
5 => Class::RAcaseal,
|
|
|
|
6 => Class::FOmarl,
|
|
|
|
7 => Class::FOnewm,
|
|
|
|
8 => Class::FOnewearl,
|
|
|
|
9 => Class::HUcaseal,
|
|
|
|
10 => Class::RAmarl,
|
|
|
|
11 => Class::FOmar,
|
|
|
|
0 => CharacterClass::HUmar,
|
|
|
|
1 => CharacterClass::HUnewearl,
|
|
|
|
2 => CharacterClass::HUcast,
|
|
|
|
3 => CharacterClass::RAmar,
|
|
|
|
4 => CharacterClass::RAcast,
|
|
|
|
5 => CharacterClass::RAcaseal,
|
|
|
|
6 => CharacterClass::FOmarl,
|
|
|
|
7 => CharacterClass::FOnewm,
|
|
|
|
8 => CharacterClass::FOnewearl,
|
|
|
|
9 => CharacterClass::HUcaseal,
|
|
|
|
10 => CharacterClass::RAmarl,
|
|
|
|
11 => CharacterClass::FOmar,
|
|
|
|
_ => panic!("unknown class")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<CharacterClass> for u8 {
|
|
|
|
fn from(other: CharacterClass) -> u8 {
|
|
|
|
match other {
|
|
|
|
CharacterClass::HUmar => 0,
|
|
|
|
CharacterClass::HUnewearl => 1,
|
|
|
|
CharacterClass::HUcast => 2,
|
|
|
|
CharacterClass::RAmar => 3,
|
|
|
|
CharacterClass::RAcast => 4,
|
|
|
|
CharacterClass::RAcaseal => 5,
|
|
|
|
CharacterClass::FOmarl => 6,
|
|
|
|
CharacterClass::FOnewm => 7,
|
|
|
|
CharacterClass::FOnewearl => 8,
|
|
|
|
CharacterClass::HUcaseal => 9,
|
|
|
|
CharacterClass::FOmar => 10,
|
|
|
|
CharacterClass::RAmarl => 11,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl CharacterClass {
|
|
|
|
pub fn is_human(&self) -> bool {
|
|
|
|
matches!(self,
|
|
|
|
CharacterClass::HUmar |
|
|
|
|
CharacterClass::RAmar |
|
|
|
|
CharacterClass::RAmarl |
|
|
|
|
CharacterClass::FOmar |
|
|
|
|
CharacterClass::FOmarl)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_newman(&self) -> bool {
|
|
|
|
matches!(self,
|
|
|
|
CharacterClass::HUnewearl |
|
|
|
|
CharacterClass::FOnewm |
|
|
|
|
CharacterClass::FOnewearl)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_android(&self) -> bool {
|
|
|
|
matches!(self,
|
|
|
|
CharacterClass::HUcast |
|
|
|
|
CharacterClass::HUcaseal |
|
|
|
|
CharacterClass::RAcast |
|
|
|
|
CharacterClass::RAcaseal)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[repr(u8)]
|
|
|
|
#[derive(PSOPacketData, Debug, Copy, Clone, Hash, PartialEq, Eq, strum::Display, strum::EnumString, Serialize, Deserialize)]
|
|
|
|
pub enum SectionID {
|
|
|
|
Viridia,
|
|
|
|
Greenill,
|
|
|
@ -56,6 +110,48 @@ pub enum SectionID { |
|
|
|
Whitill,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for SectionID {
|
|
|
|
fn default() -> SectionID {
|
|
|
|
SectionID::Viridia
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: TryFrom
|
|
|
|
impl From<u8> for SectionID {
|
|
|
|
fn from(id: u8) -> SectionID {
|
|
|
|
match id {
|
|
|
|
0 => SectionID::Viridia,
|
|
|
|
1 => SectionID::Greenill,
|
|
|
|
2 => SectionID::Skyly,
|
|
|
|
3 => SectionID::Bluefull,
|
|
|
|
4 => SectionID::Purplenum,
|
|
|
|
5 => SectionID::Pinkal,
|
|
|
|
6 => SectionID::Redria,
|
|
|
|
7 => SectionID::Oran,
|
|
|
|
8 => SectionID::Yellowboze,
|
|
|
|
9 => SectionID::Whitill,
|
|
|
|
_ => panic!(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<SectionID> for u8 {
|
|
|
|
fn from(other: SectionID) -> u8 {
|
|
|
|
match other {
|
|
|
|
SectionID::Viridia => 0,
|
|
|
|
SectionID::Greenill => 1,
|
|
|
|
SectionID::Skyly => 2,
|
|
|
|
SectionID::Bluefull => 3,
|
|
|
|
SectionID::Purplenum => 4,
|
|
|
|
SectionID::Pinkal => 5,
|
|
|
|
SectionID::Redria => 6,
|
|
|
|
SectionID::Oran => 7,
|
|
|
|
SectionID::Yellowboze => 8,
|
|
|
|
SectionID::Whitill => 9,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(PSOPacketData, Copy, Clone)]
|
|
|
@ -80,8 +176,8 @@ pub struct Character { |
|
|
|
pub _unused: [u8; 11],
|
|
|
|
pub play_time: u32,
|
|
|
|
pub name_color_checksum: u32,
|
|
|
|
pub section_id: u8,
|
|
|
|
pub ch_class: u8,
|
|
|
|
pub section_id: SectionID,
|
|
|
|
pub ch_class: CharacterClass,
|
|
|
|
pub v2flags: u8,
|
|
|
|
pub version: u8,
|
|
|
|
pub v1flags: u32,
|
|
|
@ -149,8 +245,8 @@ pub struct SelectScreenCharacter { |
|
|
|
pub model: u8,
|
|
|
|
pub _unused: [u8; 15],
|
|
|
|
pub name_color_checksum: u32,
|
|
|
|
pub section_id: u8,
|
|
|
|
pub ch_class: u8,
|
|
|
|
pub section_id: SectionID,
|
|
|
|
pub ch_class: CharacterClass,
|
|
|
|
pub v2flags: u8,
|
|
|
|
pub version: u8,
|
|
|
|
pub v1flags: u32,
|
|
|
@ -301,8 +397,8 @@ pub struct FullCharacter { |
|
|
|
pub guildcard_desc: [u16; 88],
|
|
|
|
pub _reserved1: u8,
|
|
|
|
pub _reserved2: u8,
|
|
|
|
pub section_id: u8,
|
|
|
|
pub char_class: u8,
|
|
|
|
pub section_id: SectionID,
|
|
|
|
pub char_class: CharacterClass,
|
|
|
|
pub _unknown2: u32,
|
|
|
|
pub symbol_chats: [u8; 0x4E0],
|
|
|
|
pub shortcuts: [u8; 2624],
|
|
|
|