Update rand dependency

This commit is contained in:
jiminycrick 2021-01-26 12:23:18 -08:00
parent e6620c21db
commit 8b97199245
34 changed files with 254 additions and 227 deletions

66
Cargo.lock generated
View File

@ -4240,7 +4240,7 @@ dependencies = [
"rand_isaac", "rand_isaac",
"rand_jitter", "rand_jitter",
"rand_os", "rand_os",
"rand_pcg 0.1.2", "rand_pcg",
"rand_xorshift 0.1.1", "rand_xorshift 0.1.1",
"winapi 0.3.9", "winapi 0.3.9",
] ]
@ -4256,7 +4256,18 @@ dependencies = [
"rand_chacha 0.2.2", "rand_chacha 0.2.2",
"rand_core 0.5.1", "rand_core 0.5.1",
"rand_hc 0.2.0", "rand_hc 0.2.0",
"rand_pcg 0.2.1", ]
[[package]]
name = "rand"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
dependencies = [
"libc",
"rand_chacha 0.3.0",
"rand_core 0.6.1",
"rand_hc 0.3.0",
] ]
[[package]] [[package]]
@ -4279,6 +4290,16 @@ dependencies = [
"rand_core 0.5.1", "rand_core 0.5.1",
] ]
[[package]]
name = "rand_chacha"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
dependencies = [
"ppv-lite86",
"rand_core 0.6.1",
]
[[package]] [[package]]
name = "rand_core" name = "rand_core"
version = "0.3.1" version = "0.3.1"
@ -4303,6 +4324,15 @@ dependencies = [
"getrandom 0.1.15", "getrandom 0.1.15",
] ]
[[package]]
name = "rand_core"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c026d7df8b298d90ccbbc5190bd04d85e159eaf5576caeacf8741da93ccbd2e5"
dependencies = [
"getrandom 0.2.0",
]
[[package]] [[package]]
name = "rand_hc" name = "rand_hc"
version = "0.1.0" version = "0.1.0"
@ -4321,6 +4351,15 @@ dependencies = [
"rand_core 0.5.1", "rand_core 0.5.1",
] ]
[[package]]
name = "rand_hc"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
dependencies = [
"rand_core 0.6.1",
]
[[package]] [[package]]
name = "rand_isaac" name = "rand_isaac"
version = "0.1.1" version = "0.1.1"
@ -4365,15 +4404,6 @@ dependencies = [
"rand_core 0.4.2", "rand_core 0.4.2",
] ]
[[package]]
name = "rand_pcg"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429"
dependencies = [
"rand_core 0.5.1",
]
[[package]] [[package]]
name = "rand_xorshift" name = "rand_xorshift"
version = "0.1.1" version = "0.1.1"
@ -6041,7 +6071,7 @@ dependencies = [
"num-derive", "num-derive",
"num-traits 0.2.14", "num-traits 0.2.14",
"ordered-float 2.0.1", "ordered-float 2.0.1",
"rand 0.7.3", "rand 0.8.3",
"rayon", "rayon",
"ron", "ron",
"roots", "roots",
@ -6082,7 +6112,7 @@ dependencies = [
"bincode", "bincode",
"hashbrown 0.9.1", "hashbrown 0.9.1",
"indexmap", "indexmap",
"rand 0.7.3", "rand 0.8.3",
"rayon", "rayon",
"serde", "serde",
"slab", "slab",
@ -6146,7 +6176,7 @@ dependencies = [
"libsqlite3-sys", "libsqlite3-sys",
"portpicker", "portpicker",
"prometheus", "prometheus",
"rand 0.7.3", "rand 0.8.3",
"ron", "ron",
"scan_fmt", "scan_fmt",
"serde", "serde",
@ -6227,7 +6257,7 @@ dependencies = [
"num 0.3.1", "num 0.3.1",
"old_school_gfx_glutin_ext", "old_school_gfx_glutin_ext",
"ordered-float 2.0.1", "ordered-float 2.0.1",
"rand 0.7.3", "rand 0.8.3",
"rodio", "rodio",
"ron", "ron",
"serde", "serde",
@ -6286,8 +6316,8 @@ dependencies = [
"num 0.3.1", "num 0.3.1",
"ordered-float 2.0.1", "ordered-float 2.0.1",
"packed_simd_2", "packed_simd_2",
"rand 0.7.3", "rand 0.8.3",
"rand_chacha 0.2.2", "rand_chacha 0.3.0",
"rayon", "rayon",
"ron", "ron",
"serde", "serde",
@ -6311,7 +6341,7 @@ dependencies = [
"lazy_static", "lazy_static",
"lz-fear", "lz-fear",
"prometheus", "prometheus",
"rand 0.7.3", "rand 0.8.3",
"serde", "serde",
"shellexpand", "shellexpand",
"tiny_http", "tiny_http",

View File

@ -21,7 +21,7 @@ lazy_static = "1.4.0"
num-derive = "0.3" num-derive = "0.3"
num-traits = "0.2" num-traits = "0.2"
ordered-float = { version = "2.0.1", default-features = false } ordered-float = { version = "2.0.1", default-features = false }
rand = "0.7" rand = "0.8"
rayon = "1.5" rayon = "1.5"
roots = "0.0.6" roots = "0.0.6"
spin_sleep = "1.0" spin_sleep = "1.0"

View File

@ -39,13 +39,13 @@ impl Body {
Self { Self {
species, species,
body_type, body_type,
hair_style: rng.gen_range(0, species.num_hair_styles(body_type)), hair_style: rng.gen_range(0..species.num_hair_styles(body_type)),
beard: rng.gen_range(0, species.num_beards(body_type)), beard: rng.gen_range(0..species.num_beards(body_type)),
accessory: rng.gen_range(0, species.num_accessories(body_type)), accessory: rng.gen_range(0..species.num_accessories(body_type)),
hair_color: rng.gen_range(0, species.num_hair_colors()), hair_color: rng.gen_range(0..species.num_hair_colors()),
skin: rng.gen_range(0, species.num_skin_colors()), skin: rng.gen_range(0..species.num_skin_colors()),
eye_color: rng.gen_range(0, species.num_eye_colors()), eye_color: rng.gen_range(0..species.num_eye_colors()),
eyes: rng.gen_range(0, 1), /* TODO Add a way to set specific head-segments for NPCs eyes: rng.gen_range(0..1), /* TODO Add a way to set specific head-segments for NPCs
* with the default being a random one */ * with the default being a random one */
} }
} }

View File

@ -493,7 +493,7 @@ impl Item {
SpriteKind::ShortGrass => "common.items.grasses.short", SpriteKind::ShortGrass => "common.items.grasses.short",
SpriteKind::Coconut => "common.items.food.coconut", SpriteKind::Coconut => "common.items.food.coconut",
SpriteKind::Chest => { SpriteKind::Chest => {
chosen = Lottery::<String>::load_expect(match rng.gen_range(0, 7) { chosen = Lottery::<String>::load_expect(match rng.gen_range(0..7) {
0 => "common.loot_tables.loot_table_weapon_uncommon", 0 => "common.loot_tables.loot_table_weapon_uncommon",
1 => "common.loot_tables.loot_table_weapon_common", 1 => "common.loot_tables.loot_table_weapon_common",
2 => "common.loot_tables.loot_table_armor_light", 2 => "common.loot_tables.loot_table_armor_light",
@ -505,7 +505,7 @@ impl Item {
chosen.choose() chosen.choose()
}, },
SpriteKind::ChestBurried => { SpriteKind::ChestBurried => {
chosen = Lottery::<String>::load_expect(match rng.gen_range(0, 7) { chosen = Lottery::<String>::load_expect(match rng.gen_range(0..7) {
1 => "common.loot_tables.loot_table_weapon_common", 1 => "common.loot_tables.loot_table_weapon_common",
2 => "common.loot_tables.loot_table_armor_light", 2 => "common.loot_tables.loot_table_armor_light",
3 => "common.loot_tables.loot_table_armor_cloth", 3 => "common.loot_tables.loot_table_armor_cloth",
@ -515,7 +515,7 @@ impl Item {
chosen.choose() chosen.choose()
}, },
SpriteKind::Mud => { SpriteKind::Mud => {
chosen = Lottery::<String>::load_expect(match rng.gen_range(0, 5) { chosen = Lottery::<String>::load_expect(match rng.gen_range(0..5) {
0 => "common.loot_tables.loot_table_crafting", 0 => "common.loot_tables.loot_table_crafting",
1 => "common.loot_tables.loot_table_weapon_common", 1 => "common.loot_tables.loot_table_weapon_common",
2 => "common.loot_tables.loot_table_armor_misc", 2 => "common.loot_tables.loot_table_armor_misc",
@ -525,7 +525,7 @@ impl Item {
chosen.choose() chosen.choose()
}, },
SpriteKind::Crate => { SpriteKind::Crate => {
chosen = Lottery::<String>::load_expect(match rng.gen_range(0, 4) { chosen = Lottery::<String>::load_expect(match rng.gen_range(0..4) {
0 => "common.loot_tables.loot_table_crafting", 0 => "common.loot_tables.loot_table_crafting",
_ => "common.loot_tables.loot_table_food", _ => "common.loot_tables.loot_table_food",
}) })

View File

@ -262,7 +262,7 @@ impl LoadoutBuilder {
.feet(Some(Item::new_from_asset_expect( .feet(Some(Item::new_from_asset_expect(
"common.items.armor.foot.steel_0", "common.items.armor.foot.steel_0",
))) )))
.lantern(match rand::thread_rng().gen_range(0, 3) { .lantern(match rand::thread_rng().gen_range(0..3) {
0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")), 0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")),
_ => None, _ => None,
}) })
@ -287,7 +287,7 @@ impl LoadoutBuilder {
.feet(Some(Item::new_from_asset_expect( .feet(Some(Item::new_from_asset_expect(
"common.items.armor.foot.cloth_purple_0", "common.items.armor.foot.cloth_purple_0",
))) )))
.lantern(match rand::thread_rng().gen_range(0, 3) { .lantern(match rand::thread_rng().gen_range(0..3) {
0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")), 0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")),
_ => None, _ => None,
}) })
@ -312,7 +312,7 @@ impl LoadoutBuilder {
.feet(Some(Item::new_from_asset_expect( .feet(Some(Item::new_from_asset_expect(
"common.items.armor.foot.leather_0", "common.items.armor.foot.leather_0",
))) )))
.lantern(match rand::thread_rng().gen_range(0, 3) { .lantern(match rand::thread_rng().gen_range(0..3) {
0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")), 0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")),
_ => None, _ => None,
}) })
@ -337,7 +337,7 @@ impl LoadoutBuilder {
.feet(Some(Item::new_from_asset_expect( .feet(Some(Item::new_from_asset_expect(
"common.items.armor.foot.assassin", "common.items.armor.foot.assassin",
))) )))
.lantern(match rand::thread_rng().gen_range(0, 3) { .lantern(match rand::thread_rng().gen_range(0..3) {
0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")), 0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")),
_ => None, _ => None,
}) })
@ -365,7 +365,7 @@ impl LoadoutBuilder {
.back(Some(Item::new_from_asset_expect( .back(Some(Item::new_from_asset_expect(
"common.items.armor.back.dungeon_purple-0", "common.items.armor.back.dungeon_purple-0",
))) )))
.lantern(match rand::thread_rng().gen_range(0, 3) { .lantern(match rand::thread_rng().gen_range(0..3) {
0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")), 0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")),
_ => None, _ => None,
}) })
@ -393,7 +393,7 @@ impl LoadoutBuilder {
.back(Some(Item::new_from_asset_expect( .back(Some(Item::new_from_asset_expect(
"common.items.armor.back.dungeon_purple-0", "common.items.armor.back.dungeon_purple-0",
))) )))
.lantern(match rand::thread_rng().gen_range(0, 3) { .lantern(match rand::thread_rng().gen_range(0..3) {
0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")), 0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")),
_ => None, _ => None,
}) })
@ -421,7 +421,7 @@ impl LoadoutBuilder {
.back(Some(Item::new_from_asset_expect( .back(Some(Item::new_from_asset_expect(
"common.items.armor.back.warlord", "common.items.armor.back.warlord",
))) )))
.lantern(match rand::thread_rng().gen_range(0, 3) { .lantern(match rand::thread_rng().gen_range(0..3) {
0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")), 0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")),
_ => None, _ => None,
}) })
@ -449,7 +449,7 @@ impl LoadoutBuilder {
.back(Some(Item::new_from_asset_expect( .back(Some(Item::new_from_asset_expect(
"common.items.armor.back.warlock", "common.items.armor.back.warlock",
))) )))
.lantern(match rand::thread_rng().gen_range(0, 3) { .lantern(match rand::thread_rng().gen_range(0..3) {
0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")), 0 => Some(Item::new_from_asset_expect("common.items.lantern.black_0")),
_ => None, _ => None,
}) })
@ -457,7 +457,7 @@ impl LoadoutBuilder {
Villager => LoadoutBuilder::new() Villager => LoadoutBuilder::new()
.active_item(active_item) .active_item(active_item)
.chest(Some(Item::new_from_asset_expect( .chest(Some(Item::new_from_asset_expect(
match rand::thread_rng().gen_range(0, 10) { match rand::thread_rng().gen_range(0..10) {
0 => "common.items.armor.chest.worker_green_0", 0 => "common.items.armor.chest.worker_green_0",
1 => "common.items.armor.chest.worker_green_1", 1 => "common.items.armor.chest.worker_green_1",
2 => "common.items.armor.chest.worker_red_0", 2 => "common.items.armor.chest.worker_red_0",
@ -477,7 +477,7 @@ impl LoadoutBuilder {
"common.items.armor.pants.worker_blue_0", "common.items.armor.pants.worker_blue_0",
))) )))
.feet(Some(Item::new_from_asset_expect( .feet(Some(Item::new_from_asset_expect(
match rand::thread_rng().gen_range(0, 2) { match rand::thread_rng().gen_range(0..2) {
0 => "common.items.armor.foot.leather_0", 0 => "common.items.armor.foot.leather_0",
_ => "common.items.armor.starter.sandals_0", _ => "common.items.armor.starter.sandals_0",
}, },

View File

@ -15,7 +15,7 @@ default = ["simd"]
common = { package = "veloren-common", path = ".." } common = { package = "veloren-common", path = ".." }
common-net = { package = "veloren-common-net", path = "../net" } common-net = { package = "veloren-common-net", path = "../net" }
rand = "0.7" rand = "0.8"
rayon = "1.5" rayon = "1.5"
tracing = { version = "0.1", default-features = false } tracing = { version = "0.1", default-features = false }
vek = { version = "0.12.0", features = ["serde"] } vek = { version = "0.12.0", features = ["serde"] }

View File

@ -176,13 +176,13 @@ impl<'a> System<'a> for Sys {
// keep them on // keep them on
// Only emit event for agents that sill need to // Only emit event for agents that sill need to
// turn on their lantern // turn on their lantern
if let 0 = rng.gen_range(0, 1000) { if let 0 = rng.gen_range(0..1000) {
controller.events.push(ControlEvent::EnableLantern) controller.events.push(ControlEvent::EnableLantern)
} }
} else if lantern_turned_on && day_period.is_light() { } else if lantern_turned_on && day_period.is_light() {
// agents with turned on lanterns turn them off randomly once it's daytime and // agents with turned on lanterns turn them off randomly once it's daytime and
// keep them off // keep them off
if let 0 = rng.gen_range(0, 2000) { if let 0 = rng.gen_range(0..2000) {
controller.events.push(ControlEvent::DisableLantern) controller.events.push(ControlEvent::DisableLantern)
} }
} }
@ -770,7 +770,7 @@ impl<'a> System<'a> for Sys {
inputs.move_dir = bearing inputs.move_dir = bearing
.xy() .xy()
.rotated_z( .rotated_z(
thread_rng().gen_range(0.5, 1.57), thread_rng().gen_range(0.5..1.57),
) )
.try_normalized() .try_normalized()
.unwrap_or(Vec2::zero()) .unwrap_or(Vec2::zero())
@ -865,7 +865,7 @@ impl<'a> System<'a> for Sys {
inputs.move_dir = bearing inputs.move_dir = bearing
.xy() .xy()
.rotated_z( .rotated_z(
thread_rng().gen_range(-1.57, -0.5), thread_rng().gen_range(-1.57..-0.5),
) )
.try_normalized() .try_normalized()
.unwrap_or(Vec2::zero()) .unwrap_or(Vec2::zero())

View File

@ -29,7 +29,7 @@ prometheus = { version = "0.11", default-features = false, optional = true }
futures = { version = "0.3", features = ["thread-pool"] } futures = { version = "0.3", features = ["thread-pool"] }
#mpsc channel registry #mpsc channel registry
lazy_static = { version = "1.4", default-features = false } lazy_static = { version = "1.4", default-features = false }
rand = { version = "0.7" } rand = { version = "0.8" }
#stream flags #stream flags
bitflags = "1.2.1" bitflags = "1.2.1"
lz-fear = { version = "0.1.1", optional = true } lz-fear = { version = "0.1.1", optional = true }

View File

@ -357,6 +357,6 @@ mod tests {
} }
} }
let msg = Message::serialize(&msg, &stub_stream(true)); let msg = Message::serialize(&msg, &stub_stream(true));
assert_eq!(msg.buffer.data.len(), 1296); assert_eq!(msg.buffer.data.len(), 1331);
} }
} }

View File

@ -35,7 +35,7 @@ scan_fmt = { git = "https://github.com/Imberflur/scan_fmt" }
ron = { version = "0.6", default-features = false } ron = { version = "0.6", default-features = false }
serde = { version = "1.0.110", features = ["derive"] } serde = { version = "1.0.110", features = ["derive"] }
serde_json = "1.0.50" serde_json = "1.0.50"
rand = { version = "0.7", features = ["small_rng"] } rand = { version = "0.8", features = ["small_rng"] }
chrono = "0.4.9" chrono = "0.4.9"
hashbrown = { version = "0.9", features = ["rayon", "serde", "nightly"] } hashbrown = { version = "0.9", features = ["rayon", "serde", "nightly"] }
crossbeam-channel = "0.5" crossbeam-channel = "0.5"

View File

@ -154,14 +154,14 @@ fn handle_drop_all(
let pos = pos.expect("expected pos for entity using dropall command"); let pos = pos.expect("expected pos for entity using dropall command");
for item in items { for item in items {
let vel = Vec3::new(rng.gen_range(-0.1, 0.1), rng.gen_range(-0.1, 0.1), 0.5); let vel = Vec3::new(rng.gen_range(-0.1..0.1), rng.gen_range(-0.1..0.1), 0.5);
server server
.state .state
.create_object(Default::default(), comp::object::Body::Pouch) .create_object(Default::default(), comp::object::Body::Pouch)
.with(comp::Pos(Vec3::new( .with(comp::Pos(Vec3::new(
pos.0.x + rng.gen_range(5.0, 10.0), pos.0.x + rng.gen_range(5.0..10.0),
pos.0.y + rng.gen_range(5.0, 10.0), pos.0.y + rng.gen_range(5.0..10.0),
pos.0.z + 5.0, pos.0.z + 5.0,
))) )))
.with(item) .with(item)
@ -805,8 +805,8 @@ fn handle_spawn(
for _ in 0..amount { for _ in 0..amount {
let vel = Vec3::new( let vel = Vec3::new(
rand::thread_rng().gen_range(-2.0, 3.0), rand::thread_rng().gen_range(-2.0..3.0),
rand::thread_rng().gen_range(-2.0, 3.0), rand::thread_rng().gen_range(-2.0..3.0),
10.0, 10.0,
); );
@ -922,8 +922,8 @@ fn handle_spawn_training_dummy(
match server.state.read_component_copied::<comp::Pos>(target) { match server.state.read_component_copied::<comp::Pos>(target) {
Some(pos) => { Some(pos) => {
let vel = Vec3::new( let vel = Vec3::new(
rand::thread_rng().gen_range(-2.0, 3.0), rand::thread_rng().gen_range(-2.0..3.0),
rand::thread_rng().gen_range(-2.0, 3.0), rand::thread_rng().gen_range(-2.0..3.0),
10.0, 10.0,
); );

View File

@ -313,7 +313,7 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
let mut lottery = || { let mut lottery = || {
Lottery::<String>::load_expect(match old_body { Lottery::<String>::load_expect(match old_body {
Some(common::comp::Body::Humanoid(_)) => match rng.gen_range(0, 4) { Some(common::comp::Body::Humanoid(_)) => match rng.gen_range(0..4) {
0 => "common.loot_tables.loot_table_humanoids", 0 => "common.loot_tables.loot_table_humanoids",
1 => "common.loot_tables.loot_table_armor_light", 1 => "common.loot_tables.loot_table_armor_light",
2 => "common.loot_tables.loot_table_armor_cloth", 2 => "common.loot_tables.loot_table_armor_cloth",
@ -323,11 +323,11 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc
}, },
Some(common::comp::Body::QuadrupedSmall(quadruped_small)) => { Some(common::comp::Body::QuadrupedSmall(quadruped_small)) => {
match quadruped_small.species { match quadruped_small.species {
quadruped_small::Species::Dodarock => match rng.gen_range(0, 6) { quadruped_small::Species::Dodarock => match rng.gen_range(0..6) {
1 => "common.loot_tables.loot_table_rocks", 1 => "common.loot_tables.loot_table_rocks",
_ => "common.loot_tables.loot_table_rocks", _ => "common.loot_tables.loot_table_rocks",
}, },
_ => match rng.gen_range(0, 4) { _ => match rng.gen_range(0..4) {
0 => "common.loot_tables.loot_table_food", 0 => "common.loot_tables.loot_table_food",
2 => "common.loot_tables.loot_table_animal_parts", 2 => "common.loot_tables.loot_table_animal_parts",
_ => "common.loot_tables.loot_table_animal_parts", _ => "common.loot_tables.loot_table_animal_parts",
@ -340,27 +340,27 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc
| quadruped_medium::Species::Roshwalr => { | quadruped_medium::Species::Roshwalr => {
"common.loot_tables.loot_table_animal_ice" "common.loot_tables.loot_table_animal_ice"
}, },
_ => match rng.gen_range(0, 4) { _ => match rng.gen_range(0..4) {
0 => "common.loot_tables.loot_table_food", 0 => "common.loot_tables.loot_table_food",
2 => "common.loot_tables.loot_table_animal_parts", 2 => "common.loot_tables.loot_table_animal_parts",
_ => "common.loot_tables.loot_table_animal_parts", _ => "common.loot_tables.loot_table_animal_parts",
}, },
} }
}, },
Some(common::comp::Body::BirdMedium(_)) => match rng.gen_range(0, 3) { Some(common::comp::Body::BirdMedium(_)) => match rng.gen_range(0..3) {
0 => "common.loot_tables.loot_table_food", 0 => "common.loot_tables.loot_table_food",
_ => "common.loot_tables.loot_table", _ => "common.loot_tables.loot_table",
}, },
Some(common::comp::Body::FishMedium(_)) => "common.loot_tables.loot_table_fish", Some(common::comp::Body::FishMedium(_)) => "common.loot_tables.loot_table_fish",
Some(common::comp::Body::FishSmall(_)) => "common.loot_tables.loot_table_fish", Some(common::comp::Body::FishSmall(_)) => "common.loot_tables.loot_table_fish",
Some(common::comp::Body::BipedLarge(biped_large)) => match biped_large.species { Some(common::comp::Body::BipedLarge(biped_large)) => match biped_large.species {
biped_large::Species::Wendigo => match rng.gen_range(0, 7) { biped_large::Species::Wendigo => match rng.gen_range(0..7) {
0 => "common.loot_tables.loot_table_food", 0 => "common.loot_tables.loot_table_food",
1 => "common.loot_tables.loot_table_wendigo", 1 => "common.loot_tables.loot_table_wendigo",
2 => "common.loot_tables.loot_table_weapon_uncommon", 2 => "common.loot_tables.loot_table_weapon_uncommon",
_ => "common.loot_tables.loot_table_cave_large", _ => "common.loot_tables.loot_table_cave_large",
}, },
biped_large::Species::Troll => match rng.gen_range(0, 10) { biped_large::Species::Troll => match rng.gen_range(0..10) {
0 => "common.loot_tables.loot_table_food", 0 => "common.loot_tables.loot_table_food",
1 => "common.loot_tables.loot_table_cave_large", 1 => "common.loot_tables.loot_table_cave_large",
2 => "common.loot_tables.loot_table_weapon_uncommon", 2 => "common.loot_tables.loot_table_weapon_uncommon",
@ -369,13 +369,13 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc
biped_large::Species::Occultsaurok biped_large::Species::Occultsaurok
| biped_large::Species::Mightysaurok | biped_large::Species::Mightysaurok
| biped_large::Species::Slysaurok => "common.loot_tables.loot_table_saurok", | biped_large::Species::Slysaurok => "common.loot_tables.loot_table_saurok",
_ => match rng.gen_range(0, 4) { _ => match rng.gen_range(0..4) {
0 => "common.loot_tables.loot_table_food", 0 => "common.loot_tables.loot_table_food",
1 => "common.loot_tables.loot_table_armor_nature", 1 => "common.loot_tables.loot_table_armor_nature",
_ => "common.loot_tables.loot_table_cave_large", _ => "common.loot_tables.loot_table_cave_large",
}, },
}, },
Some(common::comp::Body::Golem(_)) => match rng.gen_range(0, 9) { Some(common::comp::Body::Golem(_)) => match rng.gen_range(0..9) {
0 => "common.loot_tables.loot_table_food", 0 => "common.loot_tables.loot_table_food",
2 => "common.loot_tables.loot_table_armor_light", 2 => "common.loot_tables.loot_table_armor_light",
3 => "common.loot_tables.loot_table_armor_heavy", 3 => "common.loot_tables.loot_table_armor_heavy",
@ -387,7 +387,7 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc
Some(common::comp::Body::Theropod(theropod)) => match theropod.species { Some(common::comp::Body::Theropod(theropod)) => match theropod.species {
theropod::Species::Sandraptor theropod::Species::Sandraptor
| theropod::Species::Snowraptor | theropod::Species::Snowraptor
| theropod::Species::Woodraptor => match rng.gen_range(0, 3) { | theropod::Species::Woodraptor => match rng.gen_range(0..3) {
0 => "common.loot_tables.loot_table_raptor", 0 => "common.loot_tables.loot_table_raptor",
_ => "common.loot_tables.loot_table_animal_parts", _ => "common.loot_tables.loot_table_animal_parts",
}, },
@ -399,7 +399,7 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc
quadruped_low::Species::Maneater => { quadruped_low::Species::Maneater => {
"common.loot_tables.loot_table_maneater" "common.loot_tables.loot_table_maneater"
}, },
_ => match rng.gen_range(0, 3) { _ => match rng.gen_range(0..3) {
0 => "common.loot_tables.loot_table_food", 0 => "common.loot_tables.loot_table_food",
1 => "common.loot_tables.loot_table_animal_parts", 1 => "common.loot_tables.loot_table_animal_parts",
_ => "common.loot_tables.loot_table", _ => "common.loot_tables.loot_table",

View File

@ -515,9 +515,9 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
for (pos, vel, ori, kind) in thrown_items { for (pos, vel, ori, kind) in thrown_items {
let vel = match kind { let vel = match kind {
item::Throwable::Firework(_) => Vec3::new( item::Throwable::Firework(_) => Vec3::new(
rng.gen_range(-15.0, 15.0), rng.gen_range(-15.0..15.0),
rng.gen_range(-15.0, 15.0), rng.gen_range(-15.0..15.0),
rng.gen_range(80.0, 110.0), rng.gen_range(80.0..110.0),
), ),
_ => { _ => {
vel.0 vel.0

View File

@ -76,7 +76,7 @@ impl Entity {
.unwrap(), .unwrap(),
); );
let back = match rng.gen_range(0, 5) { let back = match rng.gen_range(0..5) {
0 => Some(comp::Item::new_from_asset_expect( 0 => Some(comp::Item::new_from_asset_expect(
"common.items.armor.back.leather_adventurer", "common.items.armor.back.leather_adventurer",
)), )),
@ -92,7 +92,7 @@ impl Entity {
_ => None, _ => None,
}; };
let lantern = match rng.gen_range(0, 3) { let lantern = match rng.gen_range(0..3) {
0 => Some(comp::Item::new_from_asset_expect( 0 => Some(comp::Item::new_from_asset_expect(
"common.items.lantern.black_0", "common.items.lantern.black_0",
)), )),
@ -133,7 +133,7 @@ impl Entity {
comp::Body::Humanoid(_) => s.1.is_settlement() | s.1.is_castle(), comp::Body::Humanoid(_) => s.1.is_settlement() | s.1.is_castle(),
_ => s.1.is_dungeon(), _ => s.1.is_dungeon(),
}) })
.filter(|_| thread_rng().gen_range(0i32, 4) == 0) .filter(|_| thread_rng().gen_range(0i32..4) == 0)
.min_by_key(|(_, site)| { .min_by_key(|(_, site)| {
let wpos = site.center * TerrainChunk::RECT_SIZE.map(|e| e as i32); let wpos = site.center * TerrainChunk::RECT_SIZE.map(|e| e as i32);
let dist = wpos.map(|e| e as f32).distance(self.pos.xy()) as u32; let dist = wpos.map(|e| e as f32).distance(self.pos.xy()) as u32;

View File

@ -93,7 +93,7 @@ pub fn init(state: &mut State, #[cfg(feature = "worldgen")] world: &world::World
.chunks .chunks
.size() .size()
.map2(TerrainChunk::RECT_SIZE, |sz, chunk_sz| { .map2(TerrainChunk::RECT_SIZE, |sz, chunk_sz| {
thread_rng().gen_range(0, sz * chunk_sz) as i32 thread_rng().gen_range(0..sz * chunk_sz) as i32
}); });
rtsim.entities.insert(Entity { rtsim.entities.insert(Entity {

View File

@ -125,8 +125,8 @@ impl StateExt for State {
.with(comp::Vel(Vec3::zero())) .with(comp::Vel(Vec3::zero()))
.with(comp::Ori(Dir::new( .with(comp::Ori(Dir::new(
Vec3::new( Vec3::new(
thread_rng().gen_range(-1.0, 1.0), thread_rng().gen_range(-1.0..1.0),
thread_rng().gen_range(-1.0, 1.0), thread_rng().gen_range(-1.0..1.0),
0.0, 0.0,
) )
.try_normalized() .try_normalized()

View File

@ -77,7 +77,7 @@ lazy_static = "1.4.0"
native-dialog = { version = "0.4.2", default-features = false, optional = true } native-dialog = { version = "0.4.2", default-features = false, optional = true }
num = "0.3.1" num = "0.3.1"
ordered-float = { version = "2.0.1", default-features = false } ordered-float = { version = "2.0.1", default-features = false }
rand = "0.7" rand = "0.8"
rodio = {version = "0.13", default-features = false, features = ["wav", "vorbis"]} rodio = {version = "0.13", default-features = false, features = ["wav", "vorbis"]}
ron = {version = "0.6", default-features = false} ron = {version = "0.6", default-features = false}
serde = {version = "1.0", features = [ "rc", "derive" ]} serde = {version = "1.0", features = [ "rc", "derive" ]}

View File

@ -150,7 +150,7 @@ impl MusicMgr {
let mut rng = thread_rng(); let mut rng = thread_rng();
// Adds a bit of randomness between plays // Adds a bit of randomness between plays
let silence_between_tracks_seconds: f32 = rng.gen_range(45.0, 120.0); let silence_between_tracks_seconds: f32 = rng.gen_range(45.0..120.0);
let game_time = (state.get_time_of_day() as u64 % 86400) as u32; let game_time = (state.get_time_of_day() as u64 % 86400) as u32;
let current_period_of_day = Self::get_current_day_period(game_time); let current_period_of_day = Self::get_current_day_period(game_time);

View File

@ -322,7 +322,7 @@ impl SfxMgr {
"voxygen.audio.sfx.abilities.arrow_shot_2", "voxygen.audio.sfx.abilities.arrow_shot_2",
"voxygen.audio.sfx.abilities.arrow_shot_3", "voxygen.audio.sfx.abilities.arrow_shot_3",
"voxygen.audio.sfx.abilities.arrow_shot_4", "voxygen.audio.sfx.abilities.arrow_shot_4",
][rand::thread_rng().gen_range(1, 4)]; ][rand::thread_rng().gen_range(1..4)];
audio.play_sfx(file_ref, *pos, None); audio.play_sfx(file_ref, *pos, None);
}, },
@ -334,7 +334,7 @@ impl SfxMgr {
let file_ref = vec![ let file_ref = vec![
"voxygen.audio.sfx.abilities.fire_shot_1", "voxygen.audio.sfx.abilities.fire_shot_1",
"voxygen.audio.sfx.abilities.fire_shot_2", "voxygen.audio.sfx.abilities.fire_shot_2",
][rand::thread_rng().gen_range(1, 2)]; ][rand::thread_rng().gen_range(1..2)];
audio.play_sfx(file_ref, *pos, None); audio.play_sfx(file_ref, *pos, None);
}, },

View File

@ -1272,13 +1272,13 @@ impl Controls {
let body_type = body.body_type; let body_type = body.body_type;
let species = body.species; let species = body.species;
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
body.hair_style = rng.gen_range(0, species.num_hair_styles(body_type)); body.hair_style = rng.gen_range(0..species.num_hair_styles(body_type));
body.beard = rng.gen_range(0, species.num_beards(body_type)); body.beard = rng.gen_range(0..species.num_beards(body_type));
body.accessory = rng.gen_range(0, species.num_accessories(body_type)); body.accessory = rng.gen_range(0..species.num_accessories(body_type));
body.hair_color = rng.gen_range(0, species.num_hair_colors()); body.hair_color = rng.gen_range(0..species.num_hair_colors());
body.skin = rng.gen_range(0, species.num_skin_colors()); body.skin = rng.gen_range(0..species.num_skin_colors());
body.eye_color = rng.gen_range(0, species.num_eye_colors()); body.eye_color = rng.gen_range(0..species.num_eye_colors());
body.eyes = rng.gen_range(0, species.num_eyes(body_type)); body.eyes = rng.gen_range(0..species.num_eyes(body_type));
*name = npc::get_npc_name( *name = npc::get_npc_name(
npc::NpcKind::Humanoid, npc::NpcKind::Humanoid,
npc::BodyType::from_body(comp::Body::Humanoid(*body)), npc::BodyType::from_body(comp::Body::Humanoid(*body)),

View File

@ -71,7 +71,7 @@ impl ParticleMgr {
time, time,
ParticleMode::EnergyNature, ParticleMode::EnergyNature,
*pos + Vec3::<f32>::zero() *pos + Vec3::<f32>::zero()
.map(|_| rng.gen_range(-1.0, 1.0)) .map(|_| rng.gen_range(-1.0..1.0))
.normalized() .normalized()
* *radius, * *radius,
) )
@ -86,7 +86,7 @@ impl ParticleMgr {
time, time,
ParticleMode::CampfireFire, ParticleMode::CampfireFire,
*pos + Vec3::<f32>::zero() *pos + Vec3::<f32>::zero()
.map(|_| rng.gen_range(-1.0, 1.0)) .map(|_| rng.gen_range(-1.0..1.0))
.normalized() .normalized()
* *radius, * *radius,
) )
@ -121,7 +121,7 @@ impl ParticleMgr {
time, time,
ParticleMode::CampfireSmoke, ParticleMode::CampfireSmoke,
*pos + Vec3::<f32>::zero() *pos + Vec3::<f32>::zero()
.map(|_| rng.gen_range(-1.0, 1.0)) .map(|_| rng.gen_range(-1.0..1.0))
.normalized() .normalized()
* *radius, * *radius,
) )
@ -221,7 +221,7 @@ impl ParticleMgr {
Duration::from_secs(10), Duration::from_secs(10),
time, time,
ParticleMode::CampfireSmoke, ParticleMode::CampfireSmoke,
pos.0.map(|e| e + thread_rng().gen_range(-0.25, 0.25)), pos.0.map(|e| e + thread_rng().gen_range(-0.25..0.25)),
)); ));
} }
} }
@ -396,7 +396,7 @@ impl ParticleMgr {
// Emit a light when using flames // Emit a light when using flames
lights.push(Light::new( lights.push(Light::new(
pos.0 + b.offset, pos.0 + b.offset,
Rgb::new(1.0, 0.25, 0.05).map(|e| e * rng.gen_range(0.8, 1.2)), Rgb::new(1.0, 0.25, 0.05).map(|e| e * rng.gen_range(0.8..1.2)),
2.0, 2.0,
)); ));
self.particles.resize_with( self.particles.resize_with(
@ -406,8 +406,8 @@ impl ParticleMgr {
), ),
|| { || {
let phi: f32 = let phi: f32 =
rng.gen_range(0.0, b.static_data.max_angle.to_radians()); rng.gen_range(0.0..b.static_data.max_angle.to_radians());
let theta: f32 = rng.gen_range(0.0, 2.0 * PI); let theta: f32 = rng.gen_range(0.0..2.0 * PI);
let offset_z = Vec3::new( let offset_z = Vec3::new(
phi.sin() * theta.cos(), phi.sin() * theta.cos(),
phi.sin() * theta.sin(), phi.sin() * theta.sin(),

View File

@ -50,17 +50,17 @@ impl BlocksOfInterest {
.for_each(|(pos, block)| { .for_each(|(pos, block)| {
match block.kind() { match block.kind() {
BlockKind::Leaves => { BlockKind::Leaves => {
if thread_rng().gen_range(0, 16) == 0 { if thread_rng().gen_range(0..16) == 0 {
leaves.push(pos) leaves.push(pos)
} }
}, },
BlockKind::Grass => { BlockKind::Grass => {
if thread_rng().gen_range(0, 16) == 0 { if thread_rng().gen_range(0..16) == 0 {
grass.push(pos) grass.push(pos)
} }
}, },
BlockKind::Water => { BlockKind::Water => {
if chunk.meta().contains_river() && thread_rng().gen_range(0, 16) == 0 { if chunk.meta().contains_river() && thread_rng().gen_range(0..16) == 0 {
river.push(pos) river.push(pos)
} }
}, },

View File

@ -24,8 +24,8 @@ ordered-float = "2.0.1"
hashbrown = { version = "0.9", features = ["rayon", "serde", "nightly"] } hashbrown = { version = "0.9", features = ["rayon", "serde", "nightly"] }
lazy_static = "1.4.0" lazy_static = "1.4.0"
tracing = { version = "0.1", default-features = false } tracing = { version = "0.1", default-features = false }
rand = "0.7" rand = "0.8"
rand_chacha = "0.2.1" rand_chacha = "0.3"
arr_macro = "0.1.2" arr_macro = "0.1.2"
packed_simd = { version = "0.3.4", package = "packed_simd_2" } packed_simd = { version = "0.3.4", package = "packed_simd_2" }
rayon = "1.5" rayon = "1.5"

View File

@ -24,7 +24,7 @@ pub struct Belief {
impl Belief { impl Belief {
pub fn choose_price(&self, ctx: &mut GenCtx<impl Rng>) -> f32 { pub fn choose_price(&self, ctx: &mut GenCtx<impl Rng>) -> f32 {
self.price + ctx.rng.gen_range(-1.0, 1.0) * self.confidence self.price + ctx.rng.gen_range(-1.0..1.0) * self.confidence
} }
pub fn update_buyer(&mut self, _years: f32, new_price: f32) { pub fn update_buyer(&mut self, _years: f32, new_price: f32) {

View File

@ -105,7 +105,7 @@ impl Civs {
for _ in 0..initial_civ_count * 3 { for _ in 0..initial_civ_count * 3 {
attempt(5, || { attempt(5, || {
let (kind, size) = match ctx.rng.gen_range(0, 8) { let (kind, size) = match ctx.rng.gen_range(0..8) {
0 => (SiteKind::Castle, 3), 0 => (SiteKind::Castle, 3),
_ => (SiteKind::Dungeon, 0), _ => (SiteKind::Dungeon, 0),
}; };
@ -188,7 +188,7 @@ impl Civs {
chunk.basement += diff; chunk.basement += diff;
chunk.rockiness = 0.0; chunk.rockiness = 0.0;
chunk.warp_factor = 0.0; chunk.warp_factor = 0.0;
chunk.surface_veg *= 1.0 - factor * rng.gen_range(0.25, 0.9); chunk.surface_veg *= 1.0 - factor * rng.gen_range(0.25..0.9);
}); });
} }
} }
@ -241,7 +241,7 @@ impl Civs {
let mut pos = ctx let mut pos = ctx
.sim .sim
.get_size() .get_size()
.map(|sz| ctx.rng.gen_range(0, sz as i32) as f32); .map(|sz| ctx.rng.gen_range(0..sz as i32) as f32);
let mut vel = pos let mut vel = pos
.map2(ctx.sim.get_size(), |pos, sz| sz as f32 / 2.0 - pos) .map2(ctx.sim.get_size(), |pos, sz| sz as f32 / 2.0 - pos)
.try_normalized() .try_normalized()
@ -252,8 +252,8 @@ impl Civs {
let depth = (i.abs() as f32 / 100.0 * std::f32::consts::PI / 2.0).cos(); let depth = (i.abs() as f32 / 100.0 * std::f32::consts::PI / 2.0).cos();
vel = (vel vel = (vel
+ Vec2::new( + Vec2::new(
ctx.rng.gen_range(-0.35, 0.35), ctx.rng.gen_range(-0.35..0.35),
ctx.rng.gen_range(-0.35, 0.35), ctx.rng.gen_range(-0.35..0.35),
)) ))
.try_normalized() .try_normalized()
.unwrap_or_else(Vec2::unit_y); .unwrap_or_else(Vec2::unit_y);
@ -290,9 +290,9 @@ impl Civs {
let mut chunk = ctx.sim.get_mut(loc.0).unwrap(); let mut chunk = ctx.sim.get_mut(loc.0).unwrap();
let depth = loc.1 * 250.0 - 20.0; let depth = loc.1 * 250.0 - 20.0;
chunk.cave.1.alt = chunk.cave.1.alt =
chunk.alt - depth + ctx.rng.gen_range(-4.0, 4.0) * (depth > 10.0) as i32 as f32; chunk.alt - depth + ctx.rng.gen_range(-4.0..4.0) * (depth > 10.0) as i32 as f32;
chunk.cave.1.width = ctx.rng.gen_range(6.0, 32.0); chunk.cave.1.width = ctx.rng.gen_range(6.0..32.0);
chunk.cave.0.offset = Vec2::new(ctx.rng.gen_range(-16, 17), ctx.rng.gen_range(-16, 17)); chunk.cave.0.offset = Vec2::new(ctx.rng.gen_range(-16..17), ctx.rng.gen_range(-16..17));
if chunk.cave.1.alt + chunk.cave.1.width + 5.0 > chunk.alt { if chunk.cave.1.alt + chunk.cave.1.width + 5.0 > chunk.alt {
chunk.spawn_rate = 0.0; chunk.spawn_rate = 0.0;
@ -305,7 +305,7 @@ impl Civs {
), ),
name: { name: {
let name = NameGen::location(&mut ctx.rng).generate(); let name = NameGen::location(&mut ctx.rng).generate();
match ctx.rng.gen_range(0, 7) { match ctx.rng.gen_range(0..7) {
0 => format!("{} Hole", name), 0 => format!("{} Hole", name),
1 => format!("{} Cavern", name), 1 => format!("{} Cavern", name),
2 => format!("{} Hollow", name), 2 => format!("{} Hollow", name),
@ -544,7 +544,7 @@ impl Civs {
chunk.path.0.neighbors |= chunk.path.0.neighbors |=
(1 << (to_prev_idx as u8)) | (1 << (to_next_idx as u8)); (1 << (to_prev_idx as u8)) | (1 << (to_next_idx as u8));
chunk.path.0.offset = chunk.path.0.offset =
Vec2::new(ctx.rng.gen_range(-16, 17), ctx.rng.gen_range(-16, 17)); Vec2::new(ctx.rng.gen_range(-16..17), ctx.rng.gen_range(-16..17));
} }
// Take note of the track // Take note of the track
@ -735,7 +735,7 @@ fn find_site_loc(
let test_loc = loc.unwrap_or_else(|| match near { let test_loc = loc.unwrap_or_else(|| match near {
Some((origin, dist)) => { Some((origin, dist)) => {
origin origin
+ (Vec2::new(ctx.rng.gen_range(-1.0, 1.0), ctx.rng.gen_range(-1.0, 1.0)) + (Vec2::new(ctx.rng.gen_range(-1.0..1.0), ctx.rng.gen_range(-1.0..1.0))
.try_normalized() .try_normalized()
.unwrap_or(Vec2::zero()) .unwrap_or(Vec2::zero())
* ctx.rng.gen::<f32>() * ctx.rng.gen::<f32>()
@ -743,8 +743,8 @@ fn find_site_loc(
.map(|e| e as i32) .map(|e| e as i32)
}, },
None => Vec2::new( None => Vec2::new(
ctx.rng.gen_range(0, ctx.sim.get_size().x as i32), ctx.rng.gen_range(0..ctx.sim.get_size().x as i32),
ctx.rng.gen_range(0, ctx.sim.get_size().y as i32), ctx.rng.gen_range(0..ctx.sim.get_size().y as i32),
), ),
}); });

View File

@ -239,10 +239,10 @@ pub fn apply_caves_supplement<'a>(
wpos2d.y as f32, wpos2d.y as f32,
cave_base as f32, cave_base as f32,
)) ))
.with_body(match dynamic_rng.gen_range(0, 5) { .with_body(match dynamic_rng.gen_range(0..5) {
0 => { 0 => {
is_hostile = false; is_hostile = false;
let species = match dynamic_rng.gen_range(0, 4) { let species = match dynamic_rng.gen_range(0..4) {
0 => comp::quadruped_small::Species::Truffler, 0 => comp::quadruped_small::Species::Truffler,
1 => comp::quadruped_small::Species::Dodarock, 1 => comp::quadruped_small::Species::Dodarock,
2 => comp::quadruped_small::Species::Holladon, 2 => comp::quadruped_small::Species::Holladon,
@ -252,7 +252,7 @@ pub fn apply_caves_supplement<'a>(
}, },
1 => { 1 => {
is_hostile = true; is_hostile = true;
let species = match dynamic_rng.gen_range(0, 2) { let species = match dynamic_rng.gen_range(0..2) {
0 => comp::quadruped_medium::Species::Tarasque, 0 => comp::quadruped_medium::Species::Tarasque,
_ => comp::quadruped_medium::Species::Bonerattler, _ => comp::quadruped_medium::Species::Bonerattler,
}; };
@ -260,7 +260,7 @@ pub fn apply_caves_supplement<'a>(
}, },
2 => { 2 => {
is_hostile = true; is_hostile = true;
let species = match dynamic_rng.gen_range(0, 3) { let species = match dynamic_rng.gen_range(0..3) {
0 => comp::quadruped_low::Species::Rocksnapper, 0 => comp::quadruped_low::Species::Rocksnapper,
1 => comp::quadruped_low::Species::Lavadrake, 1 => comp::quadruped_low::Species::Lavadrake,
_ => comp::quadruped_low::Species::Salamander, _ => comp::quadruped_low::Species::Salamander,
@ -269,7 +269,7 @@ pub fn apply_caves_supplement<'a>(
}, },
3 => { 3 => {
is_hostile = true; is_hostile = true;
let species = match dynamic_rng.gen_range(0, 5) { let species = match dynamic_rng.gen_range(0..5) {
0 => comp::theropod::Species::Sandraptor, 0 => comp::theropod::Species::Sandraptor,
1 => comp::theropod::Species::Snowraptor, 1 => comp::theropod::Species::Snowraptor,
2 => comp::theropod::Species::Woodraptor, 2 => comp::theropod::Species::Woodraptor,
@ -280,7 +280,7 @@ pub fn apply_caves_supplement<'a>(
}, },
_ => { _ => {
is_hostile = true; is_hostile = true;
let species = match dynamic_rng.gen_range(0, 4) { let species = match dynamic_rng.gen_range(0..4) {
0 => comp::biped_large::Species::Ogre, 0 => comp::biped_large::Species::Ogre,
1 => comp::biped_large::Species::Cyclops, 1 => comp::biped_large::Species::Cyclops,
2 => comp::biped_large::Species::Wendigo, 2 => comp::biped_large::Species::Wendigo,

View File

@ -41,7 +41,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
Entry { Entry {
make_entity: |pos, rng| { make_entity: |pos, rng| {
EntityInfo::at(pos) EntityInfo::at(pos)
.with_body(match rng.gen_range(0, 3) { .with_body(match rng.gen_range(0..3) {
0 => quadruped_medium::Body::random_with( 0 => quadruped_medium::Body::random_with(
rng, rng,
&quadruped_medium::Species::Frostfang, &quadruped_medium::Species::Frostfang,
@ -71,7 +71,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
Entry { Entry {
make_entity: |pos, rng| { make_entity: |pos, rng| {
EntityInfo::at(pos) EntityInfo::at(pos)
.with_body(match rng.gen_range(0, 2) { .with_body(match rng.gen_range(0..2) {
0 => { 0 => {
theropod::Body::random_with(rng, &theropod::Species::Snowraptor).into() theropod::Body::random_with(rng, &theropod::Species::Snowraptor).into()
}, },
@ -150,7 +150,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
Entry { Entry {
make_entity: |pos, rng| { make_entity: |pos, rng| {
EntityInfo::at(pos) EntityInfo::at(pos)
.with_body(match rng.gen_range(0, 5) { .with_body(match rng.gen_range(0..5) {
0 => { 0 => {
bird_medium::Body::random_with(rng, &bird_medium::Species::Eagle).into() bird_medium::Body::random_with(rng, &bird_medium::Species::Eagle).into()
}, },
@ -195,7 +195,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
Entry { Entry {
make_entity: |pos, rng| { make_entity: |pos, rng| {
EntityInfo::at(pos) EntityInfo::at(pos)
.with_body(match rng.gen_range(0, 3) { .with_body(match rng.gen_range(0..3) {
0 => quadruped_medium::Body::random_with( 0 => quadruped_medium::Body::random_with(
rng, rng,
&quadruped_medium::Species::Tarasque, &quadruped_medium::Species::Tarasque,
@ -222,7 +222,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
Entry { Entry {
make_entity: |pos, rng| { make_entity: |pos, rng| {
EntityInfo::at(pos) EntityInfo::at(pos)
.with_body(match rng.gen_range(0, 11) { .with_body(match rng.gen_range(0..11) {
0 => quadruped_medium::Body::random_with( 0 => quadruped_medium::Body::random_with(
rng, rng,
&quadruped_medium::Species::Deer, &quadruped_medium::Species::Deer,
@ -288,7 +288,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
Entry { Entry {
make_entity: |pos, rng| { make_entity: |pos, rng| {
EntityInfo::at(pos) EntityInfo::at(pos)
.with_body(match rng.gen_range(0, 13) { .with_body(match rng.gen_range(0..13) {
0 => quadruped_small::Body { 0 => quadruped_small::Body {
species: quadruped_small::Species::Fox, species: quadruped_small::Species::Fox,
body_type: quadruped_small::BodyType::Male, body_type: quadruped_small::BodyType::Male,
@ -365,7 +365,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
Entry { Entry {
make_entity: |pos, rng| { make_entity: |pos, rng| {
EntityInfo::at(pos) EntityInfo::at(pos)
.with_body(match rng.gen_range(0, 3) { .with_body(match rng.gen_range(0..3) {
0 => { 0 => {
biped_large::Body::random_with(rng, &biped_large::Species::Ogre).into() biped_large::Body::random_with(rng, &biped_large::Species::Ogre).into()
}, },
@ -385,7 +385,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
Entry { Entry {
make_entity: |pos, rng| { make_entity: |pos, rng| {
EntityInfo::at(pos) EntityInfo::at(pos)
.with_body(match rng.gen_range(0, 3) { .with_body(match rng.gen_range(0..3) {
0 => quadruped_small::Body::random_with( 0 => quadruped_small::Body::random_with(
rng, rng,
&quadruped_small::Species::Beaver, &quadruped_small::Species::Beaver,
@ -457,7 +457,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
Entry { Entry {
make_entity: |pos, rng| { make_entity: |pos, rng| {
EntityInfo::at(pos) EntityInfo::at(pos)
.with_body(match rng.gen_range(0, 2) { .with_body(match rng.gen_range(0..2) {
0 => { 0 => {
quadruped_low::Body::random_with(rng, &quadruped_low::Species::Maneater) quadruped_low::Body::random_with(rng, &quadruped_low::Species::Maneater)
.into() .into()
@ -483,7 +483,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
Entry { Entry {
make_entity: |pos, rng| { make_entity: |pos, rng| {
EntityInfo::at(pos) EntityInfo::at(pos)
.with_body(match rng.gen_range(0, 4) { .with_body(match rng.gen_range(0..4) {
0 => theropod::Body::random_with(rng, &theropod::Species::Odonto).into(), 0 => theropod::Body::random_with(rng, &theropod::Species::Odonto).into(),
1 => { 1 => {
biped_large::Body::random_with(rng, &biped_large::Species::Mightysaurok) biped_large::Body::random_with(rng, &biped_large::Species::Mightysaurok)
@ -511,7 +511,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
Entry { Entry {
make_entity: |pos, rng| { make_entity: |pos, rng| {
EntityInfo::at(pos) EntityInfo::at(pos)
.with_body(match rng.gen_range(0, 4) { .with_body(match rng.gen_range(0..4) {
0 => bird_medium::Body::random_with(rng, &bird_medium::Species::Parrot) 0 => bird_medium::Body::random_with(rng, &bird_medium::Species::Parrot)
.into(), .into(),
1 => { 1 => {
@ -561,7 +561,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
Entry { Entry {
make_entity: |pos, rng| { make_entity: |pos, rng| {
EntityInfo::at(pos) EntityInfo::at(pos)
.with_body(match rng.gen_range(0, 3) { .with_body(match rng.gen_range(0..3) {
0 => { 0 => {
quadruped_small::Body::random_with(rng, &quadruped_small::Species::Frog) quadruped_small::Body::random_with(rng, &quadruped_small::Species::Frog)
.into() .into()
@ -594,7 +594,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
Entry { Entry {
make_entity: |pos, rng| { make_entity: |pos, rng| {
EntityInfo::at(pos) EntityInfo::at(pos)
.with_body(match rng.gen_range(0, 2) { .with_body(match rng.gen_range(0..2) {
0 => quadruped_medium::Body::random_with( 0 => quadruped_medium::Body::random_with(
rng, rng,
&quadruped_medium::Species::Lion, &quadruped_medium::Species::Lion,
@ -621,7 +621,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
Entry { Entry {
make_entity: |pos, rng| { make_entity: |pos, rng| {
EntityInfo::at(pos) EntityInfo::at(pos)
.with_body(match rng.gen_range(0, 2) { .with_body(match rng.gen_range(0..2) {
0 => quadruped_medium::Body::random_with( 0 => quadruped_medium::Body::random_with(
rng, rng,
&quadruped_medium::Species::Zebra, &quadruped_medium::Species::Zebra,
@ -648,7 +648,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
Entry { Entry {
make_entity: |pos, rng| { make_entity: |pos, rng| {
EntityInfo::at(pos) EntityInfo::at(pos)
.with_body(match rng.gen_range(0, 2) { .with_body(match rng.gen_range(0..2) {
0 => quadruped_medium::Body::random_with( 0 => quadruped_medium::Body::random_with(
rng, rng,
&quadruped_medium::Species::Bonerattler, &quadruped_medium::Species::Bonerattler,
@ -678,7 +678,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
Entry { Entry {
make_entity: |pos, rng| { make_entity: |pos, rng| {
EntityInfo::at(pos) EntityInfo::at(pos)
.with_body(match rng.gen_range(0, 2) { .with_body(match rng.gen_range(0..2) {
0 => quadruped_low::Body::random_with( 0 => quadruped_low::Body::random_with(
rng, rng,
&quadruped_low::Species::Lavadrake, &quadruped_low::Species::Lavadrake,
@ -744,7 +744,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
Entry { Entry {
make_entity: |pos, rng| { make_entity: |pos, rng| {
EntityInfo::at(pos) EntityInfo::at(pos)
.with_body(match rng.gen_range(0, 6) { .with_body(match rng.gen_range(0..6) {
0 => quadruped_small::Body::random_with( 0 => quadruped_small::Body::random_with(
rng, rng,
&quadruped_small::Species::Holladon, &quadruped_small::Species::Holladon,
@ -787,7 +787,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
Entry { Entry {
make_entity: |pos, rng| { make_entity: |pos, rng| {
EntityInfo::at(pos) EntityInfo::at(pos)
.with_body(match rng.gen_range(0, 2) { .with_body(match rng.gen_range(0..2) {
0 => fish_medium::Body::random_with(rng, &fish_medium::Species::Marlin) 0 => fish_medium::Body::random_with(rng, &fish_medium::Species::Marlin)
.into(), .into(),
_ => fish_small::Body::random_with(rng, &fish_small::Species::Clownfish) _ => fish_small::Body::random_with(rng, &fish_small::Species::Clownfish)
@ -859,7 +859,7 @@ pub fn apply_wildlife_supplement<'a, R: Rng>(
}) })
}) })
{ {
let group_size = dynamic_rng.gen_range(group_size.start, group_size.end); let group_size = dynamic_rng.gen_range(group_size.start..group_size.end);
let entity = make_entity( let entity = make_entity(
Vec3::new(wpos2d.x, wpos2d.y, alt + solid_end).map(|e| e as f32), Vec3::new(wpos2d.x, wpos2d.y, alt + solid_end).map(|e| e as f32),
dynamic_rng, dynamic_rng,

View File

@ -61,16 +61,16 @@ impl Castle {
pub fn generate(wpos: Vec2<i32>, sim: Option<&mut WorldSim>, rng: &mut impl Rng) -> Self { pub fn generate(wpos: Vec2<i32>, sim: Option<&mut WorldSim>, rng: &mut impl Rng) -> Self {
let ctx = GenCtx { sim, rng }; let ctx = GenCtx { sim, rng };
let boundary_towers = ctx.rng.gen_range(5, 10); let boundary_towers = ctx.rng.gen_range(5..10);
let keep_count = ctx.rng.gen_range(1, 4); let keep_count = ctx.rng.gen_range(1..4);
let boundary_noise = ctx.rng.gen_range(-2i32, 8).max(1) as f32; let boundary_noise = ctx.rng.gen_range(-2i32..8).max(1) as f32;
let radius = 150; let radius = 150;
let this = Self { let this = Self {
name: { name: {
let name = NameGen::location(ctx.rng).generate(); let name = NameGen::location(ctx.rng).generate();
match ctx.rng.gen_range(0, 6) { match ctx.rng.gen_range(0..6) {
0 => format!("Fort {}", name), 0 => format!("Fort {}", name),
1 => format!("{} Citadel", name), 1 => format!("{} Citadel", name),
2 => format!("{} Castle", name), 2 => format!("{} Castle", name),
@ -108,7 +108,7 @@ impl Castle {
break; break;
} }
offset = (dir * dist) offset = (dir * dist)
.map(|e| (e + ctx.rng.gen_range(-1.0, 1.0) * i as f32) as i32); .map(|e| (e + ctx.rng.gen_range(-1.0..1.0) * i as f32) as i32);
} }
Tower { Tower {
@ -133,9 +133,9 @@ impl Castle {
let dist = let dist =
(radius as f32 + ((angle * boundary_noise).sin() - 1.0) * 40.0) * 0.3; (radius as f32 + ((angle * boundary_noise).sin() - 1.0) * 40.0) * 0.3;
let locus = ctx.rng.gen_range(20, 26); let locus = ctx.rng.gen_range(20..26);
let offset = (dir * dist).map(|e| e as i32); let offset = (dir * dist).map(|e| e as i32);
let storeys = ctx.rng.gen_range(1, 8).clamped(3, 5); let storeys = ctx.rng.gen_range(1..8).clamped(3, 5);
Keep { Keep {
offset, offset,

View File

@ -54,12 +54,12 @@ impl Dungeon {
#[allow(clippy::let_and_return)] // TODO: Pending review in #587 #[allow(clippy::let_and_return)] // TODO: Pending review in #587
pub fn generate(wpos: Vec2<i32>, sim: Option<&WorldSim>, rng: &mut impl Rng) -> Self { pub fn generate(wpos: Vec2<i32>, sim: Option<&WorldSim>, rng: &mut impl Rng) -> Self {
let mut ctx = GenCtx { sim, rng }; let mut ctx = GenCtx { sim, rng };
let difficulty = ctx.rng.gen_range(0, 6); let difficulty = ctx.rng.gen_range(0..6);
let floors = 3 + difficulty / 2; let floors = 3 + difficulty / 2;
let this = Self { let this = Self {
name: { name: {
let name = NameGen::location(ctx.rng).generate(); let name = NameGen::location(ctx.rng).generate();
match ctx.rng.gen_range(0, 5) { match ctx.rng.gen_range(0..5) {
0 => format!("{} Dungeon", name), 0 => format!("{} Dungeon", name),
1 => format!("{} Lair", name), 1 => format!("{} Lair", name),
2 => format!("{} Crib", name), 2 => format!("{} Crib", name),
@ -276,7 +276,7 @@ impl Floor {
Vec2::zero() Vec2::zero()
} else { } else {
std::iter::from_fn(|| { std::iter::from_fn(|| {
Some(FLOOR_SIZE.map(|sz| ctx.rng.gen_range(-sz / 2 + 2, sz / 2 - 1))) Some(FLOOR_SIZE.map(|sz| ctx.rng.gen_range(-sz / 2 + 2..sz / 2 - 1)))
}) })
.filter(|pos| *pos != stair_tile) .filter(|pos| *pos != stair_tile)
.take(8) .take(8)
@ -375,9 +375,9 @@ impl Floor {
for _ in 0..n { for _ in 0..n {
let area = match attempt(64, || { let area = match attempt(64, || {
let sz = Vec2::<i32>::zero().map(|_| ctx.rng.gen_range(dim_limits.0, dim_limits.1)); let sz = Vec2::<i32>::zero().map(|_| ctx.rng.gen_range(dim_limits.0..dim_limits.1));
let pos = FLOOR_SIZE.map2(sz, |floor_sz, room_sz| { let pos = FLOOR_SIZE.map2(sz, |floor_sz, room_sz| {
ctx.rng.gen_range(0, floor_sz + 1 - room_sz) ctx.rng.gen_range(0..floor_sz + 1 - room_sz)
}); });
let area = Rect::from((pos, Extent2::from(sz))); let area = Rect::from((pos, Extent2::from(sz)));
let area_border = Rect::from((pos - 1, Extent2::from(sz) + 2)); // The room, but with some personal space let area_border = Rect::from((pos - 1, Extent2::from(sz) + 2)); // The room, but with some personal space
@ -398,7 +398,7 @@ impl Floor {
}; };
let mut dynamic_rng = rand::thread_rng(); let mut dynamic_rng = rand::thread_rng();
match dynamic_rng.gen_range(0, 5) { match dynamic_rng.gen_range(0..5) {
0 => self.create_room(Room { 0 => self.create_room(Room {
seed: ctx.rng.gen(), seed: ctx.rng.gen(),
loot_density: 0.000025 + level as f32 * 0.00015, loot_density: 0.000025 + level as f32 * 0.00015,
@ -406,7 +406,7 @@ impl Floor {
miniboss: true, miniboss: true,
boss: false, boss: false,
area, area,
height: ctx.rng.gen_range(15, 20), height: ctx.rng.gen_range(15..20),
pillars: Some(4), pillars: Some(4),
difficulty: self.difficulty, difficulty: self.difficulty,
}), }),
@ -417,8 +417,8 @@ impl Floor {
miniboss: false, miniboss: false,
boss: false, boss: false,
area, area,
height: ctx.rng.gen_range(10, 15), height: ctx.rng.gen_range(10..15),
pillars: if ctx.rng.gen_range(0, 4) == 0 { pillars: if ctx.rng.gen_range(0..4) == 0 {
Some(4) Some(4)
} else { } else {
None None
@ -490,8 +490,8 @@ impl Floor {
if area.contains_point(stair_rcenter.xy()) { if area.contains_point(stair_rcenter.xy()) {
let offs = Vec2::new( let offs = Vec2::new(
dynamic_rng.gen_range(-1.0, 1.0), dynamic_rng.gen_range(-1.0..1.0),
dynamic_rng.gen_range(-1.0, 1.0), dynamic_rng.gen_range(-1.0..1.0),
) )
.try_normalized() .try_normalized()
.unwrap_or_else(Vec2::unit_y) .unwrap_or_else(Vec2::unit_y)
@ -529,35 +529,35 @@ impl Floor {
if room if room
.enemy_density .enemy_density
.map(|density| dynamic_rng.gen_range(0, density.recip() as usize) == 0) .map(|density| dynamic_rng.gen_range(0..density.recip() as usize) == 0)
.unwrap_or(false) .unwrap_or(false)
&& !tile_is_pillar && !tile_is_pillar
{ {
// Bad // Bad
let chosen = match room.difficulty { let chosen = match room.difficulty {
0 => { 0 => {
Lottery::<String>::load_expect(match dynamic_rng.gen_range(0, 4) { Lottery::<String>::load_expect(match dynamic_rng.gen_range(0..4) {
0 => "common.loot_tables.loot_table_humanoids", 0 => "common.loot_tables.loot_table_humanoids",
1 => "common.loot_tables.loot_table_armor_cloth", 1 => "common.loot_tables.loot_table_armor_cloth",
_ => "common.loot_tables.loot_table_weapon_common", _ => "common.loot_tables.loot_table_weapon_common",
}) })
}, },
1 => { 1 => {
Lottery::<String>::load_expect(match dynamic_rng.gen_range(0, 4) { Lottery::<String>::load_expect(match dynamic_rng.gen_range(0..4) {
0 => "common.loot_tables.loot_table_humanoids", 0 => "common.loot_tables.loot_table_humanoids",
1 => "common.loot_tables.loot_table_armor_light", 1 => "common.loot_tables.loot_table_armor_light",
_ => "common.loot_tables.loot_table_weapon_uncommon", _ => "common.loot_tables.loot_table_weapon_uncommon",
}) })
}, },
2 => { 2 => {
Lottery::<String>::load_expect(match dynamic_rng.gen_range(0, 4) { Lottery::<String>::load_expect(match dynamic_rng.gen_range(0..4) {
0 => "common.loot_tables.loot_table_humanoids", 0 => "common.loot_tables.loot_table_humanoids",
1 => "common.loot_tables.loot_table_armor_heavy", 1 => "common.loot_tables.loot_table_armor_heavy",
_ => "common.loot_tables.loot_table_weapon_rare", _ => "common.loot_tables.loot_table_weapon_rare",
}) })
}, },
3 => { 3 => {
Lottery::<String>::load_expect(match dynamic_rng.gen_range(0, 10) { Lottery::<String>::load_expect(match dynamic_rng.gen_range(0..10) {
0 => "common.loot_tables.loot_table_humanoids", 0 => "common.loot_tables.loot_table_humanoids",
1 => "common.loot_tables.loot_table_armor_heavy", 1 => "common.loot_tables.loot_table_armor_heavy",
2 => "common.loot_tables.loot_table_weapon_rare", 2 => "common.loot_tables.loot_table_weapon_rare",
@ -565,7 +565,7 @@ impl Floor {
}) })
}, },
4 => { 4 => {
Lottery::<String>::load_expect(match dynamic_rng.gen_range(0, 6) { Lottery::<String>::load_expect(match dynamic_rng.gen_range(0..6) {
0 => "common.loot_tables.loot_table_humanoids", 0 => "common.loot_tables.loot_table_humanoids",
1 => "common.loot_tables.loot_table_armor_misc", 1 => "common.loot_tables.loot_table_armor_misc",
2 => "common.loot_tables.loot_table_weapon_rare", 2 => "common.loot_tables.loot_table_weapon_rare",
@ -573,7 +573,7 @@ impl Floor {
}) })
}, },
5 => { 5 => {
Lottery::<String>::load_expect(match dynamic_rng.gen_range(0, 5) { Lottery::<String>::load_expect(match dynamic_rng.gen_range(0..5) {
0 => "common.loot_tables.loot_table_humanoids", 0 => "common.loot_tables.loot_table_humanoids",
1 => "common.loot_tables.loot_table_armor_misc", 1 => "common.loot_tables.loot_table_armor_misc",
2 => "common.loot_tables.loot_table_weapon_rare", 2 => "common.loot_tables.loot_table_weapon_rare",
@ -602,10 +602,7 @@ impl Floor {
.with_loadout_config(loadout_builder::LoadoutConfig::CultistAcolyte) .with_loadout_config(loadout_builder::LoadoutConfig::CultistAcolyte)
.with_skillset_config(common::skillset_builder::SkillSetConfig::CultistAcolyte) .with_skillset_config(common::skillset_builder::SkillSetConfig::CultistAcolyte)
.with_loot_drop(comp::Item::new_from_asset_expect(chosen)) .with_loot_drop(comp::Item::new_from_asset_expect(chosen))
.with_level(dynamic_rng.gen_range( .with_level(dynamic_rng.gen_range((room.difficulty as f32).powf(1.25) + 3.0..(room.difficulty as f32).powf(1.5) + 4.0).round() as u16);
(room.difficulty as f32).powf(1.25) + 3.0,
(room.difficulty as f32).powf(1.5) + 4.0,
).round() as u16);
let entity = match room.difficulty { let entity = match room.difficulty {
0 => entity 0 => entity
.with_name("Outcast") .with_name("Outcast")
@ -615,7 +612,7 @@ impl Floor {
) )
.with_loot_drop(comp::Item::new_from_asset_expect(chosen)) .with_loot_drop(comp::Item::new_from_asset_expect(chosen))
.with_main_tool(comp::Item::new_from_asset_expect( .with_main_tool(comp::Item::new_from_asset_expect(
match dynamic_rng.gen_range(0, 6) { match dynamic_rng.gen_range(0..6) {
0 => "common.items.weapons.axe.starter_axe", 0 => "common.items.weapons.axe.starter_axe",
1 => "common.items.weapons.sword.starter_sword", 1 => "common.items.weapons.sword.starter_sword",
2 => "common.items.weapons.sword.starter_sword", 2 => "common.items.weapons.sword.starter_sword",
@ -632,7 +629,7 @@ impl Floor {
) )
.with_loot_drop(comp::Item::new_from_asset_expect(chosen)) .with_loot_drop(comp::Item::new_from_asset_expect(chosen))
.with_main_tool(comp::Item::new_from_asset_expect( .with_main_tool(comp::Item::new_from_asset_expect(
match dynamic_rng.gen_range(0, 6) { match dynamic_rng.gen_range(0..6) {
0 => "common.items.weapons.axe.worn_iron_axe-0", 0 => "common.items.weapons.axe.worn_iron_axe-0",
1 => "common.items.weapons.sword.zweihander_sword_0", 1 => "common.items.weapons.sword.zweihander_sword_0",
2 => "common.items.weapons.sword.zweihander_sword_0", 2 => "common.items.weapons.sword.zweihander_sword_0",
@ -649,7 +646,7 @@ impl Floor {
) )
.with_loot_drop(comp::Item::new_from_asset_expect(chosen)) .with_loot_drop(comp::Item::new_from_asset_expect(chosen))
.with_main_tool(comp::Item::new_from_asset_expect( .with_main_tool(comp::Item::new_from_asset_expect(
match dynamic_rng.gen_range(0, 6) { match dynamic_rng.gen_range(0..6) {
0 => "common.items.weapons.axe.bronze_axe-0", 0 => "common.items.weapons.axe.bronze_axe-0",
1 => "common.items.weapons.sword.greatsword_2h_simple-0", 1 => "common.items.weapons.sword.greatsword_2h_simple-0",
2 => "common.items.weapons.sword.cultist_purp_2h-0", 2 => "common.items.weapons.sword.cultist_purp_2h-0",
@ -666,7 +663,7 @@ impl Floor {
) )
.with_loot_drop(comp::Item::new_from_asset_expect(chosen)) .with_loot_drop(comp::Item::new_from_asset_expect(chosen))
.with_main_tool(comp::Item::new_from_asset_expect( .with_main_tool(comp::Item::new_from_asset_expect(
match dynamic_rng.gen_range(0, 6) { match dynamic_rng.gen_range(0..6) {
0 => "common.items.weapons.axe.steel_axe-0", 0 => "common.items.weapons.axe.steel_axe-0",
1 => "common.items.weapons.sword.long_2h_orn-0", 1 => "common.items.weapons.sword.long_2h_orn-0",
2 => "common.items.weapons.sword.long_2h_orn-0", 2 => "common.items.weapons.sword.long_2h_orn-0",
@ -683,7 +680,7 @@ impl Floor {
) )
.with_loot_drop(comp::Item::new_from_asset_expect(chosen)) .with_loot_drop(comp::Item::new_from_asset_expect(chosen))
.with_main_tool(comp::Item::new_from_asset_expect( .with_main_tool(comp::Item::new_from_asset_expect(
match dynamic_rng.gen_range(0, 6) { match dynamic_rng.gen_range(0..6) {
0 => "common.items.weapons.axe.malachite_axe-0", 0 => "common.items.weapons.axe.malachite_axe-0",
1 => "common.items.weapons.sword.cultist_purp_2h-0", 1 => "common.items.weapons.sword.cultist_purp_2h-0",
2 => "common.items.weapons.sword.cultist_purp_2h-0", 2 => "common.items.weapons.sword.cultist_purp_2h-0",
@ -692,7 +689,7 @@ impl Floor {
_ => "common.items.weapons.bow.horn_longbow-0", _ => "common.items.weapons.bow.horn_longbow-0",
}, },
)), )),
5 => match dynamic_rng.gen_range(0, 6) { 5 => match dynamic_rng.gen_range(0..6) {
0 => entity 0 => entity
.with_name("Cultist Warlock") .with_name("Cultist Warlock")
.with_loadout_config(loadout_builder::LoadoutConfig::Warlock) .with_loadout_config(loadout_builder::LoadoutConfig::Warlock)
@ -711,7 +708,7 @@ impl Floor {
) )
.with_loot_drop(comp::Item::new_from_asset_expect(chosen)) .with_loot_drop(comp::Item::new_from_asset_expect(chosen))
.with_main_tool(comp::Item::new_from_asset_expect( .with_main_tool(comp::Item::new_from_asset_expect(
match dynamic_rng.gen_range(0, 5) { match dynamic_rng.gen_range(0..5) {
0 => "common.items.weapons.axe.malachite_axe-0", 0 => "common.items.weapons.axe.malachite_axe-0",
1 => "common.items.weapons.sword.cultist_purp_2h-0", 1 => "common.items.weapons.sword.cultist_purp_2h-0",
2 => "common.items.weapons.sword.cultist_purp_2h-0", 2 => "common.items.weapons.sword.cultist_purp_2h-0",
@ -783,7 +780,7 @@ impl Floor {
) )
.with_scale(2.0) .with_scale(2.0)
.with_main_tool(comp::Item::new_from_asset_expect( .with_main_tool(comp::Item::new_from_asset_expect(
match dynamic_rng.gen_range(0, 6) { match dynamic_rng.gen_range(0..6) {
0 => "common.items.weapons.axe.worn_iron_axe-0", 0 => "common.items.weapons.axe.worn_iron_axe-0",
1 => { 1 => {
"common.items.weapons.sword.zweihander_sword_0" "common.items.weapons.sword.zweihander_sword_0"
@ -832,7 +829,7 @@ impl Floor {
) )
.with_scale(2.0) .with_scale(2.0)
.with_main_tool(comp::Item::new_from_asset_expect( .with_main_tool(comp::Item::new_from_asset_expect(
match dynamic_rng.gen_range(0, 6) { match dynamic_rng.gen_range(0..6) {
0 => "common.items.weapons.axe.steel_axe-0", 0 => "common.items.weapons.axe.steel_axe-0",
1 => "common.items.weapons.sword.long_2h_orn-0", 1 => "common.items.weapons.sword.long_2h_orn-0",
2 => "common.items.weapons.sword.long_2h_orn-0", 2 => "common.items.weapons.sword.long_2h_orn-0",
@ -856,7 +853,7 @@ impl Floor {
) )
.with_scale(2.0) .with_scale(2.0)
.with_main_tool(comp::Item::new_from_asset_expect( .with_main_tool(comp::Item::new_from_asset_expect(
match dynamic_rng.gen_range(0, 6) { match dynamic_rng.gen_range(0..6) {
0 => "common.items.weapons.axe.malachite_axe-0", 0 => "common.items.weapons.axe.malachite_axe-0",
1 => "common.items.weapons.sword.cultist_purp_2h-0", 1 => "common.items.weapons.sword.cultist_purp_2h-0",
2 => "common.items.weapons.sword.cultist_purp_2h-0", 2 => "common.items.weapons.sword.cultist_purp_2h-0",
@ -909,8 +906,8 @@ impl Floor {
.with_level( .with_level(
dynamic_rng dynamic_rng
.gen_range( .gen_range(
(room.difficulty as f32).powf(1.25) + 3.0, (room.difficulty as f32).powf(1.25) + 3.0
(room.difficulty as f32).powf(1.5) + 4.0, ..(room.difficulty as f32).powf(1.5) + 4.0,
) )
.round() .round()
as u16 as u16
@ -1011,7 +1008,7 @@ impl Floor {
) )
.with_scale(2.0) .with_scale(2.0)
.with_main_tool(comp::Item::new_from_asset_expect( .with_main_tool(comp::Item::new_from_asset_expect(
match dynamic_rng.gen_range(0, 6) { match dynamic_rng.gen_range(0..6) {
0 => "common.items.weapons.axe.malachite_axe-0", 0 => "common.items.weapons.axe.malachite_axe-0",
1 => "common.items.weapons.sword.cultist_purp_2h-0", 1 => "common.items.weapons.sword.cultist_purp_2h-0",
2 => "common.items.weapons.sword.cultist_purp_2h-0", 2 => "common.items.weapons.sword.cultist_purp_2h-0",
@ -1081,8 +1078,8 @@ impl Floor {
.with_level( .with_level(
dynamic_rng dynamic_rng
.gen_range( .gen_range(
(room.difficulty as f32).powf(1.25) + 3.0, (room.difficulty as f32).powf(1.25) + 3.0
(room.difficulty as f32).powf(1.5) + 4.0, ..(room.difficulty as f32).powf(1.5) + 4.0,
) )
.round() .round()
as u16 as u16

View File

@ -10,7 +10,7 @@ pub struct NameGen<'a, R: Rng> {
impl<'a, R: Rng> NameGen<'a, R> { impl<'a, R: Rng> NameGen<'a, R> {
pub fn location(rng: &'a mut R) -> Self { pub fn location(rng: &'a mut R) -> Self {
Self { Self {
approx_syllables: rng.gen_range(1, 4), approx_syllables: rng.gen_range(1..4),
rng, rng,
} }
} }

View File

@ -151,23 +151,23 @@ impl Attr {
pub fn generate<R: Rng>(rng: &mut R, _locus: i32) -> Self { pub fn generate<R: Rng>(rng: &mut R, _locus: i32) -> Self {
Self { Self {
central_supports: rng.gen(), central_supports: rng.gen(),
storey_fill: match rng.gen_range(0, 2) { storey_fill: match rng.gen_range(0..2) {
//0 => StoreyFill::None, //0 => StoreyFill::None,
0 => StoreyFill::Upper, 0 => StoreyFill::Upper,
_ => StoreyFill::All, _ => StoreyFill::All,
}, },
roof_style: match rng.gen_range(0, 3) { roof_style: match rng.gen_range(0..3) {
0 => RoofStyle::Hip, 0 => RoofStyle::Hip,
1 => RoofStyle::Gable, 1 => RoofStyle::Gable,
_ => RoofStyle::Rounded, _ => RoofStyle::Rounded,
}, },
mansard: rng.gen_range(-7, 4).max(0), mansard: rng.gen_range(-7..4).max(0),
pillar: match rng.gen_range(0, 4) { pillar: match rng.gen_range(0..4) {
0 => Pillar::Chimney(rng.gen_range(2, 6)), 0 => Pillar::Chimney(rng.gen_range(2..6)),
_ => Pillar::None, _ => Pillar::None,
}, },
levels: rng.gen_range(1, 3), levels: rng.gen_range(1..3),
window: match rng.gen_range(0, 4) { window: match rng.gen_range(0..4) {
0 => SpriteKind::Window1, 0 => SpriteKind::Window1,
1 => SpriteKind::Window2, 1 => SpriteKind::Window2,
2 => SpriteKind::Window3, 2 => SpriteKind::Window3,
@ -181,21 +181,21 @@ impl Archetype for House {
type Attr = Attr; type Attr = Attr;
fn generate<R: Rng>(rng: &mut R) -> (Self, Skeleton<Self::Attr>) { fn generate<R: Rng>(rng: &mut R) -> (Self, Skeleton<Self::Attr>) {
let len = rng.gen_range(-8, 24).clamped(0, 20); let len = rng.gen_range(-8..24).clamped(0, 20);
let locus = 6 + rng.gen_range(0, 5); let locus = 6 + rng.gen_range(0..5);
let branches_per_side = 1 + len as usize / 20; let branches_per_side = 1 + len as usize / 20;
let levels = rng.gen_range(1, 3); let levels = rng.gen_range(1..3);
let skel = Skeleton { let skel = Skeleton {
offset: -rng.gen_range(0, len + 7).clamped(0, len), offset: -rng.gen_range(0..len + 7).clamped(0, len),
ori: if rng.gen() { Ori::East } else { Ori::North }, ori: if rng.gen() { Ori::East } else { Ori::North },
root: Branch { root: Branch {
len, len,
attr: Attr { attr: Attr {
storey_fill: StoreyFill::All, storey_fill: StoreyFill::All,
mansard: 0, mansard: 0,
pillar: match rng.gen_range(0, 3) { pillar: match rng.gen_range(0..3) {
0 => Pillar::Chimney(rng.gen_range(2, 6)), 0 => Pillar::Chimney(rng.gen_range(2..6)),
1 => Pillar::Tower(5 + rng.gen_range(1, 5)), 1 => Pillar::Tower(5 + rng.gen_range(1..5)),
_ => Pillar::None, _ => Pillar::None,
}, },
levels, levels,
@ -212,12 +212,12 @@ impl Archetype for House {
Some(( Some((
i as i32 * len / (branches_per_side - 1).max(1) as i32, i as i32 * len / (branches_per_side - 1).max(1) as i32,
Branch { Branch {
len: rng.gen_range(8, 16) * flip, len: rng.gen_range(8..16) * flip,
attr: Attr { attr: Attr {
levels: rng.gen_range(1, 4).min(levels), levels: rng.gen_range(1..4).min(levels),
..Attr::generate(rng, locus) ..Attr::generate(rng, locus)
}, },
locus: (6 + rng.gen_range(0, 3)).min(locus), locus: (6 + rng.gen_range(0..3)).min(locus),
border: 4, border: 4,
children: Vec::new(), children: Vec::new(),
}, },
@ -544,7 +544,7 @@ impl Archetype for House {
2 => SpriteKind::ChairDouble, 2 => SpriteKind::ChairDouble,
3 => SpriteKind::CoatRack, 3 => SpriteKind::CoatRack,
4 => { 4 => {
if dynamic_rng.gen_range(0, 8) == 0 { if dynamic_rng.gen_range(0..8) == 0 {
SpriteKind::Chest SpriteKind::Chest
} else { } else {
SpriteKind::Crate SpriteKind::Crate
@ -555,14 +555,14 @@ impl Archetype for House {
8 => SpriteKind::TableSide, 8 => SpriteKind::TableSide,
9 => SpriteKind::WardrobeSingle, 9 => SpriteKind::WardrobeSingle,
10 => { 10 => {
if dynamic_rng.gen_range(0, 10) == 0 { if dynamic_rng.gen_range(0..10) == 0 {
SpriteKind::PotionMinor SpriteKind::PotionMinor
} else { } else {
SpriteKind::VialEmpty SpriteKind::VialEmpty
} }
}, },
_ => { _ => {
if dynamic_rng.gen_range(0, 2) == 0 { if dynamic_rng.gen_range(0..2) == 0 {
SpriteKind::Bowl SpriteKind::Bowl
} else { } else {
SpriteKind::Pot SpriteKind::Pot

View File

@ -57,10 +57,10 @@ impl Archetype for Keep {
type Attr = Attr; type Attr = Attr;
fn generate<R: Rng>(rng: &mut R) -> (Self, Skeleton<Self::Attr>) { fn generate<R: Rng>(rng: &mut R) -> (Self, Skeleton<Self::Attr>) {
let len = rng.gen_range(-8, 24).max(0); let len = rng.gen_range(-8..24).max(0);
let storeys = rng.gen_range(1, 3); let storeys = rng.gen_range(1..3);
let skel = Skeleton { let skel = Skeleton {
offset: -rng.gen_range(0, len + 7).clamped(0, len), offset: -rng.gen_range(0..len + 7).clamped(0, len),
ori: if rng.gen() { Ori::East } else { Ori::North }, ori: if rng.gen() { Ori::East } else { Ori::North },
root: Branch { root: Branch {
len, len,
@ -72,23 +72,23 @@ impl Archetype for Keep {
rounded: true, rounded: true,
has_doors: true, has_doors: true,
}, },
locus: 10 + rng.gen_range(0, 5), locus: 10 + rng.gen_range(0..5),
border: 3, border: 3,
children: (0..1) children: (0..1)
.map(|_| { .map(|_| {
( (
rng.gen_range(-5, len + 5).clamped(0, len.max(1) - 1), rng.gen_range(-5..len + 5).clamped(0, len.max(1) - 1),
Branch { Branch {
len: 0, len: 0,
attr: Attr { attr: Attr {
storeys: storeys + rng.gen_range(1, 3), storeys: storeys + rng.gen_range(1..3),
is_tower: true, is_tower: true,
flag: true, flag: true,
ridged: false, ridged: false,
rounded: true, rounded: true,
has_doors: false, has_doors: false,
}, },
locus: 6 + rng.gen_range(0, 3), locus: 6 + rng.gen_range(0..3),
border: 3, border: 3,
children: Vec::new(), children: Vec::new(),
}, },

View File

@ -212,7 +212,7 @@ impl Settlement {
let cpos = wpos.map(|e| e.div_euclid(TerrainChunkSize::RECT_SIZE.x as i32)); let cpos = wpos.map(|e| e.div_euclid(TerrainChunkSize::RECT_SIZE.x as i32));
!sim.can_host_settlement(cpos) !sim.can_host_settlement(cpos)
}) })
|| rng.gen_range(0, 16) == 0 || rng.gen_range(0..16) == 0
// Randomly consider some tiles inaccessible // Randomly consider some tiles inaccessible
{ {
self.land.set(tile, hazard); self.land.set(tile, hazard);
@ -225,7 +225,7 @@ impl Settlement {
let river_dir = Vec2::new(rng.gen::<f32>() - 0.5, rng.gen::<f32>() - 0.5).normalized(); let river_dir = Vec2::new(rng.gen::<f32>() - 0.5, rng.gen::<f32>() - 0.5).normalized();
let radius = 500.0 + rng.gen::<f32>().powi(2) * 1000.0; let radius = 500.0 + rng.gen::<f32>().powi(2) * 1000.0;
let river = self.land.new_plot(Plot::Water); let river = self.land.new_plot(Plot::Water);
let river_offs = Vec2::new(rng.gen_range(-3, 4), rng.gen_range(-3, 4)); let river_offs = Vec2::new(rng.gen_range(-3..4), rng.gen_range(-3..4));
for x in (0..100).map(|e| e as f32 / 100.0) { for x in (0..100).map(|e| e as f32 / 100.0) {
let theta0 = x as f32 * f32::consts::PI * 2.0; let theta0 = x as f32 * f32::consts::PI * 2.0;
@ -293,7 +293,7 @@ impl Settlement {
pub fn place_town(&mut self, ctx: &mut GenCtx<impl Rng>) { pub fn place_town(&mut self, ctx: &mut GenCtx<impl Rng>) {
const PLOT_COUNT: usize = 3; const PLOT_COUNT: usize = 3;
let mut origin = Vec2::new(ctx.rng.gen_range(-2, 3), ctx.rng.gen_range(-2, 3)); let mut origin = Vec2::new(ctx.rng.gen_range(-2..3), ctx.rng.gen_range(-2..3));
for i in 0..PLOT_COUNT { for i in 0..PLOT_COUNT {
if let Some(base_tile) = self.land.find_tile_near(origin, |plot| { if let Some(base_tile) = self.land.find_tile_near(origin, |plot| {
@ -386,12 +386,12 @@ impl Settlement {
.take(16usize.pow(2)) .take(16usize.pow(2))
{ {
// This is a stupid way to decide how to place buildings // This is a stupid way to decide how to place buildings
for i in 0..ctx.rng.gen_range(2, 5) { for i in 0..ctx.rng.gen_range(2..5) {
for _ in 0..25 { for _ in 0..25 {
let house_pos = tile.map(|e| e * AREA_SIZE as i32 + AREA_SIZE as i32 / 2) let house_pos = tile.map(|e| e * AREA_SIZE as i32 + AREA_SIZE as i32 / 2)
+ Vec2::<i32>::zero().map(|_| { + Vec2::<i32>::zero().map(|_| {
ctx.rng ctx.rng
.gen_range(-(AREA_SIZE as i32) / 4, AREA_SIZE as i32 / 4) .gen_range(-(AREA_SIZE as i32) / 4..AREA_SIZE as i32 / 4)
}); });
let tile_pos = house_pos.map(|e| e.div_euclid(AREA_SIZE as i32)); let tile_pos = house_pos.map(|e| e.div_euclid(AREA_SIZE as i32));
@ -470,10 +470,10 @@ impl Settlement {
//self.land.set(base_tile, farmhouse); //self.land.set(base_tile, farmhouse);
// Farmhouses // Farmhouses
// for _ in 0..ctx.rng.gen_range(1, 3) { // for _ in 0..ctx.rng.gen_range(1..3) {
// let house_pos = base_tile.map(|e| e * AREA_SIZE as i32 + AREA_SIZE as i32 // let house_pos = base_tile.map(|e| e * AREA_SIZE as i32 + AREA_SIZE as i32
// / 2) + Vec2::new(ctx.rng.gen_range(-16, 16), // / 2) + Vec2::new(ctx.rng.gen_range(-16..16),
// ctx.rng.gen_range(-16, 16)); // ctx.rng.gen_range(-16..16));
// self.structures.push(Structure { // self.structures.push(Structure {
// kind: StructureKind::House(HouseBuilding::generate(ctx.rng, // kind: StructureKind::House(HouseBuilding::generate(ctx.rng,
@ -508,7 +508,7 @@ impl Settlement {
let field = self.land.new_plot(Plot::Field { let field = self.land.new_plot(Plot::Field {
farm, farm,
seed: rng.gen(), seed: rng.gen(),
crop: match rng.gen_range(0, 8) { crop: match rng.gen_range(0..8) {
0 => Crop::Corn, 0 => Crop::Corn,
1 => Crop::Wheat, 1 => Crop::Wheat,
2 => Crop::Cabbage, 2 => Crop::Cabbage,
@ -522,7 +522,7 @@ impl Settlement {
}); });
let tiles = let tiles =
self.land self.land
.grow_from(center, rng.gen_range(5, MAX_FIELD_SIZE), rng, |plot| { .grow_from(center, rng.gen_range(5..MAX_FIELD_SIZE), rng, |plot| {
plot.is_none() plot.is_none()
}); });
for pos in tiles.into_iter() { for pos in tiles.into_iter() {
@ -881,13 +881,13 @@ impl Settlement {
let is_dummy = let is_dummy =
RandomField::new(self.seed + 1).chance(Vec3::from(wpos2d), 1.0 / 15.0); RandomField::new(self.seed + 1).chance(Vec3::from(wpos2d), 1.0 / 15.0);
let entity = EntityInfo::at(entity_wpos) let entity = EntityInfo::at(entity_wpos)
.with_body(match dynamic_rng.gen_range(0, 5) { .with_body(match dynamic_rng.gen_range(0..5) {
_ if is_dummy => { _ if is_dummy => {
is_human = false; is_human = false;
object::Body::TrainingDummy.into() object::Body::TrainingDummy.into()
}, },
0 => { 0 => {
let species = match dynamic_rng.gen_range(0, 3) { let species = match dynamic_rng.gen_range(0..3) {
0 => quadruped_small::Species::Pig, 0 => quadruped_small::Species::Pig,
1 => quadruped_small::Species::Sheep, 1 => quadruped_small::Species::Sheep,
_ => quadruped_small::Species::Cat, _ => quadruped_small::Species::Cat,
@ -899,7 +899,7 @@ impl Settlement {
)) ))
}, },
1 => { 1 => {
let species = match dynamic_rng.gen_range(0, 4) { let species = match dynamic_rng.gen_range(0..4) {
0 => bird_medium::Species::Duck, 0 => bird_medium::Species::Duck,
1 => bird_medium::Species::Chicken, 1 => bird_medium::Species::Chicken,
2 => bird_medium::Species::Goose, 2 => bird_medium::Species::Goose,
@ -927,20 +927,20 @@ impl Settlement {
.do_if(!is_dummy, |e| e.with_automatic_name()) .do_if(!is_dummy, |e| e.with_automatic_name())
.do_if(is_dummy, |e| e.with_name("Training Dummy")) .do_if(is_dummy, |e| e.with_name("Training Dummy"))
.do_if(is_human && dynamic_rng.gen(), |entity| { .do_if(is_human && dynamic_rng.gen(), |entity| {
match dynamic_rng.gen_range(0, 5) { match dynamic_rng.gen_range(0..5) {
0 => entity 0 => entity
.with_main_tool(Item::new_from_asset_expect( .with_main_tool(Item::new_from_asset_expect(
"common.items.weapons.sword.greatsword_2h_simple-0", "common.items.weapons.sword.greatsword_2h_simple-0",
)) ))
.with_name("Guard") .with_name("Guard")
.with_level(dynamic_rng.gen_range(10, 15)) .with_level(dynamic_rng.gen_range(10..15))
.with_loadout_config(loadout_builder::LoadoutConfig::Guard) .with_loadout_config(loadout_builder::LoadoutConfig::Guard)
.with_skillset_config( .with_skillset_config(
common::skillset_builder::SkillSetConfig::Guard, common::skillset_builder::SkillSetConfig::Guard,
), ),
_ => entity _ => entity
.with_main_tool(Item::new_from_asset_expect( .with_main_tool(Item::new_from_asset_expect(
match dynamic_rng.gen_range(0, 7) { match dynamic_rng.gen_range(0..7) {
0 => "common.items.npc_weapons.tool.broom", 0 => "common.items.npc_weapons.tool.broom",
1 => "common.items.npc_weapons.tool.hoe", 1 => "common.items.npc_weapons.tool.hoe",
2 => "common.items.npc_weapons.tool.pickaxe", 2 => "common.items.npc_weapons.tool.pickaxe",

View File

@ -73,10 +73,10 @@ fn gen_plot(aabr: Aabr<i32>, ctx: &mut GenCtx<impl Rng>) -> Plot {
if aabr.size().product() <= 9 { if aabr.size().product() <= 9 {
Plot::District Plot::District
} else if aabr.size().w < aabr.size().h { } else if aabr.size().w < aabr.size().h {
let [a, b] = aabr.split_at_y(aabr.min.y + ctx.rng.gen_range(1, aabr.size().h)); let [a, b] = aabr.split_at_y(aabr.min.y + ctx.rng.gen_range(1..aabr.size().h));
Plot::Parent(vec![(a, gen_plot(a, ctx)), (b, gen_plot(b, ctx))]) Plot::Parent(vec![(a, gen_plot(a, ctx)), (b, gen_plot(b, ctx))])
} else { } else {
let [a, b] = aabr.split_at_x(aabr.min.x + ctx.rng.gen_range(1, aabr.size().w)); let [a, b] = aabr.split_at_x(aabr.min.x + ctx.rng.gen_range(1..aabr.size().w));
Plot::Parent(vec![(a, gen_plot(a, ctx)), (b, gen_plot(b, ctx))]) Plot::Parent(vec![(a, gen_plot(a, ctx)), (b, gen_plot(b, ctx))])
} }
} }