aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-inspection/src
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-07-18 16:39:52 +0300
committerValentin Popov <valentin@popov.link>2026-07-18 16:39:52 +0300
commite9c1a83c51070c4f8da76540c17c2393922b6fcc (patch)
tree5cf115fc25aa4df24848e9488bdaa919890bf7f7 /crates/fparkan-inspection/src
parent575124830b678d0c4d5b37a708bba9692a4e47ef (diff)
downloadfparkan-e9c1a83c51070c4f8da76540c17c2393922b6fcc.tar.xz
fparkan-e9c1a83c51070c4f8da76540c17c2393922b6fcc.zip
fix(terrain): preserve opaque shade lookup keys
Diffstat (limited to 'crates/fparkan-inspection/src')
-rw-r--r--crates/fparkan-inspection/src/lib.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/crates/fparkan-inspection/src/lib.rs b/crates/fparkan-inspection/src/lib.rs
index e2b9068..be1f098 100644
--- a/crates/fparkan-inspection/src/lib.rs
+++ b/crates/fparkan-inspection/src/lib.rs
@@ -146,6 +146,19 @@ pub struct WearMaterialTexture {
pub image: fparkan_texm::RgbaImage,
}
+/// Compact inspection summary of a WEAR resource stored in an archive.
+#[derive(Clone, Debug, Eq, PartialEq)]
+pub struct WearInspection {
+ /// Number of material rows.
+ pub materials: usize,
+ /// Number of lightmap rows.
+ pub lightmaps: usize,
+ /// First material resource name, when present.
+ pub first_material: Option<String>,
+ /// Last material resource name, when present.
+ pub last_material: Option<String>,
+}
+
/// Land map/msh inspection payload.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct MapInspection {
@@ -374,6 +387,34 @@ pub fn inspect_model_from_root(
})
}
+/// Inspects a WEAR resource through repository-backed lookup.
+///
+/// # Errors
+///
+/// Returns a string error when the resource cannot be resolved or parsed as a
+/// valid WEAR payload.
+pub fn inspect_wear_from_root(
+ root: &Path,
+ archive: &str,
+ resource: &str,
+) -> Result<WearInspection, String> {
+ let bytes = read_resource_bytes_diagnostic(root, archive, resource)
+ .map_err(|err| render_human(&err))?;
+ let wear = decode_wear(&bytes).map_err(|err| err.to_string())?;
+ Ok(WearInspection {
+ materials: wear.entries.len(),
+ lightmaps: wear.lightmaps.len(),
+ first_material: wear
+ .entries
+ .first()
+ .map(|entry| String::from_utf8_lossy(&entry.material.0).into_owned()),
+ last_material: wear
+ .entries
+ .last()
+ .map(|entry| String::from_utf8_lossy(&entry.material.0).into_owned()),
+ })
+}
+
/// Loads and validates a model resource through repository-backed lookup.
///
/// # Errors