mirror of
https://github.com/eigenein/wotbreplay-parser.git
synced 2026-10-21 02:17:02 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87beaf2076 | ||
|
|
581192b8c7 |
No files matched your search
BIN
Binary file not shown.
Generated
BIN
Binary file not shown.
@@ -93,6 +93,9 @@ pub struct PlayerInfo {
|
||||
|
||||
#[prost(message, required, tag = "7")]
|
||||
pub avatar: Avatar,
|
||||
|
||||
#[prost(uint32, optional, tag = "9")]
|
||||
pub rank: Option<u32>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Enumeration, Serialize)]
|
||||
|
||||
+2
-4
@@ -63,8 +63,7 @@ fn assert_magic<T: Into<u32> + PartialEq>(actual: T, expected: T) -> Result {
|
||||
#[inline]
|
||||
fn read_length_delimited(reader: &mut impl Read) -> Result<Vec<u8>> {
|
||||
let length = reader.read_u8()? as usize;
|
||||
let mut buffer = Vec::new();
|
||||
buffer.resize(length, 0);
|
||||
let mut buffer = vec![0; length];
|
||||
reader.read_exact(&mut buffer)?;
|
||||
Ok(buffer)
|
||||
}
|
||||
@@ -76,8 +75,7 @@ fn read_string(reader: &mut impl Read) -> Result<String> {
|
||||
|
||||
#[inline]
|
||||
fn read_pickled<T: DeserializeOwned>(reader: &mut impl Read, length: usize) -> Result<T> {
|
||||
let mut buffer = Vec::new();
|
||||
buffer.resize(length, 0);
|
||||
let mut buffer = vec![0; length];
|
||||
reader.read_exact(&mut buffer)?;
|
||||
Ok(serde_pickle::from_slice(&buffer, Default::default())?)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct BasePlayerCreate {
|
||||
#[serde(default, rename(deserialize = "playersBattleCategoriesIds"))]
|
||||
pub players_battle_categories_ids: Option<HashMap<u32, (u8, u32)>>,
|
||||
pub players_battle_categories_ids: Option<HashMap<u64, (u8, u32)>>,
|
||||
|
||||
#[serde(rename(deserialize = "battleLevel"))]
|
||||
pub battle_level: u8,
|
||||
@@ -34,10 +34,10 @@ pub struct BasePlayerCreate {
|
||||
pub average_mm_ratings: Option<Vec<Option<f64>>>,
|
||||
|
||||
#[serde(default, rename(deserialize = "playerWaitTimes"))]
|
||||
pub player_wait_times: Option<HashMap<u32, f64>>,
|
||||
pub player_wait_times: Option<HashMap<u64, f64>>,
|
||||
|
||||
#[serde(rename(deserialize = "accountDatabaseIds"))]
|
||||
pub account_database_ids: Option<Vec<u32>>,
|
||||
pub account_database_ids: Option<Vec<u64>>,
|
||||
|
||||
#[serde(default, rename(deserialize = "turboBattlesStats"))]
|
||||
pub turbo_battles_statistics: Option<TurboBattlesStatistics>,
|
||||
|
||||
@@ -35,7 +35,9 @@ impl Packet {
|
||||
///
|
||||
/// Parsed packet, or [`None`], when no packets are left.
|
||||
pub fn from_reader(reader: &mut impl Read) -> Result<Option<Self>> {
|
||||
let Ok(length) = reader.read_u32::<LittleEndian>() else { return Ok(None) };
|
||||
let Ok(length) = reader.read_u32::<LittleEndian>() else {
|
||||
return Ok(None);
|
||||
};
|
||||
let type_ = reader.read_u32::<LittleEndian>()?;
|
||||
let clock_secs = reader.read_f32::<LittleEndian>()?;
|
||||
let raw_payload = Self::read_raw_payload(reader, length as usize)?;
|
||||
@@ -57,8 +59,7 @@ impl Packet {
|
||||
}
|
||||
|
||||
fn read_raw_payload(reader: &mut impl Read, length: usize) -> Result<Vec<u8>> {
|
||||
let mut buffer = Vec::new();
|
||||
buffer.resize(length, 0);
|
||||
let mut buffer = vec![0; length];
|
||||
reader.read_exact(&mut buffer)?;
|
||||
Ok(buffer)
|
||||
}
|
||||
|
||||
@@ -139,3 +139,25 @@ fn room_type_ok() -> Result<()> {
|
||||
assert_eq!(battle_results.room_type(), RoomType::MadGames);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Training room on Strv K with a rank.
|
||||
#[test]
|
||||
fn rank_ok() -> Result<()> {
|
||||
let battle_results = Replay::open(File::open(
|
||||
"replays/20230802_2133__helaas_pindakaas_S31_Strv_K_15193856522497923.wotbreplay",
|
||||
)?)?
|
||||
.read_battle_results()?;
|
||||
assert_eq!(battle_results.players[0].info.rank, Some(12));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Training room on Regressor with no rank.
|
||||
#[test]
|
||||
fn no_rank_ok() -> Result<()> {
|
||||
let battle_results = Replay::open(File::open(
|
||||
"replays/20230802_2136__helaas_pindakaas_Oth38_50TP_Tyszkiewicza_S1_15188303129784363.wotbreplay",
|
||||
)?)?
|
||||
.read_battle_results()?;
|
||||
assert_eq!(battle_results.players[0].info.rank, None);
|
||||
Ok(())
|
||||
}
|
||||
Reference in new issue
Block a user