Merged
Conversation
Ralith
reviewed
Mar 8, 2026
client/src/sim.rs
Outdated
|
|
||
| pub fn prev_material(&mut self) { | ||
| self.selected_material = Material::VALUES | ||
| [(self.selected_material as usize - 1 + Material::COUNT) % Material::COUNT]; |
Owner
There was a problem hiding this comment.
Use wrapping_add and reorder operations (or also use wrapping_sub) to avoid underflow/overflow.
Collaborator
There was a problem hiding this comment.
I agree that reordering operations is needed here to avoid underflow. However, I don't think wrapping_add is necessary for the same reason as #505 (comment), and I expect using it anyway could cause panics to become logic errors.
Owner
There was a problem hiding this comment.
nit: prefer to include changes to code introduced in the same PR in the commit that introduced the revised code. This makes for easier review.
patowen
reviewed
Mar 8, 2026
| }; | ||
|
|
||
| let hit = ray_casting_result?; | ||
| let hit = self.looking_at()?; |
Ralith
approved these changes
Mar 8, 2026
patowen
approved these changes
Mar 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
this pr adds keys to cycle the selected material through all materials, and select the material the player is looking at. implements #411
there's a case to be made for scrollwheel/middle-click bindings, but mine doesnt work reliably so i cant do so myself. #403 would make this a non-issue though