mirror of
https://github.com/maciejpedzich/f1-game-packet-parser.git
synced 2025-04-20 03:21:12 +02:00
refactor: use from_bits_retain instead of truncate when reading bitmap fields
This commit is contained in:
parent
f011e68702
commit
1bdf45a1ee
@ -70,7 +70,7 @@ pub struct CarTelemetryData {
|
|||||||
)]
|
)]
|
||||||
pub rev_lights_percent: u8,
|
pub rev_lights_percent: u8,
|
||||||
/// Bitmap of active rev lights.
|
/// Bitmap of active rev lights.
|
||||||
#[br(map(RevLights::from_bits_truncate))]
|
#[br(map(RevLights::from_bits_retain))]
|
||||||
pub rev_lights_bit_value: RevLights,
|
pub rev_lights_bit_value: RevLights,
|
||||||
/// Brakes' temperature values in degrees Celsius.
|
/// Brakes' temperature values in degrees Celsius.
|
||||||
/// See [`wheel_index`](mod@crate::constants::wheel_index)
|
/// See [`wheel_index`](mod@crate::constants::wheel_index)
|
||||||
|
@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(BinRead, PartialEq, PartialOrd, Copy, Clone, Debug, Serialize, Deserialize)]
|
#[derive(BinRead, PartialEq, PartialOrd, Copy, Clone, Debug, Serialize, Deserialize)]
|
||||||
#[br(little, import(_packet_format: u16))]
|
#[br(little, import(_packet_format: u16))]
|
||||||
pub enum EventDataDetails {
|
pub enum EventDetails {
|
||||||
/// Sent when the session starts.
|
/// Sent when the session starts.
|
||||||
#[br(magic = b"SSTA")]
|
#[br(magic = b"SSTA")]
|
||||||
SessionStarted,
|
SessionStarted,
|
||||||
@ -130,7 +130,7 @@ pub enum EventDataDetails {
|
|||||||
#[br(magic = b"BUTN")]
|
#[br(magic = b"BUTN")]
|
||||||
Buttons {
|
Buttons {
|
||||||
/// Bitmap specifying which buttons are currently pressed.
|
/// Bitmap specifying which buttons are currently pressed.
|
||||||
#[br(map(ButtonStatus::from_bits_truncate))]
|
#[br(map(ButtonStatus::from_bits_retain))]
|
||||||
button_status: ButtonStatus,
|
button_status: ButtonStatus,
|
||||||
},
|
},
|
||||||
/// Sent when a car has overtaken another.
|
/// Sent when a car has overtaken another.
|
||||||
@ -154,9 +154,9 @@ pub enum EventDataDetails {
|
|||||||
Collision {
|
Collision {
|
||||||
/// Index of the first vehicle involved in the collision.
|
/// Index of the first vehicle involved in the collision.
|
||||||
#[br(map(u8_to_usize))]
|
#[br(map(u8_to_usize))]
|
||||||
vehicle1_index: usize,
|
vehicle_index: usize,
|
||||||
/// Index of the second vehicle involved in the collision.
|
/// Index of the second vehicle involved in the collision.
|
||||||
#[br(map(u8_to_usize))]
|
#[br(map(u8_to_usize))]
|
||||||
vehicle2_index: usize,
|
other_vehicle_index: usize,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ pub struct LapHistoryData {
|
|||||||
#[br(if(packet_format >= 2023))]
|
#[br(if(packet_format >= 2023))]
|
||||||
pub sector3_time_minutes: u8,
|
pub sector3_time_minutes: u8,
|
||||||
/// Bitmap of lap validity across all sectors and overall.
|
/// Bitmap of lap validity across all sectors and overall.
|
||||||
#[br(map(LapValid::from_bits_truncate))]
|
#[br(map(LapValid::from_bits_retain))]
|
||||||
pub lap_valid_bit_flags: LapValid,
|
pub lap_valid_bit_flags: LapValid,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user