From ab713a5a4f142036c1bdb1e8ab57acda4b9ebbd7 Mon Sep 17 00:00:00 2001 From: grimsace Date: Mon, 18 May 2026 10:24:06 -0500 Subject: [PATCH] pass to remove issues in cargo check --- src/app.rs | 8 ++-- src/exporter/raster.rs | 19 ++++++--- src/exporter/svg.rs | 10 ++--- src/exporter/types.rs | 21 +++++---- src/interact/add_delete.rs | 8 ++-- src/interact/mod.rs | 8 ++-- src/interact/resize.rs | 54 +++++++++++------------ src/layout/generation/connections.rs | 8 ++-- src/layout/generation/markers.rs | 11 ++--- src/layout/generation/mod.rs | 1 + src/layout/generation/passages.rs | 57 +++++++++++++------------ src/layout/generation/room_placement.rs | 4 +- src/layout/types.rs | 20 +-------- src/layout/utils.rs | 1 + src/rendering.rs | 1 + 15 files changed, 109 insertions(+), 122 deletions(-) diff --git a/src/app.rs b/src/app.rs index 4a461c1..a19ca4f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -263,10 +263,8 @@ impl eframe::App for DungeonApp { (i.key_pressed(egui::Key::Delete) || i.key_pressed(egui::Key::Backspace)) && self.hover_level_idx.is_some() }); - if level_delete_requested { - if let Some(level_idx) = self.hover_level_idx { - self.delete_level(level_idx); - } + if level_delete_requested && let Some(level_idx) = self.hover_level_idx { + self.delete_level(level_idx); } let resizing = crate::interact::handle_resize(self, ctx, &response, &geometry); @@ -305,7 +303,7 @@ pub fn generate_all_levels(settings: &UiSettings) -> Vec { let level_count = if settings.min_levels == settings.max_levels { settings.min_levels } else { - let range_seed = crate::seed::derive_seed(settings.seed, 0x1E_7E_1_u64); + let range_seed = crate::seed::derive_seed(settings.seed, 0x0001_E7E1_u64); (range_seed as usize % (settings.max_levels - settings.min_levels + 1)) + settings.min_levels }; diff --git a/src/exporter/raster.rs b/src/exporter/raster.rs index dbaf63e..c20d26a 100644 --- a/src/exporter/raster.rs +++ b/src/exporter/raster.rs @@ -5,8 +5,9 @@ */ use super::types::{ - BG, BLACK, CORRIDOR, DoorStyle, END_MARKER, ExportGeometry, GRID, MONSTER_MARKER, ROOM, STAIRS, - START_MARKER, TRAP_MARKER, WHITE, WINDOW_COLOR, door_render_width, norm_edge, + BG, BLACK, CORRIDOR, Cell, CellEdge, DoorStyle, END_MARKER, ExportGeometry, GRID, + MONSTER_MARKER, ROOM, STAIRS, START_MARKER, TRAP_MARKER, WHITE, WINDOW_COLOR, + door_render_width, norm_edge, }; use super::utils::{collect_scene_data, door_line_points, window_line_points}; use crate::layout::{AreaMarker, DungeonLayout, Room, Staircase, Window}; @@ -531,9 +532,9 @@ pub fn draw_room_crosshatch( pub fn draw_cell_walls( pixmap: &mut Pixmap, g: &ExportGeometry, - cells: &HashSet<(usize, usize)>, - connected_edges: Option<&HashSet<((usize, usize), (usize, usize))>>, - door_edges: &HashSet<((usize, usize), (usize, usize))>, + cells: &HashSet, + connected_edges: Option<&HashSet>, + door_edges: &HashSet, width: f32, color: (u8, u8, u8, u8), ) { @@ -683,6 +684,7 @@ pub fn draw_window( draw_line(pixmap, x1, y1, x2, y2, width, color, style); } +#[allow(clippy::too_many_arguments)] pub fn draw_line( pixmap: &mut Pixmap, x1: f32, @@ -705,6 +707,7 @@ pub fn draw_line( } } +#[allow(clippy::too_many_arguments)] pub fn stroke_path( pixmap: &mut Pixmap, x1: f32, @@ -725,8 +728,10 @@ pub fn stroke_path( let mut paint = Paint::default(); paint.set_color_rgba8(color.0, color.1, color.2, color.3); - let mut stroke = Stroke::default(); - stroke.width = width; + let mut stroke = Stroke { + width, + ..Default::default() + }; if let Some((dash_len, gap_len)) = dash { stroke.dash = StrokeDash::new(vec![dash_len, gap_len], 0.0); } diff --git a/src/exporter/svg.rs b/src/exporter/svg.rs index bff24bb..7ef1d0d 100644 --- a/src/exporter/svg.rs +++ b/src/exporter/svg.rs @@ -5,8 +5,8 @@ */ use super::types::{ - BG, CORRIDOR, END_MARKER, ExportGeometry, GRID, MONSTER_MARKER, ROOM, START_MARKER, - TRAP_MARKER, WINDOW_COLOR, door_render_width, norm_edge, + BG, CORRIDOR, Cell, CellEdge, END_MARKER, ExportGeometry, GRID, MONSTER_MARKER, ROOM, + START_MARKER, TRAP_MARKER, WINDOW_COLOR, door_render_width, norm_edge, }; use super::utils::{collect_scene_data, door_line_points, window_line_points}; use crate::layout::DungeonLayout; @@ -256,9 +256,9 @@ pub fn build_svg(layout: &DungeonLayout, settings: &UiSettings) -> String { pub fn append_svg_walls( out: &mut String, g: &ExportGeometry, - cells: &HashSet<(usize, usize)>, - connected_edges: Option<&HashSet<((usize, usize), (usize, usize))>>, - door_edges: &HashSet<((usize, usize), (usize, usize))>, + cells: &HashSet, + connected_edges: Option<&HashSet>, + door_edges: &HashSet, width: f32, ) { for &(col, row) in cells { diff --git a/src/exporter/types.rs b/src/exporter/types.rs index 7d8d7d6..2da88b6 100644 --- a/src/exporter/types.rs +++ b/src/exporter/types.rs @@ -9,6 +9,9 @@ use std::collections::HashSet; use std::path::PathBuf; use tiny_skia::Rect; +pub type Cell = (usize, usize); +pub type CellEdge = (Cell, Cell); + pub const BG: (u8, u8, u8, u8) = (24, 24, 26, 255); pub const GRID: (u8, u8, u8, u8) = (130, 130, 130, 255); pub const ROOM: (u8, u8, u8, u8) = (70, 120, 160, 255); @@ -105,11 +108,11 @@ impl ExportGeometry { #[derive(Default)] pub struct SceneData { - pub corridor_cells: HashSet<(usize, usize)>, - pub corridor_edges: HashSet<((usize, usize), (usize, usize))>, - pub room_cells: HashSet<(usize, usize)>, - pub room_edges: HashSet<((usize, usize), (usize, usize))>, - pub door_edges: HashSet<((usize, usize), (usize, usize))>, + pub corridor_cells: HashSet, + pub corridor_edges: HashSet, + pub room_cells: HashSet, + pub room_edges: HashSet, + pub door_edges: HashSet, } #[derive(Debug, Clone, Copy)] @@ -144,15 +147,11 @@ pub struct CompositeExportContext<'a> { pub door_width: f32, } -pub fn norm_edge(a: (usize, usize), b: (usize, usize)) -> ((usize, usize), (usize, usize)) { +pub fn norm_edge(a: Cell, b: Cell) -> CellEdge { if a <= b { (a, b) } else { (b, a) } } -pub fn door_edges_for( - door: &Door, - cols: usize, - rows: usize, -) -> Vec<((usize, usize), (usize, usize))> { +pub fn door_edges_for(door: &Door, cols: usize, rows: usize) -> Vec { let mut edges = Vec::new(); if door.from.0.abs_diff(door.to.0) + door.from.1.abs_diff(door.to.1) != 1 { return edges; diff --git a/src/interact/add_delete.rs b/src/interact/add_delete.rs index 35110c5..7acb15b 100644 --- a/src/interact/add_delete.rs +++ b/src/interact/add_delete.rs @@ -55,10 +55,10 @@ pub fn handle_add_tool(app: &mut DungeonApp, response: &egui::Response, geometry drag.current_cell = (grid_x.floor() as usize, grid_y.floor() as usize); } - if response.drag_stopped() { - if let Some(drag) = app.add_corridor_drag.take() { - add_corridor_between(app, drag.start_cell, drag.current_cell); - } + if response.drag_stopped() + && let Some(drag) = app.add_corridor_drag.take() + { + add_corridor_between(app, drag.start_cell, drag.current_cell); } } AddTool::Staircase => { diff --git a/src/interact/mod.rs b/src/interact/mod.rs index 093891c..92a5f2b 100644 --- a/src/interact/mod.rs +++ b/src/interact/mod.rs @@ -962,10 +962,10 @@ pub fn draw_resize_overlay(app: &DungeonApp, painter: &egui::Painter, geometry: if let Some(room) = layout.rooms.get(room_idx) { draw_room_resize_visuals(painter, geometry, room, false); } - } else if let Some(stair_idx) = app.hover_stair_idx { - if let Some(stair) = layout.stairs.get(stair_idx) { - draw_staircase_resize_visuals(painter, geometry, stair, false); - } + } else if let Some(stair_idx) = app.hover_stair_idx + && let Some(stair) = layout.stairs.get(stair_idx) + { + draw_staircase_resize_visuals(painter, geometry, stair, false); } } diff --git a/src/interact/resize.rs b/src/interact/resize.rs index 6359516..9966363 100644 --- a/src/interact/resize.rs +++ b/src/interact/resize.rs @@ -23,27 +23,28 @@ pub fn handle_resize( return false; } - if ctx.input(|i| i.pointer.secondary_pressed()) && app.resize_state.is_none() { - if let Some(pointer_pos) = response.interact_pointer_pos() { - if let Some(text_idx) = text_at_pointer(app, pointer_pos, geometry) { - if let Some(state) = start_text_resize(app, text_idx) { - app.push_undo_snapshot(); - app.resize_state = Some(ResizeState::Text(state)); - return true; - } - } else if let Some(stair_idx) = stair_at_pointer(app, pointer_pos, geometry) { - if let Some(state) = start_staircase_resize(app, stair_idx, pointer_pos, geometry) { - app.push_undo_snapshot(); - app.resize_state = Some(ResizeState::Staircase(state)); - return true; - } - } else if let Some(room_idx) = resize_room_at_pointer(app, pointer_pos, geometry) { - if let Some(state) = start_resize(app, room_idx, pointer_pos, geometry) { - app.push_undo_snapshot(); - app.resize_state = Some(ResizeState::Room(state)); - return true; - } + if ctx.input(|i| i.pointer.secondary_pressed()) + && app.resize_state.is_none() + && let Some(pointer_pos) = response.interact_pointer_pos() + { + if let Some(text_idx) = text_at_pointer(app, pointer_pos, geometry) { + if let Some(state) = start_text_resize(app, text_idx) { + app.push_undo_snapshot(); + app.resize_state = Some(ResizeState::Text(state)); + return true; } + } else if let Some(stair_idx) = stair_at_pointer(app, pointer_pos, geometry) { + if let Some(state) = start_staircase_resize(app, stair_idx, pointer_pos, geometry) { + app.push_undo_snapshot(); + app.resize_state = Some(ResizeState::Staircase(state)); + return true; + } + } else if let Some(room_idx) = resize_room_at_pointer(app, pointer_pos, geometry) + && let Some(state) = start_resize(app, room_idx, pointer_pos, geometry) + { + app.push_undo_snapshot(); + app.resize_state = Some(ResizeState::Room(state)); + return true; } } @@ -51,14 +52,13 @@ pub fn handle_resize( if response.dragged_by(egui::PointerButton::Secondary) && ctx.input(|i| i.pointer.secondary_down()) && let Some(pointer_pos) = response.interact_pointer_pos() + && let Some((grid_x, grid_y)) = pointer_to_grid(pointer_pos, geometry) { - if let Some((grid_x, grid_y)) = pointer_to_grid(pointer_pos, geometry) { - let cell = (grid_x.floor() as usize, grid_y.floor() as usize); - match state { - ResizeState::Room(state) => resize_room(app, &state, cell), - ResizeState::Text(state) => resize_text(app, &state, cell), - ResizeState::Staircase(state) => resize_staircase(app, &state, cell), - } + let cell = (grid_x.floor() as usize, grid_y.floor() as usize); + match state { + ResizeState::Room(state) => resize_room(app, &state, cell), + ResizeState::Text(state) => resize_text(app, &state, cell), + ResizeState::Staircase(state) => resize_staircase(app, &state, cell), } } diff --git a/src/layout/generation/connections.rs b/src/layout/generation/connections.rs index 6c357c1..0997d73 100644 --- a/src/layout/generation/connections.rs +++ b/src/layout/generation/connections.rs @@ -10,6 +10,10 @@ use super::super::utils::{ }; use std::collections::HashSet; +pub type Cell = (usize, usize); +pub type CellEdge = (Cell, Cell); +pub type RoomBoundary = (usize, usize, Vec); + pub fn build_room_connection_edges( centers: &[(usize, usize)], randomness: f32, @@ -176,9 +180,7 @@ pub fn room_collision_edges( edges } -pub fn shared_room_boundaries( - rooms: &[Room], -) -> Vec<(usize, usize, Vec<((usize, usize), (usize, usize))>)> { +pub fn shared_room_boundaries(rooms: &[Room]) -> Vec { let mut boundaries = Vec::new(); for a_idx in 0..rooms.len() { for b_idx in (a_idx + 1)..rooms.len() { diff --git a/src/layout/generation/markers.rs b/src/layout/generation/markers.rs index 8a576b4..797a2cf 100644 --- a/src/layout/generation/markers.rs +++ b/src/layout/generation/markers.rs @@ -120,6 +120,7 @@ pub fn marker_in_room( AreaMarker { cell: (x, y), size } } +#[allow(clippy::too_many_arguments)] pub fn assign_extra_markers( markers: &mut Vec, rooms: &[Room], @@ -399,7 +400,7 @@ pub fn get_stair_count(settings: &UiSettings, gap_idx: usize) -> usize { if settings.min_stairs_per_level == settings.max_stairs_per_level { settings.min_stairs_per_level } else { - let range_seed = seed::derive_seed(settings.seed, 0x2A_3B_4_u64 + gap_idx as u64); + let range_seed = seed::derive_seed(settings.seed, 0x0002_A3B4_u64 + gap_idx as u64); (range_seed as usize % (settings.max_stairs_per_level - settings.min_stairs_per_level + 1)) + settings.min_stairs_per_level } @@ -460,18 +461,14 @@ pub fn ensure_stair_in_room(layout: &mut DungeonLayout, stair: &Staircase) -> bo pub fn room_to_stair_min_dist(room: &Room, stair: &Staircase) -> usize { let dx = if stair.cell.0 + stair.width <= room.x { room.x - (stair.cell.0 + stair.width) - } else if stair.cell.0 >= room.x + room.width { - stair.cell.0 - (room.x + room.width) } else { - 0 + stair.cell.0.saturating_sub(room.x + room.width) }; let dy = if stair.cell.1 + stair.height <= room.y { room.y - (stair.cell.1 + stair.height) - } else if stair.cell.1 >= room.y + room.height { - stair.cell.1 - (room.y + room.height) } else { - 0 + stair.cell.1.saturating_sub(room.y + room.height) }; dx + dy diff --git a/src/layout/generation/mod.rs b/src/layout/generation/mod.rs index ab62770..be5590f 100644 --- a/src/layout/generation/mod.rs +++ b/src/layout/generation/mod.rs @@ -18,6 +18,7 @@ pub use markers::*; pub use passages::*; pub use room_placement::*; +#[allow(clippy::too_many_arguments)] pub fn generate_layout( cols: usize, rows: usize, diff --git a/src/layout/generation/passages.rs b/src/layout/generation/passages.rs index df02507..2d4f479 100644 --- a/src/layout/generation/passages.rs +++ b/src/layout/generation/passages.rs @@ -44,36 +44,36 @@ pub fn apply_doors( let start_room = &layout.rooms[corridor.start_room_id]; let end_room = &layout.rooms[corridor.end_room_id]; - if let Some(edge) = room_exit_edge(&corridor.path, start_room, true) { - if seen_edges.insert(edge) { - let place_door = door_chance > 0.0 && rng.next_f32() <= door_chance; - layout.doors.push(Door { - from: edge.0, - to: edge.1, - width: corridor.width.max(1), - span_width: true, - locked: place_door && rng.next_f32() <= locked, - archway: !place_door, - secret: false, - manual: false, - }); - } + if let Some(edge) = room_exit_edge(&corridor.path, start_room, true) + && seen_edges.insert(edge) + { + let place_door = door_chance > 0.0 && rng.next_f32() <= door_chance; + layout.doors.push(Door { + from: edge.0, + to: edge.1, + width: corridor.width.max(1), + span_width: true, + locked: place_door && rng.next_f32() <= locked, + archway: !place_door, + secret: false, + manual: false, + }); } - if let Some(edge) = room_exit_edge(&corridor.path, end_room, false) { - if seen_edges.insert(edge) { - let place_door = door_chance > 0.0 && rng.next_f32() <= door_chance; - layout.doors.push(Door { - from: edge.0, - to: edge.1, - width: corridor.width.max(1), - span_width: true, - locked: place_door && rng.next_f32() <= locked, - archway: !place_door, - secret: false, - manual: false, - }); - } + if let Some(edge) = room_exit_edge(&corridor.path, end_room, false) + && seen_edges.insert(edge) + { + let place_door = door_chance > 0.0 && rng.next_f32() <= door_chance; + layout.doors.push(Door { + from: edge.0, + to: edge.1, + width: corridor.width.max(1), + span_width: true, + locked: place_door && rng.next_f32() <= locked, + archway: !place_door, + secret: false, + manual: false, + }); } for (room_idx, room) in layout.rooms.iter().enumerate() { @@ -404,6 +404,7 @@ pub fn collect_window_segments( segments } +#[allow(clippy::too_many_arguments)] pub fn collect_room_side_segments( room_idx: usize, room: &Room, diff --git a/src/layout/generation/room_placement.rs b/src/layout/generation/room_placement.rs index f89facf..a291226 100644 --- a/src/layout/generation/room_placement.rs +++ b/src/layout/generation/room_placement.rs @@ -143,8 +143,8 @@ pub fn placement_order(room_count: usize, room_edges: &[(usize, usize)]) -> Vec< } } - for idx in 0..room_count { - if !visited[idx] { + for (idx, was_visited) in visited.iter().enumerate().take(room_count) { + if !was_visited { order.push(idx); } } diff --git a/src/layout/types.rs b/src/layout/types.rs index 8cc00e8..ab4b940 100644 --- a/src/layout/types.rs +++ b/src/layout/types.rs @@ -98,7 +98,7 @@ pub struct WindowSettings { pub allow_internal_windows: bool, } -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)] pub struct DungeonLayout { pub rooms: Vec, pub corridors: Vec, @@ -113,24 +113,6 @@ pub struct DungeonLayout { pub stairs: Vec, } -impl Default for DungeonLayout { - fn default() -> Self { - Self { - rooms: Vec::new(), - corridors: Vec::new(), - doors: Vec::new(), - windows: Vec::new(), - text_labels: Vec::new(), - start_markers: Vec::new(), - end_markers: Vec::new(), - trap_markers: Vec::new(), - monster_markers: Vec::new(), - packed_rooms: false, - stairs: Vec::new(), - } - } -} - impl DungeonLayout { // Build an empty layout for the current packing mode. pub(crate) fn empty(packed_rooms: bool) -> Self { diff --git a/src/layout/utils.rs b/src/layout/utils.rs index 5f90265..70abe54 100644 --- a/src/layout/utils.rs +++ b/src/layout/utils.rs @@ -218,6 +218,7 @@ pub fn overlaps_with_padding(a: &Room, b: &Room, padding: usize) -> bool { a_left < b_right && a_right > b_left && a_top < b_bottom && a_bottom > b_top } +#[allow(clippy::too_many_arguments)] pub fn rects_overlap( ax: usize, ay: usize, diff --git a/src/rendering.rs b/src/rendering.rs index 1a098a7..f325794 100644 --- a/src/rendering.rs +++ b/src/rendering.rs @@ -430,6 +430,7 @@ pub fn draw_area_marker( ); } +#[allow(clippy::too_many_arguments)] pub fn draw_area_marker_group( painter: &egui::Painter, geometry: &GridGeometry,