Skip to main content

unbanished_formats/savegame_schema/
managers.rs

1//! The schemas of the town's managers: achievements, town, jobs, tools, calendar, event log, environment, minimap.
2
3use super::*;
4
5// +0x88
6/// The game's achievement instances.
7///
8/// Original: `Achievement::AchievementManager::Persist`, Runtime `0x18009f4a0`.
9pub const ACHIEVEMENTS: Op = Block("achievements", 0, &[List("instances", &[Ptr("instance")])]);
10
11// Runtime FUN_18005d130: per 0x30-byte entry the group +0x00, the clip +0x08, the users +0x0c,
12// the instances (+0x20, FUN_18005cd90, 0x48 bytes each) and the nodes (+0x10, FUN_18005cbf0).
13// An instance: its AnimationState (FUN_18005d610), a flag, the transform pairs (FUN_18005cd00),
14// a vector, then the pose (FUN_18005a2f0).
15/// `Graphics::AnimationManager`: the shared instances of instanced clips. Each entry is one
16/// group's clip with its number of users; each of its instances is an animation state of its own
17/// with its pose, which the characters playing that clip follow.
18///
19/// Original: `AnimationManager::Serialize`, Runtime `0x1800fea20`.
20pub const ANIMATIONS: Op = Block(
21    "animations",
22    0,
23    &[List(
24        "entries",
25        &[
26            Ext("group"),
27            I32("clip"),
28            I32("users"),
29            List(
30                "instances",
31                &[
32                    List("states", super::ANIMATION_STATE),
33                    Bool("flag"),
34                    List(
35                        "pairs",
36                        &[
37                            F32s("rotation", 4),
38                            F32s("translation", 3),
39                            F32s("rotation_2", 4),
40                            F32s("translation_2", 3),
41                        ],
42                    ),
43                    F32s("vector", 3),
44                    List("pose", &[F32s("rotation", 4), F32s("translation", 3)]),
45                ],
46            ),
47            List(
48                "nodes",
49                &[
50                    Str("name"),
51                    I32("parent"),
52                    F32s("rotation", 4),
53                    F32s("translation", 3),
54                    F32s("rotation_2", 4),
55                    F32s("translation_2", 3),
56                ],
57            ),
58        ],
59    )],
60);
61
62// Game +0xf0
63/// The town manager (version 6), `Game`: the registries of buildings and people by kind, the
64/// professions' workers, the stock targets and the statistics.
65///
66/// Original: `FUN_140094c30`.
67pub const TOWN: Op = Block(
68    "town",
69    6,
70    &[
71        ptr_list("storages"),
72        ptr_list("markets"),
73        ptr_list("trading_posts"),
74        ptr_list("residences"),
75        ptr_list("healers"),
76        ptr_list("citizens"),
77        // `FUN_140018450`: profession → workplaces.
78        List("workplaces", &[Ext("profession"), ptr_list("entities")]),
79        ptr_list("pastures"),
80        ptr_list("cemeteries"),
81        ptr_list("happiness"),
82        ptr_list("attendance"),
83        ptr_list("livestock"),
84        ptr_list("herds"),
85        If(VersionAtLeast(1), &[ptr_list("diseases")]),
86        ptr_list("populations"),
87        ptr_list("sites"),
88        I32("known_material_count"),
89        I32sBy("known_materials", "known_material_count"),
90        I32("known_count"),
91        I32sBy("known", "known_count"),
92        Time("commute_time"),
93        Time("time_198"),
94        List("history", &[I32("count"), I32sBy("values", "count")]),
95        If(
96            VersionBelow(2),
97            &[List("legacy_counts", &[Ext("description"), I32("count")])],
98        ),
99        // `FUN_1400186e0`: description → entities.
100        If(
101            VersionAtLeast(2),
102            &[List("zones", &[Ext("description"), ptr_list("entities")])],
103        ),
104        ptr_list("wells"),
105        List("water_sources", &[I32("a"), I32("b")]),
106        If(
107            VersionAtLeast(5),
108            &[List(
109                "values_140",
110                &[I32("count"), I32sBy("values", "count")],
111            )],
112        ),
113        If(
114            VersionBelow(4),
115            &[
116                U32s("legacy_a", 13),
117                U32s("legacy_b", 13),
118                U32s("legacy_c", 13),
119                Times("legacy_times", 13),
120                U32s("legacy_d", 9),
121                U32s("legacy_e", 9),
122            ],
123        ),
124        If(
125            VersionAtLeast(4),
126            &[
127                List(
128                    "stock",
129                    &[
130                        I32("count"),
131                        I32("previous"),
132                        I32("limit"),
133                        I32("used"),
134                        I32("made"),
135                        Time("cooldown"),
136                    ],
137                ),
138                List(
139                    "capacity_records",
140                    &[I32("used"), I32("capacity"), Time("cooldown")],
141                ),
142            ],
143        ),
144        F32("visitor_risk"),
145        Time("visitor_time"),
146        If(VersionAtLeast(2), &[I32("trade_value")]),
147        If(VersionAtLeast(3), &[I32("nomads_admitted")]),
148    ],
149);
150
151// +0x30; +0x40..; +0x120; +0x00..+0x08; +0x10; Game +0x118
152/// The job manager (version 3): the table from id to work, the 14 category sets (13 before version
153/// 3), the work by profession, then the last id, the next priority and the pass. The priority
154/// index is rebuilt on load from each work's priority.
155///
156/// Original: `FUN_1400fe710`, `FUN_14002df50`; the category sets by `FUN_14002d9c0`.
157pub const JOBS: Op = Block(
158    "jobs",
159    3,
160    &[
161        List("works", &[I32("key"), Ptr("work")]),
162        List("category_1", &[I32("key"), Ptr("work")]),
163        List("category_2", &[I32("key"), Ptr("work")]),
164        List("category_3", &[I32("key"), Ptr("work")]),
165        List("category_4", &[I32("key"), Ptr("work")]),
166        List("category_5", &[I32("key"), Ptr("work")]),
167        List("category_6", &[I32("key"), Ptr("work")]),
168        List("category_7", &[I32("key"), Ptr("work")]),
169        List("category_8", &[I32("key"), Ptr("work")]),
170        List("category_9", &[I32("key"), Ptr("work")]),
171        List("category_10", &[I32("key"), Ptr("work")]),
172        List("category_11", &[I32("key"), Ptr("work")]),
173        List("category_12", &[I32("key"), Ptr("work")]),
174        List("category_13", &[I32("key"), Ptr("work")]),
175        If(
176            VersionAtLeast(3),
177            &[List("category_14", &[I32("key"), Ptr("work")])],
178        ),
179        List(
180            "by_profession",
181            &[Ext("profession"), List("work", &[I32("key"), Ptr("work")])],
182        ),
183        I32("next_id"),
184        I32("next_priority"),
185        U32("pass"),
186    ],
187);
188
189/// The tool manager (version 2).
190///
191/// Original: `FUN_140107df0`.
192pub const TOOLS: Op = Block(
193    "tools",
194    2,
195    &[
196        Bool("flag_30"),
197        I32("value_34"),
198        F32("value_3c"),
199        F32("value_40"),
200        F32("value_44"),
201        // `FUN_14002ec40`.
202        List(
203            "descriptions",
204            &[
205                Ext("description"),
206                I32("value_8"),
207                I32("value_c"),
208                Bool("flag_10"),
209            ],
210        ),
211        // `FUN_14002edd0`.
212        If(
213            VersionAtLeast(1),
214            &[List(
215                "entities",
216                &[
217                    Ptr("entity"),
218                    I32("value_8"),
219                    I32("value_c"),
220                    Bool("flag_10"),
221                ],
222            )],
223        ),
224        If(
225            VersionAtLeast(2),
226            &[List(
227                "points",
228                &[
229                    F32s("position", 3),
230                    F32("value_c"),
231                    F32("value_10"),
232                    F32("value_14"),
233                    Bool("flag_18"),
234                ],
235            )],
236        ),
237    ],
238);
239
240/// The calendar block of the game state: a value and the time.
241///
242/// Original: written by `FUN_14009af60`.
243pub const CALENDAR: Op = Block("calendar", 0, &[I32("value"), Time("time")]);
244
245// Game +0x138
246/// The event log (version 1), `Game`.
247///
248/// Original: `FUN_14009a790`.
249pub const EVENT_LOG: Op = Block(
250    "event_log",
251    1,
252    &[
253        Bool("notify_0"),
254        Bool("notify_1"),
255        Bool("notify_2"),
256        Bool("notify_3"),
257        Bool("notify_4"),
258        Bool("notify_5"),
259        List(
260            "entries",
261            &[
262                U32("color"),
263                Str("text"),
264                I32("kind"),
265                I32("severity"),
266                I32("cell"),
267                I32("category"),
268                I32("icon"),
269            ],
270        ),
271    ],
272);
273
274/// The environment: climate and month descriptions, weather state, then one entry per weather
275/// effect of the climate (the count is not written).
276///
277/// Original: `FUN_140099160`.
278pub const ENVIRONMENT: Op = Block(
279    "environment",
280    0,
281    &[
282        Ext("climate"),
283        Ext("month"),
284        I32("state"),
285        I32("level"),
286        F32("temperature"),
287        F32s("season", 4),
288        F32("baseline"),
289        F32("baseline_target"),
290        F32("bias"),
291        F32("bias_target"),
292        I32("slice"),
293        Rest(
294            "effects",
295            &[
296                Bool("active"),
297                If(Flag("active"), &[F32("direction"), F32("intensity")]),
298            ],
299        ),
300    ],
301);
302
303/// The minimap: the two images' texels, then the image size.
304///
305/// Original: `FUN_1400aacc0`.
306pub const MINIMAP: Op = Block(
307    "minimap",
308    0,
309    &[
310        I32("count_28"),
311        I32sBy("image_28", "count_28"),
312        I32("count_18"),
313        I32sBy("image_18", "count_18"),
314        I32("size"),
315    ],
316);