aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/fparkan-inspection/src/lib.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/crates/fparkan-inspection/src/lib.rs b/crates/fparkan-inspection/src/lib.rs
index a23baac..ff573d6 100644
--- a/crates/fparkan-inspection/src/lib.rs
+++ b/crates/fparkan-inspection/src/lib.rs
@@ -29,7 +29,7 @@ use fparkan_nres::{decode as decode_nres, NresDocument, ReadProfile};
use fparkan_path::{normalize_relative, PathPolicy};
use fparkan_resource::{archive_path, resource_name, CachedResourceRepository, ResourceRepository};
use fparkan_rsli::decode as decode_rsli;
-use fparkan_terrain_format::{decode_land_map, decode_land_msh};
+use fparkan_terrain_format::{decode_land_map, decode_land_msh, LandMeshDocument};
use fparkan_texm::decode_texm;
use fparkan_vfs::{DirectoryVfs, Vfs};
use std::fs;
@@ -437,6 +437,19 @@ pub fn inspect_land_file(path: &Path, kind: LandFileKind) -> Result<MapInspectio
}
}
+/// Loads and validates a standalone `Land.msh` file.
+///
+/// # Errors
+///
+/// Returns a human-readable error if the file cannot be read, decoded as `NRes`,
+/// or decoded as the specialized terrain mesh format.
+pub fn load_land_msh_from_path(path: &Path) -> Result<LandMeshDocument, String> {
+ let bytes = fs::read(path).map_err(|err| format!("{}: {err}", path.display()))?;
+ let document = decode_nres(Arc::from(bytes.into_boxed_slice()), ReadProfile::Compatible)
+ .map_err(|err| err.to_string())?;
+ decode_land_msh(&document).map_err(|err| err.to_string())
+}
+
fn inspect_land_msh(document: &NresDocument) -> Result<MapInspection, String> {
let land_msh = decode_land_msh(document).map_err(|err| err.to_string())?;
Ok(MapInspection {