1mod produce;
4pub use produce::{consume_produce_description, ConsumeProduceDescription, ProduceRecipe};
5
6use super::*;
7
8#[derive(Debug, Clone, PartialEq)]
15pub struct QuarryDescription {
16 pub deep: f32,
18 pub shallow: f32,
20 pub mesh: Option<String>,
22}
23
24pub fn quarry_description(data: &[u8]) -> Result<QuarryDescription> {
26 let (_, value) = crs::parse(data, |r: &mut Reader, h| {
27 if h.type_id != type_id("QuarryDescription") {
28 return format_err(format!(
29 "expected QuarryDescription, found {:#010x}",
30 h.type_id
31 ));
32 }
33 r.block(|r, _| {
34 Ok(QuarryDescription {
35 deep: r.f32()?,
36 shallow: r.f32()?,
37 mesh: r.external_ref()?,
38 })
39 })
40 })?;
41 Ok(value)
42}
43
44#[derive(Debug, Clone, PartialEq, Eq)]
50pub struct HerbalistDescription {
51 pub resources: Vec<Option<String>>,
53 pub group: i32,
55}
56
57pub fn herbalist_description(data: &[u8]) -> Result<HerbalistDescription> {
59 let (_, value) = crs::parse(data, |r: &mut Reader, h| {
60 if h.type_id != type_id("HerbalistDescription") {
61 return format_err(format!(
62 "expected HerbalistDescription, found {:#010x}",
63 h.type_id
64 ));
65 }
66 r.block(|r, _| {
67 let n = r.i32()?;
68 let resources = (0..n.max(0))
69 .map(|_| r.external_ref())
70 .collect::<Result<Vec<_>>>()?;
71 Ok(HerbalistDescription {
72 resources,
73 group: r.i32()?,
74 })
75 })
76 })?;
77 Ok(value)
78}
79
80#[derive(Debug, Clone, PartialEq, Eq)]
86pub struct ForesterDescription {
87 pub tree: Option<String>,
89 pub group: i32,
91}
92
93pub fn forester_description(data: &[u8]) -> Result<ForesterDescription> {
95 let (_, value) = crs::parse(data, |r: &mut Reader, h| {
96 if h.type_id != type_id("ForesterDescription") {
97 return format_err(format!(
98 "expected ForesterDescription, found {:#010x}",
99 h.type_id
100 ));
101 }
102 r.block(|r, version| {
103 let tree = r.external_ref()?;
104 let group = if version > 0 { r.i32()? } else { 0 };
105 Ok(ForesterDescription { tree, group })
106 })
107 })?;
108 Ok(value)
109}
110
111#[derive(Debug, Clone, PartialEq, Eq)]
117pub struct FishingDescription {
118 pub output: Option<String>,
120 pub mask: u32,
122 pub group: i32,
124}
125
126pub fn fishing_description(data: &[u8]) -> Result<FishingDescription> {
128 let (_, value) = crs::parse(data, |r: &mut Reader, h| {
129 if h.type_id != type_id("FishingDescription") {
130 return format_err(format!(
131 "expected FishingDescription, found {:#010x}",
132 h.type_id
133 ));
134 }
135 r.block(|r, version| {
136 let output = r.external_ref()?;
137 let mask = r.u32()?;
138 let group = if version > 0 { r.i32()? } else { 0 };
139 Ok(FishingDescription {
140 output,
141 mask,
142 group,
143 })
144 })
145 })?;
146 Ok(value)
147}
148
149#[derive(Debug, Clone, Copy, PartialEq)]
155pub struct HuntDescription {
156 pub time: f32,
158 pub group: i32,
160}
161
162pub fn hunt_description(data: &[u8]) -> Result<HuntDescription> {
164 let (_, value) = crs::parse(data, |r: &mut Reader, h| {
165 if h.type_id != type_id("HuntDescription") {
166 return format_err(format!(
167 "expected HuntDescription, found {:#010x}",
168 h.type_id
169 ));
170 }
171 r.block(|r, version| {
172 let time = r.f32()?;
173 let group = if version > 0 { r.i32()? } else { 0 };
174 Ok(HuntDescription { time, group })
175 })
176 })?;
177 Ok(value)
178}
179
180pub fn crop_field_description(data: &[u8]) -> Result<(f32, i32)> {
186 let (_, value) = crs::parse(data, |r: &mut Reader, h| {
187 if h.type_id != type_id("CropFieldDescription") {
188 return format_err(format!(
189 "expected CropFieldDescription, found {:#010x}",
190 h.type_id
191 ));
192 }
193 r.block(|r, version| {
194 let tend = r.f32()?;
195 let group = if version > 0 { r.i32()? } else { 0 };
196 Ok((tend, group))
197 })
198 })?;
199 Ok(value)
200}
201
202pub fn orchard_description(data: &[u8]) -> Result<((i32, i32), f32, i32)> {
208 let (_, value) = crs::parse(data, |r: &mut Reader, h| {
209 if h.type_id != type_id("OrchardDescription") {
210 return format_err(format!(
211 "expected OrchardDescription, found {:#010x}",
212 h.type_id
213 ));
214 }
215 r.block(|r, version| {
216 let spacing = (r.i32()?, r.i32()?);
217 let tend = r.f32()?;
218 let group = if version > 0 { r.i32()? } else { 0 };
219 Ok((spacing, tend, group))
220 })
221 })?;
222 Ok(value)
223}
224
225pub fn pasture_description(data: &[u8]) -> Result<i32> {
231 let (_, value) = crs::parse(data, |r: &mut Reader, h| {
232 if h.type_id != type_id("PastureDescription") {
233 return format_err(format!(
234 "expected PastureDescription, found {:#010x}",
235 h.type_id
236 ));
237 }
238 r.block(|r, version| if version > 0 { r.i32() } else { Ok(5) })
239 })?;
240 Ok(value)
241}
242
243#[derive(Debug, Clone, Default, PartialEq)]
249pub struct LivestockDescription {
250 pub product: Option<String>,
252 pub interval: f32,
254 pub group: i32,
256}
257
258pub fn livestock_description(data: &[u8]) -> Result<LivestockDescription> {
260 let (_, value) = crs::parse(data, |r: &mut Reader, h| {
261 if h.type_id != type_id("LivestockDescription") {
262 return format_err(format!(
263 "expected LivestockDescription, found {:#010x}",
264 h.type_id
265 ));
266 }
267 r.block(|r, version| {
268 let product = r.external_ref()?;
269 let interval = r.f32()?;
270 let group = if version > 0 { r.i32()? } else { 0 };
271 Ok(LivestockDescription {
272 product,
273 interval,
274 group,
275 })
276 })
277 })?;
278 Ok(value)
279}
280
281#[derive(Debug, Clone, Default)]
287pub struct WorkPlaceDescription {
288 pub profession: Option<String>,
290 pub reference_28: Option<String>,
292}
293
294pub fn workplace_description(data: &[u8]) -> Result<WorkPlaceDescription> {
296 let (_, value) = crs::parse(data, |r: &mut Reader, h| {
297 if h.type_id != type_id("WorkPlaceDescription") {
298 return format_err(format!(
299 "expected WorkPlaceDescription, found {:#010x}",
300 h.type_id
301 ));
302 }
303 r.block(|r, _| {
304 Ok(WorkPlaceDescription {
305 profession: r.external_ref()?,
306 reference_28: r.external_ref()?,
307 })
308 })
309 })?;
310 Ok(value)
311}
312
313#[derive(Debug, Clone, Default)]
317pub struct WorkDescription {
318 pub max_workers: i32,
323 pub value_28: i32,
325 pub value_2c: i32,
327 pub per_area: bool,
330 pub area: i32,
332 pub flag_20: bool,
334}
335
336pub fn work_description(data: &[u8]) -> Result<WorkDescription> {
338 let (_, value) = crs::parse(data, |r: &mut Reader, h| {
339 if h.type_id != type_id("WorkDescription") {
340 return format_err(format!(
341 "expected WorkDescription, found {:#010x}",
342 h.type_id
343 ));
344 }
345 r.block(|r, _| {
346 Ok(WorkDescription {
347 max_workers: r.i32()?,
348 value_28: r.i32()?,
349 value_2c: r.i32()?,
350 per_area: r.bool()?,
351 area: r.i32()?,
352 flag_20: r.bool()?,
353 })
354 })
355 })?;
356 Ok(value)
357}
358
359#[derive(Debug, Clone)]
363pub struct Profession {
364 pub string_table: Option<String>,
367 pub sprite_sheet: Option<String>,
369 pub name: String,
372 pub tooltip: String,
375 pub death: String,
377 pub value_48: i32,
379 pub flag_4c: bool,
381 pub flag_4d: bool,
383 pub value_54: f32,
385 pub value_58: f32,
387 pub value_50: i32,
389 pub flag_4e: bool,
391}
392
393pub fn profession(data: &[u8]) -> Result<Profession> {
395 let (_, value) = crs::parse(data, |r: &mut Reader, h| {
396 if h.type_id != type_id("Profession") {
397 return format_err(format!("expected Profession, found {:#010x}", h.type_id));
398 }
399 r.block(|r, _| {
400 Ok(Profession {
401 string_table: r.external_ref()?,
402 sprite_sheet: r.external_ref()?,
403 name: r.string()?,
404 tooltip: r.string()?,
405 death: r.string()?,
406 value_48: r.i32()?,
407 flag_4c: r.bool()?,
408 flag_4d: r.bool()?,
409 value_54: r.f32()?,
410 value_58: r.f32()?,
411 value_50: r.i32()?,
412 flag_4e: r.bool()?,
413 })
414 })
415 })?;
416 Ok(value)
417}
418
419pub fn radius_description(data: &[u8]) -> Result<(i32, Option<String>)> {
424 let (_, value) = crs::parse(data, |r: &mut Reader, h| {
425 if h.type_id != type_id("RadiusDescription") {
426 return format_err("expected RadiusDescription");
427 }
428 r.block(|r, _| Ok((r.i32()?, r.external_ref()?)))
429 })?;
430 Ok(value)
431}