Improved support for older lvl format.

This commit is contained in:
lcdr 2017-09-17 11:34:52 +02:00
parent a99be7f585
commit 2ff2a48f33

View File

@ -239,17 +239,52 @@ class LUZViewer(viewer.Viewer):
pass pass
stream._read_offset = (start_pos + chunk_length) * 8 # go to the next CHNK stream._read_offset = (start_pos + chunk_length) * 8 # go to the next CHNK
else: else:
# older lvl file structure self.parse_old_lvl_header(stream)
stream.skip_read(265)
stream.read(bytes, length_type=c_uint)
for _ in range(5):
stream.read(bytes, length_type=c_uint)
stream.skip_read(4)
for _ in range(stream.read(c_uint)):
stream.read(c_float), stream.read(c_float), stream.read(c_float)
self.lvl_parse_chunk_type_2001(stream, scene) self.lvl_parse_chunk_type_2001(stream, scene)
def parse_old_lvl_header(self, stream):
version = stream.read(c_ushort)
assert stream.read(c_ushort) == version
stream.read(c_ubyte)
stream.read(c_uint)
if version >= 45:
stream.read(c_float)
for _ in range(4*3):
stream.read(c_float)
if version >= 31:
if version >= 39:
for _ in range(12):
stream.read(c_float)
if version >= 40:
for _ in range(stream.read(c_uint)):
stream.read(c_uint)
stream.read(c_float)
stream.read(c_float)
else:
stream.read(c_float)
stream.read(c_float)
for _ in range(3):
stream.read(c_float)
if version >= 36:
for _ in range(3):
stream.read(c_float)
if version < 42:
for _ in range(3):
stream.read(c_float)
if version >= 33:
for _ in range(4):
stream.read(c_float)
stream.read(bytes, length_type=c_uint)
for _ in range(5):
stream.read(bytes, length_type=c_uint)
stream.skip_read(4)
for _ in range(stream.read(c_uint)):
stream.read(c_float), stream.read(c_float), stream.read(c_float)
def lvl_parse_chunk_type_2001(self, stream, scene): def lvl_parse_chunk_type_2001(self, stream, scene):
for _ in range(stream.read(c_uint)): for _ in range(stream.read(c_uint)):
object_id = stream.read(c_int64) # seems like the object id, but without some bits object_id = stream.read(c_int64) # seems like the object id, but without some bits