def _decode_dbg_log(self, bitstream): entrie_number = bitstream.read(UINT_32) entries = [] for i in range(entrie_number): entries.append({'frame': bitstream.read(UINT_32), 'player': read_string(bitstream), 'data:': read_string(bitstream)}) return entries
def _decode_goalframes(self, bitstream): entrie_number = bitstream.read(UINT_32) entries = [] for i in range(entrie_number): entries.append({'type': read_string(bitstream), 'frame': bitstream.read(UINT_32)}) return entries
def _decode_class_index_map(self, bitstream): entrie_number = bitstream.read(UINT_32) entries = {} for i in range(entrie_number): # corresponds to object table name = read_string(bitstream) class_id = bitstream.read(UINT_32) entries[class_id] = name return entries
def _decode_property(self, bitstream): property_key = read_string(bitstream) if property_key == 'None': return None, None property_type = read_string(bitstream) property_value_size = bitstream.read(UINT_64) if property_type == 'IntProperty': property_value = bitstream.read(UINT_32) elif property_type == 'StrProperty': property_value = read_string(bitstream) elif property_type == 'FloatProperty': property_value = bitstream.read(FLOAT_LE_32) elif property_type == 'NameProperty': property_value = read_string(bitstream) elif property_type == 'ArrayProperty': array_length = bitstream.read(UINT_32) property_value = [ self._decode_properties(bitstream) for i in range(array_length) ] elif property_type == 'ByteProperty': key_text = read_string(bitstream) value_text = read_string(bitstream) property_value = {key_text: value_text} elif property_type == 'QWordProperty': property_value = bitstream.read(64).uint elif property_type == 'BoolProperty': property_value = bitstream.read(8).uint == 1 else: msg = "Unknown property type %s for %s" % (property_type, property_key) raise PropertyParsingError(msg) return property_key, property_value
def _parse_meta(self): self._replay.pos = 0 # Just reassure we are at the beginning header_size = self._replay.read(UINT_32) self.crc = self._replay.read('hex:32') self.version = str(self._replay.read(UINT_32)) + '.' + str(self._replay.read(UINT_32)) assert int(self._replay.pos / 8) == 16 check_bytes = self._replay.read('bytes:4') if check_bytes == b'\x05\x00\x00\x00': # continue onwards pass elif check_bytes != b'\x00\x00\x00\x00': # Old replay, back it up. self._replay.pos -= 32 try: assert read_string(self._replay) == 'TAGame.Replay_Soccar_TA' except AssertionError: self._replay.pos -= 16 assert read_string(self._replay) == 'TAGame.Replay_Soccar_TA' self._header_raw = self._replay.read((header_size - 8) * 8) return True
def _decode_maps(self, bitstream): maps = [] array_len = bitstream.read(UINT_32) for i in range(array_len): maps.append(read_string(bitstream)) return maps
def _parse_header(self): read_string(self._header_raw) # Read and discard TAGame.Replay_Soccar_TA self.header = self._decode_properties(self._header_raw)
def _decode_names(self, bitstream): entrie_number = bitstream.read(UINT_32) entries = [] for i in range(entrie_number): entries.append(read_string(bitstream)) return entries
def _decode_objects(self, bitstream): entrie_number = bitstream.read(UINT_32) entries = {} for i in range(entrie_number): entries[i] = read_string(bitstream) return entries
def _parse_header(self): read_string( self._header_raw) # Read and discard TAGame.Replay_Soccar_TA self.header = self._decode_properties(self._header_raw)