fix crash on empty group in rule output

This commit is contained in:
Crispy 2024-05-06 09:54:56 +02:00
parent 4d61184edd
commit 17e8291281

View file

@ -411,9 +411,11 @@ impl Dish {
} }
RuleCellTo::GroupRandom(group_id) => { RuleCellTo::GroupRandom(group_id) => {
let group = &self.cell_groups[group_id]; let group = &self.cell_groups[group_id];
let i = random::<usize>() % group.cells.len(); if !group.cells.is_empty() {
let cell = group.cells[i]; let i = random::<usize>() % group.cells.len();
self.set_cell(px, py, cell); let cell = group.cells[i];
self.set_cell(px, py, cell);
}
} }
RuleCellTo::Copy(x, y) => { RuleCellTo::Copy(x, y) => {
let cell = old_state[x + y * variant.width]; let cell = old_state[x + y * variant.width];