mirror of
https://github.com/lcdr/utils.git
synced 2024-08-30 17:32:16 +00:00
Definition updates and changes to use bitstream's changed string handling
This commit is contained in:
parent
ee2da75c7c
commit
3bf199ca62
@ -24,7 +24,7 @@ def compressed_ldf_handler(stream):
|
|||||||
is_compressed = stream.read(c_bool)
|
is_compressed = stream.read(c_bool)
|
||||||
if is_compressed:
|
if is_compressed:
|
||||||
uncompressed_size = stream.read(c_uint)
|
uncompressed_size = stream.read(c_uint)
|
||||||
uncompressed = zlib.decompress(stream.read(bytes, length=stream.read(c_uint)))
|
uncompressed = zlib.decompress(stream.read(bytes, length_type=c_uint))
|
||||||
assert len(uncompressed) == uncompressed_size
|
assert len(uncompressed) == uncompressed_size
|
||||||
else:
|
else:
|
||||||
uncompressed = stream.read(bytes, length=size)
|
uncompressed = stream.read(bytes, length=size)
|
||||||
@ -33,9 +33,9 @@ def compressed_ldf_handler(stream):
|
|||||||
type_handlers = {}
|
type_handlers = {}
|
||||||
type_handlers["compressed_ldf"] = compressed_ldf_handler
|
type_handlers["compressed_ldf"] = compressed_ldf_handler
|
||||||
|
|
||||||
with open("packetdefinitions/replica/creation_header.structs", encoding="utf-8") as file:
|
with open(__file__+"/../packetdefinitions/replica/creation_header.structs", encoding="utf-8") as file:
|
||||||
creation_header_parser = structparser.StructParser(file.read(), type_handlers)
|
creation_header_parser = structparser.StructParser(file.read(), type_handlers)
|
||||||
with open("packetdefinitions/replica/serialization_header.structs", encoding="utf-8") as file:
|
with open(__file__+"/../packetdefinitions/replica/serialization_header.structs", encoding="utf-8") as file:
|
||||||
serialization_header_parser = structparser.StructParser(file.read(), type_handlers)
|
serialization_header_parser = structparser.StructParser(file.read(), type_handlers)
|
||||||
|
|
||||||
component_name = OrderedDict()
|
component_name = OrderedDict()
|
||||||
@ -63,6 +63,7 @@ component_name[6] = "Bouncer",
|
|||||||
component_name[39] = "ScriptedActivity",
|
component_name[39] = "ScriptedActivity",
|
||||||
component_name[71] = "RacingControl",
|
component_name[71] = "RacingControl",
|
||||||
component_name[75] = "Exhibit",
|
component_name[75] = "Exhibit",
|
||||||
|
component_name[42] = "Model",
|
||||||
component_name[2] = "Render",
|
component_name[2] = "Render",
|
||||||
component_name[107] = "Component 107",
|
component_name[107] = "Component 107",
|
||||||
component_name[69] = "Trigger",
|
component_name[69] = "Trigger",
|
||||||
@ -79,6 +80,8 @@ component_name[64] = None
|
|||||||
component_name[65] = None
|
component_name[65] = None
|
||||||
component_name[68] = None
|
component_name[68] = None
|
||||||
component_name[73] = None
|
component_name[73] = None
|
||||||
|
component_name[74] = None
|
||||||
|
component_name[95] = None
|
||||||
component_name[104] = None
|
component_name[104] = None
|
||||||
component_name[113] = None
|
component_name[113] = None
|
||||||
component_name[114] = None
|
component_name[114] = None
|
||||||
@ -89,11 +92,11 @@ for comp_id, indices in component_name.items():
|
|||||||
if indices is not None:
|
if indices is not None:
|
||||||
comp_parser[comp_id] = []
|
comp_parser[comp_id] = []
|
||||||
for index in indices:
|
for index in indices:
|
||||||
with open("packetdefinitions/replica/components/"+index+".structs") as file:
|
with open(__file__+"/../packetdefinitions/replica/components/"+index+".structs") as file:
|
||||||
comp_parser[comp_id].append(structparser.StructParser(file.read(), type_handlers))
|
comp_parser[comp_id].append(structparser.StructParser(file.read(), type_handlers))
|
||||||
|
|
||||||
norm_parser = {}
|
norm_parser = {}
|
||||||
for rootdir, _, files in os.walk("packetdefinitions"):
|
for rootdir, _, files in os.walk(__file__+"/../packetdefinitions"):
|
||||||
for filename in files:
|
for filename in files:
|
||||||
with open(rootdir+"/"+filename) as file:
|
with open(rootdir+"/"+filename) as file:
|
||||||
norm_parser[filename[:filename.rindex(".")]] = structparser.StructParser(file.read(), type_handlers)
|
norm_parser[filename[:filename.rindex(".")]] = structparser.StructParser(file.read(), type_handlers)
|
||||||
@ -495,6 +498,62 @@ class CaptureViewer(viewer.Viewer):
|
|||||||
|
|
||||||
properties.append(property)
|
properties.append(property)
|
||||||
|
|
||||||
|
elif msg_name == "ClientTradeUpdate":
|
||||||
|
attr_values["currency"] = packet.read(c_uint64)
|
||||||
|
|
||||||
|
items = []
|
||||||
|
for _ in range(packet.read(c_uint)):
|
||||||
|
item = {}
|
||||||
|
item["object_id"] = packet.read(c_int64)
|
||||||
|
item_obj_id_again = packet.read(c_int64)
|
||||||
|
assert item["object_id"] == item_obj_id_again
|
||||||
|
item["lot"] = packet.read(c_int)
|
||||||
|
if packet.read(c_bit):
|
||||||
|
item["unknown1"] = packet.read(c_int64)
|
||||||
|
if packet.read(c_bit):
|
||||||
|
item["unknown2"] = packet.read(c_uint)
|
||||||
|
if packet.read(c_bit):
|
||||||
|
item["slot"] = packet.read(c_ushort)
|
||||||
|
if packet.read(c_bit):
|
||||||
|
item["unknown3"] = packet.read(c_uint)
|
||||||
|
if packet.read(c_bit):
|
||||||
|
item["extra_info"] = compressed_ldf_handler(packet)
|
||||||
|
item["unknown4"] = packet.read(c_bit)
|
||||||
|
items.append(item)
|
||||||
|
attr_values["items"] = items
|
||||||
|
|
||||||
|
elif msg_name == "ServerTradeUpdate":
|
||||||
|
attr_values["aboutToPerform"] = packet.read(c_bit)
|
||||||
|
attr_values["currency"] = packet.read(c_uint64)
|
||||||
|
|
||||||
|
items = []
|
||||||
|
for _ in range(packet.read(c_uint)):
|
||||||
|
item = {}
|
||||||
|
item["object_id"] = packet.read(c_int64)
|
||||||
|
item_obj_id_again = packet.read(c_int64)
|
||||||
|
assert item["object_id"] == item_obj_id_again
|
||||||
|
item["lot"] = packet.read(c_int)
|
||||||
|
if packet.read(c_bit):
|
||||||
|
item["unknown1"] = packet.read(c_int64)
|
||||||
|
if packet.read(c_bit):
|
||||||
|
item["amount"] = packet.read(c_uint)
|
||||||
|
if packet.read(c_bit):
|
||||||
|
item["slot"] = packet.read(c_ushort)
|
||||||
|
if packet.read(c_bit):
|
||||||
|
item["unknown2"] = packet.read(c_uint)
|
||||||
|
if packet.read(c_bit):
|
||||||
|
item["extra_info"] = compressed_ldf_handler(packet)
|
||||||
|
item["unknown3"] = packet.read(c_bit)
|
||||||
|
items.append(item)
|
||||||
|
attr_values["items"] = items
|
||||||
|
|
||||||
|
elif msg_name == "PropertyBuildModeUpdate":
|
||||||
|
attr_values["start"] = packet.read(c_bit)
|
||||||
|
attr_values["friends"] = {}
|
||||||
|
for _ in range(packet.read(c_uint)):
|
||||||
|
attr_values["friends"][packet.read(c_int64)] = packet.read(c_bit)
|
||||||
|
attr_values["numSent"] = packet.read(c_int)
|
||||||
|
|
||||||
elif msg_name == "ModularBuildFinish":
|
elif msg_name == "ModularBuildFinish":
|
||||||
lots = []
|
lots = []
|
||||||
for _ in range(packet.read(c_ubyte)):
|
for _ in range(packet.read(c_ubyte)):
|
||||||
@ -569,14 +628,11 @@ class CaptureViewer(viewer.Viewer):
|
|||||||
elif type_ == "float":
|
elif type_ == "float":
|
||||||
value = packet.read(c_float)
|
value = packet.read(c_float)
|
||||||
elif type_ == "BinaryBuffer":
|
elif type_ == "BinaryBuffer":
|
||||||
length = packet.read(c_uint)
|
value = packet.read(bytes, length_type=c_uint)
|
||||||
value = packet.read(bytes, length=length)
|
|
||||||
elif type_ == "std::string":
|
elif type_ == "std::string":
|
||||||
length = packet.read(c_uint)
|
value = packet.read(bytes, length_type=c_uint)
|
||||||
value = packet.read(str, char_size=1, allocated_length=length)
|
|
||||||
elif type_ == "std::wstring":
|
elif type_ == "std::wstring":
|
||||||
length = packet.read(c_uint)
|
value = packet.read(str, length_type=c_uint)
|
||||||
value = packet.read(str, char_size=2, allocated_length=length*2)
|
|
||||||
elif type_ == "NiPoint3":
|
elif type_ == "NiPoint3":
|
||||||
value = packet.read(c_float), packet.read(c_float), packet.read(c_float)
|
value = packet.read(c_float), packet.read(c_float), packet.read(c_float)
|
||||||
elif type_ == "NiQuaternion":
|
elif type_ == "NiQuaternion":
|
||||||
|
@ -75,9 +75,9 @@ class LUZViewer(viewer.Viewer):
|
|||||||
number_of_scenes = stream.read(c_ubyte)
|
number_of_scenes = stream.read(c_ubyte)
|
||||||
|
|
||||||
for _ in range(number_of_scenes):
|
for _ in range(number_of_scenes):
|
||||||
filename = stream.read(str, char_size=1, length_type=c_ubyte)
|
filename = stream.read(bytes, length_type=c_ubyte).decode("latin1")
|
||||||
scene_id = stream.read(c_uint64)
|
scene_id = stream.read(c_uint64)
|
||||||
scene_name = stream.read(str, char_size=1, length_type=c_ubyte)
|
scene_name = stream.read(bytes, length_type=c_ubyte).decode("latin1")
|
||||||
scene = self.tree.insert(scenes, END, text="Scene", values=(filename, scene_id, scene_name))
|
scene = self.tree.insert(scenes, END, text="Scene", values=(filename, scene_id, scene_name))
|
||||||
assert stream.read(bytes, length=3)
|
assert stream.read(bytes, length=3)
|
||||||
lvl_path = os.path.join(os.path.dirname(luz_path), filename)
|
lvl_path = os.path.join(os.path.dirname(luz_path), filename)
|
||||||
@ -92,9 +92,9 @@ class LUZViewer(viewer.Viewer):
|
|||||||
assert stream.read(c_ubyte) == 0
|
assert stream.read(c_ubyte) == 0
|
||||||
|
|
||||||
### terrain
|
### terrain
|
||||||
filename = stream.read(str, char_size=1, length_type=c_ubyte)
|
filename = stream.read(bytes, length_type=c_ubyte).decode("latin1")
|
||||||
name = stream.read(str, char_size=1, length_type=c_ubyte)
|
name = stream.read(bytes, length_type=c_ubyte).decode("latin1")
|
||||||
description = stream.read(str, char_size=1, length_type=c_ubyte)
|
description = stream.read(bytes, length_type=c_ubyte).decode("latin1")
|
||||||
self.tree.insert(zone, END, text="Terrain", values=(filename, name, description))
|
self.tree.insert(zone, END, text="Terrain", values=(filename, name, description))
|
||||||
|
|
||||||
### scene transitions
|
### scene transitions
|
||||||
@ -102,7 +102,7 @@ class LUZViewer(viewer.Viewer):
|
|||||||
for _ in range(stream.read(c_uint)):
|
for _ in range(stream.read(c_uint)):
|
||||||
scene_transition_values = ()
|
scene_transition_values = ()
|
||||||
if version < 40:
|
if version < 40:
|
||||||
scene_transition_values += stream.read(str, char_size=1, length_type=c_ubyte),
|
scene_transition_values += stream.read(bytes, length_type=c_ubyte),
|
||||||
scene_transition_values += stream.read(c_float),
|
scene_transition_values += stream.read(c_float),
|
||||||
scene_transition = self.tree.insert(scene_transitions, END, text="Scene Transition", values=scene_transition_values)
|
scene_transition = self.tree.insert(scene_transitions, END, text="Scene Transition", values=scene_transition_values)
|
||||||
if version < 39:
|
if version < 39:
|
||||||
@ -241,9 +241,9 @@ class LUZViewer(viewer.Viewer):
|
|||||||
else:
|
else:
|
||||||
# older lvl file structure
|
# older lvl file structure
|
||||||
stream.skip_read(265)
|
stream.skip_read(265)
|
||||||
stream.read(str, char_size=1, length_type=c_uint)
|
stream.read(bytes, length_type=c_uint)
|
||||||
for _ in range(5):
|
for _ in range(5):
|
||||||
stream.read(str, char_size=1, length_type=c_uint)
|
stream.read(bytes, length_type=c_uint)
|
||||||
stream.skip_read(4)
|
stream.skip_read(4)
|
||||||
for _ in range(stream.read(c_uint)):
|
for _ in range(stream.read(c_uint)):
|
||||||
stream.read(c_float), stream.read(c_float), stream.read(c_float)
|
stream.read(c_float), stream.read(c_float), stream.read(c_float)
|
||||||
|
@ -1258,7 +1258,6 @@
|
|||||||
<message id="1301" name="HandleUGCEquipPreCreateBasedOnEditMode" network="client">
|
<message id="1301" name="HandleUGCEquipPreCreateBasedOnEditMode" network="client">
|
||||||
<attr name="modelID" type="LWOOBJID"/>
|
<attr name="modelID" type="LWOOBJID"/>
|
||||||
<attr name="modelCount" type="int"/>
|
<attr name="modelCount" type="int"/>
|
||||||
<attr name="bOnCursor" type="bool"/>
|
|
||||||
</message>
|
</message>
|
||||||
<message id="1305" name="PropertyContentsFromClient" network="server">
|
<message id="1305" name="PropertyContentsFromClient" network="server">
|
||||||
<attr default="false" name="queryDB" type="bool"/>
|
<attr default="false" name="queryDB" type="bool"/>
|
||||||
|
@ -4,5 +4,5 @@ Index 1 ($+7DC1F0)
|
|||||||
[bit] - flag
|
[bit] - flag
|
||||||
[s64] - driver object id
|
[s64] - driver object id
|
||||||
[bit] - flag
|
[bit] - flag
|
||||||
[u32] - ???
|
[u32] - possessable component id?
|
||||||
[bit] - ???
|
[bit] - ???
|
||||||
|
17
packetdefinitions/replica/components/Model.structs
Normal file
17
packetdefinitions/replica/components/Model.structs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
Component 42 - Model
|
||||||
|
Index 1:
|
||||||
|
[bit] - flag
|
||||||
|
[bit] - ???
|
||||||
|
[s32] - model type
|
||||||
|
[float] - position x
|
||||||
|
[float] - position y
|
||||||
|
[float] - position z
|
||||||
|
[float] - rotation w
|
||||||
|
[float] - rotation x
|
||||||
|
[float] - rotation y
|
||||||
|
[float] - rotation z
|
||||||
|
[bit] - flag
|
||||||
|
[u32] - ???
|
||||||
|
[bit] - ???
|
||||||
|
[bit] - flag
|
||||||
|
[u64] - ???
|
@ -5,7 +5,7 @@ if creation:
|
|||||||
[u32] - is boss?, expect == 0
|
[u32] - is boss?, expect == 0
|
||||||
[u32] - ???
|
[u32] - ???
|
||||||
[u32] - ???
|
[u32] - ???
|
||||||
[u32] - ???, assert == 0
|
[u32] - ???, expect == 0
|
||||||
[u32] - ???, assert == 0
|
[u32] - ???, assert == 0
|
||||||
[u32] - ???, assert == 0
|
[u32] - ???, assert == 0
|
||||||
[u32] - ???
|
[u32] - ???
|
||||||
|
@ -82,7 +82,7 @@ class PKViewer(viewer.Viewer):
|
|||||||
assert stream.read(c_uint) == 3
|
assert stream.read(c_uint) == 3
|
||||||
pack_files = []
|
pack_files = []
|
||||||
for _ in range(stream.read(c_uint)):
|
for _ in range(stream.read(c_uint)):
|
||||||
pack_files.append(stream.read(str, char_size=1, length_type=c_uint))
|
pack_files.append(stream.read(bytes, length_type=c_uint).decode("latin1"))
|
||||||
|
|
||||||
for _ in range(stream.read(c_uint)):
|
for _ in range(stream.read(c_uint)):
|
||||||
stream.skip_read(20)
|
stream.skip_read(20)
|
||||||
|
@ -61,11 +61,11 @@ class StructParser:
|
|||||||
self._type_handlers["s64"] = lambda stream: stream.read(c_int64)
|
self._type_handlers["s64"] = lambda stream: stream.read(c_int64)
|
||||||
self._type_handlers["u64"] = lambda stream: stream.read(c_uint64)
|
self._type_handlers["u64"] = lambda stream: stream.read(c_uint64)
|
||||||
# string types
|
# string types
|
||||||
self._type_handlers["u8-string"] = lambda stream: stream.read(str, char_size=1, length_type=c_uint8)
|
self._type_handlers["u8-string"] = lambda stream: stream.read(bytes, length_type=c_uint8)
|
||||||
self._type_handlers["u16-string"] = lambda stream: stream.read(str, char_size=1, length_type=c_uint16)
|
self._type_handlers["u16-string"] = lambda stream: stream.read(bytes, length_type=c_uint16)
|
||||||
|
|
||||||
self._type_handlers["u8-wstring"] = lambda stream: stream.read(str, char_size=2, length_type=c_uint8)
|
self._type_handlers["u8-wstring"] = lambda stream: stream.read(str, length_type=c_uint8)
|
||||||
self._type_handlers["u16-wstring"] = lambda stream: stream.read(str, char_size=2, length_type=c_uint16)
|
self._type_handlers["u16-wstring"] = lambda stream: stream.read(str, length_type=c_uint16)
|
||||||
self._type_handlers.update(type_handlers)
|
self._type_handlers.update(type_handlers)
|
||||||
|
|
||||||
def parse(self, data, variables=None):
|
def parse(self, data, variables=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user