Skip to content

Commit

Permalink
clippy: fix unnecessary casting (#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
darnuria authored Oct 11, 2022
1 parent cbe2b27 commit 55f0521
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/editor/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ impl UndoableAction for PlaceTileAction {

if let Some(layer) = map.layers.get_mut(&self.layer_id) {
if let MapLayerKind::TileLayer = layer.kind {
self.replaced_tile = layer.tiles.remove(i as usize);
self.replaced_tile = layer.tiles.remove(i);

let tile = MapTile {
tile_id: self.id,
Expand All @@ -1145,7 +1145,7 @@ impl UndoableAction for PlaceTileAction {
attributes: vec![],
};

layer.tiles.insert(i as usize, Some(tile));
layer.tiles.insert(i, Some(tile));
} else {
return Err(Error::new_const(
ErrorKind::EditorAction,
Expand Down Expand Up @@ -1173,14 +1173,14 @@ impl UndoableAction for PlaceTileAction {

if let Some(layer) = map.layers.get_mut(&self.layer_id) {
if let MapLayerKind::TileLayer = layer.kind {
if layer.tiles.get(i as usize).is_none() {
if layer.tiles.get(i).is_none() {
return Err(Error::new_const(ErrorKind::EditorAction, &"PlaceTileAction (Undo): No tile at the specified coords, in the specified layer. Undo was probably called on an action that was never applied"));
}

if let Some(tile) = self.replaced_tile.take() {
layer.tiles[i as usize] = Some(tile);
layer.tiles[i] = Some(tile);
} else {
layer.tiles[i as usize] = None;
layer.tiles[i] = None;
}
} else {
return Err(Error::new_const(
Expand Down Expand Up @@ -1233,7 +1233,7 @@ impl UndoableAction for RemoveTileAction {

if let Some(layer) = map.layers.get_mut(&self.layer_id) {
if let MapLayerKind::TileLayer = layer.kind {
if let Some(tile) = layer.tiles.remove(i as usize) {
if let Some(tile) = layer.tiles.remove(i) {
self.tile = Some(tile);

layer.tiles.insert(i, None);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/select_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ pub async fn show_select_map_menu() -> MapResource {
}

let begin = (current_page as usize * entries_per_page).clamp(0, map_cnt);
let end = (begin as usize + entries_per_page).clamp(begin, map_cnt);
let end = (begin + entries_per_page).clamp(begin, map_cnt);

for (pi, i) in (begin..end).enumerate() {
let map_entry = resources.maps.get(i).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/json/map/tiled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl TiledMap {

let grid_size = uvec2(
tiled_tileset.columns as u32,
tiled_tileset.tilecount as u32 / tiled_tileset.columns as u32,
tiled_tileset.tilecount / tiled_tileset.columns as u32,
);

let mut tile_attributes: HashMap<u32, Vec<String>> = HashMap::new();
Expand Down
4 changes: 2 additions & 2 deletions src/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl Map {
let h = texture.height();

let dest_rect = Rect::new(0., 0., w, h);
let parallax_w = w as f32 * 0.5;
let parallax_w = w * 0.5;

let mut dest_rect2 = Rect::new(
-parallax_w,
Expand Down Expand Up @@ -411,7 +411,7 @@ impl Map {
}

pub fn get_random_spawn_point(&self) -> Vec2 {
let i = rand::gen_range(0, self.spawn_points.len()) as usize;
let i = rand::gen_range(0, self.spawn_points.len());
self.spawn_points[i]
}
}
Expand Down

0 comments on commit 55f0521

Please sign in to comment.