comparison pytouhou/formats/pbg3.py @ 590:e15672733c93

Switch to Python 3.x instead of 2.7.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 30 Sep 2014 17:14:24 +0200
parents 6b76c9ba3975
children d1f0bb0b7a17
comparison
equal deleted inserted replaced
589:0768122da817 590:e15672733c93
116 unknown1 = bitstream.read_int() 116 unknown1 = bitstream.read_int()
117 unknown2 = bitstream.read_int() 117 unknown2 = bitstream.read_int()
118 checksum = bitstream.read_int() # Checksum of *compressed data* 118 checksum = bitstream.read_int() # Checksum of *compressed data*
119 offset = bitstream.read_int() 119 offset = bitstream.read_int()
120 size = bitstream.read_int() 120 size = bitstream.read_int()
121 name = bitstream.read_string(255).decode('ascii') 121 name = bitstream.read_string(255)
122 entries[name] = PBG3Entry(unknown1, unknown2, checksum, offset, size) 122 entries[name] = PBG3Entry(unknown1, unknown2, checksum, offset, size)
123 123
124 return PBG3(entries, bitstream) 124 return PBG3(entries, bitstream)
125 125
126 126
146 # Verify the checksum 146 # Verify the checksum
147 compressed_size = self.bitstream.io.tell() - offset 147 compressed_size = self.bitstream.io.tell() - offset
148 self.bitstream.seek(offset) 148 self.bitstream.seek(offset)
149 value = 0 149 value = 0
150 for c in self.bitstream.io.read(compressed_size): 150 for c in self.bitstream.io.read(compressed_size):
151 value += ord(c) 151 value += c
152 value &= 0xFFFFFFFF 152 value &= 0xFFFFFFFF
153 if value != checksum: 153 if value != checksum:
154 logger.warn('corrupted data!') 154 logger.warn('corrupted data!')
155 return BytesIO(data) 155 return BytesIO(data)