diff options
Diffstat (limited to 'server/tools/src/map_linter.rs')
-rw-r--r-- | server/tools/src/map_linter.rs | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/server/tools/src/map_linter.rs b/server/tools/src/map_linter.rs index 70a170f3..738a9e10 100644 --- a/server/tools/src/map_linter.rs +++ b/server/tools/src/map_linter.rs @@ -148,7 +148,7 @@ pub fn check_map(map: &str) -> Result<()> { let locale = &*FALLBACK_LOCALE; let mut index = DataIndex::default(); index.reload()?; - let (data, serverdata, _) = index.generate(&map)?; + let (data, serverdata, _) = index.generate(map)?; let mut warnings = Vec::new(); @@ -178,7 +178,7 @@ pub fn check_map(map: &str) -> Result<()> { if data .tile_placeable_items .get(&tile) - .map_or(false, |e| e.is_empty()) + .is_some_and(|e| e.is_empty()) { warnings.push(trm!("s.tool.map_linter.exclusive_no_recipe", t = tile)); } @@ -208,23 +208,23 @@ pub fn check_map(map: &str) -> Result<()> { for (&pos, &(tile, _item)) in &serverdata.initial_map { let tile_name = data.tile_name(tile); - if NEED_EASY_ACCESS.contains(&tile_name) || NEED_ACCESS.contains(&tile_name) { - if !has_neighbour_diag(pos, |t| chef_access.contains(&t)) { - warnings.push(trm!( - "s.tool.map_linter.no_chef_access", - t = tile, - s = pos.to_string() - )); - } + if (NEED_EASY_ACCESS.contains(&tile_name) || NEED_ACCESS.contains(&tile_name)) + && !has_neighbour_diag(pos, |t| chef_access.contains(&t)) + { + warnings.push(trm!( + "s.tool.map_linter.no_chef_access", + t = tile, + s = pos.to_string() + )); } - if NEED_EASY_ACCESS.contains(&tile_name) { - if !has_neighbour(&serverdata, pos, |t| data.tile_walkable.contains(&t)) { - warnings.push(trm!( - "s.tool.map_linter.no_easy_access", - t = tile, - s = pos.to_string() - )); - } + if NEED_EASY_ACCESS.contains(&tile_name) + && !has_neighbour(&serverdata, pos, |t| data.tile_walkable.contains(&t)) + { + warnings.push(trm!( + "s.tool.map_linter.no_easy_access", + t = tile, + s = pos.to_string() + )); } if tile_name == "chair" { if !has_neighbour(&serverdata, pos, |t| { @@ -278,7 +278,7 @@ fn has_neighbour(sd: &Serverdata, pos: IVec2, pred: impl Fn(TileIndex) -> bool) .any(|off| { sd.initial_map .get(&(pos + off)) - .map_or(false, |(tile, _)| pred(*tile)) + .is_some_and(|(tile, _)| pred(*tile)) }) } fn has_neighbour_diag(pos: IVec2, pred: impl Fn(IVec2) -> bool) -> bool { @@ -309,11 +309,10 @@ fn fill_walkable(d: &Gamedata, sd: &Serverdata, start: IVec2) -> HashSet<IVec2> if sd .initial_map .get(&npos) - .map_or(false, |(x, _)| d.tile_walkable.contains(x)) + .is_some_and(|(x, _)| d.tile_walkable.contains(x)) + && !visited.contains(&npos) { - if !visited.contains(&npos) { - open.insert(npos); - } + open.insert(npos); } } } |