Handle more states of drivers
This commit is contained in:
parent
14030b137e
commit
c152132c74
2 changed files with 36 additions and 5 deletions
|
@ -9,6 +9,9 @@ use vulkan_rs::prelude::*;
|
|||
pub enum BehindLeader {
|
||||
Time(f64),
|
||||
Laps(i32),
|
||||
DNF,
|
||||
DSQ,
|
||||
PITS,
|
||||
}
|
||||
|
||||
pub struct LeaderBoardEntry {
|
||||
|
@ -164,6 +167,15 @@ impl LeaderBoardEntry {
|
|||
BehindLeader::Laps(laps_behind) => {
|
||||
self.time_label.set_text(format!("+{}", laps_behind))?;
|
||||
}
|
||||
BehindLeader::DNF => {
|
||||
self.time_label.set_text("DNF")?;
|
||||
}
|
||||
BehindLeader::DSQ => {
|
||||
self.time_label.set_text("DSQ")?;
|
||||
}
|
||||
BehindLeader::PITS => {
|
||||
self.time_label.set_text("PIT")?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -327,6 +327,11 @@ impl LeaderBoard {
|
|||
}
|
||||
|
||||
fn query_behind_leader(scoring: &VehicleScoringInfoV01) -> BehindLeader {
|
||||
match scoring.mFinishStatus {
|
||||
0 | 1 => {
|
||||
if scoring.mInPits != 0 {
|
||||
BehindLeader::PITS
|
||||
} else {
|
||||
let laps_behind = scoring.mLapsBehindLeader;
|
||||
|
||||
if laps_behind != 0 {
|
||||
|
@ -335,6 +340,20 @@ impl LeaderBoard {
|
|||
BehindLeader::Time(scoring.mTimeBehindLeader)
|
||||
}
|
||||
}
|
||||
}
|
||||
2 => BehindLeader::DNF,
|
||||
3 => BehindLeader::DSQ,
|
||||
|
||||
_ => {
|
||||
write_log!(format!(
|
||||
"not allowed finish state: {}",
|
||||
scoring.mFinishStatus
|
||||
));
|
||||
|
||||
BehindLeader::Time(scoring.mTimeBehindLeader)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn race_leaderboard(&mut self, vehicle_scorings: &[VehicleScoringInfoV01]) -> Result<()> {
|
||||
self.update_leaderboard(
|
||||
|
|
Loading…
Reference in a new issue