mirror of
https://github.com/eigenein/wotbreplay-parser.git
synced 2026-10-23 19:29:48 +02:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
897f98c17c | ||
|
|
59353a9aca | ||
|
|
c9a2adff4c |
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
use prost::bytes::Buf;
|
use prost::bytes::Buf;
|
||||||
use prost::Message;
|
use prost::{Enumeration, Message};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::result::Result;
|
use crate::result::Result;
|
||||||
@@ -22,8 +22,8 @@ pub struct BattleResults {
|
|||||||
#[prost(int64, tag = "2")]
|
#[prost(int64, tag = "2")]
|
||||||
pub timestamp: i64,
|
pub timestamp: i64,
|
||||||
|
|
||||||
#[prost(enumeration = "TeamNumber", tag = "3")]
|
#[prost(enumeration = "TeamNumber", optional, tag = "3")]
|
||||||
pub winner_team_number: i32,
|
pub winner_team_number: Option<i32>,
|
||||||
|
|
||||||
/// Replay's author results.
|
/// Replay's author results.
|
||||||
#[prost(message, required, tag = "8")]
|
#[prost(message, required, tag = "8")]
|
||||||
@@ -78,9 +78,7 @@ pub struct PlayerInfo {
|
|||||||
pub avatar: Avatar,
|
pub avatar: Avatar,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Enumeration, Serialize)]
|
||||||
Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, prost::Enumeration, Serialize,
|
|
||||||
)]
|
|
||||||
#[repr(i32)]
|
#[repr(i32)]
|
||||||
pub enum TeamNumber {
|
pub enum TeamNumber {
|
||||||
One = 1,
|
One = 1,
|
||||||
|
|||||||
+1
-1
@@ -3,8 +3,8 @@
|
|||||||
pub mod entity_method;
|
pub mod entity_method;
|
||||||
pub mod packet;
|
pub mod packet;
|
||||||
pub mod payload;
|
pub mod payload;
|
||||||
pub mod subtype_2f;
|
|
||||||
pub mod type_0;
|
pub mod type_0;
|
||||||
|
pub mod update_arena;
|
||||||
|
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use serde::Serialize;
|
|||||||
use serde_with::serde_as;
|
use serde_with::serde_as;
|
||||||
|
|
||||||
use crate::models::data::read_quirky_length;
|
use crate::models::data::read_quirky_length;
|
||||||
use crate::models::data::subtype_2f::Subtype2F;
|
use crate::models::data::update_arena::UpdateArena;
|
||||||
use crate::result::Result;
|
use crate::result::Result;
|
||||||
|
|
||||||
#[serde_as]
|
#[serde_as]
|
||||||
@@ -13,7 +13,7 @@ use crate::result::Result;
|
|||||||
pub enum EntityMethod {
|
pub enum EntityMethod {
|
||||||
Subtype2F {
|
Subtype2F {
|
||||||
field_number: u64,
|
field_number: u64,
|
||||||
sub_type_2f: Subtype2F,
|
sub_type_2f: UpdateArena,
|
||||||
|
|
||||||
/// Original payload for investigation.
|
/// Original payload for investigation.
|
||||||
#[serde_as(as = "serde_with::hex::Hex")]
|
#[serde_as(as = "serde_with::hex::Hex")]
|
||||||
@@ -45,7 +45,7 @@ impl EntityMethod {
|
|||||||
let message_length = read_quirky_length(&mut reader)?;
|
let message_length = read_quirky_length(&mut reader)?;
|
||||||
Self::Subtype2F {
|
Self::Subtype2F {
|
||||||
field_number,
|
field_number,
|
||||||
sub_type_2f: Subtype2F::decode(&reader[..message_length])?,
|
sub_type_2f: UpdateArena::decode(&reader[..message_length])?,
|
||||||
payload,
|
payload,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
use prost::Message;
|
use prost::Message;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
/// Subtype `0x2F`.
|
||||||
#[derive(Message, Serialize)]
|
#[derive(Message, Serialize)]
|
||||||
pub struct Subtype2F {
|
pub struct UpdateArena {
|
||||||
#[prost(message, tag = "1")]
|
#[prost(message, tag = "1")]
|
||||||
pub players: Option<Players>,
|
pub players: Option<Players>,
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ fn player_results_ok() -> Result<()> {
|
|||||||
assert_eq!(battle_results_dat.arena_unique_id, 1661909200500084);
|
assert_eq!(battle_results_dat.arena_unique_id, 1661909200500084);
|
||||||
let battle_results: BattleResults = battle_results_dat.try_into()?;
|
let battle_results: BattleResults = battle_results_dat.try_into()?;
|
||||||
|
|
||||||
assert_eq!(battle_results.winner_team_number, 2);
|
assert_eq!(battle_results.winner_team_number, Some(2));
|
||||||
|
|
||||||
assert_eq!(battle_results.author.team_number, 2);
|
assert_eq!(battle_results.author.team_number, 2);
|
||||||
assert_eq!(battle_results.author.credits_earned, 59518);
|
assert_eq!(battle_results.author.credits_earned, 59518);
|
||||||
@@ -117,3 +117,11 @@ fn victory_points_ok() -> Result<()> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn draw_ok() -> Result<()> {
|
||||||
|
let battle_results = Replay::open(File::open("tests/replays/20230503_0027__helaas_pindakaas_A140_ASTRON_REX_105_2319058483532631656.wotbreplay")?)?
|
||||||
|
.read_battle_results()?;
|
||||||
|
assert_eq!(battle_results.winner_team_number, None);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
Generated
BIN
Binary file not shown.
Reference in new issue
Block a user