mirror of
https://github.com/maciejpedzich/f1-game-packet-parser.git
synced 2025-04-20 03:21:12 +02:00
fix: replace incorrect constant for lap history entry's raw size with inline function
This commit is contained in:
parent
9b165c456d
commit
70dccb8c0b
@ -37,7 +37,7 @@ use crate::packets::session::{
|
|||||||
MAX_NUM_MARSHAL_ZONES, MAX_NUM_SESSIONS,
|
MAX_NUM_MARSHAL_ZONES, MAX_NUM_SESSIONS,
|
||||||
};
|
};
|
||||||
use crate::packets::session_history::{
|
use crate::packets::session_history::{
|
||||||
LapHistoryData, TyreStintHistoryData, LAP_HISTORY_RAW_SIZE, MAX_NUM_LAPS,
|
get_lap_history_raw_size, LapHistoryData, TyreStintHistoryData, MAX_NUM_LAPS,
|
||||||
MAX_NUM_TYRE_STINTS,
|
MAX_NUM_TYRE_STINTS,
|
||||||
};
|
};
|
||||||
use crate::packets::time_trial::TimeTrialDataSet;
|
use crate::packets::time_trial::TimeTrialDataSet;
|
||||||
@ -335,6 +335,7 @@ pub struct F1PacketSession {
|
|||||||
/// Number of sessions in the ongoing race weekend.
|
/// Number of sessions in the ongoing race weekend.
|
||||||
#[br(
|
#[br(
|
||||||
map(u8_to_usize),
|
map(u8_to_usize),
|
||||||
|
if(packet_format >= 2024),
|
||||||
assert(
|
assert(
|
||||||
num_sessions_in_weekend <= MAX_NUM_SESSIONS,
|
num_sessions_in_weekend <= MAX_NUM_SESSIONS,
|
||||||
"Session packet has an invalid number of sessions in a weekend: {}",
|
"Session packet has an invalid number of sessions in a weekend: {}",
|
||||||
@ -574,7 +575,7 @@ pub struct F1PacketSessionHistory {
|
|||||||
#[br(
|
#[br(
|
||||||
count(num_laps),
|
count(num_laps),
|
||||||
args{ inner: (packet_format,) },
|
args{ inner: (packet_format,) },
|
||||||
pad_after((MAX_NUM_LAPS - num_laps) * LAP_HISTORY_RAW_SIZE)
|
pad_after((MAX_NUM_LAPS - num_laps) * get_lap_history_raw_size(packet_format))
|
||||||
)]
|
)]
|
||||||
pub lap_history_data: Vec<LapHistoryData>,
|
pub lap_history_data: Vec<LapHistoryData>,
|
||||||
/// Tyre stint history.
|
/// Tyre stint history.
|
||||||
|
@ -5,7 +5,6 @@ use binrw::BinRead;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
pub(super) const MAX_NUM_LAPS: usize = 100;
|
pub(super) const MAX_NUM_LAPS: usize = 100;
|
||||||
pub(super) const LAP_HISTORY_RAW_SIZE: usize = 14;
|
|
||||||
pub(super) const MAX_NUM_TYRE_STINTS: usize = 8;
|
pub(super) const MAX_NUM_TYRE_STINTS: usize = 8;
|
||||||
|
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
@ -53,3 +52,12 @@ pub struct TyreStintHistoryData {
|
|||||||
/// Visual tyre compound used.
|
/// Visual tyre compound used.
|
||||||
pub visual_tyre_compound: VisualTyreCompound,
|
pub visual_tyre_compound: VisualTyreCompound,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
pub(super) fn get_lap_history_raw_size(packet_format: u16) -> usize {
|
||||||
|
if packet_format >= 2023 {
|
||||||
|
14
|
||||||
|
} else {
|
||||||
|
11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user