Skip to content

Commit

Permalink
fix: fix a potential crash
Browse files Browse the repository at this point in the history
Some Windows versions will crash if user continue to click when the program window is unresponsive.
  • Loading branch information
ShenMian committed Jan 15, 2024
1 parent 762e3e3 commit 8fe342c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/systems/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ fn solve_level(board: &mut crate::board::Board, player_movement: &mut ResMut<Pla
}
Err(SolveError::Timeout) => {
info!(
"Solver(: Failed to find a solution within the given time limit ({} sec)",
"Solver: Failed to find a solution within the given time limit ({} sec)",
timer.elapsed().as_millis() as f32 / 1000.0
);
}
Expand Down Expand Up @@ -400,7 +400,11 @@ pub fn mouse_input(
let (camera, camera_transform, mut main_camera) = camera.single_mut();

if mouse_buttons.just_pressed(MouseButton::Left) {
let cursor_position = windows.single().cursor_position().unwrap();
let cursor_position = windows.single().cursor_position();
if cursor_position.is_none() {
return;
}
let cursor_position = cursor_position.unwrap();
let position = camera
.viewport_to_world_2d(camera_transform, cursor_position)
.unwrap();
Expand Down

0 comments on commit 8fe342c

Please sign in to comment.