mirror of
https://github.com/eigenein/wotbreplay-parser.git
synced 2026-10-25 03:09:49 +01:00
Break: support arena_unique_id
This commit is contained in:
1 parent
e0ce6a22b1
commit
903cd00f32
2 files changed
+20
-10
No files matched your search
@@ -10,14 +10,22 @@ use crate::result::Result;
|
|||||||
|
|
||||||
/// Represents un-pickled `battle_results.dat`.
|
/// Represents un-pickled `battle_results.dat`.
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct BattleResultsDat(
|
#[serde(from = "(u64, ByteBuf)")]
|
||||||
/// No idea what this is.
|
pub struct BattleResultsDat {
|
||||||
/// My best guess – some kind of checksum,
|
pub arena_unique_id: u64,
|
||||||
/// but none of MD5, SHA1, SHA224, SHA256, SHA384, SHA512, nor CRC64 over the buffer have matched.
|
|
||||||
pub u64,
|
|
||||||
/// Protobuf-serialized battle results.
|
/// Protobuf-serialized battle results.
|
||||||
pub ByteBuf,
|
pub buffer: ByteBuf,
|
||||||
);
|
}
|
||||||
|
|
||||||
|
impl From<(u64, ByteBuf)> for BattleResultsDat {
|
||||||
|
fn from((arena_unique_id, buffer): (u64, ByteBuf)) -> Self {
|
||||||
|
Self {
|
||||||
|
arena_unique_id,
|
||||||
|
buffer,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl BattleResultsDat {
|
impl BattleResultsDat {
|
||||||
/// Parses the pickled structure from the reader which contains `battle_results.dat`.
|
/// Parses the pickled structure from the reader which contains `battle_results.dat`.
|
||||||
@@ -30,7 +38,7 @@ impl BattleResultsDat {
|
|||||||
|
|
||||||
/// Decodes the battle results from the internal buffer.
|
/// Decodes the battle results from the internal buffer.
|
||||||
pub fn decode_battle_results(&self) -> Result<BattleResults> {
|
pub fn decode_battle_results(&self) -> Result<BattleResults> {
|
||||||
BattleResults::decode(self.1.as_ref()).map_err(Error::DecodeFailed)
|
BattleResults::decode(self.buffer.as_ref()).map_err(Error::DecodeFailed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ use wotbreplay_parser::prelude::*;
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn player_results_ok() -> Result<()> {
|
fn player_results_ok() -> Result<()> {
|
||||||
let battle_results = Replay::open(File::open("tests/replays/player_results.wotbreplay")?)?
|
let battle_results_dat = Replay::open(File::open("tests/replays/player_results.wotbreplay")?)?
|
||||||
.read_battle_results()?;
|
.read_battle_results_dat()?;
|
||||||
|
assert_eq!(battle_results_dat.arena_unique_id, 1661909200500084);
|
||||||
|
let battle_results = battle_results_dat.decode_battle_results()?;
|
||||||
|
|
||||||
let snak_the_ripper_info = &battle_results.player_results[3].info;
|
let snak_the_ripper_info = &battle_results.player_results[3].info;
|
||||||
assert_eq!(snak_the_ripper_info.base_xp, 929);
|
assert_eq!(snak_the_ripper_info.base_xp, 929);
|
||||||
|
|||||||
Reference in new issue
Block a user