mirror of
https://github.com/redstrate/Kawari.git
synced 2025-07-09 23:47:46 +00:00
Grab navimesh paths from LVB, warn when navimesh is missing
Of course we don't even generate the navimeshes to begin with, but it's a start.
This commit is contained in:
parent
d16c2c6583
commit
edf0643990
3 changed files with 37 additions and 2 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1060,7 +1060,7 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "physis"
|
name = "physis"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
source = "git+https://github.com/redstrate/physis#c0d3df99c36e1c3aedc8fd203192df556eddcc29"
|
source = "git+https://github.com/redstrate/physis#b3196219d2f4618383eba1c6c0a79a1a2dadf954"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"binrw",
|
"binrw",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
|
|
|
@ -375,6 +375,10 @@ pub struct FilesystemConfig {
|
||||||
/// If the directory is not specified, Kawari won't save file contents.
|
/// If the directory is not specified, Kawari won't save file contents.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub unpack_path: String,
|
pub unpack_path: String,
|
||||||
|
|
||||||
|
/// Navimesh file directory.
|
||||||
|
#[serde(default)]
|
||||||
|
pub navimesh_path: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Global and all-encompassing config.
|
/// Global and all-encompassing config.
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use icarus::TerritoryType::TerritoryTypeSheet;
|
use icarus::TerritoryType::TerritoryTypeSheet;
|
||||||
use physis::{
|
use physis::{
|
||||||
common::Language,
|
common::Language,
|
||||||
|
@ -8,7 +10,10 @@ use physis::{
|
||||||
resource::Resource,
|
resource::Resource,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::common::{GameData, TerritoryNameKind};
|
use crate::{
|
||||||
|
common::{GameData, TerritoryNameKind},
|
||||||
|
config::get_config,
|
||||||
|
};
|
||||||
|
|
||||||
/// Represents a loaded zone
|
/// Represents a loaded zone
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
|
@ -19,6 +24,7 @@ pub struct Zone {
|
||||||
pub place_name: String,
|
pub place_name: String,
|
||||||
pub intended_use: u8,
|
pub intended_use: u8,
|
||||||
pub layer_groups: Vec<LayerGroup>,
|
pub layer_groups: Vec<LayerGroup>,
|
||||||
|
pub navimesh_path: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Zone {
|
impl Zone {
|
||||||
|
@ -43,6 +49,21 @@ impl Zone {
|
||||||
let lgb_file = game_data.resource.read(&path).unwrap();
|
let lgb_file = game_data.resource.read(&path).unwrap();
|
||||||
let lgb = Lvb::from_existing(&lgb_file).unwrap();
|
let lgb = Lvb::from_existing(&lgb_file).unwrap();
|
||||||
|
|
||||||
|
for layer_set in &lgb.scns[0].unk3.unk2 {
|
||||||
|
// FIXME: this is wrong. I think there might be multiple, separate navimeshes in really big zones but I'm not sure yet.
|
||||||
|
zone.navimesh_path = layer_set.path_nvm.replace("/server/data/", "").to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
let config = get_config();
|
||||||
|
if config.filesystem.navimesh_path.is_empty() {
|
||||||
|
tracing::warn!("Navimesh path is not set! Monsters will not function correctly!");
|
||||||
|
} else {
|
||||||
|
let mut nvm_path = PathBuf::from(config.filesystem.navimesh_path);
|
||||||
|
nvm_path.push(&zone.navimesh_path);
|
||||||
|
|
||||||
|
Self::load_navimesh(&nvm_path.to_str().unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
let mut load_lgb = |path: &str| -> Option<LayerGroup> {
|
let mut load_lgb = |path: &str| -> Option<LayerGroup> {
|
||||||
let lgb_file = game_data.resource.read(path)?;
|
let lgb_file = game_data.resource.read(path)?;
|
||||||
tracing::info!("Loading {path}");
|
tracing::info!("Loading {path}");
|
||||||
|
@ -116,4 +137,14 @@ impl Zone {
|
||||||
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: add better error handling here
|
||||||
|
fn load_navimesh(path: &str) -> Option<()> {
|
||||||
|
if !std::fs::exists(path).unwrap_or_default() {
|
||||||
|
tracing::warn!("Navimesh {path} does not exist, monsters will not function correctly!");
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue