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

fix(pumpkin-inventory/src/drag_handler.rs): divide by 0 #393

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pumpkin-inventory/src/drag_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,12 @@ impl DragHandler {
let changing_slots =
drag.possibly_changing_slots(&slots_cloned, carried_item.item_id);
let amount_of_slots = changing_slots.clone().count();
let (amount_per_slot, remainder) =
(carried_item.item_count as usize).div_rem_euclid(&amount_of_slots);
let (amount_per_slot, remainder) = if amount_of_slots == 0 {
// TODO: please work lol
(1, 0)
} else {
(carried_item.item_count as usize).div_rem_euclid(&amount_of_slots)
};
let mut item_in_each_slot = *carried_item;
item_in_each_slot.item_count = amount_per_slot as u8;
changing_slots.for_each(|slot| *slots[slot] = Some(item_in_each_slot));
Expand Down
Loading