Merge branch 'crabman/controller-modifier-unwrap' into 'master'

Get rid of unwrap in controller modifier handler

See merge request veloren/veloren!4115
This commit is contained in:
Imbris 2023-09-18 23:57:26 +00:00
commit 256b3d1e16

View File

@ -602,8 +602,14 @@ impl Window {
if settings.modifier_buttons.contains(button) {
if is_pressed {
modifiers.push(*button);
} else {
let index = modifiers.iter().position(|x| x == button).unwrap();
// There is a possibility of voxygen not having
// registered the initial press event (either because it
// hadn't started yet, or whatever else) hence the
// modifier has no position in the list, unwrapping
// here would cause a crash in those cases
} else if let Some(index) =
modifiers.iter().position(|modifier| modifier == button)
{
modifiers.remove(index);
}
}