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

Using global rand functions can have bad results if the user attempts to use seed(...) #238

Closed
Lexari0 opened this issue Aug 21, 2024 · 2 comments · Fixed by #270
Closed

Comments

@Lexari0
Copy link

Lexari0 commented Aug 21, 2024

NetworkWeapon._generate_id(...) calls randi_range(...) for selecting random characters. This would normally be fine, but if a user attempts to use seed(...) to intentionally generate the same random values all peers it'll end up re-using the same values.

Using a RandomNumberGenerator (initialized with randomize()) to always maintain a seed unique from others' code and expectations is recommended (also for the user, so this is half on me 😉).

@Lexari0
Copy link
Author

Lexari0 commented Aug 21, 2024

Follow-up to this: NetworkWeapon._save_projectile() does no checks to see if the id is already taken.

@elementbound
Copy link
Contributor

There's some design discussions still up in the air, but in the meantime #270 should fix this.
@Lexari0 feel free to check the PR and add any notes if you have, otherwise I'll merge it in the coming days :) You can grab the modified source and plop it into your project in case you're blocked by this.

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.

2 participants