mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Sanitise controller inputs
This commit is contained in:
parent
90e5bac395
commit
e930ff6779
@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Added a skill tree for mining, which gains xp from mining ores and gems.
|
- 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
|
- 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
|
- 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
|
- Ability to toggle chat visibility
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Entity-entity pushback is no longer applied in forced movement states like rolling and leaping.
|
- Entity-entity pushback is no longer applied in forced movement states like rolling and leaping.
|
||||||
- Updated audio library (rodio 0.13 -> 0.14).
|
- Updated audio library (rodio 0.13 -> 0.14).
|
||||||
- Improve entity-terrain physics performance by reducing the number of voxel lookups.
|
- 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.
|
- Clay Golem uses shockwave only after specific fraction of health and other difficulty adjustments.
|
||||||
|
- Made strafing slightly slower
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
- Enemies no more spawn in dungeon boss room
|
- Enemies no more spawn in dungeon boss room
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Crafting Stations aren't exploadable anymore
|
- Crafting Stations aren't exploadable anymore
|
||||||
- Cases where no audio output could be produced before.
|
- Cases where no audio output could be produced before.
|
||||||
- Significantly improved the performance of playing sound effects
|
- Significantly improved the performance of playing sound effects
|
||||||
|
@ -215,6 +215,20 @@ pub struct Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ControllerInputs {
|
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
|
/// Updates Controller inputs with new version received from the client
|
||||||
pub fn update_with_new(&mut self, new: Self) {
|
pub fn update_with_new(&mut self, new: Self) {
|
||||||
self.climb = new.climb;
|
self.climb = new.climb;
|
||||||
|
@ -37,16 +37,8 @@ impl<'a> System<'a> for Sys {
|
|||||||
let mut server_emitter = read_data.server_bus.emitter();
|
let mut server_emitter = read_data.server_bus.emitter();
|
||||||
|
|
||||||
for (entity, controller) in (&read_data.entities, &mut controllers).join() {
|
for (entity, controller) in (&read_data.entities, &mut controllers).join() {
|
||||||
let mut inputs = &mut controller.inputs;
|
// Sanitize inputs to avoid clients sending bad data
|
||||||
|
controller.inputs.sanitize();
|
||||||
// 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);
|
|
||||||
|
|
||||||
// Process other controller events
|
// Process other controller events
|
||||||
for event in controller.events.drain(..) {
|
for event in controller.events.drain(..) {
|
||||||
|
Loading…
Reference in New Issue
Block a user