mirror of
https://codeberg.org/icewind/tf-log-parser.git
synced 2026-06-03 18:24:09 +02:00
handle some truncted logs
This commit is contained in:
parent
f1213a5664
commit
b32f8dd340
1 changed files with 16 additions and 1 deletions
17
src/lib.rs
17
src/lib.rs
|
|
@ -78,12 +78,27 @@ pub fn parse_with_handler<Handler: EventHandler>(
|
||||||
let mut start_time: Option<NaiveDateTime> = None;
|
let mut start_time: Option<NaiveDateTime> = None;
|
||||||
let mut subjects = SubjectMap::<Handler::PerSubjectData>::with_capacity(32);
|
let mut subjects = SubjectMap::<Handler::PerSubjectData>::with_capacity(32);
|
||||||
|
|
||||||
|
let mut game_over = false;
|
||||||
|
|
||||||
for event_res in events {
|
for event_res in events {
|
||||||
let raw_event = event_res?;
|
let raw_event = event_res?;
|
||||||
|
if raw_event.ty == RawEventType::GameOver {
|
||||||
|
game_over = true;
|
||||||
|
}
|
||||||
let should_handle = Handler::does_handle(raw_event.ty);
|
let should_handle = Handler::does_handle(raw_event.ty);
|
||||||
if should_handle || start_time.is_none() {
|
if should_handle || start_time.is_none() {
|
||||||
if should_handle {
|
if should_handle {
|
||||||
let event = GameEvent::parse(&raw_event)?;
|
let event = match GameEvent::parse(&raw_event) {
|
||||||
|
Ok(event) => event,
|
||||||
|
Err(e) => {
|
||||||
|
// handle truncated logs after game over
|
||||||
|
if game_over {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
return Err(e.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
handler.process(&raw_event, &event, &mut start_time, &mut subjects)?;
|
handler.process(&raw_event, &event, &mut start_time, &mut subjects)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue