Skip to content

Commit ec282f5

Browse files
authored
fix: use saturating_add on received_movement_packets (#894)
Without saturating_add, the server may panic if it receives too many movement packets within one tick.
1 parent e5d68ea commit ec282f5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crates/hyperion/src/simulation/handlers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ fn change_position_or_correct_client(
8989
.set(PendingTeleportation::new(pose.position));
9090
}
9191
query.view.get::<&mut MovementTracking>(|tracking| {
92-
tracking.received_movement_packets += 1;
92+
tracking.received_movement_packets = tracking.received_movement_packets.saturating_add(1);
9393
let y_delta = proposed.y - pose.y;
9494

9595
if y_delta > 0. && tracking.was_on_ground && !on_ground {

0 commit comments

Comments
 (0)