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

some times game panics #12

Open
alibahal5 opened this issue Mar 6, 2024 · 5 comments · May be fixed by #59
Open

some times game panics #12

alibahal5 opened this issue Mar 6, 2024 · 5 comments · May be fixed by #59

Comments

@alibahal5
Copy link

@thread 'main' panicked at src\main.rs:137:41:
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `C:\Users\intel\Desktop\riverraidrust-main\target\debug\riverriderust.exe` (exit code: 101)
@Arvmor
Copy link
Contributor

Arvmor commented Mar 7, 2024

duplication of #7

@Arvmor
Copy link
Contributor

Arvmor commented Mar 8, 2024

Issue

Panics due to negative results caused by world.next_right - 5

world.next_right = rng.gen_range(world.next_right-5..world.next_right+5);

Suggestion

using saturating_sub() to avoid panicking by negative results
using max() as an easy way to set boundaries

  • saturating_sub(5) results 0 >=
  • world.next_left + 3 results 3 >=
  • Therefore max() results 3 >=
world.next_right = rng.gen_range(

max(world.next_right.saturating_sub(5), world.next_left + 3) .. world.next_right + 5

);

@mahdi-salimi05
Copy link

I've the same issue 👇👇👇👇
Screenshot from 2024-04-05 17-08-27

@MortezaHeydari97
Copy link

same issue in linux 👍🏽

@tahadostifam
Copy link

Dear @jadijadi, would give me some clues why this panics happens? i can work on it to find out some solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants