diff options
Diffstat (limited to 'games/rstnode/rst-core')
-rw-r--r-- | games/rstnode/rst-core/src/lib.rs | 3 | ||||
-rw-r--r-- | games/rstnode/rst-core/src/loader.rs | 46 | ||||
-rw-r--r-- | games/rstnode/rst-core/src/mapstore.rs | 18 |
3 files changed, 25 insertions, 42 deletions
diff --git a/games/rstnode/rst-core/src/lib.rs b/games/rstnode/rst-core/src/lib.rs index bbf0e8e5933d..6e35d1937869 100644 --- a/games/rstnode/rst-core/src/lib.rs +++ b/games/rstnode/rst-core/src/lib.rs @@ -30,16 +30,15 @@ pub use _if::GameIf; mod _match; pub use _match::Match; -pub mod loader; pub mod config; pub mod data; pub mod error; pub mod gens; pub mod io; +pub mod loader; pub mod lobby; pub mod mailbox; pub mod map; -pub mod mapstore; pub mod net; pub mod server; pub mod stats; diff --git a/games/rstnode/rst-core/src/loader.rs b/games/rstnode/rst-core/src/loader.rs index 13cb3773fbf6..4bfbccfff652 100644 --- a/games/rstnode/rst-core/src/loader.rs +++ b/games/rstnode/rst-core/src/loader.rs @@ -36,31 +36,33 @@ pub struct MapLoader { impl MapLoader { pub fn load_path(path: PathBuf) -> Self { - Self { - root: path.clone(), - inner: fs::read_dir(&path) - .unwrap() - .filter_map(|map| { - let map = map.unwrap(); - let name = map.file_name().into_string().unwrap(); + info!("Loading map path: {}", path.to_str().unwrap()); + let root = path.clone(); + let inner = fs::read_dir(&path) + .unwrap() + .filter_map(|map| { + let map = map.unwrap(); + let name = map.file_name().into_string().unwrap(); - if map.path().is_dir() { - warn!("Directories in map path will be ignored: {}!", name); - None - } else { - let np = map.path().with_extension(""); - let name = np.file_name().unwrap().to_str().unwrap(); + if map.path().is_dir() { + warn!("Directories in map path will be ignored: {}!", name); + None + } else { + let np = map.path().with_extension(""); + let name = np.file_name().unwrap().to_str().unwrap(); - debug!("Loading map {}", name); - let mut c = String::new(); - let mut f = File::open(map.path()).unwrap(); - f.read_to_string(&mut c).unwrap(); + debug!("Loading map {}", name); + let mut c = String::new(); + let mut f = File::open(map.path()).unwrap(); + f.read_to_string(&mut c).unwrap(); - Some((name.into(), serde_yaml::from_str(&c).unwrap())) - } - }) - .collect(), - } + Some((name.into(), serde_yaml::from_str(&c).unwrap())) + } + }) + .collect(); + + info!("Loading complete!"); + Self { root, inner } } /// Save all maps that are present currently diff --git a/games/rstnode/rst-core/src/mapstore.rs b/games/rstnode/rst-core/src/mapstore.rs deleted file mode 100644 index eaacba34f27b..000000000000 --- a/games/rstnode/rst-core/src/mapstore.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! Map store - -use crate::config::MapCfg; -use std::{collections::BTreeMap, fs, path::Path}; - -#[deprecated] -pub struct MapStore { - configs: BTreeMap<String, MapCfg>, -} - -impl MapStore { - /// Load a set of map configs - pub fn load_path(&mut self, path: &Path) { - fs::read_dir(&path).unwrap().for_each(|d| { - let name = d.unwrap().file_name().into_string().unwrap(); - }); - } -} |