@@ -21,6 +21,47 @@ def __call__(self, data, replay):
21
21
22
22
class InitDataReader_Base (Reader ):
23
23
24
+ def __call__ (self , data , replay ):
25
+ data = BitPackedDecoder (data )
26
+
27
+ init_data = dict ( #58
28
+ player_init_data = [dict ( #38
29
+ name = data .read_aligned_bytes (data .read_uint8 ()),
30
+ random_seed = data .read_uint32 (),
31
+ race_preference = data .read_uint8 () if data .read_bool () else None , #38
32
+ team_preference = data .read_uint8 () if data .read_bool () else None , #39
33
+ test_map = data .read_bool (),
34
+ test_auto = data .read_bool (),
35
+ examine = data .read_bool (),
36
+ observe = data .read_bits (2 ),
37
+ ) for i in range (data .read_bits (5 ))
38
+ ],
39
+ )
40
+
41
+ distance = data .read_range (data .tell (), data .length ).find ('s2ma' )
42
+ data .read_aligned_bytes (distance )
43
+
44
+ # The final block of this file that we concern ourselves with is a list
45
+ # of what appears to be map data with the s2ma header on each element.
46
+ # Each element consists of two unknown bytes, a realm id (e.g EU or US)
47
+ # and a map hash which probably ties back to the sc2map files.
48
+ #
49
+ # Some replays don't seem to have a maps section at all, now we can't
50
+ # know what gateway its from? Very strange...
51
+ #
52
+ # TODO: Figure out how we could be missing a maps section.
53
+ map_data = list ()
54
+ while data .peek (4 ) == 's2ma' :
55
+ map_data .append (DepotFile (data .read_aligned_bytes (40 )))
56
+
57
+ return AttributeDict (
58
+ map_data = map_data ,
59
+ player_names = [d ['name' ] for d in init_data ['player_init_data' ] if d ['name' ]],
60
+ sc_account_id = None ,#sc_account_id,
61
+ )
62
+
63
+ class InitDataReader_23260 (Reader ):
64
+
24
65
def __call__ (self , data , replay ):
25
66
data = BitPackedDecoder (data )
26
67
@@ -83,8 +124,7 @@ def __call__(self, data, replay):
83
124
is_blizzardMap = data .read_bool (),
84
125
is_premade_ffa = data .read_bool (),
85
126
),
86
- )
87
- """ # For builds <= 1.5.4 this won't work.
127
+
88
128
lobby_state = dict ( #56
89
129
phase = data .read_bits (3 ),
90
130
max_users = data .read_bits (5 ),
@@ -98,17 +138,17 @@ def __call__(self, data, replay):
98
138
difficulty = data .read_bits (6 ),
99
139
handicap = data .read_bits (7 ),
100
140
observe = data .read_bits (2 ),
101
- rewards = [data.read_uint32() for i in range(data.read_bits(6 ))],
141
+ rewards = [data .read_uint32 () for i in range (data .read_bits (5 ))], # 52
102
142
toon_handle = data .read_aligned_bytes (data .read_bits (7 )), # 14
103
- licenses = [data.read_uint32() for i in range(data.read_bits(9))], # 56
143
+ licenses = [data .read_uint32 () for i in range (data .read_bits (9 ))], # 53
104
144
) for i in range (data .read_bits (5 ))], # 58
105
145
random_seed = data .read_uint32 (),
106
146
host_user_id = data .read_bits (4 ) if data .read_bool () else None , # 52
107
147
is_single_player = data .read_bool (), # 27
108
148
game_duration = data .read_uint32 (), # 4
109
149
default_difficulty = data .read_bits (6 ), # 1
110
150
),
111
- )"""
151
+ )
112
152
113
153
return AttributeDict (
114
154
map_data = init_data ['game_description' ]['cache_handles' ],
0 commit comments