Cleanup: Import_max #1
@ -556,16 +556,10 @@ class MaxChunk():
|
|||||||
self.previous = None
|
self.previous = None
|
||||||
self.next = None
|
self.next = None
|
||||||
self.size = size
|
self.size = size
|
||||||
self.unknown = True
|
|
||||||
self.format = None
|
|
||||||
self.data = None
|
self.data = None
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if (self.unknown):
|
return "%s[%4x]%04X:%s" % ("" * self.level, self.number, self.types, self.data)
|
||||||
return "%s[%4x]%04X:%s" % ("" * self.level, self.number, self.types,
|
|
||||||
":".join("%02x" % (c) for c in self.data))
|
|
||||||
return "%s[%4x]%04X:%s=%s" % ("" * self.level, self.number, self.types,
|
|
||||||
self.format, self.data)
|
|
||||||
|
|
||||||
|
|
||||||
class ByteArrayChunk(MaxChunk):
|
class ByteArrayChunk(MaxChunk):
|
||||||
@ -574,11 +568,9 @@ class ByteArrayChunk(MaxChunk):
|
|||||||
def __init__(self, types, data, level, number):
|
def __init__(self, types, data, level, number):
|
||||||
MaxChunk.__init__(self, types, data, level, number)
|
MaxChunk.__init__(self, types, data, level, number)
|
||||||
|
|
||||||
def set(self, data, name, fmt, start, end):
|
def set(self, data, fmt, start, end):
|
||||||
try:
|
try:
|
||||||
self.data = struct.unpack(fmt, data[start:end])
|
self.data = struct.unpack(fmt, data[start:end])
|
||||||
self.format = name
|
|
||||||
self.unknown = False
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
self.data = data
|
self.data = data
|
||||||
# print('StructError:', exc, name)
|
# print('StructError:', exc, name)
|
||||||
@ -586,8 +578,6 @@ class ByteArrayChunk(MaxChunk):
|
|||||||
def set_string(self, data):
|
def set_string(self, data):
|
||||||
try:
|
try:
|
||||||
self.data = data.decode('UTF-16LE')
|
self.data = data.decode('UTF-16LE')
|
||||||
self.format = "Str16"
|
|
||||||
self.unknown = False
|
|
||||||
except:
|
except:
|
||||||
self.data = data
|
self.data = data
|
||||||
|
|
||||||
@ -595,15 +585,14 @@ class ByteArrayChunk(MaxChunk):
|
|||||||
if (self.types in [0x0340, 0x4001, 0x0456, 0x0962]):
|
if (self.types in [0x0340, 0x4001, 0x0456, 0x0962]):
|
||||||
self.set_string(data)
|
self.set_string(data)
|
||||||
elif (self.types in [0x2034, 0x2035]):
|
elif (self.types in [0x2034, 0x2035]):
|
||||||
self.set(data, "ints", '<' + 'I' * int(len(data) / 4), 0, len(data))
|
self.set(data, '<' + 'I' * int(len(data) / 4), 0, len(data))
|
||||||
elif (self.types in [0x2501, 0x2503, 0x2504, 0x2505, 0x2511]):
|
elif (self.types in [0x2501, 0x2503, 0x2504, 0x2505, 0x2511]):
|
||||||
self.set(data, "floats", '<' + 'f' * int(len(data) / 4), 0, len(data))
|
self.set(data, '<' + 'f' * int(len(data) / 4), 0, len(data))
|
||||||
elif (self.types == 0x2510):
|
elif (self.types == 0x2510):
|
||||||
self.set(data, "struct", '<' + 'f' * int(len(data) / 4 - 1) + 'I', 0, len(data))
|
self.set(data, '<' + 'f' * int(len(data) / 4 - 1) + 'I', 0, len(data))
|
||||||
elif (self.types == 0x0100):
|
elif (self.types == 0x0100):
|
||||||
self.set(data, "float", '<f', 0, len(data))
|
self.set(data, '<f', 0, len(data))
|
||||||
else:
|
else:
|
||||||
self.unknown = True
|
|
||||||
self.data = data
|
self.data = data
|
||||||
|
|
||||||
|
|
||||||
@ -618,9 +607,8 @@ class ClassIDChunk(ByteArrayChunk):
|
|||||||
if (self.types == 0x2042):
|
if (self.types == 0x2042):
|
||||||
self.set_string(data) # ClsName
|
self.set_string(data) # ClsName
|
||||||
elif (self.types == 0x2060):
|
elif (self.types == 0x2060):
|
||||||
self.set(data, "struct", '<IQI', 0, 16) # DllIndex, ID, SuperID
|
self.set(data, '<IQI', 0, 16) # DllIndex, ID, SuperID
|
||||||
else:
|
else:
|
||||||
self.unknown = False
|
|
||||||
self.data = ":".join("%02x" % (c) for c in data)
|
self.data = ":".join("%02x" % (c) for c in data)
|
||||||
|
|
||||||
|
|
||||||
@ -645,9 +633,7 @@ class ContainerChunk(MaxChunk):
|
|||||||
self.primReader = primReader
|
self.primReader = primReader
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if (self.unknown):
|
|
||||||
return "%s[%4x]%04X" % ("" * self.level, self.number, self.types)
|
return "%s[%4x]%04X" % ("" * self.level, self.number, self.types)
|
||||||
return "%s[%4x]%04X: %s" % ("" * self.level, self.number, self.types, self.format)
|
|
||||||
|
|
||||||
def get_first(self, types):
|
def get_first(self, types):
|
||||||
for child in self.children:
|
for child in self.children:
|
||||||
@ -671,9 +657,7 @@ class SceneChunk(ContainerChunk):
|
|||||||
self.matrix = None
|
self.matrix = None
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if (self.unknown):
|
|
||||||
return "%s[%4x]%s" % ("" * self.level, self.number, get_cls_name(self))
|
return "%s[%4x]%s" % ("" * self.level, self.number, get_cls_name(self))
|
||||||
return "%s[%4x]%s: %s" % ("" * self.level, self.number, get_cls_name(self), self.format)
|
|
||||||
|
|
||||||
def set_data(self, data):
|
def set_data(self, data):
|
||||||
previous = None
|
previous = None
|
||||||
|
Loading…
Reference in New Issue
Block a user