-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCoH3Rec.bt
355 lines (315 loc) · 7.72 KB
/
CoH3Rec.bt
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
//------------------------------------------------
//--- 010 Editor v13.0.1 Binary Template
//
// File: CoH3Rec.bt
// Authors: Ryan Taylor
// Version: 0.2.0
// Purpose: Parse Company of Heroes 3 replay files.
// Category: Game
// File Mask: *.rec
// ID Bytes:
// History:
// 0.2.0 2023-04-16 Ryan Taylor: Additional command parsing
// 0.1.0 2023-04-16 Ryan Taylor: Initial submission
//------------------------------------------------
LittleEndian();
local uint16 global_version = 0;
struct HEADER {
uint16 zero;
global_version = ReadShort();
uint16 version;
char name[];
wstring timestamp;
};
HEADER h;
while(ReadUShort() == 0)
FSkip(2);
struct CHUNKY {
char name[12];
uint32 signature;
uint32 major_version;
uint32 minor_version;
};
CHUNKY c;
struct CHUNKHEADER {
char kind[4];
char type[4];
uint32 version;
uint32 length;
uint32 name_length;
};
struct ITEM {
uint32 id_a;
if (id_a == 0) {
uint32 sublength_maybe;
uint32 id_a_actual;
}
uint16 player_id_a;
char zeroes_a[5];
uint32 id_b;
uint16 player_id_b;
char zeroes_b[5];
uint16 flag_a;
uint32 length;
local uint32 start = FTell();
uint64 iteminstance_id;
uint64 some_flag;
uint64 itemdefinition_id;
uint64 profile_id;
uint32 durability;
uint32 durability_type;
ubyte some_other_flag;
uint32 metadata_length;
char metadata[metadata_length];
uint64 some_crazy_number;
uint64 itemlocation_id;
char rest_data[length - (FTell() - start)];
uint32 spacer;
};
struct CPUITEM {
char blob[8];
uint32 spacer;
};
struct PLAYER {
ubyte is_human;
uint32 name_length;
wchar_t name[name_length];
uint32 team;
uint32 id;
ubyte small_flag;
uint32 faction_length;
char faction[faction_length];
uint32 length_maybe;
uint32 another_flag;
uint32 ai_length;
char ai[ai_length];
uint32 max_one;
uint32 zero_one;
char maxes[20];
uint32 zero_two;
uint32 one_one;
uint32 zero_three;
uint64 profile_id;
ubyte short_zero;
uint32 steam_id_length;
wchar_t steam_id[steam_id_length];
uint32 zero_five;
uint32 flag_a;
uint32 flag_b;
uint32 flag_c;
uint16 flag_d;
if (is_human == 1) {
uint32 battlegroup_count;
ITEM battlegroup_items[battlegroup_count] <optimize=false>;
uint32 spacer;
uint32 cosmetics_count;
ITEM cosmetic_items[cosmetics_count] <optimize=false>;
} else {
uint32 battlegroup_count;
CPUITEM battlegroup_items[battlegroup_count] <optimize=false>;
uint32 spacer;
uint32 cosmetics_count;
CPUITEM cosmetic_items[cosmetics_count] <optimize=false>;
}
};
struct OPTIONCONFIG {
uint32 name_length;
char name[name_length];
uint32 value;
};
struct DATADATACHUNK {
CHUNKHEADER header;
local uint32 start = FTell();
if(header.version == 1)
char data[header.length];
else {
uint32 opponent_type;
char data[6];
uint32 num_players;
PLAYER players[num_players] <optimize=false>;
uint32 length_a;
char data_a[length_a];
uint32 length_c;
char data_c[length_c];
uint64 matchhistory_id;
uint32 some_flag_probs_not_length;
uint32 usually_zero;
uint32 usually_one;
uint32 one_or_zero;
uint32 option_group_count;
uint32 options_per_group;
while (ReadUInt() != 0 && ReadUInt() != 1) {
OPTIONCONFIG options;
}
uint32 zero_d;
uint32 zero_e;
uint32 zero_f;
uint32 some_string_length;
char some_string[some_string_length];
FSeek(start + header.length);
}
};
struct DATAPLASCHUNK {
CHUNKHEADER header;
char data[header.length];
};
struct DATAGRIFCHUNK {
CHUNKHEADER header;
char data[header.length];
};
struct DATASAVPCHUNK {
CHUNKHEADER header;
char data[header.length];
};
struct DATAMTYPCHUNK {
CHUNKHEADER header;
char data[header.length];
};
struct DATAREPLCHUNK {
CHUNKHEADER header;
char data[header.length];
};
struct DATALOCSCHUNK {
CHUNKHEADER header;
char data[header.length];
};
struct DATAAUTOCHUNK {
CHUNKHEADER header;
char data[header.length];
};
struct DATASDSCCHUNK {
CHUNKHEADER header;
local uint32 start = FTell();
char data[121];
if (header.version > 3026) char more_data[8];
uint32 map_file_length;
char map_file[map_file_length];
uint32 map_name_length;
wchar_t map_name[map_name_length];
if (ReadUInt() == 0) uint32 zero_a;
uint32 map_description_length;
wchar_t map_description[map_description_length];
char rest_data[header.length - (FTell() - start)];
};
struct FOLDPOSTCHUNK {
CHUNKHEADER header;
DATADATACHUNK data_chunk;
};
struct FOLDINFOCHUNK {
CHUNKHEADER header;
DATADATACHUNK data_chunk;
DATAPLASCHUNK plas_chunk;
DATAGRIFCHUNK grif_chunk;
DATASAVPCHUNK savp_chunk;
if (global_version >= 19802) {
DATAMTYPCHUNK mtyp_chunk;
DATAREPLCHUNK repl_chunk;
DATALOCSCHUNK locs_chunk;
DATAAUTOCHUNK auto_chunk;
}
DATASDSCCHUNK sdsc_chunk;
};
struct TICK_BUNDLE_PART {
ubyte bundle_part_length;
ubyte some_zero_maybe;
ubyte action_type;
ubyte base_location;
ubyte some_id;
ubyte player_id;
uint16 current_num_of_tick_size_maybe;
uint16 some_num;
ubyte command_type;
ubyte target_id_maybe;
ubyte command_sub_id;
char data[bundle_part_length - 12];
};
struct CMD_BUILDSQUAD {
char zeroes[6];
uint32 some_nonsense;
uint16 maybe_one;
uint16 maybe_zero;
uint32 maybe_thousand;
uint32 kinda_zero;
char lotta_stuff[7];
uint32 pbgid;
uint32 maybe_thousand_again;
ubyte zero_byte;
};
struct CMD_USEBATTLEGROUPABILITY {
char data[29];
uint32 pbgid;
};
struct CMD_SELECTBATTLEGROUP {
char data[29];
uint32 pbgid;
};
struct CMD_SELECTBATTLEGROUPABILITY {
char data[29];
uint32 pbgid;
};
struct CMD_GLOBALUPDGRADE {
char data[29];
uint32 pbgid;
};
struct TICK_BUNDLE {
uint32 bundle_num;
uint32 some_num;
uint32 bundle_length;
uint16 checksum;
ubyte action_type;
ubyte player_id;
ubyte some_player_id_part_maybe;
ubyte base_location;
local uint32 start = FTell();
switch (action_type) {
case 3: CMD_BUILDSQUAD build_squad_action; break;
case 16: CMD_GLOBALUPDGRADE global_upgrade_action; break;
case 132: CMD_USEBATTLEGROUPABILITY use_battlegroup_ability_action; break;
case 136: CMD_SELECTBATTLEGROUP select_battlegroup_action; break;
case 137: CMD_SELECTBATTLEGROUPABILITY select_battlegroup_ability_action; break;
default: break;
}
char remainder[bundle_length - (FTell() - start) - 6];
};
struct TICK {
uint32 tick_type;
uint32 tick_size;
ubyte some_id;
uint32 tick_id;
uint32 some_big_num;
uint32 bundle_size;
TICK_BUNDLE bundles[bundle_size] <optimize=false>;
};
struct MESSAGE_BODY {
uint32 name_length;
wchar_t player_name[name_length];
uint32 message_length;
wchar_t message[message_length];
};
struct MESSAGE {
uint32 tick_type;
uint32 tick_size;
uint32 num_messages;
uint32 message_length;
if (num_messages == 0) {
char data[message_length];
} else {
uint32 some_flag;
uint32 some_other_flag;
uint32 some_third_flag;
}
local int i = 0;
for (i = 0; i < num_messages; i++) {
MESSAGE_BODY body;
}
};
struct TICKS {
while (!FEof()) {
if (ReadUInt() == 0) TICK tick;
else MESSAGE message;
}
};
FOLDPOSTCHUNK f;
CHUNKY c2;
FOLDINFOCHUNK f2;
TICKS ticks;