mirror of
https://github.com/eigenein/wotbreplay-parser.git
synced 2026-10-21 10:27:01 +02:00
💥 Hide raw payloads behind the feature flag, and improve the performance
This commit is contained in:
1 parent
2d2c85c18a
commit
a177447ca1
4 files changed
+40
-44
No files matched your search
@@ -15,48 +15,37 @@ pub mod update_arena;
|
||||
#[serde_as]
|
||||
#[derive(Debug, Serialize)]
|
||||
pub enum EntityMethod {
|
||||
/// Subtype `0x2F`.
|
||||
/// Subtype 47.
|
||||
UpdateArena {
|
||||
field_number: u64,
|
||||
arguments: UpdateArena,
|
||||
|
||||
/// Original payload for investigation.
|
||||
#[serde_as(as = "serde_with::hex::Hex")]
|
||||
payload: Vec<u8>,
|
||||
},
|
||||
|
||||
/// Default variant when subtype is not known by the parser.
|
||||
Unknown {
|
||||
sub_type: u32,
|
||||
|
||||
/// Whole packet payload (including the sub-type).
|
||||
#[serde_as(as = "serde_with::hex::Hex")]
|
||||
payload: Vec<u8>,
|
||||
},
|
||||
Unknown { sub_type: u32 },
|
||||
}
|
||||
|
||||
impl EntityMethod {
|
||||
/// Parse the entity method payload.
|
||||
pub fn new(payload: Vec<u8>) -> Result<Self> {
|
||||
let mut reader = payload.as_slice();
|
||||
pub fn new(payload: &[u8]) -> Result<Self> {
|
||||
let mut payload = payload;
|
||||
|
||||
reader.read_u32::<LittleEndian>()?;
|
||||
let sub_type = reader.read_u32::<LittleEndian>()?;
|
||||
payload.read_u32::<LittleEndian>()?;
|
||||
let sub_type = payload.read_u32::<LittleEndian>()?;
|
||||
|
||||
let this = match sub_type {
|
||||
0x2F => {
|
||||
let _inner_length = reader.read_u32::<LittleEndian>()?;
|
||||
47 => {
|
||||
let _inner_length = payload.read_u32::<LittleEndian>()?;
|
||||
|
||||
let field_number = decode_varint(&mut reader)?;
|
||||
let message_length = read_quirky_length(&mut reader)?;
|
||||
let field_number = decode_varint(&mut payload)?;
|
||||
let message_length = read_quirky_length(&mut payload)?;
|
||||
Self::UpdateArena {
|
||||
field_number,
|
||||
arguments: UpdateArena::decode(&reader[..message_length])?,
|
||||
payload,
|
||||
arguments: UpdateArena::decode(&payload[..message_length])?,
|
||||
}
|
||||
}
|
||||
|
||||
_ => Self::Unknown { sub_type, payload },
|
||||
_ => Self::Unknown { sub_type },
|
||||
};
|
||||
Ok(this)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user