diff --git a/CHANGELOG.md b/CHANGELOG.md index b0874a123a..9bb77bcb69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added + - Added a skill tree for mining, which gains xp from mining ores and gems. - Added debug line info to release builds, enhancing the usefulness of panic backtraces - NPCs and animals can now make sounds in response to certain events @@ -15,15 +16,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Ability to toggle chat visibility ### Changed + - Entity-entity pushback is no longer applied in forced movement states like rolling and leaping. - Updated audio library (rodio 0.13 -> 0.14). - Improve entity-terrain physics performance by reducing the number of voxel lookups. - Clay Golem uses shockwave only after specific fraction of health and other difficulty adjustments. +- Made strafing slightly slower ### Removed + - Enemies no more spawn in dungeon boss room ### Fixed + - Crafting Stations aren't exploadable anymore - Cases where no audio output could be produced before. - Significantly improved the performance of playing sound effects diff --git a/common/src/comp/controller.rs b/common/src/comp/controller.rs index 2979de12a5..7d4a1a7448 100644 --- a/common/src/comp/controller.rs +++ b/common/src/comp/controller.rs @@ -215,6 +215,20 @@ pub struct Controller { } impl ControllerInputs { + /// Sanitize inputs to avoid clients sending bad data. + pub fn sanitize(&mut self) { + self.move_dir = if self.move_dir.map(|e| e.is_finite()).reduce_and() { + self.move_dir / self.move_dir.magnitude().max(1.0) + } else { + Vec2::zero() + }; + self.move_z = if self.move_z.is_finite() { + self.move_z.clamped(-1.0, 1.0) + } else { + 0.0 + }; + } + /// Updates Controller inputs with new version received from the client pub fn update_with_new(&mut self, new: Self) { self.climb = new.climb; diff --git a/common/systems/src/controller.rs b/common/systems/src/controller.rs index 2aea04b55a..7cc1e67e23 100644 --- a/common/systems/src/controller.rs +++ b/common/systems/src/controller.rs @@ -37,16 +37,8 @@ impl<'a> System<'a> for Sys { let mut server_emitter = read_data.server_bus.emitter(); for (entity, controller) in (&read_data.entities, &mut controllers).join() { - let mut inputs = &mut controller.inputs; - - // Update `inputs.move_dir`. - inputs.move_dir = if inputs.move_dir.magnitude_squared() > 1.0 { - // Cap move_dir to 1 - inputs.move_dir.normalized() - } else { - inputs.move_dir - }; - inputs.move_z = inputs.move_z.clamped(-1.0, 1.0); + // Sanitize inputs to avoid clients sending bad data + controller.inputs.sanitize(); // Process other controller events for event in controller.events.drain(..) {