mirror of
https://github.com/eigenein/wotbreplay-parser.git
synced 2026-10-21 10:27:01 +02:00
Break: read replay packets
This commit is contained in:
1 parent
615537ce45
commit
fb5f52038d
16 files changed
+232
-119
No files matched your search
@@ -0,0 +1,28 @@
|
||||
use byteorder::{LittleEndian, ReadBytesExt};
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::result::Result;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub enum EntityMethod {
|
||||
/// TODO: team composition.
|
||||
Subtype2F,
|
||||
|
||||
/// Default variant when subtype is not known.
|
||||
Unknown { sub_type: u32, payload: Vec<u8> },
|
||||
}
|
||||
|
||||
impl EntityMethod {
|
||||
pub fn new(payload: Vec<u8>) -> Result<Self> {
|
||||
let mut reader = payload.as_slice();
|
||||
|
||||
reader.read_u32::<LittleEndian>()?;
|
||||
let sub_type = reader.read_u32::<LittleEndian>()?;
|
||||
|
||||
let this = match sub_type {
|
||||
0x2F => Self::Subtype2F,
|
||||
_ => Self::Unknown { sub_type, payload },
|
||||
};
|
||||
Ok(this)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user