Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
terrarier2111 committed May 25, 2024
1 parent d9d7a0d commit 0e321d0
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 17 deletions.
5 changes: 2 additions & 3 deletions src/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,6 @@ fn calculate_biome(
z: i32,
img: &image::DynamicImage,
) -> (u8, u8, u8) {
use std::cmp::{max, min};
let mut count = 0;
let mut r = 0;
let mut g = 0;
Expand All @@ -1062,8 +1061,8 @@ fn calculate_biome(
let ix = color_index & 0xFF;
let iy = color_index >> 8;

let ix = min(max(ix, 0), 255);
let iy = min(max(iy, 0), 255);
let ix = ix.clamp(0, 255);
let iy = iy.clamp(0, 255);

let col = img.get_pixel(ix as u32, iy as u32);
let col = bi.process_color(col);
Expand Down
2 changes: 1 addition & 1 deletion src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,7 @@ impl TextureManager {
// work with the new name
let mut old = self.textures.remove(&old_name).unwrap();
old.name = format!("leafish-dynamic:{}", name);
t.name = old.name.clone();
t.name.clone_from(&old.name);
self.textures
.insert(format!("leafish-dynamic:{}", name), old);
t
Expand Down
2 changes: 1 addition & 1 deletion src/screen/background.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Screen for Background {
ui_container: &mut Container,
) {
let path = self.settings.get_string(StringSetting::BackgroundImage);
self.last_path = path.clone();
self.last_path.clone_from(&path);
let background =
if Renderer::get_texture_optional(renderer.get_textures_ref(), &path).is_some() {
Some(
Expand Down
8 changes: 2 additions & 6 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1204,11 +1204,7 @@ impl Server {
offset = prev_offset + (offset - prev_offset) / 3.0;

offset = 1.0 - ((offset * PI * 2.0).cos() * 2.0 + 0.2);
if offset > 1.0 {
offset = 1.0;
} else if offset < 0.0 {
offset = 0.0;
}
offset = offset.clamp(0.0, 1.0);
offset = 1.0 - offset;
offset * 0.8 + 0.2
}
Expand Down Expand Up @@ -1703,7 +1699,7 @@ impl Server {
stack,
}
});
top_inventory.write().cursor = item.clone();
top_inventory.write().cursor.clone_from(&item);
self.inventory_context.write().set_cursor(item);
self.hud_context
.read()
Expand Down
3 changes: 2 additions & 1 deletion src/ui/logo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ impl Logo {
let mut text = self.text.borrow_mut();
if self.text_index != text_index {
self.text_index = text_index;
text.text = self.text_strings[text_index as usize].clone();
text.text
.clone_from(&self.text_strings[text_index as usize]);
let width = (renderer.ui.lock().size_of_string(&text.text) + 2.0) * text.scale_x;
self.text_base_scale = 300.0 / width;
if self.text_base_scale > 1.0 {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ impl UIElement for Image {
element.a = self.colour.3;
self.data.extend_from_slice(&element.bytes(width, height));
self.super_draw(renderer, r, sw, sh, width, height, delta);
self.last_texture = self.texture.clone();
self.last_texture.clone_from(&self.texture);
self.last_colour = self.colour;
self.last_texture_coords = self.texture_coords;
}
Expand Down Expand Up @@ -1040,7 +1040,7 @@ impl UIElement for Text {
self.data.extend_from_slice(&text.bytes(width, height));
self.super_draw(renderer, r, sw, sh, width, height, delta);

self.last_text = self.text.clone();
self.last_text.clone_from(&self.text);
self.last_colour = self.colour;
self.last_scale_x = self.scale_x;
self.last_scale_y = self.scale_y;
Expand Down
4 changes: 2 additions & 2 deletions src/world/biome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ impl Biome {
}

pub fn get_color_index(self) -> usize {
let t = (self.temperature as f64 / 100f64).min(1.0).max(0.0);
let m = (self.moisture as f64 / 100f64).min(1.0).max(0.0);
let t = (self.temperature as f64 / 100f64).clamp(0.0, 1.0);
let m = (self.moisture as f64 / 100f64).clamp(0.0, 1.0);
(((1.0 - t) * 255.0) as usize) | ((((1.0 - (m * t)) * 255.0) as usize) << 8)
}

Expand Down
2 changes: 1 addition & 1 deletion src/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1483,7 +1483,7 @@ impl Command for UpdateSignInfoCmd {
.as_mut()
.and_then(|entity| entity.get_mut::<SignInfo>())
{
info.lines = self.0.clone();
info.lines.clone_from(&self.0);
info.dirty = true;
}
}
Expand Down

0 comments on commit 0e321d0

Please sign in to comment.