aboutsummaryrefslogtreecommitdiff
path: root/server/protocol
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-07-18 15:52:12 +0200
committermetamuffin <metamuffin@disroot.org>2024-07-18 15:52:12 +0200
commit1bff001db2914e8ee7bc331a4104592ad6e2e9a3 (patch)
tree28b12471e0dc905a8135123df8ddf400c24ed8b2 /server/protocol
parent1dd3f549debdffd85639d74248a12dd884c5a59b (diff)
downloadhurrycurry-1bff001db2914e8ee7bc331a4104592ad6e2e9a3.tar
hurrycurry-1bff001db2914e8ee7bc331a4104592ad6e2e9a3.tar.bz2
hurrycurry-1bff001db2914e8ee7bc331a4104592ad6e2e9a3.tar.zst
clippy
Diffstat (limited to 'server/protocol')
-rw-r--r--server/protocol/src/movement.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/server/protocol/src/movement.rs b/server/protocol/src/movement.rs
index ab4eb818..76a243e2 100644
--- a/server/protocol/src/movement.rs
+++ b/server/protocol/src/movement.rs
@@ -67,11 +67,11 @@ impl MovementBase {
} else {
dt / BOOST_RESTORE
};
- self.stamina = self.stamina.max(0.).min(1.);
+ self.stamina = self.stamina.clamp(0., 1.);
let speed = PLAYER_SPEED * if self.boosting { BOOST_FACTOR } else { 1. };
self.velocity += direction * dt * speed;
self.position += self.velocity * dt;
- self.velocity = self.velocity * (-dt * PLAYER_FRICTION).exp();
+ self.velocity *= (-dt * PLAYER_FRICTION).exp();
collide_player_tiles(self, map);
PacketS::Movement {
@@ -84,7 +84,10 @@ impl MovementBase {
pub fn collide(&mut self, other: &mut Self, dt: f32) {
let diff = self.position - other.position;
let d = diff.length();
- if d < 0.01 || d > PLAYER_SIZE * 2. {
+ if d < 0.01 {
+ return;
+ }
+ if d > PLAYER_SIZE * 2. {
return;
}
let norm = diff.normalize();