From d5f0ee2fc5d180b5fdf9537d237bcbbcb8ac0f89 Mon Sep 17 00:00:00 2001 From: floppy <sunflowerstarfishmail@gmail.com> Date: Sun, 16 Jan 2022 16:40:22 +0100 Subject: [PATCH 01/22] create fn generate_biome in namegen --- world/src/civ/mod.rs | 2 +- world/src/site/namegen.rs | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index 76450f204f..5d9b93baa2 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -548,7 +548,7 @@ impl Civs { let size_parameter = ((chords[2] + chords[3]) + (chords[0] + chords[1]) / 4) as u32; let lake = PointOfInterest { name: { - let name = NameGen::location(rng).generate(); + let name = NameGen::location(rng).generate_biome(); if size_parameter > 30 { format!("{} Sea", name) } else if (water_alt - alt) < 30 { diff --git a/world/src/site/namegen.rs b/world/src/site/namegen.rs index d9a55a377f..6eb9819fce 100644 --- a/world/src/site/namegen.rs +++ b/world/src/site/namegen.rs @@ -49,4 +49,38 @@ impl<'a, R: Rng> NameGen<'a, R> { .map(|(i, c)| if i == 0 { c.to_ascii_uppercase() } else { c }) .collect() } + + pub fn generate_biome(self) -> String { + let cons = vec![ + "d", "f", "ph", "r", "st", "t", "s", "p", "sh", "th", "br", "tr", "m", "k", "st", "w", + "y", "cr", "fr", "dr", "pl", "wr", "sn", "g", "qu", "l", + ]; + let mut start = cons.clone(); + start.extend(vec![ + "cr", "thr", "str", "br", "iv", "est", "ost", "ing", "kr", "in", "on", "tr", "tw", + "wh", "eld", "ar", "or", "ear", "irr", "mi", "en", "ed", "et", "ow", "fr", "shr", "wr", + "gr", "pr", + ]); + let mut middle = cons.clone(); + middle.extend(vec!["tt"]); + let vowel = vec!["o", "e", "a", "i", "u", "au", "ee", "ow", "ay", "ey", "oe"]; + let end = vec![ + "a", "ia", "ium", "ist", "en", "on", "og", "end", "ind", "ock", "een", "edge", "ed", + "est", "ean", "ead", "eon", "ow", "in", "on", "id", "ir", "or", "in", "en", + ]; + + let mut name = String::new(); + + name += start.choose(self.rng).unwrap(); + for _ in 0..self.approx_syllables.saturating_sub(2) { + name += vowel.choose(self.rng).unwrap(); + name += middle.choose(self.rng).unwrap(); + } + name += end.choose(self.rng).unwrap(); + + name.chars() + .enumerate() + .map(|(i, c)| if i == 0 { c.to_ascii_uppercase() } else { c }) + .collect() + } } From 5bd7507f317255f1b0d3e50de8952498c2976165 Mon Sep 17 00:00:00 2001 From: IsseW <isidornie@gmail.com> Date: Sun, 16 Jan 2022 16:54:49 +0100 Subject: [PATCH 02/22] Added poi for all biomes --- world/src/civ/mod.rs | 158 ++++++++++++++----------------------------- world/src/lib.rs | 2 +- 2 files changed, 52 insertions(+), 108 deletions(-) diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index 5d9b93baa2..6c9ec77e6a 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -4,10 +4,10 @@ mod econ; use crate::{ config::CONFIG, - sim::{RiverKind, WorldSim}, + sim::WorldSim, site::{namegen::NameGen, Castle, Settlement, Site as WorldSite, Tree}, site2, - util::{attempt, seed_expan, CARDINALS, NEIGHBORS}, + util::{attempt, seed_expan, NEIGHBORS}, Index, Land, }; use common::{ @@ -15,7 +15,7 @@ use common::{ path::Path, spiral::Spiral2d, store::{Id, Store}, - terrain::{uniform_idx_as_vec2, vec2_as_uniform_idx, MapSizeLg, TerrainChunkSize}, + terrain::{uniform_idx_as_vec2, MapSizeLg, TerrainChunkSize}, vol::RectVolSize, }; use core::{fmt, hash::BuildHasherDefault, ops::Range}; @@ -89,8 +89,8 @@ impl Civs { let mut ctx = GenCtx { sim, rng }; info!("starting peak naming"); this.name_peaks(&mut ctx); - info!("starting lake naming"); - this.name_lakes(&mut ctx); + info!("starting biome naming"); + this.name_biomes(&mut ctx); for _ in 0..ctx.sim.get_size().product() / 10_000 { this.generate_cave(&mut ctx); @@ -468,113 +468,57 @@ impl Civs { } /// Adds lake POIs and names them - fn name_lakes(&mut self, ctx: &mut GenCtx<impl Rng>) { + fn name_biomes(&mut self, ctx: &mut GenCtx<impl Rng>) { let map_size_lg = ctx.sim.map_size_lg(); - let rng = &mut ctx.rng; - let sim_chunks = &ctx.sim.chunks; - let lakes = sim_chunks - .iter() - .enumerate() - .filter(|(posi, chunk)| { - let neighbor_alts_min = common::terrain::neighbors(map_size_lg, *posi) - .map(|i| sim_chunks[i].alt as u32) - .min(); - chunk - .river - .river_kind - .map_or(false, |r_kind| matches!(r_kind, RiverKind::Lake { .. })) - && neighbor_alts_min.map_or(false, |n_alt| (chunk.alt as u32) < n_alt) - }) - .map(|(posi, chunk)| { - ( - uniform_idx_as_vec2(map_size_lg, posi), - chunk.alt as u32, - chunk.water_alt as u32, - ) - }) - .collect::<Vec<(Vec2<i32>, u32, u32)>>(); - let mut removals = vec![false; lakes.len()]; - let mut lake_alts = HashSet::new(); - for (i, (loc, alt, water_alt)) in lakes.iter().enumerate() { - for (k, (n_loc, n_alt, n_water_alt)) in lakes.iter().enumerate() { - // If the difference in position of this low point and another is - // below a threshold and this chunk's altitude is higher, remove the - // lake from the list. Also remove shallow ponds. - // If this lake water altitude is already accounted for and the lake bed - // altitude is lower than the neighboring lake bed altitude, remove this - // lake from the list. Otherwise, add this lake water altitude to the list - // of counted lake water altitudes. - if i != k - && (*water_alt <= CONFIG.sea_level as u32 - || (!lake_alts.insert(water_alt) - && water_alt == n_water_alt - && alt > n_alt) - || ((loc).distance_squared(*n_loc) < POI_THINNING_DIST_SQRD - && alt >= n_alt)) - { - // This cannot panic as `removals` is the same length as `lakes` - // i is the index in `lakes` - removals[i] = true; - } - } - } - let mut num_lakes = 0; - for (_j, (loc, alt, water_alt)) in lakes.iter().enumerate().filter(|&(i, _)| !removals[i]) { - // Recenter the location of the lake POI - // Sample every few units to speed this up - let sample_step = 3; - let mut chords: [i32; 4] = [0, 0, 0, 0]; - // only search up to 100 chunks in any direction - for (j, chord) in chords.iter_mut().enumerate() { - for i in 0..100 { - let posi = vec2_as_uniform_idx( - map_size_lg, - Vec2::new(loc.x, loc.y) + CARDINALS[j] * sample_step * i, - ); - if let Some(r_kind) = sim_chunks[posi].river.river_kind { - if matches!(r_kind, RiverKind::Lake { .. }) { - *chord += sample_step; - } else { - break; - } + let mut biomes: Vec<(common::terrain::BiomeKind, Vec<usize>)> = Vec::new(); + let mut explored = HashSet::new(); + let mut to_explore = HashSet::new(); + let mut to_floodfill = HashSet::new(); + // TODO: have start point in center and ignore ocean? + let start_point = 0; + to_explore.insert(start_point); + explored.insert(start_point); + + while to_explore.len() > 0 { + let exploring = *to_explore.iter().next().unwrap(); + to_explore.remove(&exploring); + to_floodfill.insert(exploring); + // Should always be a chunk on the map + let biome = ctx.sim.chunks[exploring].get_biome(); + biomes.push((biome, Vec::new())); + while to_floodfill.len() > 0 { + let filling = *to_floodfill.iter().next().unwrap(); + to_explore.remove(&filling); + to_floodfill.remove(&filling); + explored.insert(filling); + biomes.last_mut().unwrap().1.push(filling); + for neighbour in common::terrain::neighbors(map_size_lg, filling) { + if explored.contains(&neighbour) { + continue; + } + let n_biome = ctx.sim.chunks[neighbour].get_biome(); + if n_biome == biome { + to_floodfill.insert(neighbour); } else { - break; + to_explore.insert(neighbour); } } } - let center_y = ((chords[0] + chords[1]) / 2) - chords[1] + loc.y; - let center_x = ((chords[2] + chords[3]) / 2) - chords[3] + loc.x; - let new_loc = Vec2::new(center_x, center_y); - let size_parameter = ((chords[2] + chords[3]) + (chords[0] + chords[1]) / 4) as u32; - let lake = PointOfInterest { - name: { - let name = NameGen::location(rng).generate_biome(); - if size_parameter > 30 { - format!("{} Sea", name) - } else if (water_alt - alt) < 30 { - match rng.gen_range(0..5) { - 0 => format!("{} Shallows", name), - 1 => format!("{} Pool", name), - 2 => format!("{} Well", name), - _ => format!("{} Pond", name), - } - } else { - match rng.gen_range(0..6) { - 0 => format!("{} Lake", name), - 1 => format!("Loch {}", name), - _ => format!("Lake {}", name), - } - } - }, - // Size parameter is based on the east west chord length with a smaller factor from - // the north south chord length. This is used for text scaling on the map - kind: PoiKind::Lake(size_parameter), - loc: new_loc, - }; - num_lakes += 1; - self.pois.insert(lake); } - info!(?num_lakes, "all lakes named"); + let num_biomes = biomes.len(); + + for biome in biomes { + // Select point + let idx = biome.1[ctx.rng.gen_range(0..biome.1.len())]; + let name = format!("{:?}", biome.0); + self.pois.insert(PointOfInterest { + name, + loc: uniform_idx_as_vec2(map_size_lg, idx), + kind: PoiKind::Biome(biome.1.len() as u32), + }); + } + + info!(?num_biomes, "all biomes named"); } /// Adds mountain POIs and name them @@ -934,5 +878,5 @@ pub enum PoiKind { /// Peak stores the altitude Peak(u32), /// Lake stores a metric relating to size - Lake(u32), + Biome(u32), } diff --git a/world/src/lib.rs b/world/src/lib.rs index a801fb0e50..153ff783a1 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -131,7 +131,7 @@ impl World { name: poi.name.clone(), kind: match &poi.kind { civ::PoiKind::Peak(alt) => world_msg::PoiKind::Peak(*alt), - civ::PoiKind::Lake(size) => world_msg::PoiKind::Lake(*size), + civ::PoiKind::Biome(size) => world_msg::PoiKind::Lake(*size), }, wpos: poi.loc * TerrainChunkSize::RECT_SIZE.map(|e| e as i32), } From f8d94ef25f336dc996cf92344fcdf3fafa4c8368 Mon Sep 17 00:00:00 2001 From: IsseW <isidornie@gmail.com> Date: Sun, 16 Jan 2022 18:11:22 +0100 Subject: [PATCH 03/22] biome name to chunk name --- world/src/canvas.rs | 1 + world/src/civ/mod.rs | 5 ++++- world/src/lib.rs | 3 ++- world/src/sim/mod.rs | 4 +++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/world/src/canvas.rs b/world/src/canvas.rs index 14a3284bd6..670d312fe5 100644 --- a/world/src/canvas.rs +++ b/world/src/canvas.rs @@ -112,6 +112,7 @@ impl<'a> CanvasInfo<'a> { surface_veg: 0.0, sites: Vec::new(), place: None, + poi: None, path: Default::default(), cave: Default::default(), cliff_height: 0.0, diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index 6c9ec77e6a..83623d2bed 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -511,11 +511,14 @@ impl Civs { // Select point let idx = biome.1[ctx.rng.gen_range(0..biome.1.len())]; let name = format!("{:?}", biome.0); - self.pois.insert(PointOfInterest { + let id = self.pois.insert(PointOfInterest { name, loc: uniform_idx_as_vec2(map_size_lg, idx), kind: PoiKind::Biome(biome.1.len() as u32), }); + for chunk in biome.1 { + ctx.sim.chunks[chunk].poi = Some(id); + } } info!(?num_biomes, "all biomes named"); diff --git a/world/src/lib.rs b/world/src/lib.rs index 153ff783a1..9d993d4467 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -282,7 +282,8 @@ impl World { .get_origin() .distance_squared(chunk_center_wpos2d) }) - .map(|id| index.sites[*id].name().to_string()), + .map(|id| index.sites[*id].name().to_string()) + .or_else(|| sim_chunk.poi.map(|poi| self.civs.pois[poi].name.clone())), sim_chunk.get_biome(), sim_chunk.alt, sim_chunk.tree_density, diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index 397fd741c2..2d1f8d21b1 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -28,7 +28,7 @@ pub(crate) use self::{ use crate::{ all::{Environment, ForestKind, TreeAttr}, block::BlockGen, - civ::Place, + civ::{Place, PointOfInterest}, column::ColumnGen, layer::spot::Spot, site::Site, @@ -2178,6 +2178,7 @@ pub struct SimChunk { pub sites: Vec<Id<Site>>, pub place: Option<Id<Place>>, + pub poi: Option<Id<PointOfInterest>>, pub path: (Way, Path), pub cave: (Way, Cave), @@ -2419,6 +2420,7 @@ impl SimChunk { sites: Vec::new(), place: None, + poi: None, path: Default::default(), cave: Default::default(), cliff_height: 0.0, From 5b9f4056716a9a5cbb8fd3ba94fca5aaf2eea1e5 Mon Sep 17 00:00:00 2001 From: IsseW <isidornie@gmail.com> Date: Sun, 16 Jan 2022 20:28:53 +0100 Subject: [PATCH 04/22] Better placement of poi and actual names --- world/src/civ/mod.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index 83623d2bed..0083ecbd6b 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -508,9 +508,26 @@ impl Civs { let num_biomes = biomes.len(); for biome in biomes { - // Select point - let idx = biome.1[ctx.rng.gen_range(0..biome.1.len())]; - let name = format!("{:?}", biome.0); + // find average center of the biome + let mut biomes = biome.1.iter(); + // There is always at least 1 biome + let mut center = uniform_idx_as_vec2(map_size_lg, *biomes.next().unwrap()); + biomes.for_each(|b| { + center += uniform_idx_as_vec2(map_size_lg, *b); + center /= 2; + }); + // Select the point closest to the center + + let idx = *biome + .1 + .iter() + .min_by_key(|&b| center.distance_squared(uniform_idx_as_vec2(map_size_lg, *b))) + .unwrap(); + let name = format!( + "{} {:?}", + NameGen::location(&mut ctx.rng).generate_biome(), + biome.0 + ); let id = self.pois.insert(PointOfInterest { name, loc: uniform_idx_as_vec2(map_size_lg, idx), From 5ad8501cc883828ccb5e8b92bef9b45f748913be Mon Sep 17 00:00:00 2001 From: floppy <sunflowerstarfishmail@gmail.com> Date: Sun, 16 Jan 2022 21:22:12 +0100 Subject: [PATCH 05/22] update bricks in fn generate_biome in namegen, tweaks WIP --- world/src/site/namegen.rs | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/world/src/site/namegen.rs b/world/src/site/namegen.rs index 6eb9819fce..5e18616189 100644 --- a/world/src/site/namegen.rs +++ b/world/src/site/namegen.rs @@ -3,6 +3,7 @@ use rand::prelude::*; pub struct NameGen<'a, R: Rng> { // 2.. pub approx_syllables: usize, + pub approx_syllables_long: usize, rng: &'a mut R, } @@ -11,6 +12,7 @@ impl<'a, R: Rng> NameGen<'a, R> { pub fn location(rng: &'a mut R) -> Self { Self { approx_syllables: rng.gen_range(1..4), + approx_syllables_long: rng.gen_range(3..4), rng, } } @@ -52,27 +54,31 @@ impl<'a, R: Rng> NameGen<'a, R> { pub fn generate_biome(self) -> String { let cons = vec![ - "d", "f", "ph", "r", "st", "t", "s", "p", "sh", "th", "br", "tr", "m", "k", "st", "w", - "y", "cr", "fr", "dr", "pl", "wr", "sn", "g", "qu", "l", + "b", "d", "f", "g", "h", "k", "l", "m", "n", "s", "t", "w", "br", "dr", "gr", "gh", + "kh", "kr", "st", "str", "th", "tr", "ar", "ark", "adr", "ath", "an", "el", "elb", + "eldr", "estr", "ostr", "ond", "ondr", "ul", "uld", "eld", "eldr", ]; - let mut start = cons.clone(); - start.extend(vec![ - "cr", "thr", "str", "br", "iv", "est", "ost", "ing", "kr", "in", "on", "tr", "tw", - "wh", "eld", "ar", "or", "ear", "irr", "mi", "en", "ed", "et", "ow", "fr", "shr", "wr", - "gr", "pr", - ]); - let mut middle = cons.clone(); + let start = cons.clone(); + let mid = vec![ + "br", "d", "dr", "dn", "dm", "fr", "g", "gr", "gl", "k", "kr", "l", "ll", "m", "mm", + "n", "nn", "nd", "st", "th", "rw", "nw", "thr", "lk", "nk", "ng", "rd", "rk", "nr", + "nth", "rth", "kn", "rl", "gg", "lg", "str", "nb", "lb", "ld", "rm", "sd", "sb", + ]; + let mut middle = mid.clone(); middle.extend(vec!["tt"]); - let vowel = vec!["o", "e", "a", "i", "u", "au", "ee", "ow", "ay", "ey", "oe"]; + let vowel = vec!["o", "e", "a", "u", "ae"]; let end = vec![ - "a", "ia", "ium", "ist", "en", "on", "og", "end", "ind", "ock", "een", "edge", "ed", - "est", "ean", "ead", "eon", "ow", "in", "on", "id", "ir", "or", "in", "en", + "ul", "um", "un", "uth", "und", "ur", "an", "a", "ar", "a", "amar", "amur", "ath", + "or", "on", "oth", "omor", "omur", "omar", "ador", "odor", "en", "end", "eth", "amon", + "edur", "aden", "oden", "alas", "elas", "alath", "aloth", "eloth", "eres", "ond", + "ondor", "undor", "andor", "od", "ed", "amad", "ud", "amud", "ulud", "alud", "allen", + "alad", "and", "an", "as", "es", ]; let mut name = String::new(); name += start.choose(self.rng).unwrap(); - for _ in 0..self.approx_syllables.saturating_sub(2) { + for _ in 0..self.approx_syllables_long.saturating_sub(2) { name += vowel.choose(self.rng).unwrap(); name += middle.choose(self.rng).unwrap(); } From c00f5bafee1ec582a744679f60a98b854c1ad3e0 Mon Sep 17 00:00:00 2001 From: floppy <sunflowerstarfishmail@gmail.com> Date: Mon, 17 Jan 2022 08:36:35 +0100 Subject: [PATCH 06/22] add fn generate_forest in namegen to name forest biomes --- world/src/civ/mod.rs | 19 ++++++++++++++----- world/src/site/namegen.rs | 22 ++++++++++++++++++++++ 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index 0083ecbd6b..7396036a15 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -523,11 +523,20 @@ impl Civs { .iter() .min_by_key(|&b| center.distance_squared(uniform_idx_as_vec2(map_size_lg, *b))) .unwrap(); - let name = format!( - "{} {:?}", - NameGen::location(&mut ctx.rng).generate_biome(), - biome.0 - ); + let name = match biome.0 { + common::terrain::BiomeKind::Forest => format!("{}\n{:?}", NameGen::location(&mut ctx.rng).generate_forest(), biome.0), + common::terrain::BiomeKind::Grassland + |common::terrain::BiomeKind::Lake + | common::terrain::BiomeKind::Ocean + | common::terrain::BiomeKind::Mountain + | common::terrain::BiomeKind::Snowland + | common::terrain::BiomeKind::Desert + | common::terrain::BiomeKind::Swamp + | common::terrain::BiomeKind::Jungle + | common::terrain::BiomeKind::Savannah + | common::terrain::BiomeKind::Taiga => format!("{}\n{:?}", NameGen::location(&mut ctx.rng).generate_biome(), biome.0), + _ => String::new() + }; let id = self.pois.insert(PointOfInterest { name, loc: uniform_idx_as_vec2(map_size_lg, idx), diff --git a/world/src/site/namegen.rs b/world/src/site/namegen.rs index 5e18616189..566abec599 100644 --- a/world/src/site/namegen.rs +++ b/world/src/site/namegen.rs @@ -89,4 +89,26 @@ impl<'a, R: Rng> NameGen<'a, R> { .map(|(i, c)| if i == 0 { c.to_ascii_uppercase() } else { c }) .collect() } + + pub fn generate_forest(self) -> String { + let cons = vec![ + "green", "moss", "ever", "briar", "thorn", "oak", "deep", "moon", "star", "sun", "bright", "glare", + "fair", "calm", "mistral", "whisper", "clover", "hollow", "spring", "morrow", "dim", "dusk", "dawn", "night", + "shimmer", "silver", "gold", "whisper", "fern", "quiet", "still", "gleam", "wild", "blind", "swift", + ]; + let start = cons.clone(); + let end = vec![ + "root", "bark", "log", "brook", "well", "shire", "leaf", "more", "bole", "heart", "song", "dew", + "bough", "path", "wind", "breeze", "light", "branch", "bloom", "vale", "glen", "rest", "shade", + "fall", "sward", "thicket", "shrub", "bush", "grasp", "grip", "gale", "crawl", "run", "shadow", + ]; + let mut name = String::new(); + name += start.choose(self.rng).unwrap(); + name += end.choose(self.rng).unwrap(); + + name.chars() + .enumerate() + .map(|(i, c)| if i == 0 { c.to_ascii_uppercase() } else { c }) + .collect() + } } From 18c434c61388872f9387a5db83e578f40100ef15 Mon Sep 17 00:00:00 2001 From: floppy <sunflowerstarfishmail@gmail.com> Date: Mon, 17 Jan 2022 09:04:12 +0100 Subject: [PATCH 07/22] tweak generate_biome --- world/src/site/namegen.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/world/src/site/namegen.rs b/world/src/site/namegen.rs index 566abec599..3c974f837d 100644 --- a/world/src/site/namegen.rs +++ b/world/src/site/namegen.rs @@ -3,8 +3,6 @@ use rand::prelude::*; pub struct NameGen<'a, R: Rng> { // 2.. pub approx_syllables: usize, - pub approx_syllables_long: usize, - rng: &'a mut R, } @@ -12,7 +10,6 @@ impl<'a, R: Rng> NameGen<'a, R> { pub fn location(rng: &'a mut R) -> Self { Self { approx_syllables: rng.gen_range(1..4), - approx_syllables_long: rng.gen_range(3..4), rng, } } @@ -78,7 +75,7 @@ impl<'a, R: Rng> NameGen<'a, R> { let mut name = String::new(); name += start.choose(self.rng).unwrap(); - for _ in 0..self.approx_syllables_long.saturating_sub(2) { + for _ in 0..self.approx_syllables.saturating_sub(2) + 1 { name += vowel.choose(self.rng).unwrap(); name += middle.choose(self.rng).unwrap(); } From ced1a8282476ae4bd2084e10ae2cf9acd246e9be Mon Sep 17 00:00:00 2001 From: floppy <sunflowerstarfishmail@gmail.com> Date: Mon, 17 Jan 2022 11:19:34 +0100 Subject: [PATCH 08/22] - add size threshold for biomes to name, to exclude mini-biomes from clogging the map. - fmt, clippy --- world/src/civ/mod.rs | 52 +++++++++++++++++++++++---------------- world/src/site/namegen.rs | 14 ++++++----- 2 files changed, 39 insertions(+), 27 deletions(-) diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index 7396036a15..d314f21b86 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -523,27 +523,37 @@ impl Civs { .iter() .min_by_key(|&b| center.distance_squared(uniform_idx_as_vec2(map_size_lg, *b))) .unwrap(); - let name = match biome.0 { - common::terrain::BiomeKind::Forest => format!("{}\n{:?}", NameGen::location(&mut ctx.rng).generate_forest(), biome.0), - common::terrain::BiomeKind::Grassland - |common::terrain::BiomeKind::Lake - | common::terrain::BiomeKind::Ocean - | common::terrain::BiomeKind::Mountain - | common::terrain::BiomeKind::Snowland - | common::terrain::BiomeKind::Desert - | common::terrain::BiomeKind::Swamp - | common::terrain::BiomeKind::Jungle - | common::terrain::BiomeKind::Savannah - | common::terrain::BiomeKind::Taiga => format!("{}\n{:?}", NameGen::location(&mut ctx.rng).generate_biome(), biome.0), - _ => String::new() - }; - let id = self.pois.insert(PointOfInterest { - name, - loc: uniform_idx_as_vec2(map_size_lg, idx), - kind: PoiKind::Biome(biome.1.len() as u32), - }); - for chunk in biome.1 { - ctx.sim.chunks[chunk].poi = Some(id); + if biome.1.len() as u32 > 750 { + let name = match biome.0 { + common::terrain::BiomeKind::Forest => format!( + "{}\n{:?}", + NameGen::location(&mut ctx.rng).generate_forest(), + biome.0 + ), + common::terrain::BiomeKind::Grassland + | common::terrain::BiomeKind::Lake + | common::terrain::BiomeKind::Ocean + | common::terrain::BiomeKind::Mountain + | common::terrain::BiomeKind::Snowland + | common::terrain::BiomeKind::Desert + | common::terrain::BiomeKind::Swamp + | common::terrain::BiomeKind::Jungle + | common::terrain::BiomeKind::Savannah + | common::terrain::BiomeKind::Taiga => format!( + "{}\n{:?}", + NameGen::location(&mut ctx.rng).generate_biome(), + biome.0 + ), + _ => String::new(), + }; + let id = self.pois.insert(PointOfInterest { + name, + loc: uniform_idx_as_vec2(map_size_lg, idx), + kind: PoiKind::Biome(biome.1.len() as u32), + }); + for chunk in biome.1 { + ctx.sim.chunks[chunk].poi = Some(id); + } } } diff --git a/world/src/site/namegen.rs b/world/src/site/namegen.rs index 3c974f837d..5ba77e01b5 100644 --- a/world/src/site/namegen.rs +++ b/world/src/site/namegen.rs @@ -89,15 +89,17 @@ impl<'a, R: Rng> NameGen<'a, R> { pub fn generate_forest(self) -> String { let cons = vec![ - "green", "moss", "ever", "briar", "thorn", "oak", "deep", "moon", "star", "sun", "bright", "glare", - "fair", "calm", "mistral", "whisper", "clover", "hollow", "spring", "morrow", "dim", "dusk", "dawn", "night", - "shimmer", "silver", "gold", "whisper", "fern", "quiet", "still", "gleam", "wild", "blind", "swift", + "green", "moss", "ever", "briar", "thorn", "oak", "deep", "moon", "star", "sun", + "bright", "glare", "fair", "calm", "mistral", "whisper", "clover", "hollow", "spring", + "morrow", "dim", "dusk", "dawn", "night", "shimmer", "silver", "gold", "whisper", + "fern", "quiet", "still", "gleam", "wild", "blind", "swift", ]; let start = cons.clone(); let end = vec![ - "root", "bark", "log", "brook", "well", "shire", "leaf", "more", "bole", "heart", "song", "dew", - "bough", "path", "wind", "breeze", "light", "branch", "bloom", "vale", "glen", "rest", "shade", - "fall", "sward", "thicket", "shrub", "bush", "grasp", "grip", "gale", "crawl", "run", "shadow", + "root", "bark", "log", "brook", "well", "shire", "leaf", "more", "bole", "heart", + "song", "dew", "bough", "path", "wind", "breeze", "light", "branch", "bloom", "vale", + "glen", "rest", "shade", "fall", "sward", "thicket", "shrub", "bush", "grasp", "grip", + "gale", "crawl", "run", "shadow", ]; let mut name = String::new(); name += start.choose(self.rng).unwrap(); From 609d23ae4f7dcdcca15307f3fdd02f318f9b2079 Mon Sep 17 00:00:00 2001 From: floppy <sunflowerstarfishmail@gmail.com> Date: Mon, 17 Jan 2022 16:02:52 +0100 Subject: [PATCH 09/22] - make individual size thresholds for biome name generation to include small lakes - add original Lake naming pattern, partly (no water_alt check) --- world/src/civ/mod.rs | 72 ++++++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 29 deletions(-) diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index d314f21b86..8d8d0b984b 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -517,43 +517,57 @@ impl Civs { center /= 2; }); // Select the point closest to the center - let idx = *biome .1 .iter() .min_by_key(|&b| center.distance_squared(uniform_idx_as_vec2(map_size_lg, *b))) .unwrap(); - if biome.1.len() as u32 > 750 { - let name = match biome.0 { - common::terrain::BiomeKind::Forest => format!( - "{}\n{:?}", - NameGen::location(&mut ctx.rng).generate_forest(), - biome.0 - ), - common::terrain::BiomeKind::Grassland - | common::terrain::BiomeKind::Lake - | common::terrain::BiomeKind::Ocean - | common::terrain::BiomeKind::Mountain - | common::terrain::BiomeKind::Snowland - | common::terrain::BiomeKind::Desert - | common::terrain::BiomeKind::Swamp - | common::terrain::BiomeKind::Jungle - | common::terrain::BiomeKind::Savannah - | common::terrain::BiomeKind::Taiga => format!( + let name = match biome.0 { + common::terrain::BiomeKind::Forest if biome.1.len() as u32 > 750 => format!( + "{}\n{:?}", + NameGen::location(&mut ctx.rng).generate_forest(), + biome.0 + ), + common::terrain::BiomeKind::Grassland + | common::terrain::BiomeKind::Ocean + | common::terrain::BiomeKind::Mountain + | common::terrain::BiomeKind::Snowland + | common::terrain::BiomeKind::Desert + | common::terrain::BiomeKind::Swamp + | common::terrain::BiomeKind::Jungle + | common::terrain::BiomeKind::Savannah + | common::terrain::BiomeKind::Taiga + if biome.1.len() as u32 > 750 => + { + format!( "{}\n{:?}", NameGen::location(&mut ctx.rng).generate_biome(), biome.0 - ), - _ => String::new(), - }; - let id = self.pois.insert(PointOfInterest { - name, - loc: uniform_idx_as_vec2(map_size_lg, idx), - kind: PoiKind::Biome(biome.1.len() as u32), - }); - for chunk in biome.1 { - ctx.sim.chunks[chunk].poi = Some(id); - } + ) + }, + common::terrain::BiomeKind::Lake if biome.1.len() as u32 > 200 => { + match ctx.rng.gen_range(0..6) { + 0 => format!("{} Lake", NameGen::location(&mut ctx.rng).generate()), + 1 => format!("Loch {}", NameGen::location(&mut ctx.rng).generate()), + _ => format!("{} Lake", NameGen::location(&mut ctx.rng).generate()), + } + }, + common::terrain::BiomeKind::Lake if biome.1.len() as u32 > 10 => { + match ctx.rng.gen_range(0..4) { + 0 => format!("{} Pool", NameGen::location(&mut ctx.rng).generate()), + 1 => format!("{} Well", NameGen::location(&mut ctx.rng).generate()), + _ => format!("{} Pond", NameGen::location(&mut ctx.rng).generate()), + } + }, + _ => String::new(), + }; + let id = self.pois.insert(PointOfInterest { + name, + loc: uniform_idx_as_vec2(map_size_lg, idx), + kind: PoiKind::Biome(biome.1.len() as u32), + }); + for chunk in biome.1 { + ctx.sim.chunks[chunk].poi = Some(id); } } From 88a39476bc78b21455a1f8bb6a939627cae8f429 Mon Sep 17 00:00:00 2001 From: floppy <sunflowerstarfishmail@gmail.com> Date: Mon, 17 Jan 2022 19:03:15 +0100 Subject: [PATCH 10/22] tweak fn generate_biome in namegen --- world/src/site/namegen.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/world/src/site/namegen.rs b/world/src/site/namegen.rs index 5ba77e01b5..4192081870 100644 --- a/world/src/site/namegen.rs +++ b/world/src/site/namegen.rs @@ -3,6 +3,8 @@ use rand::prelude::*; pub struct NameGen<'a, R: Rng> { // 2.. pub approx_syllables: usize, + pub approx_syllables_long: usize, + rng: &'a mut R, } @@ -10,6 +12,8 @@ impl<'a, R: Rng> NameGen<'a, R> { pub fn location(rng: &'a mut R) -> Self { Self { approx_syllables: rng.gen_range(1..4), + approx_syllables_long: rng.gen_range(2..4), + rng, } } @@ -75,7 +79,7 @@ impl<'a, R: Rng> NameGen<'a, R> { let mut name = String::new(); name += start.choose(self.rng).unwrap(); - for _ in 0..self.approx_syllables.saturating_sub(2) + 1 { + for _ in 0..self.approx_syllables_long.saturating_sub(2) { name += vowel.choose(self.rng).unwrap(); name += middle.choose(self.rng).unwrap(); } From 0c97a6e91a16eb3240ca5870537d31844f9f307e Mon Sep 17 00:00:00 2001 From: floppy <sunflowerstarfishmail@gmail.com> Date: Mon, 17 Jan 2022 20:14:16 +0100 Subject: [PATCH 11/22] add synonyms for biomes --- world/src/civ/mod.rs | 401 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 372 insertions(+), 29 deletions(-) diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index 8d8d0b984b..1c41bbabb0 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -523,40 +523,383 @@ impl Civs { .min_by_key(|&b| center.distance_squared(uniform_idx_as_vec2(map_size_lg, *b))) .unwrap(); let name = match biome.0 { - common::terrain::BiomeKind::Forest if biome.1.len() as u32 > 750 => format!( - "{}\n{:?}", - NameGen::location(&mut ctx.rng).generate_forest(), - biome.0 - ), - common::terrain::BiomeKind::Grassland - | common::terrain::BiomeKind::Ocean - | common::terrain::BiomeKind::Mountain - | common::terrain::BiomeKind::Snowland - | common::terrain::BiomeKind::Desert - | common::terrain::BiomeKind::Swamp - | common::terrain::BiomeKind::Jungle - | common::terrain::BiomeKind::Savannah - | common::terrain::BiomeKind::Taiga - if biome.1.len() as u32 > 750 => - { - format!( - "{}\n{:?}", - NameGen::location(&mut ctx.rng).generate_biome(), - biome.0 - ) + common::terrain::BiomeKind::Forest if biome.1.len() as u32 > 750 => { + match ctx.rng.gen_range(0..8) { + 0 => format!( + "{}\nForest", + NameGen::location(&mut ctx.rng).generate_forest() + ), + 1 => format!( + "{}\nWoodlands", + NameGen::location(&mut ctx.rng).generate_forest() + ), + 2 => format!( + "{}\nWoods", + NameGen::location(&mut ctx.rng).generate_forest() + ), + 3 => format!( + "{}\nGlades", + NameGen::location(&mut ctx.rng).generate_forest() + ), + 4 => format!( + "{}\nGrove", + NameGen::location(&mut ctx.rng).generate_forest() + ), + 5 => format!( + "{}\nGlades", + NameGen::location(&mut ctx.rng).generate_forest() + ), + 6 => format!( + "{}\nThickets", + NameGen::location(&mut ctx.rng).generate_forest() + ), + 7 => format!( + "{}\nWeald", + NameGen::location(&mut ctx.rng).generate_forest() + ), + _ => format!( + "{}\nForest", + NameGen::location(&mut ctx.rng).generate_forest() + ), + } + }, + common::terrain::BiomeKind::Grassland if biome.1.len() as u32 > 750 => { + match ctx.rng.gen_range(0..11) { + 0 => format!( + "{}\nGrasslands", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 1 => format!( + "{}\nFlats", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 2 => format!( + "{}\nGreens", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 3 => format!( + "{}\nPlains", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 4 => format!( + "{}\nMeadows", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 5 => format!( + "{}\nFields", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 6 => format!( + "{}\nHeath", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 7 => format!( + "{}\nPrairie", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 8 => format!( + "{}\nSteppe", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 9 => format!( + "{}\nDowns", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 10 => format!( + "{}\nHeath", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 11 => format!( + "{}\nHeath", + NameGen::location(&mut ctx.rng).generate_biome() + ), + _ => format!( + "{}\nGrassland", + NameGen::location(&mut ctx.rng).generate_biome() + ), + } + }, + common::terrain::BiomeKind::Ocean if biome.1.len() as u32 > 750 => { + match ctx.rng.gen_range(0..3) { + 0 => format!( + "{}\nOcean", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 1 => format!("{}\nBlue", NameGen::location(&mut ctx.rng).generate_biome()), + 2 => format!("{}\nDeep", NameGen::location(&mut ctx.rng).generate_biome()), + 3 => format!( + "{}\nDepths", + NameGen::location(&mut ctx.rng).generate_biome() + ), + _ => format!( + "{}\nOcean", + NameGen::location(&mut ctx.rng).generate_biome() + ), + } + }, + common::terrain::BiomeKind::Mountain if biome.1.len() as u32 > 750 => { + match ctx.rng.gen_range(0..11) { + 0 => format!( + "{}\nMountains", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 1 => format!( + "{}\nRange", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 2 => format!( + "{}\nReach", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 3 => format!( + "{}\nMassif", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 4 => format!( + "{}\nRocks", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 5 => format!( + "{}\nCliffs", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 6 => format!( + "{}\nPeaks", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 7 => format!( + "{}\nHeights", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 8 => format!( + "{}\nBluffs", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 9 => format!( + "{}\nRidge", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 10 => format!( + "{}\nCanyon", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 11 => format!( + "{}\nPlateau", + NameGen::location(&mut ctx.rng).generate_biome() + ), + _ => format!( + "{}\nMountains", + NameGen::location(&mut ctx.rng).generate_biome() + ), + } + }, + common::terrain::BiomeKind::Snowland if biome.1.len() as u32 > 750 => { + match ctx.rng.gen_range(0..6) { + 0 => format!( + "{}\nSnowlands", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 1 => format!( + "{}\nGlacier", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 2 => format!( + "{}\nTundra", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 3 => format!( + "{}\nDrifts", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 4 => format!( + "{}\nSnowfields", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 5 => format!( + "{}\nHills", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 6 => format!( + "{}\nHighlands", + NameGen::location(&mut ctx.rng).generate_biome() + ), + _ => format!( + "{}\nSnowlands", + NameGen::location(&mut ctx.rng).generate_biome() + ), + } + }, + common::terrain::BiomeKind::Desert if biome.1.len() as u32 > 750 => { + match ctx.rng.gen_range(0..5) { + 0 => format!( + "{}\nDesert", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 1 => format!( + "{}\nSands", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 2 => format!( + "{}\nSandsea", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 3 => format!( + "{}\nDrifts", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 4 => format!( + "{}\nDunes", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 5 => format!( + "{}\nSandfield", + NameGen::location(&mut ctx.rng).generate_biome() + ), + _ => format!( + "{}\nDesert", + NameGen::location(&mut ctx.rng).generate_biome() + ), + } + }, + common::terrain::BiomeKind::Swamp if biome.1.len() as u32 > 750 => { + match ctx.rng.gen_range(0..7) { + 0 => format!( + "{}\nSwamp", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 1 => format!( + "{}\nSwamps", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 2 => format!( + "{}\nSwamplands", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 3 => format!( + "{}\nMarsh", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 4 => format!( + "{}\nMarshlands", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 5 => format!( + "{}\nMorass", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 6 => format!("{}\nMire", NameGen::location(&mut ctx.rng).generate_biome()), + 7 => format!("{}\nBog", NameGen::location(&mut ctx.rng).generate_biome()), + _ => format!( + "{}\nSnowlands", + NameGen::location(&mut ctx.rng).generate_biome() + ), + } + }, + common::terrain::BiomeKind::Jungle if biome.1.len() as u32 > 750 => { + match ctx.rng.gen_range(0..7) { + 0 => format!( + "{}\nJungle", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 1 => format!( + "{}\nRainforest", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 2 => format!( + "{}\nGreatwood", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 3 => format!( + "{}\nWilds", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 4 => format!( + "{}\nWildwood", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 5 => format!( + "{}\nTangle", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 6 => format!( + "{}\nTanglewood", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 7 => format!("{}\nBush", NameGen::location(&mut ctx.rng).generate_biome()), + _ => format!( + "{}\nJungle", + NameGen::location(&mut ctx.rng).generate_biome() + ), + } + }, + common::terrain::BiomeKind::Savannah if biome.1.len() as u32 > 750 => { + match ctx.rng.gen_range(0..4) { + 0 => format!( + "{}\nSavannah", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 1 => format!( + "{}\nShrubland", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 2 => format!( + "{}\nSierra", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 3 => format!( + "{}\nPrairie", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 4 => format!( + "{}\nLowlands", + NameGen::location(&mut ctx.rng).generate_biome() + ), + _ => format!( + "{}\nSavannah", + NameGen::location(&mut ctx.rng).generate_biome() + ), + } + }, + common::terrain::BiomeKind::Taiga if biome.1.len() as u32 > 750 => { + match ctx.rng.gen_range(0..4) { + 0 => format!( + "{}\nTaiga", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 1 => format!( + "{}\nTimberlands", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 2 => format!( + "{}\nUplands", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 3 => format!( + "{}\nWoodlands", + NameGen::location(&mut ctx.rng).generate_biome() + ), + 4 => format!( + "{}\nHighlands", + NameGen::location(&mut ctx.rng).generate_biome() + ), + _ => format!( + "{}\nTaiga", + NameGen::location(&mut ctx.rng).generate_biome() + ), + } }, common::terrain::BiomeKind::Lake if biome.1.len() as u32 > 200 => { - match ctx.rng.gen_range(0..6) { - 0 => format!("{} Lake", NameGen::location(&mut ctx.rng).generate()), - 1 => format!("Loch {}", NameGen::location(&mut ctx.rng).generate()), - _ => format!("{} Lake", NameGen::location(&mut ctx.rng).generate()), + match ctx.rng.gen_range(0..2) { + 0 => format!("{}\nLake", NameGen::location(&mut ctx.rng).generate()), + 1 => format!("Loch\n{}", NameGen::location(&mut ctx.rng).generate()), + _ => format!("{}\nLake", NameGen::location(&mut ctx.rng).generate()), } }, common::terrain::BiomeKind::Lake if biome.1.len() as u32 > 10 => { - match ctx.rng.gen_range(0..4) { - 0 => format!("{} Pool", NameGen::location(&mut ctx.rng).generate()), - 1 => format!("{} Well", NameGen::location(&mut ctx.rng).generate()), - _ => format!("{} Pond", NameGen::location(&mut ctx.rng).generate()), + match ctx.rng.gen_range(0..1) { + 0 => format!("{}\nPool", NameGen::location(&mut ctx.rng).generate()), + 1 => format!("{}\nWell", NameGen::location(&mut ctx.rng).generate()), + _ => format!("{}\nPond", NameGen::location(&mut ctx.rng).generate()), } }, _ => String::new(), From a836b61190ed47960b9639aee69bed9b7f9482a7 Mon Sep 17 00:00:00 2001 From: floppy <sunflowerstarfishmail@gmail.com> Date: Mon, 17 Jan 2022 23:45:51 +0100 Subject: [PATCH 12/22] allow enabling/disabling biome names on map --- .../voxygen/element/ui/map/buttons/biome.png | 3 ++ assets/voxygen/i18n/en/hud/map.ron | 1 + voxygen/src/hud/img_ids.rs | 1 + voxygen/src/hud/map.rs | 44 ++++++++++++++++++- voxygen/src/session/settings_change.rs | 4 ++ voxygen/src/settings/interface.rs | 2 + 6 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 assets/voxygen/element/ui/map/buttons/biome.png diff --git a/assets/voxygen/element/ui/map/buttons/biome.png b/assets/voxygen/element/ui/map/buttons/biome.png new file mode 100644 index 0000000000..e0b7450714 --- /dev/null +++ b/assets/voxygen/element/ui/map/buttons/biome.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:afcfc6df378dc85091d7681a662efd85e157d0037ce87e4bd1292ee1d0a3b805 +size 8123 diff --git a/assets/voxygen/i18n/en/hud/map.ron b/assets/voxygen/i18n/en/hud/map.ron index 0ef0218382..09138bf279 100644 --- a/assets/voxygen/i18n/en/hud/map.ron +++ b/assets/voxygen/i18n/en/hud/map.ron @@ -14,6 +14,7 @@ "hud.map.caves": "Caves", "hud.map.cave": "Cave", "hud.map.peaks": "Mountains", + "hud.map.biomes": "Biomes", "hud.map.voxel_map": "Voxel map", "hud.map.trees": "Giant Trees", "hud.map.tree": "Giant Tree", diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index 0d795e563f..9bf816567a 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -414,6 +414,7 @@ image_ids! { mmap_site_tree: "voxygen.element.ui.map.buttons.tree", mmap_site_tree_hover: "voxygen.element.ui.map.buttons.tree_hover", mmap_poi_peak: "voxygen.element.ui.map.buttons.peak", + mmap_poi_biome: "voxygen.element.ui.map.buttons.biome", mmap_poi_peak_hover: "voxygen.element.ui.map.buttons.peak_hover", // Window Parts diff --git a/voxygen/src/hud/map.rs b/voxygen/src/hud/map.rs index f48ed7addc..850d53e89a 100644 --- a/voxygen/src/hud/map.rs +++ b/voxygen/src/hud/map.rs @@ -42,6 +42,8 @@ widget_ids! { mmap_poi_titles[], peaks_txt, peaks_txt_bg, + biomes_txt, + biomes_txt_bg, site_difs[], member_indicators[], member_height_indicators[], @@ -65,6 +67,9 @@ widget_ids! { show_peaks_img, show_peaks_box, show_peaks_text, + show_biomes_img, + show_biomes_box, + show_biomes_text, show_voxel_map_img, show_voxel_map_box, show_voxel_map_text, @@ -209,6 +214,7 @@ impl<'a> Widget for Map<'a> { let show_caves = self.global_state.settings.interface.map_show_caves; let show_trees = self.global_state.settings.interface.map_show_trees; let show_peaks = self.global_state.settings.interface.map_show_peaks; + let show_biomes = self.global_state.settings.interface.map_show_biomes; let show_voxel_map = self.global_state.settings.interface.map_show_voxel_map; let show_topo_map = self.global_state.settings.interface.map_show_topo_map; let mut events = Vec::new(); @@ -641,9 +647,43 @@ impl<'a> Widget for Map<'a> { .graphics_for(state.ids.show_trees_box) .color(TEXT_COLOR) .set(state.ids.show_trees_text, ui); + // Biomes + Image::new(self.imgs.mmap_poi_biome) + .down_from(state.ids.show_trees_img, 10.0) + .w_h(20.0, 20.0) + .set(state.ids.show_biomes_img, ui); + if Button::image(if show_biomes { + self.imgs.checkbox_checked + } else { + self.imgs.checkbox + }) + .w_h(18.0, 18.0) + .hover_image(if show_biomes { + self.imgs.checkbox_checked_mo + } else { + self.imgs.checkbox_mo + }) + .press_image(if show_biomes { + self.imgs.checkbox_checked + } else { + self.imgs.checkbox_press + }) + .right_from(state.ids.show_biomes_img, 10.0) + .set(state.ids.show_biomes_box, ui) + .was_clicked() + { + events.push(Event::SettingsChange(MapShowBiomes(!show_biomes))); + } + Text::new(i18n.get("hud.map.biomes")) + .right_from(state.ids.show_biomes_box, 10.0) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .graphics_for(state.ids.show_biomes_box) + .color(TEXT_COLOR) + .set(state.ids.show_biomes_text, ui); // Peaks Image::new(self.imgs.mmap_poi_peak) - .down_from(state.ids.show_trees_img, 10.0) + .down_from(state.ids.show_biomes_img, 10.0) .w_h(20.0, 20.0) .set(state.ids.show_peaks_img, ui); if Button::image(if show_peaks { @@ -1023,7 +1063,7 @@ impl<'a> Widget for Map<'a> { } }, PoiKind::Lake(size) => { - if zoom.powi(2) * size as f64 > 30.0 { + if show_biomes && zoom > 2.0 && zoom.powi(2) * size as f64 > 30.0 { let font_scale_factor = if size > 20 { size as f64 / 25.0 } else if size > 10 { diff --git a/voxygen/src/session/settings_change.rs b/voxygen/src/session/settings_change.rs index 2f0dd5b2b2..b164acade5 100644 --- a/voxygen/src/session/settings_change.rs +++ b/voxygen/src/session/settings_change.rs @@ -129,6 +129,7 @@ pub enum Interface { MapShowCaves(bool), MapShowTrees(bool), MapShowPeaks(bool), + MapShowBiomes(bool), MapShowVoxelMap(bool), ResetInterfaceSettings, @@ -535,6 +536,9 @@ impl SettingsChange { Interface::MapShowPeaks(map_show_peaks) => { settings.interface.map_show_peaks = map_show_peaks; }, + Interface::MapShowBiomes(map_show_biomes) => { + settings.interface.map_show_biomes = map_show_biomes; + }, Interface::MapShowVoxelMap(map_show_voxel_map) => { settings.interface.map_show_voxel_map = map_show_voxel_map; }, diff --git a/voxygen/src/settings/interface.rs b/voxygen/src/settings/interface.rs index 494ea651c8..18bd31720a 100644 --- a/voxygen/src/settings/interface.rs +++ b/voxygen/src/settings/interface.rs @@ -38,6 +38,7 @@ pub struct InterfaceSettings { pub map_show_caves: bool, pub map_show_trees: bool, pub map_show_peaks: bool, + pub map_show_biomes: bool, pub map_show_voxel_map: bool, pub minimap_show: bool, pub minimap_face_north: bool, @@ -77,6 +78,7 @@ impl Default for InterfaceSettings { map_show_caves: true, map_show_trees: false, map_show_peaks: false, + map_show_biomes: false, map_show_voxel_map: true, minimap_show: true, minimap_face_north: true, From fd920cea1d728eeaebd3e9b19e0db4b996052b18 Mon Sep 17 00:00:00 2001 From: floppy <sunflowerstarfishmail@gmail.com> Date: Mon, 17 Jan 2022 23:47:27 +0100 Subject: [PATCH 13/22] allow enabling/disabling biome names on map --- voxygen/src/hud/map.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/voxygen/src/hud/map.rs b/voxygen/src/hud/map.rs index 850d53e89a..645f563dc1 100644 --- a/voxygen/src/hud/map.rs +++ b/voxygen/src/hud/map.rs @@ -42,8 +42,6 @@ widget_ids! { mmap_poi_titles[], peaks_txt, peaks_txt_bg, - biomes_txt, - biomes_txt_bg, site_difs[], member_indicators[], member_height_indicators[], From 1a5c1ae3195a0b9a978fac9bd676be8a354fb12e Mon Sep 17 00:00:00 2001 From: floppy <sunflowerstarfishmail@gmail.com> Date: Tue, 18 Jan 2022 00:41:59 +0100 Subject: [PATCH 14/22] length comparison to zero in /civ/mod.rs warning: length comparison to zero --> world/src/civ/mod.rs:482:15 | 482 | while to_explore.len() > 0 { | ^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!to_explore.is_empty()` | = note: `#[warn(clippy::len_zero)]` on by default = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero warning: length comparison to zero --> world/src/civ/mod.rs:489:19 | 489 | while to_floodfill.len() > 0 { | ^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!to_floodfill.is_empty()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero --- world/src/civ/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index 1c41bbabb0..870b880534 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -479,14 +479,14 @@ impl Civs { to_explore.insert(start_point); explored.insert(start_point); - while to_explore.len() > 0 { + while !to_explore.is_empty() { let exploring = *to_explore.iter().next().unwrap(); to_explore.remove(&exploring); to_floodfill.insert(exploring); // Should always be a chunk on the map let biome = ctx.sim.chunks[exploring].get_biome(); biomes.push((biome, Vec::new())); - while to_floodfill.len() > 0 { + while !to_floodfill.is_empty() { let filling = *to_floodfill.iter().next().unwrap(); to_explore.remove(&filling); to_floodfill.remove(&filling); From 4a8c428a3fe41b81a9a718356e3ca86a99965a6d Mon Sep 17 00:00:00 2001 From: floppy <sunflowerstarfishmail@gmail.com> Date: Tue, 18 Jan 2022 08:36:40 +0100 Subject: [PATCH 15/22] update/add namegen-bricks for forest and grassland --- world/src/civ/mod.rs | 46 ++++++++++++++++++--------------------- world/src/site/namegen.rs | 34 ++++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 28 deletions(-) diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index 870b880534..5355027896 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -527,79 +527,79 @@ impl Civs { match ctx.rng.gen_range(0..8) { 0 => format!( "{}\nForest", - NameGen::location(&mut ctx.rng).generate_forest() + NameGen::location(&mut ctx.rng).generate_temp_forest() ), 1 => format!( "{}\nWoodlands", - NameGen::location(&mut ctx.rng).generate_forest() + NameGen::location(&mut ctx.rng).generate_temp_forest() ), 2 => format!( "{}\nWoods", - NameGen::location(&mut ctx.rng).generate_forest() + NameGen::location(&mut ctx.rng).generate_temp_forest() ), 3 => format!( "{}\nGlades", - NameGen::location(&mut ctx.rng).generate_forest() + NameGen::location(&mut ctx.rng).generate_temp_forest() ), 4 => format!( "{}\nGrove", - NameGen::location(&mut ctx.rng).generate_forest() + NameGen::location(&mut ctx.rng).generate_temp_forest() ), 5 => format!( "{}\nGlades", - NameGen::location(&mut ctx.rng).generate_forest() + NameGen::location(&mut ctx.rng).generate_temp_forest() ), 6 => format!( "{}\nThickets", - NameGen::location(&mut ctx.rng).generate_forest() + NameGen::location(&mut ctx.rng).generate_temp_forest() ), 7 => format!( "{}\nWeald", - NameGen::location(&mut ctx.rng).generate_forest() + NameGen::location(&mut ctx.rng).generate_temp_forest() ), _ => format!( "{}\nForest", - NameGen::location(&mut ctx.rng).generate_forest() + NameGen::location(&mut ctx.rng).generate_temp_forest() ), } }, common::terrain::BiomeKind::Grassland if biome.1.len() as u32 > 750 => { - match ctx.rng.gen_range(0..11) { + match ctx.rng.gen_range(0..10) { 0 => format!( "{}\nGrasslands", - NameGen::location(&mut ctx.rng).generate_biome() + NameGen::location(&mut ctx.rng).generate_grassland() ), 1 => format!( "{}\nFlats", - NameGen::location(&mut ctx.rng).generate_biome() + NameGen::location(&mut ctx.rng).generate_grassland() ), 2 => format!( "{}\nGreens", - NameGen::location(&mut ctx.rng).generate_biome() + NameGen::location(&mut ctx.rng).generate_grassland() ), 3 => format!( "{}\nPlains", - NameGen::location(&mut ctx.rng).generate_biome() + NameGen::location(&mut ctx.rng).generate_grassland() ), 4 => format!( "{}\nMeadows", - NameGen::location(&mut ctx.rng).generate_biome() + NameGen::location(&mut ctx.rng).generate_grassland() ), 5 => format!( "{}\nFields", - NameGen::location(&mut ctx.rng).generate_biome() + NameGen::location(&mut ctx.rng).generate_grassland() ), 6 => format!( "{}\nHeath", - NameGen::location(&mut ctx.rng).generate_biome() + NameGen::location(&mut ctx.rng).generate_grassland() ), 7 => format!( "{}\nPrairie", - NameGen::location(&mut ctx.rng).generate_biome() + NameGen::location(&mut ctx.rng).generate_grassland() ), 8 => format!( "{}\nSteppe", - NameGen::location(&mut ctx.rng).generate_biome() + NameGen::location(&mut ctx.rng).generate_grassland() ), 9 => format!( "{}\nDowns", @@ -607,15 +607,11 @@ impl Civs { ), 10 => format!( "{}\nHeath", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 11 => format!( - "{}\nHeath", - NameGen::location(&mut ctx.rng).generate_biome() + NameGen::location(&mut ctx.rng).generate_grassland() ), _ => format!( "{}\nGrassland", - NameGen::location(&mut ctx.rng).generate_biome() + NameGen::location(&mut ctx.rng).generate_grassland() ), } }, diff --git a/world/src/site/namegen.rs b/world/src/site/namegen.rs index 4192081870..aea001bafe 100644 --- a/world/src/site/namegen.rs +++ b/world/src/site/namegen.rs @@ -91,19 +91,47 @@ impl<'a, R: Rng> NameGen<'a, R> { .collect() } - pub fn generate_forest(self) -> String { + pub fn generate_temp_forest(self) -> String { let cons = vec![ "green", "moss", "ever", "briar", "thorn", "oak", "deep", "moon", "star", "sun", "bright", "glare", "fair", "calm", "mistral", "whisper", "clover", "hollow", "spring", "morrow", "dim", "dusk", "dawn", "night", "shimmer", "silver", "gold", "whisper", - "fern", "quiet", "still", "gleam", "wild", "blind", "swift", + "fern", "quiet", "still", "gleam", "wild", "blind", "swift", "gnarl", "flutter", + "silent", "honey", "bramble", "rose", ]; let start = cons.clone(); let end = vec![ "root", "bark", "log", "brook", "well", "shire", "leaf", "more", "bole", "heart", "song", "dew", "bough", "path", "wind", "breeze", "light", "branch", "bloom", "vale", "glen", "rest", "shade", "fall", "sward", "thicket", "shrub", "bush", "grasp", "grip", - "gale", "crawl", "run", "shadow", + "gale", "crawl", "run", "shadow", "rise", "glow", "wish", "will", "walk", "wander", + "wake", "eye", "blossom", "sprout", "barb", + ]; + let mut name = String::new(); + name += start.choose(self.rng).unwrap(); + name += end.choose(self.rng).unwrap(); + + name.chars() + .enumerate() + .map(|(i, c)| if i == 0 { c.to_ascii_uppercase() } else { c }) + .collect() + } + + pub fn generate_grassland(self) -> String { + let cons = vec![ + "green", "heather", "flower", "blue", "yellow", "vast", "moon", "star", "sun", + "bright", "fair", "calm", "mistral", "whisper", "clover", "sooth", "spring", "morrow", + "dim", "dusk", "dawn", "night", "shimmer", "silver", "gold", "amber", "quiet", "still", + "gleam", "wild", "corm", "mint", "feather", "silent", "bronze", "bister", "thistle", + "bristle", "dew", "bramble", "sorrel", "broad", "petal", + ]; + let start = cons.clone(); + let end = vec![ + "brook", "well", "flight", "more", "heart", "song", "barb", "wort", "hoof", "foot", + "herd", "path", "wind", "breeze", "light", "bloom", "rest", "balm", "reach", "flow", + "graze", "trail", "fall", "thicket", "shrub", "bush", "gale", "run", "stem", "glare", + "gaze", "rove", "brew", "rise", "glow", "wish", "will", "walk", "wander", "wake", + "sky", "burrow", "cross", "roam", ]; let mut name = String::new(); name += start.choose(self.rng).unwrap(); From dcf36df781b575c943f108f7dba237eec69a4319 Mon Sep 17 00:00:00 2001 From: floppy <sunflowerstarfishmail@gmail.com> Date: Tue, 18 Jan 2022 09:17:51 +0100 Subject: [PATCH 16/22] tweak biome icon --- assets/voxygen/element/ui/map/buttons/biome.png | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/voxygen/element/ui/map/buttons/biome.png b/assets/voxygen/element/ui/map/buttons/biome.png index e0b7450714..00754516bd 100644 --- a/assets/voxygen/element/ui/map/buttons/biome.png +++ b/assets/voxygen/element/ui/map/buttons/biome.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:afcfc6df378dc85091d7681a662efd85e157d0037ce87e4bd1292ee1d0a3b805 -size 8123 +oid sha256:4eb2736e6118e83afc1d95c326b63d5e3fbf113a60ee2b21ac8b38c4714be889 +size 6718 From 28a7b004451b48e24143bb76b5ce078bb688a908 Mon Sep 17 00:00:00 2001 From: floppy <sunflowerstarfishmail@gmail.com> Date: Tue, 18 Jan 2022 09:19:55 +0100 Subject: [PATCH 17/22] tweak biome icon --- assets/voxygen/element/ui/map/buttons/biome.png | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/voxygen/element/ui/map/buttons/biome.png b/assets/voxygen/element/ui/map/buttons/biome.png index 00754516bd..01e6b67d5f 100644 --- a/assets/voxygen/element/ui/map/buttons/biome.png +++ b/assets/voxygen/element/ui/map/buttons/biome.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4eb2736e6118e83afc1d95c326b63d5e3fbf113a60ee2b21ac8b38c4714be889 -size 6718 +oid sha256:dfc0bb3f376b20bb122ab5a7f56c80e37a74b7b3c9fbb5ed5126407ea1e143f2 +size 6760 From 40580578a04e8f026326ffcfe7b890ae1eee0f55 Mon Sep 17 00:00:00 2001 From: IsseW <isidornie@gmail.com> Date: Tue, 18 Jan 2022 10:07:26 +0100 Subject: [PATCH 18/22] Don't add unnecessary biome pois --- world/src/civ/mod.rs | 100 ++++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 49 deletions(-) diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index 5355027896..885074e2c2 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -505,26 +505,11 @@ impl Civs { } } } - let num_biomes = biomes.len(); - + let mut biome_count = 0; for biome in biomes { - // find average center of the biome - let mut biomes = biome.1.iter(); - // There is always at least 1 biome - let mut center = uniform_idx_as_vec2(map_size_lg, *biomes.next().unwrap()); - biomes.for_each(|b| { - center += uniform_idx_as_vec2(map_size_lg, *b); - center /= 2; - }); - // Select the point closest to the center - let idx = *biome - .1 - .iter() - .min_by_key(|&b| center.distance_squared(uniform_idx_as_vec2(map_size_lg, *b))) - .unwrap(); let name = match biome.0 { common::terrain::BiomeKind::Forest if biome.1.len() as u32 > 750 => { - match ctx.rng.gen_range(0..8) { + Some(match ctx.rng.gen_range(0..8) { 0 => format!( "{}\nForest", NameGen::location(&mut ctx.rng).generate_temp_forest() @@ -561,10 +546,10 @@ impl Civs { "{}\nForest", NameGen::location(&mut ctx.rng).generate_temp_forest() ), - } + }) }, common::terrain::BiomeKind::Grassland if biome.1.len() as u32 > 750 => { - match ctx.rng.gen_range(0..10) { + Some(match ctx.rng.gen_range(0..10) { 0 => format!( "{}\nGrasslands", NameGen::location(&mut ctx.rng).generate_grassland() @@ -613,10 +598,10 @@ impl Civs { "{}\nGrassland", NameGen::location(&mut ctx.rng).generate_grassland() ), - } + }) }, common::terrain::BiomeKind::Ocean if biome.1.len() as u32 > 750 => { - match ctx.rng.gen_range(0..3) { + Some(match ctx.rng.gen_range(0..3) { 0 => format!( "{}\nOcean", NameGen::location(&mut ctx.rng).generate_biome() @@ -631,10 +616,10 @@ impl Civs { "{}\nOcean", NameGen::location(&mut ctx.rng).generate_biome() ), - } + }) }, common::terrain::BiomeKind::Mountain if biome.1.len() as u32 > 750 => { - match ctx.rng.gen_range(0..11) { + Some(match ctx.rng.gen_range(0..11) { 0 => format!( "{}\nMountains", NameGen::location(&mut ctx.rng).generate_biome() @@ -687,10 +672,10 @@ impl Civs { "{}\nMountains", NameGen::location(&mut ctx.rng).generate_biome() ), - } + }) }, common::terrain::BiomeKind::Snowland if biome.1.len() as u32 > 750 => { - match ctx.rng.gen_range(0..6) { + Some(match ctx.rng.gen_range(0..6) { 0 => format!( "{}\nSnowlands", NameGen::location(&mut ctx.rng).generate_biome() @@ -723,10 +708,10 @@ impl Civs { "{}\nSnowlands", NameGen::location(&mut ctx.rng).generate_biome() ), - } + }) }, common::terrain::BiomeKind::Desert if biome.1.len() as u32 > 750 => { - match ctx.rng.gen_range(0..5) { + Some(match ctx.rng.gen_range(0..5) { 0 => format!( "{}\nDesert", NameGen::location(&mut ctx.rng).generate_biome() @@ -755,10 +740,10 @@ impl Civs { "{}\nDesert", NameGen::location(&mut ctx.rng).generate_biome() ), - } + }) }, common::terrain::BiomeKind::Swamp if biome.1.len() as u32 > 750 => { - match ctx.rng.gen_range(0..7) { + Some(match ctx.rng.gen_range(0..7) { 0 => format!( "{}\nSwamp", NameGen::location(&mut ctx.rng).generate_biome() @@ -789,10 +774,10 @@ impl Civs { "{}\nSnowlands", NameGen::location(&mut ctx.rng).generate_biome() ), - } + }) }, common::terrain::BiomeKind::Jungle if biome.1.len() as u32 > 750 => { - match ctx.rng.gen_range(0..7) { + Some(match ctx.rng.gen_range(0..7) { 0 => format!( "{}\nJungle", NameGen::location(&mut ctx.rng).generate_biome() @@ -826,10 +811,10 @@ impl Civs { "{}\nJungle", NameGen::location(&mut ctx.rng).generate_biome() ), - } + }) }, common::terrain::BiomeKind::Savannah if biome.1.len() as u32 > 750 => { - match ctx.rng.gen_range(0..4) { + Some(match ctx.rng.gen_range(0..4) { 0 => format!( "{}\nSavannah", NameGen::location(&mut ctx.rng).generate_biome() @@ -854,10 +839,10 @@ impl Civs { "{}\nSavannah", NameGen::location(&mut ctx.rng).generate_biome() ), - } + }) }, common::terrain::BiomeKind::Taiga if biome.1.len() as u32 > 750 => { - match ctx.rng.gen_range(0..4) { + Some(match ctx.rng.gen_range(0..4) { 0 => format!( "{}\nTaiga", NameGen::location(&mut ctx.rng).generate_biome() @@ -882,35 +867,52 @@ impl Civs { "{}\nTaiga", NameGen::location(&mut ctx.rng).generate_biome() ), - } + }) }, common::terrain::BiomeKind::Lake if biome.1.len() as u32 > 200 => { - match ctx.rng.gen_range(0..2) { + Some(match ctx.rng.gen_range(0..2) { 0 => format!("{}\nLake", NameGen::location(&mut ctx.rng).generate()), 1 => format!("Loch\n{}", NameGen::location(&mut ctx.rng).generate()), _ => format!("{}\nLake", NameGen::location(&mut ctx.rng).generate()), - } + }) }, common::terrain::BiomeKind::Lake if biome.1.len() as u32 > 10 => { - match ctx.rng.gen_range(0..1) { + Some(match ctx.rng.gen_range(0..1) { 0 => format!("{}\nPool", NameGen::location(&mut ctx.rng).generate()), 1 => format!("{}\nWell", NameGen::location(&mut ctx.rng).generate()), _ => format!("{}\nPond", NameGen::location(&mut ctx.rng).generate()), - } + }) }, - _ => String::new(), + _ => None, }; - let id = self.pois.insert(PointOfInterest { - name, - loc: uniform_idx_as_vec2(map_size_lg, idx), - kind: PoiKind::Biome(biome.1.len() as u32), - }); - for chunk in biome.1 { - ctx.sim.chunks[chunk].poi = Some(id); + if let Some(name) = name { + // find average center of the biome + let mut biomes = biome.1.iter(); + // There is always at least 1 biome + let mut center = uniform_idx_as_vec2(map_size_lg, *biomes.next().unwrap()); + biomes.for_each(|b| { + center += uniform_idx_as_vec2(map_size_lg, *b); + center /= 2; + }); + // Select the point closest to the center + let idx = *biome + .1 + .iter() + .min_by_key(|&b| center.distance_squared(uniform_idx_as_vec2(map_size_lg, *b))) + .unwrap(); + let id = self.pois.insert(PointOfInterest { + name, + loc: uniform_idx_as_vec2(map_size_lg, idx), + kind: PoiKind::Biome(biome.1.len() as u32), + }); + for chunk in biome.1 { + ctx.sim.chunks[chunk].poi = Some(id); + } + biome_count += 1; } } - info!(?num_biomes, "all biomes named"); + info!(?biome_count, "all biomes named"); } /// Adds mountain POIs and name them From ceb3507e500e60f7834e1d170db726abb0328606 Mon Sep 17 00:00:00 2001 From: floppy <sunflowerstarfishmail@gmail.com> Date: Tue, 18 Jan 2022 11:27:55 +0100 Subject: [PATCH 19/22] -remove line breaks from biome names -disable Wilderness world message in unspecified mini-biomes -remove duplicate name in Grasslands name pattern --- common/src/terrain/mod.rs | 2 +- world/src/civ/mod.rs | 229 +++++++++++++++----------------------- 2 files changed, 91 insertions(+), 140 deletions(-) diff --git a/common/src/terrain/mod.rs b/common/src/terrain/mod.rs index 2084852f56..8ea9ebe53f 100644 --- a/common/src/terrain/mod.rs +++ b/common/src/terrain/mod.rs @@ -131,7 +131,7 @@ impl TerrainChunkMeta { } } - pub fn name(&self) -> &str { self.name.as_deref().unwrap_or("Wilderness") } + pub fn name(&self) -> &str { self.name.as_deref().unwrap_or("") } pub fn biome(&self) -> BiomeKind { self.biome } diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index 885074e2c2..81fb523814 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -511,165 +511,140 @@ impl Civs { common::terrain::BiomeKind::Forest if biome.1.len() as u32 > 750 => { Some(match ctx.rng.gen_range(0..8) { 0 => format!( - "{}\nForest", + "{} Forest", NameGen::location(&mut ctx.rng).generate_temp_forest() ), 1 => format!( - "{}\nWoodlands", + "{} Woodlands", NameGen::location(&mut ctx.rng).generate_temp_forest() ), 2 => format!( - "{}\nWoods", + "{} Woods", NameGen::location(&mut ctx.rng).generate_temp_forest() ), 3 => format!( - "{}\nGlades", + "{} Glades", NameGen::location(&mut ctx.rng).generate_temp_forest() ), 4 => format!( - "{}\nGrove", + "{} Grove", NameGen::location(&mut ctx.rng).generate_temp_forest() ), 5 => format!( - "{}\nGlades", + "{} Glades", NameGen::location(&mut ctx.rng).generate_temp_forest() ), 6 => format!( - "{}\nThickets", + "{} Thickets", NameGen::location(&mut ctx.rng).generate_temp_forest() ), 7 => format!( - "{}\nWeald", + "{} Weald", NameGen::location(&mut ctx.rng).generate_temp_forest() ), _ => format!( - "{}\nForest", + "{} Forest", NameGen::location(&mut ctx.rng).generate_temp_forest() ), }) }, common::terrain::BiomeKind::Grassland if biome.1.len() as u32 > 750 => { - Some(match ctx.rng.gen_range(0..10) { + Some(match ctx.rng.gen_range(0..9) { 0 => format!( - "{}\nGrasslands", + "{} Grasslands", NameGen::location(&mut ctx.rng).generate_grassland() ), 1 => format!( - "{}\nFlats", + "{} Flats", NameGen::location(&mut ctx.rng).generate_grassland() ), 2 => format!( - "{}\nGreens", + "{} Greens", NameGen::location(&mut ctx.rng).generate_grassland() ), 3 => format!( - "{}\nPlains", + "{} Plains", NameGen::location(&mut ctx.rng).generate_grassland() ), 4 => format!( - "{}\nMeadows", + "{} Meadows", NameGen::location(&mut ctx.rng).generate_grassland() ), 5 => format!( - "{}\nFields", + "{} Fields", NameGen::location(&mut ctx.rng).generate_grassland() ), 6 => format!( - "{}\nHeath", + "{} Heath", NameGen::location(&mut ctx.rng).generate_grassland() ), 7 => format!( - "{}\nPrairie", + "{} Prairie", NameGen::location(&mut ctx.rng).generate_grassland() ), 8 => format!( - "{}\nSteppe", + "{} Steppe", NameGen::location(&mut ctx.rng).generate_grassland() ), 9 => format!( - "{}\nDowns", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 10 => format!( - "{}\nHeath", + "{} Downs", NameGen::location(&mut ctx.rng).generate_grassland() ), _ => format!( - "{}\nGrassland", + "{} Grassland", NameGen::location(&mut ctx.rng).generate_grassland() ), }) }, common::terrain::BiomeKind::Ocean if biome.1.len() as u32 > 750 => { Some(match ctx.rng.gen_range(0..3) { - 0 => format!( - "{}\nOcean", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 1 => format!("{}\nBlue", NameGen::location(&mut ctx.rng).generate_biome()), - 2 => format!("{}\nDeep", NameGen::location(&mut ctx.rng).generate_biome()), + 0 => format!("{} Ocean", NameGen::location(&mut ctx.rng).generate_biome()), + 1 => format!("{} Blue", NameGen::location(&mut ctx.rng).generate_biome()), + 2 => format!("{} Deep", NameGen::location(&mut ctx.rng).generate_biome()), 3 => format!( - "{}\nDepths", - NameGen::location(&mut ctx.rng).generate_biome() - ), - _ => format!( - "{}\nOcean", + "{} Depths", NameGen::location(&mut ctx.rng).generate_biome() ), + _ => format!("{} Ocean", NameGen::location(&mut ctx.rng).generate_biome()), }) }, common::terrain::BiomeKind::Mountain if biome.1.len() as u32 > 750 => { Some(match ctx.rng.gen_range(0..11) { 0 => format!( - "{}\nMountains", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 1 => format!( - "{}\nRange", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 2 => format!( - "{}\nReach", + "{} Mountains", NameGen::location(&mut ctx.rng).generate_biome() ), + 1 => format!("{} Range", NameGen::location(&mut ctx.rng).generate_biome()), + 2 => format!("{} Reach", NameGen::location(&mut ctx.rng).generate_biome()), 3 => format!( - "{}\nMassif", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 4 => format!( - "{}\nRocks", + "{} Massif", NameGen::location(&mut ctx.rng).generate_biome() ), + 4 => format!("{} Rocks", NameGen::location(&mut ctx.rng).generate_biome()), 5 => format!( - "{}\nCliffs", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 6 => format!( - "{}\nPeaks", + "{} Cliffs", NameGen::location(&mut ctx.rng).generate_biome() ), + 6 => format!("{} Peaks", NameGen::location(&mut ctx.rng).generate_biome()), 7 => format!( - "{}\nHeights", + "{} Heights", NameGen::location(&mut ctx.rng).generate_biome() ), 8 => format!( - "{}\nBluffs", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 9 => format!( - "{}\nRidge", + "{} Bluffs", NameGen::location(&mut ctx.rng).generate_biome() ), + 9 => format!("{} Ridge", NameGen::location(&mut ctx.rng).generate_biome()), 10 => format!( - "{}\nCanyon", + "{} Canyon", NameGen::location(&mut ctx.rng).generate_biome() ), 11 => format!( - "{}\nPlateau", + "{} Plateau", NameGen::location(&mut ctx.rng).generate_biome() ), _ => format!( - "{}\nMountains", + "{} Mountains", NameGen::location(&mut ctx.rng).generate_biome() ), }) @@ -677,35 +652,32 @@ impl Civs { common::terrain::BiomeKind::Snowland if biome.1.len() as u32 > 750 => { Some(match ctx.rng.gen_range(0..6) { 0 => format!( - "{}\nSnowlands", + "{} Snowlands", NameGen::location(&mut ctx.rng).generate_biome() ), 1 => format!( - "{}\nGlacier", + "{} Glacier", NameGen::location(&mut ctx.rng).generate_biome() ), 2 => format!( - "{}\nTundra", + "{} Tundra", NameGen::location(&mut ctx.rng).generate_biome() ), 3 => format!( - "{}\nDrifts", + "{} Drifts", NameGen::location(&mut ctx.rng).generate_biome() ), 4 => format!( - "{}\nSnowfields", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 5 => format!( - "{}\nHills", + "{} Snowfields", NameGen::location(&mut ctx.rng).generate_biome() ), + 5 => format!("{} Hills", NameGen::location(&mut ctx.rng).generate_biome()), 6 => format!( - "{}\nHighlands", + "{} Highlands", NameGen::location(&mut ctx.rng).generate_biome() ), _ => format!( - "{}\nSnowlands", + "{} Snowlands", NameGen::location(&mut ctx.rng).generate_biome() ), }) @@ -713,65 +685,53 @@ impl Civs { common::terrain::BiomeKind::Desert if biome.1.len() as u32 > 750 => { Some(match ctx.rng.gen_range(0..5) { 0 => format!( - "{}\nDesert", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 1 => format!( - "{}\nSands", + "{} Desert", NameGen::location(&mut ctx.rng).generate_biome() ), + 1 => format!("{} Sands", NameGen::location(&mut ctx.rng).generate_biome()), 2 => format!( - "{}\nSandsea", + "{} Sandsea", NameGen::location(&mut ctx.rng).generate_biome() ), 3 => format!( - "{}\nDrifts", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 4 => format!( - "{}\nDunes", + "{} Drifts", NameGen::location(&mut ctx.rng).generate_biome() ), + 4 => format!("{} Dunes", NameGen::location(&mut ctx.rng).generate_biome()), 5 => format!( - "{}\nSandfield", + "{} Sandfield", NameGen::location(&mut ctx.rng).generate_biome() ), _ => format!( - "{}\nDesert", + "{} Desert", NameGen::location(&mut ctx.rng).generate_biome() ), }) }, common::terrain::BiomeKind::Swamp if biome.1.len() as u32 > 750 => { Some(match ctx.rng.gen_range(0..7) { - 0 => format!( - "{}\nSwamp", - NameGen::location(&mut ctx.rng).generate_biome() - ), + 0 => format!("{} Swamp", NameGen::location(&mut ctx.rng).generate_biome()), 1 => format!( - "{}\nSwamps", + "{} Swamps", NameGen::location(&mut ctx.rng).generate_biome() ), 2 => format!( - "{}\nSwamplands", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 3 => format!( - "{}\nMarsh", + "{} Swamplands", NameGen::location(&mut ctx.rng).generate_biome() ), + 3 => format!("{} Marsh", NameGen::location(&mut ctx.rng).generate_biome()), 4 => format!( - "{}\nMarshlands", + "{} Marshlands", NameGen::location(&mut ctx.rng).generate_biome() ), 5 => format!( - "{}\nMorass", + "{} Morass", NameGen::location(&mut ctx.rng).generate_biome() ), - 6 => format!("{}\nMire", NameGen::location(&mut ctx.rng).generate_biome()), - 7 => format!("{}\nBog", NameGen::location(&mut ctx.rng).generate_biome()), + 6 => format!("{} Mire", NameGen::location(&mut ctx.rng).generate_biome()), + 7 => format!("{} Bog", NameGen::location(&mut ctx.rng).generate_biome()), _ => format!( - "{}\nSnowlands", + "{} Snowlands", NameGen::location(&mut ctx.rng).generate_biome() ), }) @@ -779,36 +739,33 @@ impl Civs { common::terrain::BiomeKind::Jungle if biome.1.len() as u32 > 750 => { Some(match ctx.rng.gen_range(0..7) { 0 => format!( - "{}\nJungle", + "{} Jungle", NameGen::location(&mut ctx.rng).generate_biome() ), 1 => format!( - "{}\nRainforest", + "{} Rainforest", NameGen::location(&mut ctx.rng).generate_biome() ), 2 => format!( - "{}\nGreatwood", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 3 => format!( - "{}\nWilds", + "{} Greatwood", NameGen::location(&mut ctx.rng).generate_biome() ), + 3 => format!("{} Wilds", NameGen::location(&mut ctx.rng).generate_biome()), 4 => format!( - "{}\nWildwood", + "{} Wildwood", NameGen::location(&mut ctx.rng).generate_biome() ), 5 => format!( - "{}\nTangle", + "{} Tangle", NameGen::location(&mut ctx.rng).generate_biome() ), 6 => format!( - "{}\nTanglewood", + "{} Tanglewood", NameGen::location(&mut ctx.rng).generate_biome() ), - 7 => format!("{}\nBush", NameGen::location(&mut ctx.rng).generate_biome()), + 7 => format!("{} Bush", NameGen::location(&mut ctx.rng).generate_biome()), _ => format!( - "{}\nJungle", + "{} Jungle", NameGen::location(&mut ctx.rng).generate_biome() ), }) @@ -816,71 +773,65 @@ impl Civs { common::terrain::BiomeKind::Savannah if biome.1.len() as u32 > 750 => { Some(match ctx.rng.gen_range(0..4) { 0 => format!( - "{}\nSavannah", + "{} Savannah", NameGen::location(&mut ctx.rng).generate_biome() ), 1 => format!( - "{}\nShrubland", + "{} Shrubland", NameGen::location(&mut ctx.rng).generate_biome() ), 2 => format!( - "{}\nSierra", + "{} Sierra", NameGen::location(&mut ctx.rng).generate_biome() ), 3 => format!( - "{}\nPrairie", + "{} Prairie", NameGen::location(&mut ctx.rng).generate_biome() ), 4 => format!( - "{}\nLowlands", + "{} Lowlands", NameGen::location(&mut ctx.rng).generate_biome() ), _ => format!( - "{}\nSavannah", + "{} Savannah", NameGen::location(&mut ctx.rng).generate_biome() ), }) }, common::terrain::BiomeKind::Taiga if biome.1.len() as u32 > 750 => { Some(match ctx.rng.gen_range(0..4) { - 0 => format!( - "{}\nTaiga", - NameGen::location(&mut ctx.rng).generate_biome() - ), + 0 => format!("{} Taiga", NameGen::location(&mut ctx.rng).generate_biome()), 1 => format!( - "{}\nTimberlands", + "{} Timberlands", NameGen::location(&mut ctx.rng).generate_biome() ), 2 => format!( - "{}\nUplands", + "{} Uplands", NameGen::location(&mut ctx.rng).generate_biome() ), 3 => format!( - "{}\nWoodlands", + "{} Woodlands", NameGen::location(&mut ctx.rng).generate_biome() ), 4 => format!( - "{}\nHighlands", - NameGen::location(&mut ctx.rng).generate_biome() - ), - _ => format!( - "{}\nTaiga", + "{} Highlands", NameGen::location(&mut ctx.rng).generate_biome() ), + _ => format!("{} Taiga", NameGen::location(&mut ctx.rng).generate_biome()), }) }, common::terrain::BiomeKind::Lake if biome.1.len() as u32 > 200 => { Some(match ctx.rng.gen_range(0..2) { - 0 => format!("{}\nLake", NameGen::location(&mut ctx.rng).generate()), - 1 => format!("Loch\n{}", NameGen::location(&mut ctx.rng).generate()), - _ => format!("{}\nLake", NameGen::location(&mut ctx.rng).generate()), + 0 => format!("{} Lake", NameGen::location(&mut ctx.rng).generate()), + 1 => format!("Loch {}", NameGen::location(&mut ctx.rng).generate()), + _ => format!("{} Lake", NameGen::location(&mut ctx.rng).generate()), }) }, common::terrain::BiomeKind::Lake if biome.1.len() as u32 > 10 => { Some(match ctx.rng.gen_range(0..1) { - 0 => format!("{}\nPool", NameGen::location(&mut ctx.rng).generate()), - 1 => format!("{}\nWell", NameGen::location(&mut ctx.rng).generate()), - _ => format!("{}\nPond", NameGen::location(&mut ctx.rng).generate()), + 0 => format!("{} Pool", NameGen::location(&mut ctx.rng).generate()), + 1 => format!("{} Well", NameGen::location(&mut ctx.rng).generate()), + _ => format!("{} Pond", NameGen::location(&mut ctx.rng).generate()), }) }, _ => None, From 51356d5fad02ac3333d67d7bb487f6a5f22d3612 Mon Sep 17 00:00:00 2001 From: floppy <sunflowerstarfishmail@gmail.com> Date: Tue, 18 Jan 2022 19:53:20 +0100 Subject: [PATCH 20/22] in terrain.mod.rs, return name as Option in fn name --- common/src/terrain/mod.rs | 2 +- voxygen/src/hud/minimap.rs | 30 ++++++++++++++++-------------- voxygen/src/hud/popup.rs | 35 ++++++++++++++++++----------------- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/common/src/terrain/mod.rs b/common/src/terrain/mod.rs index 8ea9ebe53f..ca8e0a67a0 100644 --- a/common/src/terrain/mod.rs +++ b/common/src/terrain/mod.rs @@ -131,7 +131,7 @@ impl TerrainChunkMeta { } } - pub fn name(&self) -> &str { self.name.as_deref().unwrap_or("") } + pub fn name(&self) -> Option<&str> { self.name.as_deref() } pub fn biome(&self) -> BiomeKind { self.biome } diff --git a/voxygen/src/hud/minimap.rs b/voxygen/src/hud/minimap.rs index 8b51741b74..c1fc992035 100644 --- a/voxygen/src/hud/minimap.rs +++ b/voxygen/src/hud/minimap.rs @@ -886,20 +886,22 @@ impl<'a> Widget for MiniMap<'a> { match self.client.current_chunk() { Some(chunk) => { // Count characters in the name to avoid clipping with the name display - let name_len = chunk.meta().name().chars().count(); - Text::new(chunk.meta().name()) - .mid_top_with_margin_on(state.ids.mmap_frame, match name_len { - 15..=30 => 4.0, - _ => 2.0, - }) - .font_size(self.fonts.cyri.scale(match name_len { - 0..=15 => 18, - 16..=30 => 14, - _ => 14, - })) - .font_id(self.fonts.cyri.conrod_id) - .color(TEXT_COLOR) - .set(state.ids.mmap_location, ui) + if let Some(name) = chunk.meta().name() { + let name_len = name.chars().count(); + Text::new(name) + .mid_top_with_margin_on(state.ids.mmap_frame, match name_len { + 15..=30 => 4.0, + _ => 2.0, + }) + .font_size(self.fonts.cyri.scale(match name_len { + 0..=15 => 18, + 16..=30 => 14, + _ => 14, + })) + .font_id(self.fonts.cyri.conrod_id) + .color(TEXT_COLOR) + .set(state.ids.mmap_location, ui) + } }, None => Text::new(" ") .mid_top_with_margin_on(state.ids.mmap_frame, 0.0) diff --git a/voxygen/src/hud/popup.rs b/voxygen/src/hud/popup.rs index afb10a7de9..9daca35dec 100644 --- a/voxygen/src/hud/popup.rs +++ b/voxygen/src/hud/popup.rs @@ -98,23 +98,24 @@ impl<'a> Widget for Popup<'a> { // Push chunk name to message queue if let Some(chunk) = self.client.current_chunk() { - let current = chunk.meta().name(); - // Check if no other popup is displayed and a new one is needed - if state.messages.is_empty() - && state - .last_region_name - .as_ref() - .map(|l| l != current) - .unwrap_or(true) - { - // Update last_region - state.update(|s| { - if s.messages.is_empty() { - s.last_message_update = Instant::now(); - } - s.last_region_name = Some(current.to_owned()); - s.messages.push_back(current.to_owned()); - }); + if let Some(current) = chunk.meta().name() { + // Check if no other popup is displayed and a new one is needed + if state.messages.is_empty() + && state + .last_region_name + .as_ref() + .map(|l| l != current) + .unwrap_or(true) + { + // Update last_region + state.update(|s| { + if s.messages.is_empty() { + s.last_message_update = Instant::now(); + } + s.last_region_name = Some(current.to_owned()); + s.messages.push_back(current.to_owned()); + }); + } } } From 9f0664c73bda79423e7de08b2cb2590b2aaea038 Mon Sep 17 00:00:00 2001 From: floppy <sunflowerstarfishmail@gmail.com> Date: Thu, 20 Jan 2022 16:17:40 +0100 Subject: [PATCH 21/22] civ/mod.rs - replace duplicate code --- world/src/civ/mod.rs | 453 +++++++++++++------------------------------ 1 file changed, 136 insertions(+), 317 deletions(-) diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index 81fb523814..5aa4122b95 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -508,332 +508,151 @@ impl Civs { let mut biome_count = 0; for biome in biomes { let name = match biome.0 { - common::terrain::BiomeKind::Forest if biome.1.len() as u32 > 750 => { - Some(match ctx.rng.gen_range(0..8) { - 0 => format!( - "{} Forest", - NameGen::location(&mut ctx.rng).generate_temp_forest() - ), - 1 => format!( - "{} Woodlands", - NameGen::location(&mut ctx.rng).generate_temp_forest() - ), - 2 => format!( - "{} Woods", - NameGen::location(&mut ctx.rng).generate_temp_forest() - ), - 3 => format!( - "{} Glades", - NameGen::location(&mut ctx.rng).generate_temp_forest() - ), - 4 => format!( - "{} Grove", - NameGen::location(&mut ctx.rng).generate_temp_forest() - ), - 5 => format!( - "{} Glades", - NameGen::location(&mut ctx.rng).generate_temp_forest() - ), - 6 => format!( - "{} Thickets", - NameGen::location(&mut ctx.rng).generate_temp_forest() - ), - 7 => format!( - "{} Weald", - NameGen::location(&mut ctx.rng).generate_temp_forest() - ), - _ => format!( - "{} Forest", - NameGen::location(&mut ctx.rng).generate_temp_forest() - ), - }) - }, + common::terrain::BiomeKind::Forest if biome.1.len() as u32 > 750 => Some(format!( + "{} {}", + NameGen::location(&mut ctx.rng).generate_temp_forest(), + [ + "Forest", + "Woodlands", + "Woods", + "Glades", + "Grove", + "Thickets", + "Weald" + ] + .choose(&mut ctx.rng) + .unwrap() + )), common::terrain::BiomeKind::Grassland if biome.1.len() as u32 > 750 => { - Some(match ctx.rng.gen_range(0..9) { - 0 => format!( - "{} Grasslands", - NameGen::location(&mut ctx.rng).generate_grassland() - ), - 1 => format!( - "{} Flats", - NameGen::location(&mut ctx.rng).generate_grassland() - ), - 2 => format!( - "{} Greens", - NameGen::location(&mut ctx.rng).generate_grassland() - ), - 3 => format!( - "{} Plains", - NameGen::location(&mut ctx.rng).generate_grassland() - ), - 4 => format!( - "{} Meadows", - NameGen::location(&mut ctx.rng).generate_grassland() - ), - 5 => format!( - "{} Fields", - NameGen::location(&mut ctx.rng).generate_grassland() - ), - 6 => format!( - "{} Heath", - NameGen::location(&mut ctx.rng).generate_grassland() - ), - 7 => format!( - "{} Prairie", - NameGen::location(&mut ctx.rng).generate_grassland() - ), - 8 => format!( - "{} Steppe", - NameGen::location(&mut ctx.rng).generate_grassland() - ), - 9 => format!( - "{} Downs", - NameGen::location(&mut ctx.rng).generate_grassland() - ), - _ => format!( - "{} Grassland", - NameGen::location(&mut ctx.rng).generate_grassland() - ), - }) - }, - common::terrain::BiomeKind::Ocean if biome.1.len() as u32 > 750 => { - Some(match ctx.rng.gen_range(0..3) { - 0 => format!("{} Ocean", NameGen::location(&mut ctx.rng).generate_biome()), - 1 => format!("{} Blue", NameGen::location(&mut ctx.rng).generate_biome()), - 2 => format!("{} Deep", NameGen::location(&mut ctx.rng).generate_biome()), - 3 => format!( - "{} Depths", - NameGen::location(&mut ctx.rng).generate_biome() - ), - _ => format!("{} Ocean", NameGen::location(&mut ctx.rng).generate_biome()), - }) + Some(format!( + "{} {}", + NameGen::location(&mut ctx.rng).generate_grassland(), + [ + "Grasslands", + "Flats", + "Greens", + "Plains", + "Meadows", + "Fields", + "Heath", + "Steppe", + "Downs" + ] + .choose(&mut ctx.rng) + .unwrap() + )) }, + common::terrain::BiomeKind::Ocean if biome.1.len() as u32 > 750 => Some(format!( + "{} {}", + NameGen::location(&mut ctx.rng).generate_biome(), + ["Ocean", "Blue", "Deep"].choose(&mut ctx.rng).unwrap() + )), common::terrain::BiomeKind::Mountain if biome.1.len() as u32 > 750 => { - Some(match ctx.rng.gen_range(0..11) { - 0 => format!( - "{} Mountains", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 1 => format!("{} Range", NameGen::location(&mut ctx.rng).generate_biome()), - 2 => format!("{} Reach", NameGen::location(&mut ctx.rng).generate_biome()), - 3 => format!( - "{} Massif", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 4 => format!("{} Rocks", NameGen::location(&mut ctx.rng).generate_biome()), - 5 => format!( - "{} Cliffs", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 6 => format!("{} Peaks", NameGen::location(&mut ctx.rng).generate_biome()), - 7 => format!( - "{} Heights", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 8 => format!( - "{} Bluffs", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 9 => format!("{} Ridge", NameGen::location(&mut ctx.rng).generate_biome()), - 10 => format!( - "{} Canyon", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 11 => format!( - "{} Plateau", - NameGen::location(&mut ctx.rng).generate_biome() - ), - _ => format!( - "{} Mountains", - NameGen::location(&mut ctx.rng).generate_biome() - ), - }) + Some(format!( + "{} {}", + NameGen::location(&mut ctx.rng).generate_biome(), + [ + "Mountains", + "Range", + "Reach", + "Massif", + "Rocks", + "Cliffs", + "Peaks", + "Heights", + "Bluffs", + "Ridge", + "Canyon", + "Plateau" + ] + .choose(&mut ctx.rng) + .unwrap() + )) }, common::terrain::BiomeKind::Snowland if biome.1.len() as u32 > 750 => { - Some(match ctx.rng.gen_range(0..6) { - 0 => format!( - "{} Snowlands", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 1 => format!( - "{} Glacier", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 2 => format!( - "{} Tundra", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 3 => format!( - "{} Drifts", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 4 => format!( - "{} Snowfields", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 5 => format!("{} Hills", NameGen::location(&mut ctx.rng).generate_biome()), - 6 => format!( - "{} Highlands", - NameGen::location(&mut ctx.rng).generate_biome() - ), - _ => format!( - "{} Snowlands", - NameGen::location(&mut ctx.rng).generate_biome() - ), - }) + Some(format!( + "{} {}", + NameGen::location(&mut ctx.rng).generate_biome(), + [ + "Snowlands", + "Glacier", + "Tundra", + "Snowfields", + "Hills", + "Highlands" + ] + .choose(&mut ctx.rng) + .unwrap() + )) }, - common::terrain::BiomeKind::Desert if biome.1.len() as u32 > 750 => { - Some(match ctx.rng.gen_range(0..5) { - 0 => format!( - "{} Desert", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 1 => format!("{} Sands", NameGen::location(&mut ctx.rng).generate_biome()), - 2 => format!( - "{} Sandsea", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 3 => format!( - "{} Drifts", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 4 => format!("{} Dunes", NameGen::location(&mut ctx.rng).generate_biome()), - 5 => format!( - "{} Sandfield", - NameGen::location(&mut ctx.rng).generate_biome() - ), - _ => format!( - "{} Desert", - NameGen::location(&mut ctx.rng).generate_biome() - ), - }) - }, - common::terrain::BiomeKind::Swamp if biome.1.len() as u32 > 750 => { - Some(match ctx.rng.gen_range(0..7) { - 0 => format!("{} Swamp", NameGen::location(&mut ctx.rng).generate_biome()), - 1 => format!( - "{} Swamps", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 2 => format!( - "{} Swamplands", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 3 => format!("{} Marsh", NameGen::location(&mut ctx.rng).generate_biome()), - 4 => format!( - "{} Marshlands", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 5 => format!( - "{} Morass", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 6 => format!("{} Mire", NameGen::location(&mut ctx.rng).generate_biome()), - 7 => format!("{} Bog", NameGen::location(&mut ctx.rng).generate_biome()), - _ => format!( - "{} Snowlands", - NameGen::location(&mut ctx.rng).generate_biome() - ), - }) - }, - common::terrain::BiomeKind::Jungle if biome.1.len() as u32 > 750 => { - Some(match ctx.rng.gen_range(0..7) { - 0 => format!( - "{} Jungle", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 1 => format!( - "{} Rainforest", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 2 => format!( - "{} Greatwood", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 3 => format!("{} Wilds", NameGen::location(&mut ctx.rng).generate_biome()), - 4 => format!( - "{} Wildwood", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 5 => format!( - "{} Tangle", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 6 => format!( - "{} Tanglewood", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 7 => format!("{} Bush", NameGen::location(&mut ctx.rng).generate_biome()), - _ => format!( - "{} Jungle", - NameGen::location(&mut ctx.rng).generate_biome() - ), - }) + common::terrain::BiomeKind::Desert if biome.1.len() as u32 > 750 => Some(format!( + "{} {}", + NameGen::location(&mut ctx.rng).generate_biome(), + ["Desert", "Sands", "Sandsea", "Drifts", "Dunes", "Sandfield"] + .choose(&mut ctx.rng) + .unwrap() + )), + common::terrain::BiomeKind::Mountain if biome.1.len() as u32 > 750 => { + Some(format!( + "{} {}", + NameGen::location(&mut ctx.rng).generate_biome(), + [ + "Swamp", + "Swamps", + "Swamplands", + "Marsh", + "Marshlands", + "Morass", + "Mire", + "Bog", + "Snowlands" + ] + .choose(&mut ctx.rng) + .unwrap() + )) }, + common::terrain::BiomeKind::Jungle if biome.1.len() as u32 > 750 => Some(format!( + "{} {}", + NameGen::location(&mut ctx.rng).generate_biome(), + [ + "Jungle", + "Rainforest", + "Greatwood", + "Wilds", + "Wildwood", + "Tangle", + "Tanglewood", + "Bush" + ] + .choose(&mut ctx.rng) + .unwrap() + )), common::terrain::BiomeKind::Savannah if biome.1.len() as u32 > 750 => { - Some(match ctx.rng.gen_range(0..4) { - 0 => format!( - "{} Savannah", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 1 => format!( - "{} Shrubland", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 2 => format!( - "{} Sierra", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 3 => format!( - "{} Prairie", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 4 => format!( - "{} Lowlands", - NameGen::location(&mut ctx.rng).generate_biome() - ), - _ => format!( - "{} Savannah", - NameGen::location(&mut ctx.rng).generate_biome() - ), - }) - }, - common::terrain::BiomeKind::Taiga if biome.1.len() as u32 > 750 => { - Some(match ctx.rng.gen_range(0..4) { - 0 => format!("{} Taiga", NameGen::location(&mut ctx.rng).generate_biome()), - 1 => format!( - "{} Timberlands", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 2 => format!( - "{} Uplands", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 3 => format!( - "{} Woodlands", - NameGen::location(&mut ctx.rng).generate_biome() - ), - 4 => format!( - "{} Highlands", - NameGen::location(&mut ctx.rng).generate_biome() - ), - _ => format!("{} Taiga", NameGen::location(&mut ctx.rng).generate_biome()), - }) - }, - common::terrain::BiomeKind::Lake if biome.1.len() as u32 > 200 => { - Some(match ctx.rng.gen_range(0..2) { - 0 => format!("{} Lake", NameGen::location(&mut ctx.rng).generate()), - 1 => format!("Loch {}", NameGen::location(&mut ctx.rng).generate()), - _ => format!("{} Lake", NameGen::location(&mut ctx.rng).generate()), - }) - }, - common::terrain::BiomeKind::Lake if biome.1.len() as u32 > 10 => { - Some(match ctx.rng.gen_range(0..1) { - 0 => format!("{} Pool", NameGen::location(&mut ctx.rng).generate()), - 1 => format!("{} Well", NameGen::location(&mut ctx.rng).generate()), - _ => format!("{} Pond", NameGen::location(&mut ctx.rng).generate()), - }) + Some(format!( + "{} {}", + NameGen::location(&mut ctx.rng).generate_biome(), + ["Savannah", "Shrubland", "Sierra", "Prairie", "Lowlands"] + .choose(&mut ctx.rng) + .unwrap() + )) }, + common::terrain::BiomeKind::Taiga if biome.1.len() as u32 > 750 => Some(format!( + "{} {}", + NameGen::location(&mut ctx.rng).generate_biome(), + ["Taiga", "Timberlands", "Uplands", "Highlands"] + .choose(&mut ctx.rng) + .unwrap() + )), + common::terrain::BiomeKind::Lake if biome.1.len() as u32 > 200 => Some(format!( + "{} {}", + ["Lake", "Loch"].choose(&mut ctx.rng).unwrap(), + NameGen::location(&mut ctx.rng).generate() + )), + common::terrain::BiomeKind::Lake if biome.1.len() as u32 > 10 => Some(format!( + "{} {}", + NameGen::location(&mut ctx.rng).generate(), + ["Pool", "Well", "Pond"].choose(&mut ctx.rng).unwrap() + )), _ => None, }; if let Some(name) = name { From 8f0ad56d2523d0628fe76ac5a4209384d3529ddb Mon Sep 17 00:00:00 2001 From: floppy <sunflowerstarfishmail@gmail.com> Date: Thu, 20 Jan 2022 20:08:59 +0100 Subject: [PATCH 22/22] change algorithm for biome-naming to weigh chunks evenly --- world/src/civ/mod.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index 5aa4122b95..98b345fe7a 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -657,13 +657,12 @@ impl Civs { }; if let Some(name) = name { // find average center of the biome - let mut biomes = biome.1.iter(); - // There is always at least 1 biome - let mut center = uniform_idx_as_vec2(map_size_lg, *biomes.next().unwrap()); - biomes.for_each(|b| { - center += uniform_idx_as_vec2(map_size_lg, *b); - center /= 2; - }); + let center = biome + .1 + .iter() + .map(|b| uniform_idx_as_vec2(map_size_lg, *b)) + .sum::<Vec2<i32>>() + / biome.1.len() as i32; // Select the point closest to the center let idx = *biome .1