satisfy linter

This commit is contained in:
Corwin Kuiper 2021-08-07 18:41:28 +01:00
parent 724147ecfa
commit 0ccde7d328

View file

@ -111,9 +111,7 @@ impl<'a> Map<'a> {
} }
} }
fn get_position(&self, x: i32, y: i32) -> u16 { fn get_position(&self, x: i32, y: i32) -> u16 {
if x < 0 || x as u32 >= self.dimensions.x { if x < 0 || x as u32 >= self.dimensions.x || y < 0 || y as u32 >= self.dimensions.y {
self.default
} else if y < 0 || y as u32 >= self.dimensions.y {
self.default self.default
} else { } else {
self.store[y as usize * self.dimensions.x as usize + x as usize] self.store[y as usize * self.dimensions.x as usize + x as usize]
@ -220,30 +218,22 @@ impl<'a> Background<'a> {
let tile_position_difference = position_difference / 8; let tile_position_difference = position_difference / 8;
// how much of the map needs updating // how much of the map needs updating
let difference_x: Rect<i32> = if tile_position_difference.x == 0 { let difference_x: Rect<i32> = match tile_position_difference.x {
Rect::new((0, 0).into(), (0, 0).into()) 0 => Rect::new((0, 0).into(), (0, 0).into()),
} else if tile_position_difference.x > 0 { 1..=i32::MAX => Rect::new((0, 0).into(), (tile_position_difference.x, 0).into()),
Rect::new((0, 0).into(), (tile_position_difference.x, 0).into()) i32::MIN..=-1 => Rect::new(
} else if tile_position_difference.x < 0 {
Rect::new(
(32 + tile_position_difference.x, 0).into(), (32 + tile_position_difference.x, 0).into(),
(tile_position_difference.x.abs(), 0).into(), (tile_position_difference.x.abs(), 0).into(),
) ),
} else {
unreachable!();
}; };
let difference_y: Rect<i32> = if tile_position_difference.y == 0 { let difference_y: Rect<i32> = match tile_position_difference.y {
Rect::new((0, 0).into(), (0, 0).into()) 0 => Rect::new((0, 0).into(), (0, 0).into()),
} else if tile_position_difference.y > 0 { 1..=i32::MAX => Rect::new((0, 0).into(), (0, tile_position_difference.y).into()),
Rect::new((0, 0).into(), (0, tile_position_difference.y).into()) i32::MIN..=-1 => Rect::new(
} else if tile_position_difference.y < 0 {
Rect::new(
(0, 32 + tile_position_difference.y).into(), (0, 32 + tile_position_difference.y).into(),
(0, tile_position_difference.y.abs()).into(), (0, tile_position_difference.y.abs()).into(),
) ),
} else {
unreachable!();
}; };
// update those positions // update those positions