mirror of
https://codeberg.org/icewind/tf-log-parser.git
synced 2026-06-03 10:14:10 +02:00
handle some more event types
This commit is contained in:
parent
f5957059d8
commit
3ad9ebafd7
5 changed files with 33 additions and 5 deletions
|
|
@ -93,14 +93,29 @@ pub enum GameEvent<'a> {
|
|||
PointCaptured(PointCapturedEvent<'a>),
|
||||
CurrentScore(CurrentScoreEvent),
|
||||
BuiltObject(BuiltObjectEvent<'a>),
|
||||
DropObject(DropObjectEvent<'a>),
|
||||
CarryObject(BuiltCarryEvent<'a>),
|
||||
KilledObject(KilledObjectEvent<'a>),
|
||||
Extinguished(ExtinguishedEvent<'a>),
|
||||
GameOver(GameOverEvent<'a>),
|
||||
FinalScore(FinalScoreEvent),
|
||||
ObjectDetonated(ObjectDetonatedEvent<'a>),
|
||||
Request(UnparsedEvent<'a>),
|
||||
Response(UnparsedEvent<'a>),
|
||||
LogFileClosed,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct UnparsedEvent<'a> {
|
||||
pub params: &'a str,
|
||||
}
|
||||
|
||||
impl<'a> Event<'a> for UnparsedEvent<'a> {
|
||||
fn parse(input: &'a str) -> IResult<Self> {
|
||||
Ok(("", UnparsedEvent { params: input }))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ParamIter<'a> {
|
||||
input: &'a str,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,6 +100,18 @@ pub struct BuiltObjectEvent<'a> {
|
|||
pub position: Option<(i32, i32, i32)>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Event)]
|
||||
pub struct BuiltCarryEvent<'a> {
|
||||
pub object: Option<&'a str>,
|
||||
pub position: Option<(i32, i32, i32)>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Event)]
|
||||
pub struct DropObjectEvent<'a> {
|
||||
pub object: Option<&'a str>,
|
||||
pub position: Option<(i32, i32, i32)>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Event)]
|
||||
pub struct KilledObjectEvent<'a> {
|
||||
pub object: Option<&'a str>,
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ impl<'a> LineSplit<'a> {
|
|||
LineSplit {
|
||||
input,
|
||||
start: 0,
|
||||
iter: find_iter(input.as_bytes(), b"L "),
|
||||
iter: find_iter(input.as_bytes(), b"\nL "),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -131,8 +131,8 @@ impl<'a> Iterator for LineSplit<'a> {
|
|||
fn next(&mut self) -> Option<Self::Item> {
|
||||
match self.iter.next() {
|
||||
Some(next) => {
|
||||
let line = &self.input[self.start..next - 1]; // -1 for the newline we strip
|
||||
self.start = next + 2;
|
||||
let line = &self.input[self.start..next];
|
||||
self.start = next + 3;
|
||||
Some(line)
|
||||
}
|
||||
None if self.start < self.input.len() => {
|
||||
|
|
|
|||
|
|
@ -180,9 +180,9 @@ pub enum RawEventType {
|
|||
#[token(r#"triggered "player_builtobject""#)]
|
||||
BuiltObject,
|
||||
#[token(r#"triggered "player_dropobject""#)]
|
||||
PlayerCarryObject,
|
||||
CarryObject,
|
||||
#[token(r#"triggered "player_carryobject""#)]
|
||||
PlayerDropObject,
|
||||
DropObject,
|
||||
#[token(r#"triggered "killedobject""#)]
|
||||
KilledObject,
|
||||
#[token(r#"triggered "object_detonated""#)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue