From e34271cf0b2f926562a15f7281d7aa4a0a86c47e Mon Sep 17 00:00:00 2001 From: Nils Hasenbanck Date: Sat, 28 Dec 2024 18:25:23 +0100 Subject: [PATCH] Properly handle when ClientTick is wrapping --- korangar/src/input/mod.rs | 2 +- korangar/src/world/entity/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/korangar/src/input/mod.rs b/korangar/src/input/mod.rs index ed92e93e..3ac94f46 100644 --- a/korangar/src/input/mod.rs +++ b/korangar/src/input/mod.rs @@ -326,7 +326,7 @@ impl InputSystem { if self.right_mouse_button.pressed() && self.previous_mouse_button.button == MouseButton::Right - && client_tick.0.saturating_sub(self.previous_mouse_button.tick.0) < DOUBLE_CLICK_TIME_MS + && client_tick.0.wrapping_sub(self.previous_mouse_button.tick.0) < DOUBLE_CLICK_TIME_MS { events.push(UserEvent::CameraResetRotation); } diff --git a/korangar/src/world/entity/mod.rs b/korangar/src/world/entity/mod.rs index 961fb227..a4f8a961 100644 --- a/korangar/src/world/entity/mod.rs +++ b/korangar/src/world/entity/mod.rs @@ -108,7 +108,7 @@ impl SoundState { let should_play = if Some(sound_effect_key) == self.previous_key && let Some(last_tick) = self.last_played_at { - (client_tick.0.saturating_sub(last_tick.0)) >= SOUND_COOLDOWN_DURATION + (client_tick.0.wrapping_sub(last_tick.0)) >= SOUND_COOLDOWN_DURATION } else { true };