mirror of
https://github.com/maciejpedzich/f1-game-packet-parser.git
synced 2025-04-12 00:21:11 +02:00
fix: offset f32 assert range ends by a tenth
This commit is contained in:
parent
a93b93cfb5
commit
53af241949
@ -4,6 +4,11 @@ use crate::constants::{RevLights, Surface};
|
||||
use binrw::BinRead;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
// f32 range ends were offset by a tenth to account for values ever so slightly
|
||||
// greater or lower than the respective extreme.
|
||||
// There's probably a better way of going about handling this,
|
||||
// but this will do for now.
|
||||
|
||||
#[non_exhaustive]
|
||||
#[derive(BinRead, PartialEq, PartialOrd, Copy, Clone, Debug, Serialize, Deserialize)]
|
||||
#[br(little, import(_packet_format: u16))]
|
||||
@ -13,7 +18,7 @@ pub struct CarTelemetryData {
|
||||
/// Amount of throttle applied. Value in range `(0.0..=1.0)`.
|
||||
#[br(
|
||||
assert(
|
||||
(0.0..=1.0).contains(&throttle),
|
||||
(-0.1..=1.1).contains(&throttle),
|
||||
"Car telemetry entry has an invalid throttle value: {}",
|
||||
throttle
|
||||
),
|
||||
@ -22,7 +27,7 @@ pub struct CarTelemetryData {
|
||||
/// Steering lock. Value in range `(-1.0..=1.0)`.
|
||||
#[br(
|
||||
assert(
|
||||
(-1.0..=1.0).contains(&steer),
|
||||
(-1.1..=1.1).contains(&steer),
|
||||
"Car telemetry entry has an invalid steering lock value: {}",
|
||||
steer
|
||||
),
|
||||
@ -31,7 +36,7 @@ pub struct CarTelemetryData {
|
||||
/// Amount of brake applied. Value in range `(0.0..=1.0)`.
|
||||
#[br(
|
||||
assert(
|
||||
(0.0..=1.0).contains(&brake),
|
||||
(-0.1..=1.1).contains(&brake),
|
||||
"Car telemetry entry has an invalid brake value: {}",
|
||||
brake
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user