2022-07-19 19:29:41 -04:00
# Physis
2022-10-17 19:32:40 -04:00
[](https://crates.io/crates/physis)
2022-09-15 16:26:18 -04:00
2024-04-28 11:12:09 -04:00
Physis is a library for reading and writing FFXIV data.
Even though this library was written with and for [Rust ](https://www.rust-lang.org/ ) in mind, Physis has bindings for other languages:
* [PhysisSharp ](https://github.com/redstrate/PhysisSharp ) can be used in any C# application, and is built on top of libphysis.
* [libphysis ](https://github.com/redstrate/libphysis ) can be used for anything that can interface with the C FFI. [Novus ](https://github.com/redstrate/Novus ) and [Astra ](https://github.com/redstrate/Astra ) is built on top of libphysis, for example.
2022-07-19 19:29:41 -04:00
## Goals
2024-04-22 15:43:35 -04:00
Physis should:
* ... Make it easy for developers to tinker around with game data.
* ... Document file formats along the way, to make writing future and applications libraries easier.
* ... Make parsing data safe, and create automated tests when possible.
* ... Aim to be have minimal dependencies, and easy to use regardless of platform.
2022-07-19 19:29:41 -04:00
## Features
2024-04-22 15:43:35 -04:00
Here is a list of supported formats and their status:
| File Format | Read | Write | Note |
| --- | --- | --- | --- |
| [Configuration files ](https://docs.xiv.zone/format/cfg/ ) | ✅ | ✅ | |
| [Saved character data ](https://docs.xiv.zone/format/chardat/ ) | ✅ | ❌ | Only some versions are currently supported. |
| [Chara make params ](https://docs.xiv.zone/format/cmp/ ) | ✅ | ❌ | |
| Dictionaries | ✅ | ❌ | |
| [Excel data ](https://docs.xiv.zone/format/exd/ ) | ✅ | ❌ | |
| [File infos ](https://docs.xiv.zone/format/fiin/ ) | ✅ | ✅ | |
| Map layers | ✅ | ❌ | Layer support isn't well tested yet. |
| [Chat logs ](https://docs.xiv.zone/format/log/ ) | ✅ | ❌ | Not all chat categories are discovered yet. |
| [Models ](https://docs.xiv.zone/format/mdl/ ) | ✅ | ✅ | Adding custom shape keys aren't fully supported yet. |
| [Materials ](https://docs.xiv.zone/format/mtrl/ ) | ✅ | ❌ | |
| Patch files | ✅ | ❌ | |
| Pre bone deformers | ✅ | ❌ | |
| [Shader packages ](https://docs.xiv.zone/format/shpk/ ) | ✅ | ❌ | |
| [Skeletons ](https://docs.xiv.zone/format/sklb/ ) | ✅ | ❌ | |
| Terrain | ✅ | ❌ | |
| [Textures ](https://docs.xiv.zone/format/tex/ ) | ✅ | ❌ | Only some formats are supported. |
Physis also supports doing some other useful things other than reading and writing file formats:
* Extract game data from SqPack files, and list file hashes from index/index2.
* Apply game patches. Indexed ZiPatch is not yet supported, though.
* Blockfish ciphers for encrypting and decrypting [SqexArg ](https://docs.xiv.zone/concept/sqexarg/ ).
* Extract retail installer contents, useful on Linux for avoiding having to run the InstallShield installer.
* Construct paths to equipment, items, faces, and other useful models.
* Extract strings from executables.
2022-08-06 18:40:16 -04:00
## Usage
2024-04-22 15:43:35 -04:00
If you want to use Physis in your Rust project, you can simply add it as a dependency in `Cargo.toml` :
2022-08-06 18:40:16 -04:00
2024-04-22 15:43:35 -04:00
```toml
2022-10-20 12:03:19 -04:00
[dependencies]
2024-04-22 15:43:35 -04:00
physis = "0.2"
2022-10-20 12:03:19 -04:00
```
2024-04-22 15:43:35 -04:00
Documentation is availavble online at [docs.xiv.zone ](https://docs.xiv.zone/docs/physis ). It's automatically updated as new
2022-10-20 12:03:19 -04:00
commits are pushed to the main branch.
2022-08-06 18:40:16 -04:00
2024-04-28 11:12:09 -04:00
C# projects can use [PhysisSharp ](https://github.com/redstrate/PhysisSharp ) which exposes Physis in C#.
C/C++ projects (or anything that can interface with C libraries) can use [libphysis ](https://github.com/redstrate/libphysis ) which exposes Physis functionality under a C API.
2024-04-22 15:43:35 -04:00
## Building
Physis only has a few dependencies, and very little if nothing is turned on by default. You need to set up [Rust ](https://www.rust-lang.org/learn/get-started ) and then run `cargo build` .
If you want to build the `game_install` feature, you also need to install [unshield ](https://github.com/twogood/unshield ).
2022-07-19 19:29:41 -04:00
## Development
2024-04-22 15:43:35 -04:00
If you're interested to read how these formats work in more detail, see [xiv.dev ](https://xiv.dev/ ) and
[docs.xiv.zone ](https://docs.xiv.zone ).
2022-10-20 12:03:19 -04:00
### Testing
One of the main goals of Physis is to avoid accidental regressions, this is especially important when handling game
2023-12-02 19:48:42 -05:00
data that might take hours to download.
2022-10-20 12:03:19 -04:00
#### Unit Testing
2022-07-19 19:29:41 -04:00
2022-10-20 12:03:19 -04:00
There are a set of basic unit tests you can run via `cargo test` . You can also find the relevant test resources in `resources/tests` .
This does **NOT** contain copyrighted material, but actually fake game data created by physis itself. These tests are
run automatically by the CI.
#### Retail Testing
There are some tests and benchmarks require the environment variable `FFXIV_GAME_DIR` to be set. By default, these are disabled
2022-07-27 20:58:12 -04:00
since they require a legitimate copy of the retail game data. These tests can be turned on via the `retail_game_testing`
feature.
2022-07-19 19:29:41 -04:00
2022-10-20 12:03:19 -04:00
#### Patch Testing
2022-10-13 15:45:23 -04:00
Patching is an extremely sensitive operation since it is not easily reversible if done wrong. Repairing the game files
2022-10-20 12:03:19 -04:00
is an option, but it's time-consuming and not yet implemented in physis. To prevent regressions in patching the
2022-10-13 15:45:23 -04:00
game, I have set up a testing bed for cross-checking our implementation with others. Currently, this is limited to XIVLauncher's implementation,
but I will eventually adopt a way to test the retail patch installer as well.
1. Enable the `patch_testing` feature.
2. Set a couple of environment variables:
* `FFXIV_PATCH_DIR` is the directory of patches to install. It should be structured as `$FFXIV_PATCH_DIR/game/D2017.07.11.0000.0001.patch` .
2022-10-17 15:37:02 -04:00
* `FFXIV_XIV_LAUNCHER_PATCHER` should be the path to the XIVLauncher patcher executable. If you're running on Linux, we will handle running Wine for you.
2022-10-13 15:45:23 -04:00
* `FFXIV_INSTALLER` is the path to the installer executable. This will be installed using the usual InstallShield emulation physis already includes.
As you can see, you must have the previous patches downloaded first as well as the installer before running the tests.
This is left up to the developer to figure out how to download them legally.
2022-10-20 12:03:19 -04:00
**Note:** These tests create the `game_test` and `game_test_xivlauncher` folders in `$HOME` and does not
2022-10-17 15:37:02 -04:00
delete them on exit, in case you want to check on the results. You may want to remove these folders as they
are full game installations and take up a considerable amount of space.
2022-10-20 12:03:19 -04:00
#### Semver and Dependency Checks
2023-12-02 19:48:42 -05:00
Even though package management in Rust is easier, it's a double-edged sword. I try to prevent getting carried away
2022-10-20 12:03:19 -04:00
from including crates - but the ones we do include, have to get checked often. I use `cargo deny` to check my
dependencies for mismatched versions, deprecation warnings, updates and more. This is also run on the CI!
2022-10-26 17:16:08 -04:00
Making sure that the library is semver-compliant is also important, and I use `cargo semver` for this task. This is to ensure the API does not break when moving between patch
2022-10-20 12:03:19 -04:00
versions.
2022-08-06 18:40:16 -04:00
## Contributing & Support
2022-07-19 19:29:41 -04:00
2024-04-22 15:43:35 -04:00
The best way you can help is by [monetarily supporting me ](https://redstrate.com/fund/ ) or by submitting patches to
help fix bugs or add functionality. Filing issues is appreciated, but I do this in my free time so please don't expect professional support.
2022-10-25 13:06:49 -04:00
2024-04-22 15:43:35 -04:00
## Credits & Thank You
2022-10-25 13:06:49 -04:00
- [goatcorp ](https://goatcorp.github.io ) (XIVQuickLauncher, docs.xiv.dev, and even more)
- [Ioncannon ](http://ffxivexplorer.fragmenterworks.com/research.php ) (FFXIV Data Explorer) for the first documenting the file formats
- [binrw team ](https://binrw.rs ) for an awesome Rust library!
- [sha1-smol ](https://github.com/mitsuhiko/sha1-smol ) for a dependency-free SHA1 implementation
2023-12-02 19:48:42 -05:00
And everyone else who writes FFXIV tools!
## License

2024-04-22 15:43:35 -04:00
This project is licensed under the GNU General Public License 3. Some parts of the code or assets may be licensed differently, refer to the REUSE metadata.