-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsavegame.h
485 lines (449 loc) · 12.5 KB
/
savegame.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
#include <stdint.h>
static const char *unit_type_list[] {
/* 0 */ "Colonist",
/* 1 */ "Soldier",
/* 2 */ "Pioneer",
/* 3 */ "Missionary",
/* 4 */ "Dragoon",
/* 5 */ "Scout",
/* 6 */ "Tory regular",
/* 7 */ "Continental cavalry",
/* 8 */ "Tory cavalry",
/* 9 */ "Continental army",
/* 10 */ "Treasure",
/* 11 */ "Artillery",
/* 12 */ "Wagon train",
/* 13 */ "Caravel",
/* 14 */ "Merchantman",
/* 15 */ "Galeon",
/* 16 */ "Privateer",
/* 17 */ "Frigate",
/* 18 */ "Man-O-War",
/* 19 */ "Brave",
/* 20 */ "Armed brave",
/* 21 */ "Mounted brave",
/* 22 */ "Mounted warrior",
};
static const char *profession_list[] = {
/* 0 */ "Expert farmer",
/* 1 */ "Master sugar planter",
/* 2 */ "Master tobacco planter",
/* 3 */ "Master cotton planter",
/* 4 */ "Expert fur trapper",
/* 5 */ "Expert lumberjack",
/* 6 */ "Expert ore miner",
/* 7 */ "Expert silver miner",
/* 8 */ "Expert fisherman",
/* 9 */ "Master distiller",
/* 10 */ "Master tobacconist",
/* 11 */ "Master weaver",
/* 12 */ "Master fur trader",
/* 13 */ "Master carpenter",
/* 14 */ "Master blacksmith",
/* 15 */ "Master gunsmith",
/* 16 */ "Firebrand preacher",
/* 17 */ "Elder statesman",
/* 18 */ "*(Student)",
/* 19 */ "*(Free colonist)",
/* 20 */ "Hardy pioneer",
/* 21 */ "Veteran soldier",
/* 22 */ "Seasoned scout",
/* 23 */ "Veteran dragoon",
/* 24 */ "Jesuit missionary",
/* 25 */ "Indentured servant",
/* 26 */ "Petty criminal",
/* 27 */ "Indian convert",
/* 28 */ "Free colonist ???",
};
#define INDIAN_OFFSET 4
static const char *nation_list[] = {
/* 0 */ "England",
/* 1 */ "France",
/* 2 */ "Spain",
/* 3 */ "Netherlands",
/* 4 */ "Inca",
/* 5 */ "Aztec",
/* 6 */ "Awarak",
/* 7 */ "Iroquoi",
/* 8 */ "Cherokee",
/* 9 */ "Apache",
/* 10 */ "Sioux",
/* 11 */ "Tupi",
};
static const char *indian_level[] = {
/* 0 */ "Semi-Nomadic",
/* 1 */ "Agrarian",
/* 2 */ "Advanced",
/* 3 */ "Civilized",
};
static const char *cargo_list[] = {
"Food",
"Sugar",
"Tobacco",
"Cotton",
"Furs",
"Lumber",
"Ore",
"Silver",
"Horses",
"Rum",
"Cigars",
"Cloth",
"Coats",
"Trade goods",
"Tools",
"Muskets",
};
static const char *founding_father_list[] = {
"Adam Smith",
"Jakob Fugger",
"Peter Minuit",
"Peter Stuyvesant",
"Jan de Witt",
"Ferdinand Magellan",
"Francisco de Coronado",
"Hernando de Soto",
"Henry Hudson",
"Sieur de La Salle",
"Hernan Cortes",
"George Washington",
"Paul Revere",
"Francis Drake",
"John Paul Jones",
"Thomas Jefferson",
"Pocahontas",
"Thomas Paine",
"founding18",
"Benjamin Franklin",
"William Brewster",
"William Penn",
"Jean de Brebeuf",
"Juan de Sepulveda",
"Bartolme de las Casas",
};
static const char *difficulty_list[] = {
"Discoverer ",
"Explorer ",
"Conquistador",
"Governor ",
"Viceroy ",
};
struct savegame {
struct head {
char sig_colonize[9];
uint8_t unk0[ 3];
uint16_t map_size_x;
uint16_t map_size_y;
struct tut1 {
uint8_t nr13 : 1;
uint8_t nr14 : 1;
uint8_t unk3 : 1;
uint8_t nr15 : 1;
uint8_t nr16 : 1;
uint8_t nr17 : 1;
uint8_t unk7 : 1;
uint8_t nr19 : 1;
} __attribute__ ((packed)) tut1;
uint8_t unk1[1];
struct game_options {
uint16_t unknown7 : 7;
uint16_t tutorial_hints : 1;
uint16_t water_color_cycling: 1;
uint16_t combat_analysis : 1;
uint16_t autosave : 1;
uint16_t end_of_turn : 1;
uint16_t fast_piece_slide : 1;
uint16_t cheat : 1; // alt + 'w', 'i', 'n'
uint16_t show_foreign_moves : 1;
uint16_t show_indian_moves : 1;
} __attribute__ ((packed)) game_options;
struct colony_report_options {
uint16_t labels_on_cargo_and_terrain : 1;
uint16_t labels_on_buildings : 1;
uint16_t report_new_cargos_available : 1;
uint16_t report_inefficient_government : 1;
uint16_t report_tools_needed_for_production : 1;
uint16_t report_raw_materials_shortages : 1;
uint16_t report_food_shortages : 1;
uint16_t report_when_colonists_trained : 1;
uint16_t report_sons_of_liberty_membership : 1;
uint16_t report_rebel_majorities : 1;
uint16_t unused : 6;
} __attribute__ ((packed)) colony_report_options;
struct tut2 {
uint8_t howtowin : 1;
uint8_t background_music : 1;
uint8_t event_music : 1;
uint8_t sound_effects : 1;
uint8_t nr1 : 1; // shown immediately on game-start
uint8_t nr2 : 1; // probably not used, also triggers event_discovery_of_the_new_world
uint8_t nr3 : 1;
uint8_t nr4 : 1;
} __attribute__ ((packed)) tut2;
struct tut3 {
uint8_t nr5 : 1;
uint8_t nr6 : 1;
uint8_t nr7 : 1;
uint8_t nr8 : 1;
uint8_t nr9 : 1;
uint8_t nr10 : 1;
uint8_t nr11 : 1;
uint8_t nr12 : 1;
} __attribute__ ((packed)) tut3;
int16_t numbers00;
uint16_t year;
uint16_t autumn; //boolean, true if autumn
uint16_t turn;
int16_t numbers01;
uint16_t active_unit;
int16_t numbers02[3];
uint16_t tribe_count;
uint16_t unit_count;
uint16_t colony_count;
uint16_t trade_route_count;
int16_t numbers03[2];
uint8_t difficulty; enum { DISCOVERER = 0, EXPLORER = 1, CONQUISTADOR = 2, GOVERNOR = 3, VICEROY = 4 }; //36
int16_t numbers04;
int8_t founding_father[25];
uint16_t numbers05[3];
int16_t nation_relation[4];
int16_t numbers06[ 5];
uint16_t expeditionary_force[4];
uint16_t numbers07[ 4]; //backup force, once you produce enough bells.
uint16_t count_down[16];
struct event { //these are events that trigger the "woodframe"
uint16_t discovery_of_the_new_world : 1;
uint16_t building_a_colony : 1;
uint16_t meeting_the_natives : 1;
uint16_t the_aztec_empire : 1;
uint16_t the_inca_nation : 1;
uint16_t discovery_of_the_pacific_ocean : 1;
uint16_t entering_indian_village : 1;
uint16_t the_fountain_of_youth : 1;
uint16_t cargo_from_the_new_world : 1;
uint16_t meeting_fellow_europeans : 1;
uint16_t colony_burning : 1;
uint16_t colony_destroyed : 1;
uint16_t indian_raid : 1;
uint16_t woodcut14 : 1;
uint16_t woodcut15 : 1;
uint16_t woodcut16 : 1;
} __attribute__ ((packed)) event;
uint8_t unkb[2];
} __attribute__ ((packed)) head;
struct player {
char name[24];
char country[24];
uint8_t unk00;
uint8_t control; enum { PLAYER = 0, AI = 1, WITHDRAWN = 2 };
uint8_t founded_colonies; // founded colonies, probably used pick next colony name
uint8_t diplomacy;
} __attribute__ ((packed)) player[4];
struct other {
uint8_t unkXX_xx[24];
} __attribute__ ((packed)) other;
struct colony {
uint8_t x, y;
char name[24];
uint8_t nation;
uint8_t unk0[ 4];
uint8_t population;
uint8_t occupation[32];
uint8_t profession[32];
uint8_t unk6[16];
int8_t tiles[ 8]; //represents tiles around the colony. idx to citizen.
uint8_t unk8[12];
struct buildings {
uint32_t stockade : 3;
uint32_t armory : 3;
uint32_t docks : 3;
uint32_t town_hall : 3;
uint32_t schoolhouse : 3;
uint32_t warehouse : 2;
uint32_t stables : 1;
uint32_t custom_house : 1;
uint32_t printing_press : 2;
uint32_t weavers_house : 3;
uint32_t tobacconists_house : 3;
uint32_t rum_distillers_house : 3;
uint32_t capitol : 2; /* not really in use */
uint16_t fur_traders_house : 3;
uint16_t carpenters_shop : 2;
uint16_t church : 2;
uint16_t blacksmiths_house : 3;
uint16_t unused : 6;
} __attribute__ ((packed)) buildings;
struct custom_house {
uint16_t food : 1;
uint16_t sugar : 1;
uint16_t tobacco : 1;
uint16_t cotton : 1;
uint16_t furs : 1;
uint16_t lumber : 1;
uint16_t ore : 1;
uint16_t silver : 1;
uint16_t horses : 1;
uint16_t rum : 1;
uint16_t cigars : 1;
uint16_t cloth : 1;
uint16_t coats : 1;
uint16_t trade_goods : 1;
uint16_t tools : 1;
uint16_t muskets : 1;
} __attribute__ ((packed)) custom_house;
uint8_t unka[6];
uint16_t hammers;
uint8_t building_in_production;
uint8_t unkb[ 5];
int16_t stock[16];
uint8_t unkd[ 8];
uint32_t rebel_dividend;
uint32_t rebel_divisor;
} __attribute__ ((packed)) *colony;
struct unit {
uint8_t x, y;
uint8_t type;
uint8_t owner : 4; /* likely to be owner of unit, eng, fra, spa, dut, indian tribes, etc. */
uint8_t unk04 : 4;
uint8_t unk05;
uint8_t moves; /* Accumulated moves (3 between land, 1 on roads, etc.) */
uint8_t unk06;
uint8_t unk07;
uint8_t order; enum { PLOW = 8, ROAD = 9 };
uint8_t unk08[ 3];
uint8_t holds_occupied;
uint8_t cargo_item_0 : 4;
uint8_t cargo_item_1 : 4;
uint8_t cargo_item_2 : 4;
uint8_t cargo_item_3 : 4;
uint8_t cargo_item_4 : 4;
uint8_t cargo_item_5 : 4;
uint8_t cargo_hold[6];
uint8_t turns_worked;
uint8_t profession;
struct transport_chain {
int16_t next_unit_idx;
int16_t prev_unit_idx; // index to unit being transported? (treasure)
} __attribute__ ((packed)) transport_chain;
} __attribute__ ((packed)) *unit;
struct nation {
uint8_t unk0;
uint8_t tax_rate;
uint8_t recruit[3];
uint8_t unk1;
uint8_t recruit_count; //recruit penalty 120 + (count * 20) (does not go above 180)
uint8_t unk2[ 5];
uint16_t liberty_bells_total;
uint16_t liberty_bells_last_turn;
uint8_t unk3[ 2];
int16_t next_founding_father;
uint16_t founding_father_count;
uint16_t ffc_high; //suspect founding_father_count is 32bit.
uint8_t villages_burned;
uint8_t unk4[5];
uint16_t artillery_count; //artillery purchased in europe. 500 + (count * 100) price penalty.
uint16_t boycott_bitmap;
uint8_t unk5[ 8];
uint32_t gold;
uint16_t crosses;
int16_t unk6[ 4];
uint8_t indian_relation[8]; enum { NOT_MET = 0x00, WAR = 0x20, PEACE = 0x60};
uint8_t unk7[12];
struct trade {
uint8_t euro_price[16];
int16_t nr[16];
int32_t gold[16];
int32_t tons[16];
int32_t tons2[16];
} __attribute__ ((packed)) trade;
} __attribute__ ((packed)) nation[4];
struct tribe {
uint8_t x, y;
uint8_t nation;
struct state {
uint8_t artillery : 1; //artillery has been nearby?
uint8_t learned : 1; //visited and learned skill
uint8_t capital : 1;
uint8_t scouted : 1; //visited by scout
uint8_t unk5 : 1;
uint8_t unk6 : 1;
uint8_t unk7 : 1;
uint8_t unk8 : 1;
} __attribute__ ((packed)) state;
uint8_t population;
int8_t mission; //ff if none, 0 1 2 3 = eng fra spa dut
uint8_t unk1;
int8_t flag_0;
int8_t last_cargo_bought;
int8_t last_cargo_sold;
uint8_t panic;
uint8_t unk2[6];
uint8_t population_loss_in_current_turn; //due to attacks
} __attribute__ ((packed)) *tribe;
struct indian_relations {
uint8_t unk0;
uint8_t unk1;
uint8_t level;
uint8_t unk2[4];
uint8_t armed_braves; // if you sell 100 muskets, this increases by 2 (50 muskets per unit)
uint8_t horse_herds;
uint8_t unk3[5];
int16_t stock[16]; // trading with indians, they offer 25 of some item they don't actually have. So the game allows for negative numbers.
uint8_t unk4[12];
struct meeting {
uint8_t met;
} __attribute__ ((packed)) meeting[4];
uint8_t unk5[8];
struct aggr {
uint8_t aggr;
uint8_t aggr_high;
} __attribute__ ((packed)) aggr[4];
} __attribute__ ((packed)) indian_relations[8];
struct stuff {
uint8_t unk15[15];
uint16_t counter_decreasing_on_new_colony;
uint16_t unk_short;
uint16_t counter_increasing_on_new_colony;
uint8_t unk_big[696];
uint16_t x;
uint16_t y;
uint8_t zoom_level;
uint8_t unk7;
uint16_t viewport_x;
uint16_t viewport_y;
} __attribute__ ((packed)) stuff;
// 56*70 visible + border, = 58*72 = 4176
struct map { /* 58 x 72 ... (visible 56 x 70) */
union {
struct {
uint8_t tile : 3;
uint8_t forest : 1;
uint8_t water : 1;
uint8_t phys : 3;
} __attribute__ ((packed));
uint8_t full;
} __attribute__ ((packed)) layer[4][58*72];
} __attribute__ ((packed)) map;
struct tail {
uint8_t unk[614];
} __attribute__ ((packed)) tail;
struct trade_route {
char name[32];
uint8_t type;
uint8_t entries;
struct entry {
uint16_t destination;
uint8_t unloading_size: 4;
uint8_t loading_size : 4;
struct {
uint8_t item_0 : 4;
uint8_t item_1 : 4;
uint8_t item_2 : 4;
uint8_t item_3 : 4;
uint8_t item_4 : 4;
uint8_t item_5 : 4;
} __attribute__ ((packed)) cargo[2]; // 0 for loading, 1 for unloading
uint8_t padding;
} __attribute__ ((packed)) entry[4];
} __attribute__ ((packed)) trade_route[12];
} __attribute__ ((packed));