diff --git a/README.md b/README.md new file mode 100644 index 0000000..2946525 --- /dev/null +++ b/README.md @@ -0,0 +1,101 @@ +# skyrim-cell-dump + +Library and binary for parsing Skyrim plugin files and extracing CELL data. + +The main objective of this library is to extract the form ID and X and Y coordinates of every exterior cell a plugin edits as fast as possible, ignoring the rest of the plugin. + +## Install + +``` +cargo install skyrim_cell_dump +``` + +Or, build yourself by checking out the repository and running: + +``` +cargo build --release --features build-binary +``` + +## Usage + +``` +Usage: skyrim-cell-dump.exe [-f ] [-p] + +Extracts cell edits from a TES5 Skyrim plugin file + +Options: + -f, --format format of the output (json or text) + -p, --pretty pretty print json output + --help display usage information +``` + +The pretty JSON format looks something like: + +```json +{ + "header": { + "version": 1.0, + "num_records_and_groups": 792, + "next_object_id": 221145, + "author": "Critterman", + "description": "An example plugin", + "masters": [ + "Skyrim.esm", + "Update.esm", + "Dawnguard.esm", + "HearthFires.esm", + "Dragonborn.esm" + ] + }, + "cells": [ + { + "form_id": 100000001, + "editor_id": "SomeInterior", + "x": null, + "y": null, + "is_persistent": false + }, + { + "form_id": 3444, + "editor_id": null, + "x": 0, + "y": 0, + "is_persistent": true + }, + { + "form_id": 46432, + "editor_id": "SomeExterior01", + "x": 32, + "y": 3, + "is_persistent": false + }, + { + "form_id": 46464, + "editor_id": "SomeExterior02", + "x": 33, + "y": 2, + "is_persistent": false + }, + { + "form_id": 46498, + "editor_id": null, + "x": 32, + "y": 1, + "is_persistent": false + } + ] +} +``` + +## Import + +You can include this crate in your `Cargo.toml` and get the parsed `Plugin` struct with: + +```rust +use skyrim_cell_dump::parse_plugin; + +fn main() { + let plugin_contents = std::fs::read("Plugin.esp").unwrap(); + let plugin = parse_plugin(&plugin_contents).unwrap(); +} +``` diff --git a/src/bin/cli.rs b/src/bin/cli.rs index 0ca6baf..e87a171 100644 --- a/src/bin/cli.rs +++ b/src/bin/cli.rs @@ -17,10 +17,7 @@ impl FromStr for Format { fn from_str(s: &str) -> Result { match s.trim().to_lowercase().as_str() { "json" => Ok(Format::Json), - "text" => Ok(Format::PlainText), - "plain" => Ok(Format::PlainText), - "plain_text" => Ok(Format::PlainText), - "plaintext" => Ok(Format::PlainText), + "text" | "plain" | "plain_text" | "plaintext" => Ok(Format::PlainText), _ => Err(anyhow!("Unrecognized format {}", s)), } } diff --git a/src/parser.rs b/src/parser.rs index ac26f47..eefdea4 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -364,7 +364,6 @@ fn parse_field_header(input: &[u8]) -> IResult<&[u8], FieldHeader> { todo!() } let (input, size) = le_u16(input)?; - // let (input, data) = take(size)(input)?; Ok((input, FieldHeader { field_type, size })) }