diff --git a/bin/app/src/modules/hook.rs b/bin/app/src/modules/hook.rs index 0f5cd5b0..80da149c 100644 --- a/bin/app/src/modules/hook.rs +++ b/bin/app/src/modules/hook.rs @@ -21,7 +21,6 @@ pub fn scope(ctx: &Context, vfs: bool) -> Result { } scope.push_constant("HEMTT_PROJECT_NAME", ctx.config().name().to_string()); scope.push_constant("HEMTT_PROJECT_PREFIX", ctx.config().prefix().to_string()); - scope.push_constant("HEMTT_PROJECT_HEADERS", ctx.config().headers().clone()); scope.push_constant("HEMTT_ADDONS", ctx.addons().to_vec()); if vfs { scope.push_constant("HEMTT_VFS", ctx.vfs().clone()); diff --git a/bin/app/src/modules/pbo.rs b/bin/app/src/modules/pbo.rs index 08a28e87..6f78baa5 100644 --- a/bin/app/src/modules/pbo.rs +++ b/bin/app/src/modules/pbo.rs @@ -102,11 +102,11 @@ pub fn build(ctx: &Context, collapse: Collapse) -> Result<(), Error> { pbo.add_file(file, entry.open_file().unwrap()).unwrap(); } } - for header in ctx.config().headers() { + for header in ctx.config().properties() { pbo.add_extension(header.0, header.1.clone()); } if let Some(config) = addon.config() { - for header in config.headers() { + for header in config.properties() { pbo.add_extension(header.0, header.1.clone()); } } diff --git a/bin/libs/config/src/addon/mod.rs b/bin/libs/config/src/addon/mod.rs index bc454395..170009c7 100644 --- a/bin/libs/config/src/addon/mod.rs +++ b/bin/libs/config/src/addon/mod.rs @@ -18,8 +18,8 @@ pub struct Configuration { no_bin: Vec, #[serde(default)] - /// Headers to add to the pbo - headers: HashMap, + /// Properties to add to the pbo + properties: HashMap, #[serde(default)] /// Files to exclude from the pbo @@ -65,9 +65,9 @@ impl Configuration { } #[must_use] - /// Headers to be added to the built PBO - pub const fn headers(&self) -> &HashMap { - &self.headers + /// Properties to be added to the built PBO + pub const fn properties(&self) -> &HashMap { + &self.properties } #[must_use] diff --git a/bin/libs/config/src/project/mod.rs b/bin/libs/config/src/project/mod.rs index 6890315c..c40ddf18 100644 --- a/bin/libs/config/src/project/mod.rs +++ b/bin/libs/config/src/project/mod.rs @@ -23,8 +23,8 @@ pub struct Configuration { version: version::Options, #[serde(default)] - /// Headers to be added to built PBOs - headers: HashMap, + /// Properties to be added to built PBOs + properties: HashMap, #[serde(default)] /// Files to be included in the root of the project, supports glob patterns @@ -62,9 +62,9 @@ impl Configuration { } #[must_use] - /// Headers to be added to built PBOs - pub const fn headers(&self) -> &HashMap { - &self.headers + /// Properties to be added to built PBOs + pub const fn properties(&self) -> &HashMap { + &self.properties } #[must_use] diff --git a/book/configuration-addon.md b/book/configuration-addon.md index 24cd18df..ac82d091 100644 --- a/book/configuration-addon.md +++ b/book/configuration-addon.md @@ -16,7 +16,7 @@ exclude = [ "data/*.psd", ] -[headers] +[properties] iso = "14001" ``` @@ -57,13 +57,13 @@ exclude = [ ] ``` -## headers +## properties -Much like the `headers` key in `.hemtt/project.toml`, the `headers` key in `addon.toml` allows you to add custom headers to the PBO. +Much like the `properties` key in `.hemtt/project.toml`, the `properties` key in `addon.toml` allows you to add custom properties to the PBO. ***/addons/banana/addon.toml*** ```toml -[headers] +[properties] iso = "14001" ``` diff --git a/book/configuration.md b/book/configuration.md index 128c7ded..bac1653b 100644 --- a/book/configuration.md +++ b/book/configuration.md @@ -64,7 +64,7 @@ exclude = [ ] ``` -#### Include +#### include By default, those 5 files are included in the build directory if they exist in the root of your project. You do not need to add them to your list. Additon files or [glob path](https://en.wikipedia.org/wiki/Glob_(programming)) can be added to the list. @@ -81,7 +81,7 @@ include = [ ] ``` -#### Exclude +#### exclude By default, no files are excluded from PBOs. You can add files or [glob path](https://en.wikipedia.org/wiki/Glob_(programming)) to the list. @@ -95,14 +95,14 @@ exclude = [ ] ``` -### Headers +### properties -You can add a list of headers to be added to every PBO. +You can add a list of properties to be added to every PBO. **.hemtt/project.toml** ```toml -[headers] +[properties] author = "ABE Team" url = "https://github.com/ABE-Mod/ABE" ``` diff --git a/book/hooks.md b/book/hooks.md index ac866519..3d687b4f 100644 --- a/book/hooks.md +++ b/book/hooks.md @@ -60,7 +60,6 @@ Several constants are available to the hook scripts. These are: | `HEMTT_PROJECT_VERSION_HASBUILD` | Whether the project has a build, ex: true | | `HEMTT_PROJECT_NAME` | The name of the project | | `HEMTT_PROJECT_PREFIX` | The prefix of the project | -| `HEMTT_PROJECT_HEADERS` | The headers of the project | | `HEMTT_PROJECT_ADDONS` | The addons of the project | ## File System diff --git a/libs/pbo/src/model/checksum.rs b/libs/pbo/src/model/checksum.rs index e45f2637..96670a6a 100644 --- a/libs/pbo/src/model/checksum.rs +++ b/libs/pbo/src/model/checksum.rs @@ -3,7 +3,7 @@ use crate::ReadPbo; #[derive(Copy, Clone, Debug, PartialEq, Eq)] /// A checksum found at the end of a PBO /// -/// The checksum is a SHA1 hash of the PBO's extensions & files +/// The checksum is a SHA1 hash of the PBO's properties & files pub struct Checksum([u8; 20]); impl Checksum { diff --git a/libs/pbo/src/model/mime.rs b/libs/pbo/src/model/mime.rs index 631bda00..1c0f59a4 100644 --- a/libs/pbo/src/model/mime.rs +++ b/libs/pbo/src/model/mime.rs @@ -9,7 +9,7 @@ pub enum Mime { /// A compressed entry used by VBS Enco, #[default] - /// A blank entry, use to denote the end of the extensions section + /// A blank entry, use to denote the end of the properties section Blank, } diff --git a/libs/pbo/src/prefix.rs b/libs/pbo/src/prefix.rs index 2fa96c44..742501f1 100644 --- a/libs/pbo/src/prefix.rs +++ b/libs/pbo/src/prefix.rs @@ -1,6 +1,6 @@ //! A prefix file for a PBO //! -//! It can be a single line defining the prefix, or a key-value pair defining the prefix and extra headers +//! It can be a single line defining the prefix, or a key-value pair defining the prefix and extra properties //! //! # Examples //! diff --git a/libs/pbo/src/read.rs b/libs/pbo/src/read.rs index 5a80f050..eb8f767b 100644 --- a/libs/pbo/src/read.rs +++ b/libs/pbo/src/read.rs @@ -14,7 +14,7 @@ use crate::{ /// An existing PBO file that can be read from pub struct ReadablePbo { - extensions: IndexMap, + properties: IndexMap, headers: Vec
, checksum: Checksum, input: I, @@ -27,7 +27,7 @@ impl ReadablePbo { /// # Errors /// if the file cannot be read pub fn from(mut input: I) -> Result { - let mut extensions = IndexMap::new(); + let mut properties = IndexMap::new(); let mut headers = Vec::new(); let mut blob_start = 0; loop { @@ -42,7 +42,7 @@ impl ReadablePbo { } let value = input.read_cstring()?; blob_start += value.len() as u64 + 1; - extensions.insert(key, value); + properties.insert(key, value); } } else if header.filename().is_empty() { break; @@ -61,7 +61,7 @@ impl ReadablePbo { return Err(Error::UnexpectedDataAfterChecksum); } Ok(Self { - extensions, + properties, headers, checksum, input, @@ -76,9 +76,9 @@ impl ReadablePbo { .find(|h| h.filename() == name.replace('/', "\\")) } - /// Get the PBO's extensions - pub const fn extensions(&self) -> &IndexMap { - &self.extensions + /// Get the PBO's properties + pub const fn properties(&self) -> &IndexMap { + &self.properties } /// Get the PBO's stored checksum @@ -156,12 +156,12 @@ impl ReadablePbo { let mut headers: Cursor> = Cursor::new(Vec::new()); Header::ext().write_pbo(&mut headers)?; - if let Some(prefix) = self.extensions.get("prefix") { + if let Some(prefix) = self.properties.get("prefix") { headers.write_cstring(b"prefix")?; headers.write_cstring(prefix)?; } - for (key, value) in &self.extensions { + for (key, value) in &self.properties { if key == "prefix" { continue; } diff --git a/libs/pbo/src/write.rs b/libs/pbo/src/write.rs index 1dc12c95..98d018c5 100644 --- a/libs/pbo/src/write.rs +++ b/libs/pbo/src/write.rs @@ -12,7 +12,7 @@ use crate::{error::Error, model::Header, WritePbo}; #[derive(Default)] /// A PBO file that can be written to pub struct WritablePbo { - extensions: IndexMap, + properties: IndexMap, files: HashMap, } @@ -21,7 +21,7 @@ impl WritablePbo { /// Create a new PBO pub fn new() -> Self { Self { - extensions: IndexMap::new(), + properties: IndexMap::new(), files: HashMap::new(), } } @@ -99,25 +99,25 @@ impl WritablePbo { key: K, value: V, ) -> Option { - self.extensions + self.properties .insert(key.into(), value.into().trim_matches('\\').to_string()) } /// Remove an extension from the PBO pub fn remove_extension(&mut self, key: &str) -> Option { - self.extensions.remove(key) + self.properties.remove(key) } #[must_use] /// Get an extension from the PBO pub fn extension(&self, key: &str) -> Option<&String> { - self.extensions.get(key) + self.properties.get(key) } #[must_use] - /// Get all extensions from the PBO - pub const fn extensions(&self) -> &IndexMap { - &self.extensions + /// Get all properties from the PBO + pub const fn properties(&self) -> &IndexMap { + &self.properties } /// Write the PBO to a file @@ -127,9 +127,9 @@ impl WritablePbo { /// /// # Panics /// if a file does not exist but a header is present - pub fn write(&mut self, output: &mut O, extensions: bool) -> Result<(), Error> { + pub fn write(&mut self, output: &mut O, properties: bool) -> Result<(), Error> { let mut headers: Cursor> = Cursor::new(Vec::new()); - if extensions { + if properties { Header::ext().write_pbo(&mut headers)?; if let Some(prefix) = self.extension("prefix") { @@ -137,7 +137,7 @@ impl WritablePbo { headers.write_cstring(prefix)?; } - for (key, value) in &self.extensions { + for (key, value) in &self.properties { if key == "prefix" { continue; } diff --git a/libs/pbo/tests/ace_weather.rs b/libs/pbo/tests/ace_weather.rs index 35f4c134..0afe321e 100644 --- a/libs/pbo/tests/ace_weather.rs +++ b/libs/pbo/tests/ace_weather.rs @@ -55,7 +55,7 @@ fn ace_weather_cba6f72c() { ) .unwrap(); } - for ext in pbo.extensions() { + for ext in pbo.properties() { new_pbo.add_extension(ext.0, ext.1); } let mut new_pbo_bin = std::io::Cursor::new(Vec::new()); diff --git a/libs/pbo/tests/utils.rs b/libs/pbo/tests/utils.rs index bdbd081a..22c7e903 100644 --- a/libs/pbo/tests/utils.rs +++ b/libs/pbo/tests/utils.rs @@ -13,10 +13,10 @@ pub fn pbo( ) -> ReadablePbo { let mut pbo = ReadablePbo::from(file).unwrap(); assert_eq!(pbo.files().len(), file_count); - assert_eq!(pbo.extensions().len(), extension_count); + assert_eq!(pbo.properties().len(), extension_count); assert_eq!(pbo.is_sorted().is_ok(), sorted); - assert_eq!(pbo.extensions().get("version"), Some(&version.to_string())); - assert_eq!(pbo.extensions().get("prefix"), Some(&prefix.to_string())); + assert_eq!(pbo.properties().get("version"), Some(&version.to_string())); + assert_eq!(pbo.properties().get("prefix"), Some(&prefix.to_string())); assert!(pbo.file("not_real").unwrap().is_none()); assert!(pbo.header("not_real").is_none()); if sorted { @@ -33,7 +33,7 @@ pub fn pbo( // let original = ReadablePbo::from(file).unwrap(); // assert_eq!(original.files(), writeable.files_sorted().unwrap()); -// assert_eq!(original.extensions(), writeable.extensions()); +// assert_eq!(original.properties(), writeable.properties()); // assert_eq!(original.checksum(), writeable.checksum().unwrap()); // } diff --git a/libs/signing/src/private.rs b/libs/signing/src/private.rs index 42e85d62..7e424fa3 100644 --- a/libs/signing/src/private.rs +++ b/libs/signing/src/private.rs @@ -216,7 +216,7 @@ fn generate_hashes( hasher.update(hash1.as_bytes()); hasher.update(pbo.hash_filenames()?); - if let Some(prefix) = pbo.extensions().get("prefix") { + if let Some(prefix) = pbo.properties().get("prefix") { hasher.update(prefix.as_bytes()); if !prefix.ends_with('\\') { hasher.update(b"\\"); @@ -227,7 +227,7 @@ fn generate_hashes( let mut hasher = Sha1::new(); hasher.update(pbo.hash_files(version)?); hasher.update(pbo.hash_filenames()?); - if let Some(prefix) = pbo.extensions().get("prefix") { + if let Some(prefix) = pbo.properties().get("prefix") { hasher.update(prefix.as_bytes()); if !prefix.ends_with('\\') { hasher.update(b"\\");