✨ Add MapId

This commit is contained in:
eigenein committed 2023-05-12 01:00:55 +02:00
1 parent c986abca5d
commit 1313bc82f7
5 files changed
+46 -1

No files matched your search

+1
View File
@@ -1,4 +1,5 @@
pub mod battle_results;
pub mod battle_results_dat;
pub mod data;
pub mod map_id;
pub mod meta;
+9 -1
View File
@@ -21,6 +21,15 @@ impl BattleResults {
/// TODO: 150[0].21[0].8[0].801[0].unsigned is arena end time.
#[derive(Message, Serialize)]
pub struct BattleResults {
/// The two least-significant bytes is map ID.
///
/// The 3rd byte is probably a game mode:
///
/// - `0x0xxxx` is «encounter»
/// - `0x1xxxx` flag is «supremacy»
#[prost(uint32, tag = "1")]
pub mode_map_id: u32,
/// Battle timestamp.
#[prost(int64, tag = "2")]
pub timestamp_secs: i64,
@@ -83,7 +92,6 @@ pub struct PlayerInfo {
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Enumeration, Serialize)]
#[repr(i32)]
pub enum TeamNumber {
One = 1,
Two = 2,
+31
View File
@@ -0,0 +1,31 @@
use prost::Enumeration;
use serde::{Deserialize, Serialize};
use serde_with::rust::deserialize_ignore_any;
#[derive(Debug, Deserialize, Serialize, Enumeration)]
#[serde(untagged)]
pub enum MapId {
DesertSands = 2,
Middleburg = 3,
Copperfield = 4,
Mines = 6,
DeadRail = 7,
FortDespair = 8,
Himmelsdorf = 9,
OasisPalms = 11,
Molendijk = 14,
PortBay = 15,
Castilla = 20,
Canal = 21,
YamatoHarbor = 25,
Canyon = 27,
MayanRuins = 30,
NavalFrontier = 35,
Alpenstadt = 38,
NewBay = 40,
Normandy = 42,
/// Default value for Protocol Buffers and fallback value for Serde.
#[serde(deserialize_with = "deserialize_ignore_any")]
Undefined = 0,
}
+4
View File
@@ -5,6 +5,7 @@ use std::io::Read;
use serde::Deserialize;
use crate::models::map_id::MapId;
use crate::result::Result;
/// The model for `meta.json`.
@@ -21,6 +22,9 @@ pub struct Meta {
#[serde(rename = "vehicleCompDescriptor")]
pub tank_id: u16,
#[serde(rename = "mapId")]
pub map_id: MapId,
}
impl Meta {
+1
View File
@@ -14,6 +14,7 @@ fn meta_ok() -> Result<()> {
assert_eq!(meta.arena_unique_id, "1661909200500084");
assert_eq!(meta.battle_duration_secs, 164.08485);
assert_eq!(meta.tank_id, 26657);
// TODO: assert_eq!(meta.map_id);
Ok(())
}