mirror of
https://github.com/eigenein/wotbreplay-parser.git
synced 2026-10-21 10:27:01 +02:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1fb4bea267 | ||
|
|
705280fc19 | ||
|
|
3f557e33bf |
No files matched your search
@@ -14,7 +14,8 @@ World of Tanks Blitz replay parser in Rust.
|
||||
use std::fs::File;
|
||||
|
||||
use anyhow::Result;
|
||||
use wotbreplay_parser::prelude::*;
|
||||
use wotbreplay_parser::models::battle_results::TeamNumber;
|
||||
use wotbreplay_parser::replay::Replay;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let battle_results = Replay::open(File::open("tests/replays/battle_results.wotbreplay")?)?
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
use byteorder::{LittleEndian, ReadBytesExt};
|
||||
use serde::Serialize;
|
||||
use serde_with::serde_as;
|
||||
|
||||
use crate::result::Result;
|
||||
|
||||
#[serde_as]
|
||||
#[derive(Debug, Serialize)]
|
||||
pub enum EntityMethod {
|
||||
/// TODO: team composition.
|
||||
Subtype2F,
|
||||
|
||||
/// Default variant when subtype is not known.
|
||||
Unknown { sub_type: u32, payload: Vec<u8> },
|
||||
Unknown {
|
||||
sub_type: u32,
|
||||
|
||||
/// Whole packet payload (including the sub-type).
|
||||
#[serde_as(as = "serde_with::hex::Hex")]
|
||||
payload: Vec<u8>,
|
||||
},
|
||||
}
|
||||
|
||||
impl EntityMethod {
|
||||
|
||||
@@ -15,7 +15,13 @@ pub enum Payload {
|
||||
EntityMethod(EntityMethod),
|
||||
|
||||
/// Default payload when type is not known.
|
||||
Unknown(#[serde_as(as = "serde_with::hex::Hex")] Vec<u8>),
|
||||
Unknown {
|
||||
type_: u32,
|
||||
|
||||
/// Whole packet payload.
|
||||
#[serde_as(as = "serde_with::hex::Hex")]
|
||||
raw: Vec<u8>,
|
||||
},
|
||||
}
|
||||
|
||||
impl Payload {
|
||||
@@ -44,7 +50,10 @@ impl Payload {
|
||||
|
||||
8 => Self::EntityMethod(EntityMethod::new(payload)?),
|
||||
|
||||
_ => Self::Unknown(payload),
|
||||
_ => Self::Unknown {
|
||||
raw: payload,
|
||||
type_,
|
||||
},
|
||||
};
|
||||
Ok(this)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user