1 /*
2  * Seven Kingdoms: Ancient Adversaries
3  *
4  * Copyright 2018 Jesse Allen
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 //Filename    : OMP_CRC.H
22 //Description : crc checking for multiplayer debugging
23 
24 #ifndef _OMP_CRC_H
25 #define _OMP_CRC_H
26 
27 #include <stdint.h>
28 
29 #include <OF_CAMP.h>
30 #include <OF_HARB.h>
31 #include <OF_INN.h>
32 #include <OF_MARK.h>
33 #include <OF_MONS.h>
34 #include <OF_WAR.h>
35 #include <OSKILL.h>
36 #include <OU_CARA.h>
37 #include <OU_MARI.h>
38 
39 #pragma pack(1)
40 struct FirmCrc
41 {
42 	char		firm_id;
43 	short		firm_build_id;
44 	short		firm_recno;
45 	char		firm_ai;
46 	char		ai_processed;
47 	char		ai_status;
48 	char		ai_link_checked;
49 	char		ai_sell_flag;
50 
51 	char		race_id;
52 	short		nation_recno;
53 
54 	short		closest_town_name_id;
55 	short		firm_name_instance_id;
56 
57 	short		loc_x1;
58 	short		loc_y1;
59 	short		loc_x2;
60 	short		loc_y2;
61 	short		abs_x1;
62 	short		abs_y1;
63 	short		abs_x2;
64 	short		abs_y2;
65 	short		center_x;
66 	short		center_y;
67 	uint8_t		region_id;
68 
69 	char		cur_frame;
70 	char		remain_frame_delay;
71 
72 	float		hit_points;
73 	float		max_hit_points;
74 	char		under_construction;
75 
76 	char		firm_skill_id;
77 	short		overseer_recno;
78 	short		overseer_town_recno;
79 	short		builder_recno;
80 	uint8_t		builder_region_id;
81 	float		productivity;
82 
83 	char		worker_count;
84 
85 	uint8_t		sabotage_level;
86 
87 	char		linked_firm_count;
88 	char		linked_town_count;
89 
90 	short		linked_firm_array[MAX_LINKED_FIRM_FIRM];
91 	short		linked_town_array[MAX_LINKED_FIRM_TOWN];
92 
93 	char		linked_firm_enable_array[MAX_LINKED_FIRM_FIRM];
94 	char		linked_town_enable_array[MAX_LINKED_FIRM_TOWN];
95 
96 	float		last_year_income;
97 	float		cur_year_income;
98 
99 	int		setup_date;
100 
101 	char		should_set_power;
102 	int		last_attacked_date;
103 
104 	char		should_close_flag;
105 	char		no_neighbor_space;
106 	char		ai_should_build_factory_count;
107 };
108 
109 struct FirmBaseCrc : FirmCrc
110 {
111 	short		god_id;
112 	short		god_unit_recno;
113 
114 	float		pray_points;
115 };
116 
117 struct FirmCampCrc : FirmCrc
118 {
119 	DefenseUnit	defense_array[MAX_WORKER+1];
120 	char		employ_new_worker;
121 	short		defend_target_recno;
122 	char		defense_flag;
123 
124 	char		patrol_unit_count;
125 	short		patrol_unit_array[MAX_WORKER+1];
126 
127 	char		coming_unit_count;
128 	short		coming_unit_array[MAX_WORKER+1];
129 
130 	short		ai_capture_town_recno;
131 	char		ai_recruiting_soldier;
132 
133 	char		is_attack_camp;
134 };
135 
136 struct FirmFactoryCrc : FirmCrc
137 {
138 	int		product_raw_id;
139 
140 	float		stock_qty;
141 	float		max_stock_qty;
142 
143 	float		raw_stock_qty;
144 	float		max_raw_stock_qty;
145 
146 	float		cur_month_production;
147 	float		last_month_production;
148 	short		next_output_link_id;
149 	short		next_output_firm_recno;
150 };
151 
152 
153 struct FirmHarborCrc : FirmCrc
154 {
155 	short		ship_recno_array[MAX_SHIP_IN_HARBOR];
156 	short		ship_count;
157 
158 	short		build_unit_id;
159 	uint32_t	start_build_frame_no;
160 
161 	char		build_queue_array[MAX_BUILD_SHIP_QUEUE];
162 	char		build_queue_count;
163 
164 	uint8_t		land_region_id;
165 	uint8_t		sea_region_id;
166 
167 	char		link_checked;
168 	char		linked_mine_num;
169 	char		linked_factory_num;
170 	char		linked_market_num;
171 	short		linked_mine_array[MAX_LINKED_FIRM_FIRM];
172 	short		linked_factory_array[MAX_LINKED_FIRM_FIRM];
173 	short		linked_market_array[MAX_LINKED_FIRM_FIRM];
174 };
175 
176 struct FirmInnCrc : FirmCrc
177 {
178 	short		next_skill_id;
179 
180 	InnUnit		inn_unit_array[MAX_INN_UNIT];
181 	short		inn_unit_count;
182 };
183 
184 struct FirmMarketCrc : FirmCrc
185 {
186 	float		max_stock_qty;
187 
188 	MarketGoods	market_goods_array[MAX_MARKET_GOODS];
189 
190 	short		next_output_link_id;
191 	short		next_output_firm_recno;
192 
193 	int		no_linked_town_since_date;
194 	int		last_import_new_goods_date;
195 	char		is_retail_market;
196 };
197 
198 struct FirmMineCrc : FirmCrc
199 {
200 	short		raw_id;
201 	short		site_recno;
202 	float		reserve_qty;
203 	float		stock_qty;
204 	float		max_stock_qty;
205 
206 	short		next_output_link_id;
207 	short		next_output_firm_recno;
208 
209 	float		cur_month_production;
210 	float		last_month_production;
211 };
212 
213 struct FirmMonsterCrc : FirmCrc
214 {
215 	short		monster_id;
216 	short		monster_general_count;
217 
218 	char		monster_aggressiveness;
219 
220 	char		defending_king_count;
221 	char		defending_general_count;
222 	char		defending_soldier_count;
223 
224 	MonsterInFirm	monster_king;
225 	MonsterInFirm	monster_general_array[MAX_MONSTER_GENERAL_IN_FIRM];
226 
227 	char		waiting_soldier_count;
228 	short		waiting_soldier_array[FirmMonster::MAX_WAITING_SOLDIER];
229 
230 	char		monster_nation_relation;
231 	short		defend_target_recno;
232 
233 	char		patrol_unit_count;
234 	short		patrol_unit_array[MAX_SOLDIER_PER_GENERAL+1];
235 };
236 
237 struct FirmResearchCrc : FirmCrc
238 {
239 	short		tech_id;
240 	float		complete_percent;
241 };
242 
243 struct FirmWarCrc : FirmCrc
244 {
245 	short		build_unit_id;
246 	uint32_t	last_process_build_frame_no;
247 	float		build_progress_days;
248 
249 	char		build_queue_array[MAX_BUILD_QUEUE];
250 	char		build_queue_count;
251 };
252 
253 struct SpriteCrc
254 {
255 	short		sprite_id;
256 	short		sprite_recno;
257 
258 	char		mobile_type;
259 
260 	uint8_t		cur_action;
261 	uint8_t		cur_dir;
262 	uint8_t		cur_frame;
263 	uint8_t		cur_attack;
264 	uint8_t		final_dir;
265 	char		turn_delay;
266 	char		guard_count;
267 
268 	uint8_t		remain_attack_delay;
269 	uint8_t		remain_frames_per_step;
270 
271 	short		cur_x;
272 	short		cur_y;
273 	short		go_x;
274 	short		go_y;
275 	short		next_x;
276 	short		next_y;
277 };
278 
279 struct BulletCrc : SpriteCrc
280 {
281 	char		parent_type;
282 	short		parent_recno;
283 
284 	char		target_mobile_type;
285 	float		attack_damage;
286 	short		damage_radius;
287 	short		nation_recno;
288 	char		fire_radius;
289 
290 	short		origin_x;
291 	short		origin_y;
292 	short		target_x_loc;
293 	short		target_y_loc;
294 	char		cur_step;
295 	char		total_step;
296 };
297 
298 struct BulletFlameCrc : BulletCrc
299 {
300 };
301 
302 struct BulletHomingCrc : BulletCrc
303 {
304 	char		max_step;
305 	char		target_type;
306 	short		target_recno;
307 	short		speed;
308 	short		origin2_x;
309 	short		origin2_y;
310 };
311 
312 struct ProjectileCrc : BulletCrc
313 {
314 	float		z_coff;
315 };
316 
317 struct UnitCrc : SpriteCrc
318 {
319 	char		unit_id;
320 	char		rank_id;
321 	char		race_id;
322 	char		nation_recno;
323 	char		ai_unit;
324 	uint16_t	name_id;
325 
326 	uint32_t	unit_group_id;
327 	uint32_t	team_id;
328 
329 	char		waiting_term;
330 	char		blocked_by_member;
331 	char		swapping;
332 
333 	short		leader_unit_recno;
334 
335 	char		action_misc;
336 	short		action_misc_para;
337 
338 	char		action_mode;
339 	short		action_para;
340 	short		action_x_loc;
341 	short		action_y_loc;
342 
343 	char		action_mode2;
344 	short		action_para2;
345 	short		action_x_loc2;
346 	short		action_y_loc2;
347 
348 	char		blocked_edge[4];
349 	uint8_t		attack_dir;
350 
351 	short		range_attack_x_loc;
352 	short		range_attack_y_loc;
353 
354 	short		move_to_x_loc;
355 	short		move_to_y_loc;
356 
357 	char		loyalty;
358 	char		target_loyalty;
359 
360 	float		hit_points;
361 	short		max_hit_points;
362 
363 	Skill		skill;
364 
365 	char		unit_mode;
366 	short		unit_mode_para;
367 
368 	short		spy_recno;
369 
370 	short		nation_contribution;
371 	short		total_reward;
372 
373 	char		attack_count;
374 	char		attack_range;
375 	short		cur_power;
376 	short		max_power;
377 
378 	int		result_node_count;
379 	short		result_node_recno;
380 	short		result_path_dist;
381 
382 	short		way_point_array_size;
383 	short		way_point_count;
384 
385 	uint16_t	ai_action_id;
386 
387 	char		original_action_mode;
388 	short		original_action_para;
389 	short		original_action_x_loc;
390 	short		original_action_y_loc;
391 
392 	short		original_target_x_loc;
393 	short		original_target_y_loc;
394 
395 	short		ai_original_target_x_loc;
396 	short		ai_original_target_y_loc;
397 
398 	char		ai_no_suitable_action;
399 
400 	char		can_guard_flag;
401 	char		can_attack_flag;
402 	char		force_move_flag;
403 
404 	short		home_camp_firm_recno;
405 
406 	char		aggressive_mode;
407 
408 	char		seek_path_fail_count;
409 	char		ignore_power_nation;
410 };
411 
412 struct UnitGodCrc : UnitCrc
413 {
414 	short		god_id;
415 	short		base_firm_recno;
416 	char		cast_power_type;
417 	short		cast_origin_x;
418 	short		cast_origin_y;
419 	short		cast_target_x;
420 	short		cast_target_y;
421 };
422 
423 struct UnitVehicleCrc : UnitCrc
424 {
425 	short		solider_hit_points;
426 	short		vehicle_hit_points;
427 };
428 
429 struct UnitMonsterCrc : UnitCrc
430 {
431 	char		monster_action_mode;
432 };
433 
434 struct UnitExpCartCrc : UnitCrc
435 {
436 	char		triggered;
437 };
438 
439 struct UnitMarineCrc : UnitCrc
440 {
441 	char		extra_move_in_beach;
442 	char		in_beach;
443 
444 	short		unit_recno_array[MAX_UNIT_IN_SHIP];
445 	char		unit_count;
446 
447 	char		journey_status;
448 	char		dest_stop_id;
449 	char		stop_defined_num;
450 	char		wait_count;
451 
452 	short		stop_x_loc;
453 	short		stop_y_loc;
454 
455 	char		auto_mode;
456 	short		cur_firm_recno;
457 	short		carry_goods_capacity;
458 
459 	ShipStop	stop_array[MAX_STOP_FOR_SHIP];
460 
461 	short		raw_qty_array[MAX_RAW];
462 	short		product_raw_qty_array[MAX_PRODUCT];
463 
464 	AttackInfo	ship_attack_info;
465 	uint8_t		attack_mode_selected;
466 
467 	int		last_load_goods_date;
468 };
469 
470 struct UnitCaravanCrc : UnitCrc
471 {
472 	char		journey_status;
473 	char		dest_stop_id;
474 	char		stop_defined_num;
475 	char		wait_count;
476 
477 	short		stop_x_loc;
478 	short		stop_y_loc;
479 
480 	CaravanStop	stop_array[MAX_STOP_FOR_CARAVAN];
481 
482 	int		last_set_stop_date;
483 	int		last_load_goods_date;
484 
485 	short		raw_qty_array[MAX_RAW];
486 	short		product_raw_qty_array[MAX_PRODUCT];
487 };
488 #pragma pack()
489 
490 #endif
491