Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clippy: fix unnecessary casting #469

Merged
merged 1 commit into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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