From 80490580a4cde291d9f8788e4669ace06dce733a Mon Sep 17 00:00:00 2001 From: floppy Date: Wed, 9 Feb 2022 23:44:27 +0100 Subject: [PATCH] fix plazas in site2 towns spawning on top of each other --- world/src/site2/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/world/src/site2/mod.rs b/world/src/site2/mod.rs index c3dc9d8358..41e895c234 100644 --- a/world/src/site2/mod.rs +++ b/world/src/site2/mod.rs @@ -232,7 +232,7 @@ impl Site { self.find_aabr(search_pos, area_range, min_dims) } - pub fn make_plaza(&mut self, land: &Land, rng: &mut impl Rng) -> Id { + pub fn make_plaza(&mut self, land: &Land, rng: &mut impl Rng) -> Option> { let plaza_radius = rng.gen_range(1..4); let plaza_dist = 6.5 + plaza_radius as f32 * 4.0; let pos = attempt(32, || { @@ -245,6 +245,7 @@ impl Site { * plaza_dist) .map(|e| e as i32) }) + .or_else(|| Some(Vec2::zero())) .filter(|tile| !self.tiles.get(*tile).is_obstacle()) .filter(|&tile| { self.plazas.iter().all(|&p| { @@ -252,8 +253,7 @@ impl Site { > (plaza_dist * 0.85).powi(2) }) && rng.gen_range(0..48) > tile.map(|e| e.abs()).reduce_max() }) - }) - .unwrap_or_else(Vec2::zero); + })?; let plaza_alt = land.get_alt_approx(self.tile_center_wpos(pos)) as i32; @@ -304,7 +304,7 @@ impl Site { } } - plaza + Some(plaza) } pub fn demarcate_obstacles(&mut self, land: &Land) {