mirror of
https://github.com/redstrate/Physis.git
synced 2025-04-20 03:37:47 +00:00
Begin Race and Subrace enums at 1
This simplifies charsave parsing and will be useful in other projects like Kawari.
This commit is contained in:
parent
a34361b956
commit
50ea4dde40
2 changed files with 34 additions and 117 deletions
|
@ -10,104 +10,15 @@ use binrw::{BinRead, BinWrite};
|
|||
|
||||
use crate::race::{Gender, Race, Subrace};
|
||||
|
||||
fn convert_dat_race(x: u8) -> Race {
|
||||
match x {
|
||||
1 => Race::Hyur,
|
||||
2 => Race::Elezen,
|
||||
3 => Race::Lalafell,
|
||||
4 => Race::Miqote,
|
||||
5 => Race::Roegadyn,
|
||||
6 => Race::AuRa,
|
||||
7 => Race::Hrothgar,
|
||||
8 => Race::Viera,
|
||||
_ => Race::Hyur,
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_race_dat(race: &Race) -> u8 {
|
||||
match race {
|
||||
Race::Hyur => 1,
|
||||
Race::Elezen => 2,
|
||||
Race::Lalafell => 3,
|
||||
Race::Miqote => 4,
|
||||
Race::Roegadyn => 5,
|
||||
Race::AuRa => 6,
|
||||
Race::Hrothgar => 7,
|
||||
Race::Viera => 8,
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_dat_gender(x: u8) -> Gender {
|
||||
match x {
|
||||
0 => Gender::Male,
|
||||
1 => Gender::Female,
|
||||
_ => Gender::Male,
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_gender_dat(gender: &Gender) -> u8 {
|
||||
match gender {
|
||||
Gender::Male => 0,
|
||||
Gender::Female => 1,
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_dat_subrace(x: u8) -> Subrace {
|
||||
match x {
|
||||
1 => Subrace::Midlander,
|
||||
2 => Subrace::Highlander,
|
||||
3 => Subrace::Wildwood,
|
||||
4 => Subrace::Duskwight,
|
||||
5 => Subrace::Plainsfolk,
|
||||
6 => Subrace::Dunesfolk,
|
||||
7 => Subrace::Seeker,
|
||||
8 => Subrace::Keeper,
|
||||
9 => Subrace::SeaWolf,
|
||||
10 => Subrace::Hellsguard,
|
||||
11 => Subrace::Raen,
|
||||
12 => Subrace::Xaela,
|
||||
13 => Subrace::Hellion,
|
||||
14 => Subrace::Lost,
|
||||
15 => Subrace::Rava,
|
||||
16 => Subrace::Veena,
|
||||
_ => Subrace::Midlander,
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_subrace_dat(subrace: &Subrace) -> u8 {
|
||||
match subrace {
|
||||
Subrace::Midlander => 1,
|
||||
Subrace::Highlander => 2,
|
||||
Subrace::Wildwood => 3,
|
||||
Subrace::Duskwight => 4,
|
||||
Subrace::Plainsfolk => 5,
|
||||
Subrace::Dunesfolk => 6,
|
||||
Subrace::Seeker => 7,
|
||||
Subrace::Keeper => 8,
|
||||
Subrace::SeaWolf => 9,
|
||||
Subrace::Hellsguard => 10,
|
||||
Subrace::Raen => 11,
|
||||
Subrace::Xaela => 12,
|
||||
Subrace::Hellion => 13,
|
||||
Subrace::Lost => 14,
|
||||
Subrace::Rava => 15,
|
||||
Subrace::Veena => 16,
|
||||
}
|
||||
}
|
||||
|
||||
#[binrw]
|
||||
#[br(little)]
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct CustomizeData {
|
||||
/// The race of the character.
|
||||
#[br(map = convert_dat_race)]
|
||||
#[bw(map = convert_race_dat)]
|
||||
pub race: Race,
|
||||
|
||||
/// The gender of the character.
|
||||
#[br(map = convert_dat_gender)]
|
||||
#[bw(map = convert_gender_dat)]
|
||||
pub gender: Gender,
|
||||
|
||||
/// The age of the character. Normal = 1, Old = 3, Young = 4.
|
||||
|
@ -117,8 +28,6 @@ pub struct CustomizeData {
|
|||
pub height: u8,
|
||||
|
||||
/// The character's subrace.
|
||||
#[br(map = convert_dat_subrace)]
|
||||
#[bw(map = convert_subrace_dat)]
|
||||
pub subrace: Subrace,
|
||||
|
||||
/// The character's selected face.
|
||||
|
|
60
src/race.rs
60
src/race.rs
|
@ -1,49 +1,57 @@
|
|||
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
use binrw::binrw;
|
||||
|
||||
#[binrw]
|
||||
#[brw(repr = u8)]
|
||||
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||
#[repr(u8)]
|
||||
/// Gender of the character.
|
||||
pub enum Gender {
|
||||
Male,
|
||||
Female,
|
||||
Male = 0,
|
||||
Female = 1,
|
||||
}
|
||||
|
||||
#[binrw]
|
||||
#[brw(repr = u8)]
|
||||
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||
#[repr(u8)]
|
||||
/// The race's "subrace". Each race has two subraces, which are actually identical (even down to the ids!)
|
||||
/// with the exception of Hyurs, which have two unique subraces that are really two separate races.
|
||||
pub enum Subrace {
|
||||
Midlander,
|
||||
Highlander,
|
||||
Wildwood,
|
||||
Duskwight,
|
||||
Plainsfolk,
|
||||
Dunesfolk,
|
||||
Seeker,
|
||||
Keeper,
|
||||
SeaWolf,
|
||||
Hellsguard,
|
||||
Raen,
|
||||
Xaela,
|
||||
Hellion,
|
||||
Lost,
|
||||
Rava,
|
||||
Veena,
|
||||
Midlander = 1,
|
||||
Highlander = 2,
|
||||
Wildwood = 3,
|
||||
Duskwight = 4,
|
||||
Plainsfolk = 5,
|
||||
Dunesfolk = 6,
|
||||
Seeker = 7,
|
||||
Keeper = 8,
|
||||
SeaWolf = 9,
|
||||
Hellsguard = 10,
|
||||
Raen = 11,
|
||||
Xaela = 12,
|
||||
Hellion = 13,
|
||||
Lost = 14,
|
||||
Rava = 15,
|
||||
Veena = 16,
|
||||
}
|
||||
|
||||
#[binrw]
|
||||
#[brw(repr = u8)]
|
||||
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||
#[repr(u8)]
|
||||
/// The major races of Eorzea.
|
||||
pub enum Race {
|
||||
Hyur,
|
||||
Elezen,
|
||||
Lalafell,
|
||||
Miqote,
|
||||
Roegadyn,
|
||||
AuRa,
|
||||
Hrothgar,
|
||||
Viera,
|
||||
Hyur = 1,
|
||||
Elezen = 2,
|
||||
Lalafell = 3,
|
||||
Miqote = 4,
|
||||
Roegadyn = 5,
|
||||
AuRa = 6,
|
||||
Hrothgar = 7,
|
||||
Viera = 8,
|
||||
}
|
||||
|
||||
/// Gets a proper race identifier (such as 101, for Hyur-Midlander-Males) given a race, a subrace,
|
||||
|
|
Loading…
Add table
Reference in a new issue