Compare commits

..

No commits in common. "master" and "v1.0.0" have entirely different histories.

6 changed files with 48 additions and 55 deletions

View File

@ -7,12 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [1.0.3](https://github.com/maciejpedzich/f1-game-packet-parser/compare/v1.0.2...v1.0.3) - 2025-03-16
### Other
- *(deps)* bump the patch-updates group with 3 updates
## [1.0.0](https://github.com/maciejpedzich/f1-game-packet-parser/releases/tag/v1.0.0) - 2025-02-28 ## [1.0.0](https://github.com/maciejpedzich/f1-game-packet-parser/releases/tag/v1.0.0) - 2025-02-28
### Added ### Added

34
Cargo.lock generated
View File

@ -34,25 +34,25 @@ dependencies = [
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "2.9.0" version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
[[package]] [[package]]
name = "bytemuck" name = "bytemuck"
version = "1.22.0" version = "1.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6b1fc10dbac614ebc03540c9dbd60e83887fda27794998c6528f1782047d540" checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3"
[[package]] [[package]]
name = "either" name = "either"
version = "1.15.0" version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
[[package]] [[package]]
name = "f1-game-packet-parser" name = "f1-game-packet-parser"
version = "1.0.3" version = "1.0.0"
dependencies = [ dependencies = [
"binrw", "binrw",
"bitflags", "bitflags",
@ -67,36 +67,36 @@ checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.95" version = "1.0.93"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.40" version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.219" version = "1.0.218"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.219" version = "1.0.218"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -127,6 +127,6 @@ dependencies = [
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.18" version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe"

View File

@ -1,7 +1,7 @@
[package] [package]
name = "f1-game-packet-parser" name = "f1-game-packet-parser"
description = "Convert binary data from F1 24, F1 23, and F1 22 UDP telemetry into organised structs." description = "Convert binary data from F1 24, F1 23, and F1 22 UDP telemetry into organised structs."
version = "1.0.3" version = "1.0.0"
edition = "2021" edition = "2021"
rust-version = "1.78" rust-version = "1.78"
readme = "README.md" readme = "README.md"
@ -14,10 +14,9 @@ license = "MIT"
exclude = [ exclude = [
".github/*", ".github/*",
".idea/*", ".idea/*",
"tests/*"
] ]
[dependencies] [dependencies]
binrw = "0.14.1" binrw = "0.14.1"
bitflags = "2.9.0" bitflags = "2.8.0"
serde = { version = "1.0.219", features = ["derive"] } serde = { version = "1.0.218", features = ["derive"] }

View File

@ -105,7 +105,7 @@ pub enum Weather {
Storm = 5, Storm = 5,
} }
/// Temperature change direction. Represents an [`i8`]. /// Temperature change direction. Represents a [`u8`].
#[non_exhaustive] #[non_exhaustive]
#[derive( #[derive(
BinRead, BinRead,
@ -666,20 +666,18 @@ pub enum InfringementType {
SafetyCarExceedingAllowedPace = 37, SafetyCarExceedingAllowedPace = 37,
VirtualSafetyCarExceedingAllowedPace = 38, VirtualSafetyCarExceedingAllowedPace = 38,
FormationLapBelowAllowedSpeed = 39, FormationLapBelowAllowedSpeed = 39,
FormationLapParking = 40, RetiredMechanicalFailure = 40,
RetiredMechanicalFailure = 41, RetiredTerminallyDamaged = 41,
RetiredTerminallyDamaged = 42, SafetyCarFallingTooFarBack = 42,
SafetyCarFallingTooFarBack = 43, BlackFlagTimer = 43,
BlackFlagTimer = 44, UnservedStopGoPenalty = 44,
UnservedStopGoPenalty = 45, UnservedDriveThroughPenalty = 45,
UnservedDriveThroughPenalty = 46, EngineComponentChange = 46,
EngineComponentChange = 47, GearboxChange = 47,
GearboxChange = 48, LeagueGridPenalty = 48,
ParcFermeChange = 49, RetryPenalty = 49,
LeagueGridPenalty = 50, IllegalTimeGain = 50,
RetryPenalty = 51, MandatoryPitStop = 51,
IllegalTimeGain = 52,
MandatoryPitStop = 53,
AttributeAssigned = 54, AttributeAssigned = 54,
} }
@ -1067,7 +1065,7 @@ pub enum ErsDeployMode {
Hotlap = 3, Hotlap = 3,
} }
/// Flag the driver is currently being shown. Represents an [`i8`]. /// Flag the driver is currently being shown. Represents a [`u8`].
#[non_exhaustive] #[non_exhaustive]
#[derive( #[derive(
BinRead, BinRead,

View File

@ -1,7 +1,7 @@
//! Convert binary data from F1 24, F1 23, and F1 22 UDP telemetry into organised structs. //! Convert binary data from F1 24, F1 23, and F1 22 UDP telemetry into organised structs.
//! ## Getting started //! ## Getting started
//! //!
//! Add `f1-game-packet-parser` to your project by running the following command: //! Add `f1_game_packet_parser` to your project by running the following command:
//! //!
//! ```sh //! ```sh
//! cargo add f1-game-packet-parser //! cargo add f1-game-packet-parser
@ -186,7 +186,7 @@ pub mod constants;
/// and submodules for packet-specific structs. /// and submodules for packet-specific structs.
pub mod packets; pub mod packets;
use crate::constants::PacketId; use crate::constants::{PacketId, MAX_NUM_CARS};
use crate::packets::{ use crate::packets::{
u8_to_usize, F1PacketCarDamage, F1PacketCarSetups, F1PacketCarStatus, u8_to_usize, F1PacketCarDamage, F1PacketCarSetups, F1PacketCarStatus,
F1PacketCarTelemetry, F1PacketEvent, F1PacketFinalClassification, F1PacketLaps, F1PacketCarTelemetry, F1PacketEvent, F1PacketFinalClassification, F1PacketLaps,
@ -361,8 +361,15 @@ pub struct F1PacketHeader {
/// Available from the 2023 format onwards. /// Available from the 2023 format onwards.
#[br(if(packet_format >= 2023))] #[br(if(packet_format >= 2023))]
pub overall_frame_identifier: u32, pub overall_frame_identifier: u32,
/// Index of player 1's car (255 if in spectator mode). /// Index of player 1's car.
#[br(map(u8_to_usize))] #[br(
map(u8_to_usize),
assert(
player_car_index < MAX_NUM_CARS,
"Header has an invalid player 1 car index: {}",
player_car_index
)
)]
pub player_car_index: usize, pub player_car_index: usize,
/// Index of player 2's car in splitscreen mode. /// Index of player 2's car in splitscreen mode.
/// Set to 255 if not in splitscreen mode. /// Set to 255 if not in splitscreen mode.

View File

@ -4,11 +4,6 @@ use crate::constants::{RevLights, Surface};
use binrw::BinRead; use binrw::BinRead;
use serde::{Deserialize, Serialize}; 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] #[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))]
@ -18,7 +13,7 @@ pub struct CarTelemetryData {
/// Amount of throttle applied. Value in range `(0.0..=1.0)`. /// Amount of throttle applied. Value in range `(0.0..=1.0)`.
#[br( #[br(
assert( assert(
(-0.1..=1.1).contains(&throttle), (0.0..=1.0).contains(&throttle),
"Car telemetry entry has an invalid throttle value: {}", "Car telemetry entry has an invalid throttle value: {}",
throttle throttle
), ),
@ -27,7 +22,7 @@ pub struct CarTelemetryData {
/// Steering lock. Value in range `(-1.0..=1.0)`. /// Steering lock. Value in range `(-1.0..=1.0)`.
#[br( #[br(
assert( assert(
(-1.1..=1.1).contains(&steer), (-1.0..=1.0).contains(&steer),
"Car telemetry entry has an invalid steering lock value: {}", "Car telemetry entry has an invalid steering lock value: {}",
steer steer
), ),
@ -36,7 +31,7 @@ pub struct CarTelemetryData {
/// Amount of brake applied. Value in range `(0.0..=1.0)`. /// Amount of brake applied. Value in range `(0.0..=1.0)`.
#[br( #[br(
assert( assert(
(-0.1..=1.1).contains(&brake), (0.0..=1.0).contains(&brake),
"Car telemetry entry has an invalid brake value: {}", "Car telemetry entry has an invalid brake value: {}",
brake brake
), ),