Unify behind leader update
This commit is contained in:
parent
440de381c7
commit
14030b137e
1 changed files with 12 additions and 18 deletions
|
@ -172,15 +172,7 @@ impl LeaderBoard {
|
|||
vehicle_scoring.mID,
|
||||
driver_name,
|
||||
vehicle_scoring.mPlace,
|
||||
{
|
||||
let laps_behind = vehicle_scoring.mLapsBehindLeader;
|
||||
|
||||
if laps_behind != 0 {
|
||||
BehindLeader::Laps(laps_behind)
|
||||
} else {
|
||||
BehindLeader::Time(vehicle_scoring.mTimeBehindLeader)
|
||||
}
|
||||
},
|
||||
Self::query_behind_leader(vehicle_scoring),
|
||||
vehicle_scoring.mTimeBehindNext,
|
||||
vehicle_scoring.mBestLapTime,
|
||||
)?;
|
||||
|
@ -334,18 +326,20 @@ impl LeaderBoard {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn query_behind_leader(scoring: &VehicleScoringInfoV01) -> BehindLeader {
|
||||
let laps_behind = scoring.mLapsBehindLeader;
|
||||
|
||||
if laps_behind != 0 {
|
||||
BehindLeader::Laps(laps_behind)
|
||||
} else {
|
||||
BehindLeader::Time(scoring.mTimeBehindLeader)
|
||||
}
|
||||
}
|
||||
|
||||
fn race_leaderboard(&mut self, vehicle_scorings: &[VehicleScoringInfoV01]) -> Result<()> {
|
||||
self.update_leaderboard(
|
||||
vehicle_scorings,
|
||||
|entry, scoring| {
|
||||
let laps_behind = scoring.mLapsBehindLeader;
|
||||
|
||||
if laps_behind != 0 {
|
||||
entry.update_time_behind_leader(BehindLeader::Laps(laps_behind))
|
||||
} else {
|
||||
entry.update_time_behind_leader(BehindLeader::Time(scoring.mTimeBehindLeader))
|
||||
}
|
||||
},
|
||||
|entry, scoring| entry.update_time_behind_leader(Self::query_behind_leader(scoring)),
|
||||
|entry| entry.force_display_behind_leader(),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue