1const SLOT_SIZE: usize = 10;
2const AGES: usize = 5;
3
4#[derive(Protocol, Debug, Clone, PartialEq)]
5pub struct TechTree {
6 pub tech_tree_ages_size: u8,
7 pub building_connections_size: u8,
8 pub unit_connections_size: u8,
9 pub research_connections_size: u8,
10 pub total_unit_tech_groups: i32,
11 #[protocol(length_prefix(elements(tech_tree_ages_size)))]
12 pub tech_tree_ages: Vec<TechTreeAge>,
13 #[protocol(length_prefix(elements(building_connections_size)))]
14 pub building_connections: Vec<BuildingConnection>,
15 #[protocol(length_prefix(elements(unit_connections_size)))]
16 pub unit_connections: Vec<UnitConnection>,
17 #[protocol(length_prefix(elements(research_connections_size)))]
18 pub research_connections: Vec<ResearchConnection>,
19}
20
21#[derive(Protocol, Debug, Clone, PartialEq)]
22pub struct TechTreeAge {
23 pub id: u32,
24 pub status: TechTreeStatus,
25 pub buildings_size: u8,
26 #[protocol(length_prefix(elements(buildings_size)))]
27 pub buildings: Vec<i32>,
28 pub units_size: u8,
29 #[protocol(length_prefix(elements(units_size)))]
30 pub units: Vec<i32>,
31 pub techs_size: u8,
32 #[protocol(length_prefix(elements(techs_size)))]
33 pub techs: Vec<i32>,
34 pub common: TechTreeCommon,
35 pub num_building_levels: u8,
36 #[protocol(fixed_length(SLOT_SIZE))]
37 pub buildings_per_zone: Vec<u8>,
38 #[protocol(fixed_length(SLOT_SIZE))]
39 pub group_length_per_zone: Vec<u8>,
40 pub max_age_length: u8,
41 pub line_mode: i32,
42}
43
44#[derive(Protocol, Debug, Clone, PartialEq)]
45pub struct BuildingConnection {
46 pub id: i32,
47 pub status: TechTreeStatus,
48 pub buildings_size: u8,
49 #[protocol(length_prefix(elements(buildings_size)))]
50 pub buildings: Vec<i32>,
51 pub units_size: u8,
52 #[protocol(length_prefix(elements(units_size)))]
53 pub units: Vec<i32>,
54 pub techs_size: u8,
55 #[protocol(length_prefix(elements(techs_size)))]
56 pub techs: Vec<i32>,
57 pub common: TechTreeCommon,
58 pub location_in_age: u8,
59 #[protocol(fixed_length(AGES))]
60 pub units_techs_total: Vec<u8>,
61 #[protocol(fixed_length(AGES))]
62 pub units_techs_first: Vec<u8>,
63 pub line_mode: i32,
64 pub enabling_research: i32,
65}
66
67#[derive(Protocol, Debug, Clone, PartialEq)]
68pub struct UnitConnection {
69 pub id: i32,
70 pub status: TechTreeStatus,
71 pub upper_building: i32,
72 pub tech_tree_common: TechTreeCommon,
73 pub vertical_line: u32,
74 pub units_size: u8,
75 #[protocol(length_prefix(elements(units_size)))]
76 pub units: Vec<i32>,
77 pub location_in_age: i32,
78 pub required_research: i32,
79 pub line_mode: i32,
80 pub enabling_research: i32,
81}
82
83#[derive(Protocol, Debug, Clone, PartialEq)]
84pub struct ResearchConnection {
85 pub id: u32,
86 pub status: TechTreeStatus,
87 pub upper_building: u32,
88 pub buildings_size: u8,
89 #[protocol(length_prefix(elements(buildings_size)))]
90 pub buildings: Vec<u32>,
91 pub units_size: u8,
92 #[protocol(length_prefix(elements(units_size)))]
93 pub units: Vec<u32>,
94 pub techs_size: u8,
95 #[protocol(length_prefix(elements(techs_size)))]
96 pub techs: Vec<u32>,
97 pub tech_tree_common: TechTreeCommon,
98 pub vertical_line: u32,
99 pub location_in_age: u32,
100 pub line_mode: u32,
101}
102
103#[derive(Protocol, Debug, Clone, PartialEq)]
104pub struct TechTreeCommon {
105 pub slots_used: u32,
106 #[protocol(fixed_length(SLOT_SIZE))]
108 pub unit_research: Vec<u32>,
109 #[protocol(fixed_length(SLOT_SIZE))]
111 pub mode: Vec<TechTreeMode>,
112}
113
114#[derive(Protocol, Debug, Clone, PartialEq, PartialOrd)]
115#[protocol(discriminant = "integer")]
116#[repr(u32)]
117pub enum TechTreeMode {
118 AgeOrTechlevel = 0,
119 Building = 1,
120 Unit = 2,
121 Tech = 3,
122}
123
124#[derive(Protocol, Debug, Clone, PartialEq, PartialOrd)]
125#[protocol(discriminant = "integer")]
126#[repr(u8)]
127pub enum TechTreeStatus {
128 AvailablePlayer = 2,
130}