mirror of
https://github.com/redstrate/Physis.git
synced 2025-04-24 05:27:45 +00:00
Document more public APIs in preparation for docs release
This commit is contained in:
parent
be9c850fc1
commit
c36c4b7470
8 changed files with 58 additions and 10 deletions
|
@ -11,6 +11,7 @@ pub struct Blowfish {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Blowfish {
|
impl Blowfish {
|
||||||
|
/// Initializes a new Blowfish session with a key.
|
||||||
pub fn new(key: &[u8]) -> Blowfish {
|
pub fn new(key: &[u8]) -> Blowfish {
|
||||||
let mut s = Self {
|
let mut s = Self {
|
||||||
p: BLOWFISH_P,
|
p: BLOWFISH_P,
|
||||||
|
@ -90,8 +91,8 @@ impl Blowfish {
|
||||||
vec
|
vec
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Decrypts a block of data. If the decryption fails due to buffer overflow issues, will return None - but it
|
/// Decrypts a block of data. If the decryption fails due to buffer overflow issues, will return
|
||||||
/// does not indicate that the wrong key was used.
|
/// None - but this does not indicate that the wrong key was used.
|
||||||
pub fn decrypt(&self, data: &[u8]) -> Option<Vec<u8>> {
|
pub fn decrypt(&self, data: &[u8]) -> Option<Vec<u8>> {
|
||||||
let padded_data = Blowfish::pad_buffer(data);
|
let padded_data = Blowfish::pad_buffer(data);
|
||||||
|
|
||||||
|
|
|
@ -3,17 +3,27 @@ use binrw::binread;
|
||||||
#[binread]
|
#[binread]
|
||||||
#[br(repr(u8))]
|
#[br(repr(u8))]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
|
/// The language the game data is written for.
|
||||||
pub enum Language {
|
pub enum Language {
|
||||||
|
/// Used for data that is language-agnostic, such as item data.
|
||||||
None,
|
None,
|
||||||
|
/// Japanese language.
|
||||||
Japanese,
|
Japanese,
|
||||||
|
/// English language.
|
||||||
English,
|
English,
|
||||||
|
/// German language.
|
||||||
German,
|
German,
|
||||||
|
/// French language.
|
||||||
French,
|
French,
|
||||||
|
/// Chinese (Simplified) language.
|
||||||
ChineseSimplified,
|
ChineseSimplified,
|
||||||
|
/// Chinese (Traditional) language.
|
||||||
ChineseTraditional,
|
ChineseTraditional,
|
||||||
|
/// Korean language.
|
||||||
Korean,
|
Korean,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the shorthand language code for `language`. For example, English becomes "en".
|
||||||
pub fn get_language_code(lang: &Language) -> &'static str {
|
pub fn get_language_code(lang: &Language) -> &'static str {
|
||||||
match &lang {
|
match &lang {
|
||||||
Language::None => "",
|
Language::None => "",
|
||||||
|
|
|
@ -166,7 +166,6 @@ impl DatFile {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn read_from_offset(&mut self, offset: u32) -> Option<MemoryBuffer> {
|
pub fn read_from_offset(&mut self, offset: u32) -> Option<MemoryBuffer> {
|
||||||
let offset: u64 = (offset * 0x80) as u64;
|
let offset: u64 = (offset * 0x80) as u64;
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,29 @@
|
||||||
use crate::race::{Gender, get_race_id, Race, Subrace};
|
use crate::race::{Gender, get_race_id, Race, Subrace};
|
||||||
|
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
|
/// The slot the item is for.
|
||||||
pub enum Slot {
|
pub enum Slot {
|
||||||
|
/// The head slot. Shorthand is "met".
|
||||||
Head,
|
Head,
|
||||||
|
/// The hands slot. Shorthand is "glv".
|
||||||
Hands,
|
Hands,
|
||||||
|
/// The legs slot. Shorthand is "dwn".
|
||||||
Legs,
|
Legs,
|
||||||
|
/// The feet slot. Shorthand is "sho".
|
||||||
Feet,
|
Feet,
|
||||||
|
/// The body or chest slot. Shorthand is "top".
|
||||||
Body,
|
Body,
|
||||||
|
/// The earrings slot. Shorthand is "ear".
|
||||||
Earring,
|
Earring,
|
||||||
|
/// The neck slot. Shorthand is "nek".
|
||||||
Neck,
|
Neck,
|
||||||
|
/// The ring slot. Shorthand is "rir".
|
||||||
Rings,
|
Rings,
|
||||||
|
/// The wrists slot. Shorthand is "wrs".
|
||||||
Wrists,
|
Wrists,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the shorthand abbreviation of `slot`. For example, Body's shorthand is "top".
|
||||||
pub fn get_slot_abbreviation(slot: Slot) -> &'static str {
|
pub fn get_slot_abbreviation(slot: Slot) -> &'static str {
|
||||||
match slot {
|
match slot {
|
||||||
Slot::Head => "met",
|
Slot::Head => "met",
|
||||||
|
@ -27,6 +38,8 @@ pub fn get_slot_abbreviation(slot: Slot) -> &'static str {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Determines the correct slot from an id. This can fail, so a None is returned when no slot matches
|
||||||
|
/// that id.
|
||||||
pub fn get_slot_from_id(id: i32) -> Option<Slot> {
|
pub fn get_slot_from_id(id: i32) -> Option<Slot> {
|
||||||
match id {
|
match id {
|
||||||
3 => Some(Slot::Head),
|
3 => Some(Slot::Head),
|
||||||
|
@ -42,6 +55,7 @@ pub fn get_slot_from_id(id: i32) -> Option<Slot> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Builds a game path to the equipment specified.
|
||||||
pub fn build_equipment_path(model_id: i32, race: Race, subrace: Subrace, gender: Gender, slot: Slot) -> String {
|
pub fn build_equipment_path(model_id: i32, race: Race, subrace: Subrace, gender: Gender, slot: Slot) -> String {
|
||||||
format!("chara/equipment/e{:04}/model/c{:04}e{:04}_{}.mdl",
|
format!("chara/equipment/e{:04}/model/c{:04}e{:04}_{}.mdl",
|
||||||
model_id,
|
model_id,
|
||||||
|
|
27
src/lib.rs
27
src/lib.rs
|
@ -1,32 +1,51 @@
|
||||||
extern crate core;
|
extern crate core;
|
||||||
|
|
||||||
|
/// Reading and writing game data repositories, such as "ffxiv" and "ex1", and so on.
|
||||||
pub mod gamedata;
|
pub mod gamedata;
|
||||||
|
|
||||||
/// Reading game data repositories, such as "ffxiv" and "ex1", and so on.
|
/// Parsing game repositories, such as "ffxiv", "ex1" and their version information.
|
||||||
pub mod repository;
|
pub mod repository;
|
||||||
|
|
||||||
|
/// Reading and writing the boot data repository.
|
||||||
pub mod bootdata;
|
pub mod bootdata;
|
||||||
|
|
||||||
/// Everything to do with reading SqPack files.
|
mod sqpack;
|
||||||
pub mod sqpack;
|
|
||||||
|
|
||||||
|
/// Reading and writing SqPack index files.
|
||||||
pub mod index;
|
pub mod index;
|
||||||
pub mod dat;
|
|
||||||
|
mod dat;
|
||||||
mod compression;
|
mod compression;
|
||||||
mod model;
|
mod model;
|
||||||
|
|
||||||
|
/// All of the races in Eorzea in a nice enum package.
|
||||||
pub mod race;
|
pub mod race;
|
||||||
|
|
||||||
/// Reading Excel lists (EXL).
|
/// Reading Excel lists (EXL).
|
||||||
pub mod exl;
|
pub mod exl;
|
||||||
|
|
||||||
|
/// Reading equipment and equipment-related data.
|
||||||
pub mod equipment;
|
pub mod equipment;
|
||||||
|
|
||||||
|
/// Common structures used by other modules.
|
||||||
pub mod common;
|
pub mod common;
|
||||||
|
|
||||||
|
/// Methods for installing game and boot patches.
|
||||||
pub mod patch;
|
pub mod patch;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod macros;
|
mod macros;
|
||||||
|
|
||||||
|
/// Implementation of the Blowfish ECB block cipher used by the retail client.
|
||||||
pub mod blowfish;
|
pub mod blowfish;
|
||||||
|
|
||||||
mod blowfish_constants;
|
mod blowfish_constants;
|
||||||
|
|
||||||
|
/// Initializing a new retail game install from the official retail installer. No execution required!
|
||||||
pub mod installer;
|
pub mod installer;
|
||||||
|
|
||||||
|
/// Reading Excel header files (EXH).
|
||||||
pub mod exh;
|
pub mod exh;
|
||||||
|
|
||||||
|
/// Reading Excel data files (EXD).
|
||||||
pub mod exd;
|
pub mod exd;
|
|
@ -1,5 +1,5 @@
|
||||||
/// Creates a enum list of combined race identifiers.
|
/// Creates a enum list of combined race identifiers. For example, (Hyur, Midlander, Male) becomes a new variant called HyurMidlanderMale.
|
||||||
#[macro_export] macro_rules! define_race_enum {
|
#[macro_export(crate)] macro_rules! define_race_enum {
|
||||||
(
|
(
|
||||||
pub enum $name:ident {
|
pub enum $name:ident {
|
||||||
$(
|
$(
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
|
/// Gender of the character.
|
||||||
pub enum Gender {
|
pub enum Gender {
|
||||||
Male,
|
Male,
|
||||||
Female,
|
Female,
|
||||||
|
@ -7,6 +8,8 @@ pub enum Gender {
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
#[repr(u8)]
|
#[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 {
|
pub enum Subrace {
|
||||||
Midlander,
|
Midlander,
|
||||||
Highlander,
|
Highlander,
|
||||||
|
@ -28,6 +31,7 @@ pub enum Subrace {
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
|
/// The major races of Eorzea.
|
||||||
pub enum Race {
|
pub enum Race {
|
||||||
Hyur,
|
Hyur,
|
||||||
Elezen,
|
Elezen,
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use physis::index;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(not(feature = "retail_game_testing"), ignore)]
|
#[cfg_attr(not(feature = "retail_game_testing"), ignore)]
|
||||||
fn test_index_read() {
|
fn test_index_read() {
|
||||||
let game_dir = env::var("FFXIV_GAME_DIR").unwrap();
|
let game_dir = env::var("FFXIV_GAME_DIR").unwrap();
|
||||||
|
|
||||||
physis::index::IndexFile::from_existing(format!("{}/game/sqpack/ffxiv/000000.win32.index", game_dir).as_str());
|
index::IndexFile::from_existing(format!("{}/game/sqpack/ffxiv/000000.win32.index", game_dir).as_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Reference in a new issue