mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
e2531b2273
# Objective Timer with zero `Duration` panics at `tick()` because of division by zero. This PR Fixes #8463 . ## Solution - Handle division by zero separately with `checked_div` and `checked_rem`. --- ## Changelog - Replace division with `checked_div`. Set `times_finished_this_tick` to u32::MAX when duration is zero. - Set `elapsed` to `Duration::ZERO` when timer duration is zero. - Set `percent` to `1.0` when duration is zero. - `times_finished_this_tick` is [not used anywhere](https://github.com/bevyengine/bevy/search?q=times_finished_this_tick), that's why this change will not affect other parts of the project. - `times_finished_this_tick` is set to `0` after `reset()` and before first `tick()` call. |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |