warcraft3_stats_observer/unit.rs
1use crate::string_utils::PaddedString;
2
3const MAX_NAME_LENGTH: usize = 100;
4const MAX_BUTTON_ART_LENGTH: usize = 100;
5
6/// Aggregate state for one unit kind owned by a player.
7#[repr(C, packed)]
8pub struct UnitInfo {
9 /// Game-internal unit ID.
10 pub id: u32,
11 /// Display name.
12 pub name: PaddedString<MAX_NAME_LENGTH>,
13 /// ID of the owning player.
14 pub owner_id: u32,
15 /// Number currently alive.
16 pub current_amount: u32,
17 /// Number ever trained / spawned.
18 pub total_amount: u32,
19 /// Path to the unit's button icon.
20 pub button_art: PaddedString<MAX_BUTTON_ART_LENGTH>,
21 /// Whether the unit is classified as a worker.
22 /// Not sure how this differs from `is_function_peop`[Self::is_functional_peon].
23 pub is_peon: bool,
24 /// Whether the unit is classified as a worker.
25 /// Not sure how this differs from `is_peon`[Self::is_peon].
26 pub is_functional_peon: bool,
27 /// Total damage dealt by units of this kind.
28 pub damage_dealt: u32,
29 /// Total damage received by units of this kind.
30 pub damage_received: u32,
31 /// Total healing done by units of this kind.
32 pub healing_done: u32,
33}
34
35// Number generated from SIZE fields of https://github.com/TinkerWorX/Blizzard.Net.Warcraft3
36// noinspection RsAssertEqual
37const _: () = assert!(size_of::<UnitInfo>() == 230);