From 4d50fcc5142e5c9510bc43227e9be1efba637364 Mon Sep 17 00:00:00 2001 From: t20kdc Date: Tue, 4 Feb 2025 10:34:20 +0000 Subject: [PATCH 1/2] Create .luminol directory when saving data_cache, and mark resources as modified by default --- crates/core/src/data_cache.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/core/src/data_cache.rs b/crates/core/src/data_cache.rs index 9f15b092..7c8a0e04 100644 --- a/crates/core/src/data_cache.rs +++ b/crates/core/src/data_cache.rs @@ -74,7 +74,7 @@ macro_rules! from_defaults { ($parent:ident, $child:ident) => { RefCell::new(rpg::$parent { data: vec![rpg::$child::default()], - ..Default::default() + modified: true, }) }; } @@ -184,11 +184,12 @@ impl Data { map_infos.insert(1, rpg::MapInfo::default()); let map_infos = RefCell::new(rpg::MapInfos { data: map_infos, - ..Default::default() + modified: true, }); let system = rpg::System { magic_number: rand::random(), + modified: true, ..Default::default() }; let system = RefCell::new(system); @@ -196,7 +197,7 @@ impl Data { let scripts = vec![]; // FIXME legality of providing defualt scripts is unclear let scripts = RefCell::new(rpg::Scripts { data: scripts, - ..Default::default() + modified: true, }); let mut maps = std::collections::HashMap::with_capacity(32); @@ -320,6 +321,12 @@ impl Data { .struct_names(true) .enumerate_arrays(true); + // this is autocreated on load. however: + // since we're creating project config now, we need this directory + filesystem + .create_dir(".luminol") + .wrap_err("While creating .luminol")?; + let project_config = ron::ser::to_string_pretty(&config.project, pretty_config.clone()) .wrap_err("While serializing .luminol/config")?; filesystem From 9266d44dfe89804793704ce888a7217ee5080af5 Mon Sep 17 00:00:00 2001 From: t20kdc Date: Tue, 4 Feb 2025 11:08:13 +0000 Subject: [PATCH 2/2] New project: Be sure to save the map. Change autotile_names field to be a fixed-size array. Baking the array size into the datastructure feels like the safe, Rusty option. R48 (and I imagine other things) encounter an error loading the zero-size map (perhaps layers=0?), but the Tileset object is no longer corrupt. --- crates/core/src/data_cache.rs | 16 ++++++++++++++-- crates/data/src/rmxp/tileset.rs | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/core/src/data_cache.rs b/crates/core/src/data_cache.rs index 7c8a0e04..dc310b86 100644 --- a/crates/core/src/data_cache.rs +++ b/crates/core/src/data_cache.rs @@ -181,7 +181,13 @@ impl Data { pub fn from_defaults() -> Self { let mut map_infos = std::collections::HashMap::with_capacity(16); - map_infos.insert(1, rpg::MapInfo::default()); + map_infos.insert( + 1, + rpg::MapInfo { + order: 1, + ..Default::default() + }, + ); let map_infos = RefCell::new(rpg::MapInfos { data: map_infos, modified: true, @@ -201,7 +207,13 @@ impl Data { }); let mut maps = std::collections::HashMap::with_capacity(32); - maps.insert(1, rpg::Map::default()); + maps.insert( + 1, + rpg::Map { + modified: true, + ..Default::default() + }, + ); let maps = RefCell::new(maps); Self::Loaded { diff --git a/crates/data/src/rmxp/tileset.rs b/crates/data/src/rmxp/tileset.rs index c8f9d59c..47dc753b 100644 --- a/crates/data/src/rmxp/tileset.rs +++ b/crates/data/src/rmxp/tileset.rs @@ -28,7 +28,7 @@ pub struct Tileset { #[serde(with = "optional_path_serde")] #[marshal(with = "optional_path_alox")] pub tileset_name: Path, - pub autotile_names: Vec, + pub autotile_names: [String; 7], #[serde(with = "optional_path_serde")] #[marshal(with = "optional_path_alox")] pub panorama_name: Path,