mirror of
https://codeberg.org/icewind/log-normalizer.git
synced 2026-06-03 13:54:11 +02:00
less panicy
This commit is contained in:
parent
1b256ecfd9
commit
1df2cd0357
2 changed files with 8 additions and 6 deletions
|
|
@ -92,7 +92,7 @@ impl From<RawLog> for NormalizedLog {
|
|||
.into_iter()
|
||||
.map(|raw| Round::from(raw))
|
||||
.collect();
|
||||
let teams = raw.teams.or(raw.info.teams).unwrap();
|
||||
let teams = raw.teams.or(raw.info.teams).unwrap_or_default();
|
||||
|
||||
let mut normalized = NormalizedLog {
|
||||
version: raw.version,
|
||||
|
|
@ -127,8 +127,8 @@ impl From<crate::raw::Round> for Round {
|
|||
_ => None,
|
||||
})
|
||||
})
|
||||
.unwrap();
|
||||
let team = raw.team.or(raw.flat_team).unwrap();
|
||||
.unwrap_or(TeamId::Blue);
|
||||
let team = raw.team.or(raw.flat_team).unwrap_or_default();
|
||||
|
||||
Round {
|
||||
start_time: raw.start_time,
|
||||
|
|
@ -191,7 +191,9 @@ fn normalize_stopwatch_events(log: &mut NormalizedLog) {
|
|||
team: TeamId::Blue,
|
||||
point: first_half_rounds,
|
||||
});
|
||||
log.rounds[1].events.push(last_event.unwrap());
|
||||
if let Some(last_event) = last_event {
|
||||
log.rounds[1].events.push(last_event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,14 +26,14 @@ pub struct RawLog {
|
|||
pub info: Info,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[derive(Debug, Clone, Deserialize, Default)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
pub struct Teams {
|
||||
pub red: Team,
|
||||
pub blue: Team,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[derive(Debug, Clone, Deserialize, Default)]
|
||||
pub struct Team {
|
||||
pub score: u8,
|
||||
#[serde(default)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue