mirror of
https://github.com/eigenein/wotbreplay-parser.git
synced 2026-10-23 11:19:47 +02:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1e0ce05c18 | ||
|
|
f63ba599ec | ||
|
|
f619ffd93e | ||
|
|
7d99456aaa | ||
|
|
be4a6c21b5 |
No files matched your search
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2022 Pavel Perestoronin
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
use prost::bytes::Buf;
|
use prost::bytes::Buf;
|
||||||
use prost::Message;
|
use prost::Message;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use crate::result::Result;
|
use crate::result::Result;
|
||||||
@@ -14,7 +15,7 @@ impl BattleResults {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parsed battle results.
|
/// Parsed battle results.
|
||||||
#[derive(Message)]
|
#[derive(Message, Serialize)]
|
||||||
pub struct BattleResults {
|
pub struct BattleResults {
|
||||||
/// Battle timestamp.
|
/// Battle timestamp.
|
||||||
#[prost(int64, tag = "2")]
|
#[prost(int64, tag = "2")]
|
||||||
@@ -30,7 +31,7 @@ pub struct BattleResults {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Battle player.
|
/// Battle player.
|
||||||
#[derive(Message)]
|
#[derive(Message, Serialize)]
|
||||||
pub struct Player {
|
pub struct Player {
|
||||||
/// Player's account ID.
|
/// Player's account ID.
|
||||||
#[prost(uint32, tag = "1")]
|
#[prost(uint32, tag = "1")]
|
||||||
@@ -42,7 +43,7 @@ pub struct Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Player's extended information.
|
/// Player's extended information.
|
||||||
#[derive(Message)]
|
#[derive(Message, Serialize)]
|
||||||
pub struct PlayerInfo {
|
pub struct PlayerInfo {
|
||||||
/// Player's nickname.
|
/// Player's nickname.
|
||||||
#[prost(string, tag = "1")]
|
#[prost(string, tag = "1")]
|
||||||
@@ -62,7 +63,9 @@ pub struct PlayerInfo {
|
|||||||
pub clan_tag: Option<String>,
|
pub clan_tag: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, prost::Enumeration)]
|
#[derive(
|
||||||
|
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,
|
||||||
@@ -70,7 +73,7 @@ pub enum TeamNumber {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Player's battle results.
|
/// Player's battle results.
|
||||||
#[derive(Message)]
|
#[derive(Message, Serialize)]
|
||||||
pub struct PlayerResults {
|
pub struct PlayerResults {
|
||||||
/// Looks like some sort of sequential result ID. They reference each other,
|
/// Looks like some sort of sequential result ID. They reference each other,
|
||||||
/// but I haven't figured this out yet.
|
/// but I haven't figured this out yet.
|
||||||
@@ -83,7 +86,7 @@ pub struct PlayerResults {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Extended player's results information.
|
/// Extended player's results information.
|
||||||
#[derive(Message)]
|
#[derive(Message, Serialize)]
|
||||||
pub struct PlayerResultsInfo {
|
pub struct PlayerResultsInfo {
|
||||||
/// Credits earned – without special awards and medals and premium account excluded.
|
/// Credits earned – without special awards and medals and premium account excluded.
|
||||||
#[prost(uint32, tag = "2")]
|
#[prost(uint32, tag = "2")]
|
||||||
|
|||||||
@@ -11,9 +11,11 @@ use crate::{Error, Result};
|
|||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct BattleResultsDat(
|
pub struct BattleResultsDat(
|
||||||
/// No idea what this is.
|
/// No idea what this is.
|
||||||
u64,
|
/// My best guess – some kind of checksum,
|
||||||
|
/// 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.
|
||||||
ByteBuf,
|
pub ByteBuf,
|
||||||
);
|
);
|
||||||
|
|
||||||
impl BattleResultsDat {
|
impl BattleResultsDat {
|
||||||
|
|||||||
+6
-1
@@ -19,10 +19,15 @@ impl<R: Read + Seek> Replay<R> {
|
|||||||
|
|
||||||
/// Reads and parses the battle results from the replay.
|
/// Reads and parses the battle results from the replay.
|
||||||
pub fn read_battle_results(&mut self) -> Result<BattleResults> {
|
pub fn read_battle_results(&mut self) -> Result<BattleResults> {
|
||||||
|
self.read_battle_results_dat()?.decode_battle_results()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Reads and parses the included `battle_results.dat`.
|
||||||
|
pub fn read_battle_results_dat(&mut self) -> Result<BattleResultsDat> {
|
||||||
let pickled_battle_results = self
|
let pickled_battle_results = self
|
||||||
.0
|
.0
|
||||||
.by_name("battle_results.dat")
|
.by_name("battle_results.dat")
|
||||||
.map_err(Error::OpenBattleResultsFailed)?;
|
.map_err(Error::OpenBattleResultsFailed)?;
|
||||||
BattleResultsDat::from_reader(pickled_battle_results)?.decode_battle_results()
|
BattleResultsDat::from_reader(pickled_battle_results)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user