mirror of
https://github.com/louis-e/arnis.git
synced 2026-04-19 21:49:36 -04:00
Fix clippy warnings for Rust 1.95: collapsible_match, unnecessary_cast, sort_by_key, explicit_counter_loop
This commit is contained in:
@@ -135,8 +135,8 @@ pub fn generate_landuse(
|
||||
|
||||
// Add specific features for different landuse types
|
||||
match landuse_tag.as_str() {
|
||||
"cemetery" => {
|
||||
if (x % 3 == 0) && (z % 3 == 0) {
|
||||
"cemetery"
|
||||
if (x % 3 == 0) && (z % 3 == 0) => {
|
||||
let random_choice: i32 = rng.random_range(0..100);
|
||||
if random_choice < 15 {
|
||||
// Place graves
|
||||
@@ -168,9 +168,8 @@ pub fn generate_landuse(
|
||||
editor.set_block(LARGE_FERN_UPPER, x, 2, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
"forest" => {
|
||||
if editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK])) {
|
||||
"forest"
|
||||
if editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK])) => {
|
||||
let random_choice: i32 = rng.random_range(0..30);
|
||||
if random_choice == 20 {
|
||||
let tree_type = *trees_ok_to_generate
|
||||
@@ -200,10 +199,9 @@ pub fn generate_landuse(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"farmland" => {
|
||||
"farmland"
|
||||
// Check if the current block is not water or another undesired block
|
||||
if !editor.check_for_block(x, 0, z, Some(&[WATER])) {
|
||||
if !editor.check_for_block(x, 0, z, Some(&[WATER])) => {
|
||||
if x % 9 == 0 && z % 9 == 0 {
|
||||
// Place water in dot pattern
|
||||
editor.set_block(WATER, x, 0, z, Some(&[FARMLAND]), None);
|
||||
@@ -222,7 +220,6 @@ pub fn generate_landuse(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"construction" => {
|
||||
let random_choice: i32 = rng.random_range(0..1501);
|
||||
if random_choice < 15 {
|
||||
@@ -295,8 +292,8 @@ pub fn generate_landuse(
|
||||
editor.set_block(COBBLESTONE, x, 0, z, None, Some(&[SPONGE]));
|
||||
}
|
||||
}
|
||||
"grass" => {
|
||||
if editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK])) {
|
||||
"grass"
|
||||
if editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK])) => {
|
||||
match rng.random_range(0..200) {
|
||||
0 => editor.set_block(OAK_LEAVES, x, 1, z, None, None),
|
||||
1..=8 => editor.set_block(FERN, x, 1, z, None, None),
|
||||
@@ -304,9 +301,8 @@ pub fn generate_landuse(
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
"greenfield" => {
|
||||
if editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK])) {
|
||||
"greenfield"
|
||||
if editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK])) => {
|
||||
match rng.random_range(0..200) {
|
||||
0 => editor.set_block(OAK_LEAVES, x, 1, z, None, None),
|
||||
1..=2 => editor.set_block(FERN, x, 1, z, None, None),
|
||||
@@ -314,9 +310,8 @@ pub fn generate_landuse(
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
"meadow" => {
|
||||
if editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK])) {
|
||||
"meadow"
|
||||
if editor.check_for_block(x, 0, z, Some(&[GRASS_BLOCK])) => {
|
||||
let random_choice: i32 = rng.random_range(0..1001);
|
||||
if random_choice < 5 {
|
||||
Tree::create(editor, (x, 1, z), Some(building_footprints));
|
||||
@@ -333,7 +328,6 @@ pub fn generate_landuse(
|
||||
editor.set_block(GRASS, x, 1, z, None, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
"orchard" => {
|
||||
if x % 18 == 0 && z % 10 == 0 {
|
||||
Tree::create(editor, (x, 1, z), Some(building_footprints));
|
||||
|
||||
@@ -300,17 +300,14 @@ pub fn generate_natural(
|
||||
editor.set_block(GRASS, x, 1, z, None, None);
|
||||
}
|
||||
}
|
||||
"sand" => {
|
||||
"sand"
|
||||
if editor.check_for_block(x, 0, z, Some(&[SAND]))
|
||||
&& rng.random_range(0..100) == 1
|
||||
{
|
||||
editor.set_block(DEAD_BUSH, x, 1, z, None, None);
|
||||
}
|
||||
&& rng.random_range(0..100) == 1 =>
|
||||
{
|
||||
editor.set_block(DEAD_BUSH, x, 1, z, None, None);
|
||||
}
|
||||
"shoal" => {
|
||||
if rng.random_bool(0.05) {
|
||||
editor.set_block(WATER, x, 0, z, Some(&[SAND, GRAVEL]), None);
|
||||
}
|
||||
"shoal" if rng.random_bool(0.05) => {
|
||||
editor.set_block(WATER, x, 0, z, Some(&[SAND, GRAVEL]), None);
|
||||
}
|
||||
"wetland" => {
|
||||
if let Some(wetland_type) = element.tags().get("wetland") {
|
||||
@@ -406,8 +403,8 @@ pub fn generate_natural(
|
||||
let cluster_size = rng.random_range(5..=10);
|
||||
|
||||
// Create cluster around current position
|
||||
for dx in -(cluster_size as i32)..=(cluster_size as i32) {
|
||||
for dz in -(cluster_size as i32)..=(cluster_size as i32) {
|
||||
for dx in -cluster_size..=cluster_size {
|
||||
for dz in -cluster_size..=cluster_size {
|
||||
let cluster_x = x + dx;
|
||||
let cluster_z = z + dz;
|
||||
|
||||
|
||||
@@ -379,12 +379,13 @@ impl FloodFillCache {
|
||||
|
||||
for element in elements {
|
||||
match element {
|
||||
ProcessedElement::Way(way) => {
|
||||
if way.tags.contains_key("building") || way.tags.contains_key("building:part") {
|
||||
if let Some(cached) = self.way_cache.get(&way.id) {
|
||||
for &(x, z) in cached {
|
||||
footprints.set(x, z);
|
||||
}
|
||||
ProcessedElement::Way(way)
|
||||
if way.tags.contains_key("building")
|
||||
|| way.tags.contains_key("building:part") =>
|
||||
{
|
||||
if let Some(cached) = self.way_cache.get(&way.id) {
|
||||
for &(x, z) in cached {
|
||||
footprints.set(x, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,7 +470,7 @@ pub fn generate_ground_layer(
|
||||
);
|
||||
}
|
||||
}
|
||||
land_cover::LC_CROPLAND => {
|
||||
land_cover::LC_CROPLAND
|
||||
// Only place crops if the ground is actually farmland
|
||||
if editor.check_for_block_absolute(
|
||||
x,
|
||||
@@ -478,7 +478,7 @@ pub fn generate_ground_layer(
|
||||
z,
|
||||
Some(&[FARMLAND]),
|
||||
None,
|
||||
) {
|
||||
) => {
|
||||
if x % 9 == 0 && z % 9 == 0 {
|
||||
editor.set_block_absolute(
|
||||
WATER,
|
||||
@@ -512,7 +512,6 @@ pub fn generate_ground_layer(
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
land_cover::LC_WETLAND | land_cover::LC_MANGROVES
|
||||
if ground_is_natural =>
|
||||
{
|
||||
@@ -555,9 +554,9 @@ pub fn generate_ground_layer(
|
||||
);
|
||||
}
|
||||
}
|
||||
land_cover::LC_BARE if ground_is_natural => {
|
||||
land_cover::LC_BARE if ground_is_natural
|
||||
// Sparse dead bushes
|
||||
if rng.random_range(0..100) == 0 {
|
||||
&& rng.random_range(0..100) == 0 => {
|
||||
editor.set_block_absolute(
|
||||
DEAD_BUSH,
|
||||
x,
|
||||
@@ -567,7 +566,6 @@ pub fn generate_ground_layer(
|
||||
None,
|
||||
);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ fn get_sorted_sections<'a>(sections: &[&'a Value]) -> Vec<(i8, &'a Value)> {
|
||||
})
|
||||
.collect();
|
||||
|
||||
sorted.sort_by(|a, b| b.0.cmp(&a.0));
|
||||
sorted.sort_by_key(|b| std::cmp::Reverse(b.0));
|
||||
sorted
|
||||
}
|
||||
|
||||
|
||||
@@ -25,17 +25,14 @@ pub fn transform_map(
|
||||
});
|
||||
|
||||
let nop: usize = ops.len();
|
||||
let mut iop: usize = 1;
|
||||
|
||||
let progress_increment_prcs: f64 = 5.0 / nop as f64;
|
||||
|
||||
for op in ops {
|
||||
for (iop, op) in (1..).zip(ops) {
|
||||
let current_progress_prcs = 20.0 + (iop as f64 * progress_increment_prcs);
|
||||
//let message = format!("Applying operation: {}, {}/{}", op.repr(), iop, nop);
|
||||
emit_gui_progress_update(current_progress_prcs, "");
|
||||
|
||||
iop += 1;
|
||||
|
||||
op.operate(elements, xzbbox, ground);
|
||||
}
|
||||
|
||||
|
||||
@@ -450,7 +450,7 @@ fn compute_heightmaps(sections: &[Section], min_section_y: i8, total_height: i32
|
||||
.collect();
|
||||
|
||||
// Sort by Y descending so we scan top-down
|
||||
metas.sort_by(|a, b| b.y.cmp(&a.y));
|
||||
metas.sort_by_key(|b| std::cmp::Reverse(b.y));
|
||||
|
||||
let mut heights = [0i32; 256]; // 16x16 grid, Z-major order
|
||||
let min_block_y = min_section_y as i32 * 16;
|
||||
|
||||
Reference in New Issue
Block a user