comparison pytouhou/formats/t6rp.py @ 328:56523a16db1d

Fix some replay synchronization issues and update the TODO.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 21 Jun 2012 19:59:41 +0200
parents 5492472963b0
children 6deab6ad8be8
comparison
equal deleted inserted replaced
327:13201d90bb22 328:56523a16db1d
30 30
31 class Level(object): 31 class Level(object):
32 def __init__(self): 32 def __init__(self):
33 self.score = 0 33 self.score = 0
34 self.random_seed = 0 34 self.random_seed = 0
35 self.point_items = 0
35 36
36 self.power = 0 37 self.power = 0
37 self.lives = 2 38 self.lives = 2
38 self.bombs = 3 39 self.bombs = 3
39 self.difficulty = 16 40 self.difficulty = 16
41 self.unknown = 0
40 self.keys = [] 42 self.keys = []
41 43
42 44
43 class T6RP(object): 45 class T6RP(object):
44 def __init__(self): 46 def __init__(self):
83 data = file.read() 85 data = file.read()
84 file.seek(15) 86 file.seek(15)
85 if checksum != (sum(ord(c) for c in data) + 0x3f000318 + replay.key) & 0xffffffff: 87 if checksum != (sum(ord(c) for c in data) + 0x3f000318 + replay.key) & 0xffffffff:
86 raise Exception #TODO 88 raise Exception #TODO
87 89
88 replay.unknown3 = unpack('<B', file.read(1)) 90 replay.unknown3, = unpack('<B', file.read(1))
89 replay.date = file.read(9) #read_string(file, 9, 'ascii') 91 replay.date = file.read(9) #read_string(file, 9, 'ascii')
90 replay.name = file.read(9) #read_string(file, 9, 'ascii').rstrip() 92 replay.name = file.read(9) #read_string(file, 9, 'ascii').rstrip()
91 replay.unknown4, replay.score, replay.unknown5, replay.slowdown, replay.unknown6 = unpack('<HIIfI', file.read(18)) 93 replay.unknown4, replay.score, replay.unknown5, replay.slowdown, replay.unknown6 = unpack('<HIIfI', file.read(18))
92 94
93 stages_offsets = unpack('<7I', file.read(28)) 95 stages_offsets = unpack('<7I', file.read(28))
98 100
99 level = Level() 101 level = Level()
100 replay.levels[i] = level 102 replay.levels[i] = level
101 103
102 file.seek(offset) 104 file.seek(offset)
103 (level.score, level.random_seed, level.unknown1, level.power, 105 (level.score, level.random_seed, level.point_items, level.power,
104 level.lives, level.bombs, level.difficulty, level.unknown2) = unpack('<IHHBbbBI', file.read(16)) 106 level.lives, level.bombs, level.difficulty, level.unknown) = unpack('<IHHBbbBI', file.read(16))
105 107
106 while True: 108 while True:
107 time, keys, unknown = unpack('<IHH', file.read(8)) 109 time, keys, unknown = unpack('<IHH', file.read(8))
108 110
109 if time == 9999999: 111 if time == 9999999: