mirror of
https://github.com/lcdr/utils.git
synced 2024-08-30 17:32:16 +00:00
Added option to retry replica parsing with added ScriptComponent
to account for objects with custom scripts not mentioned in the registry
This commit is contained in:
parent
dd914f7f5e
commit
8498b35ca5
@ -5,3 +5,4 @@ creations=True
|
|||||||
serializations=True
|
serializations=True
|
||||||
game_messages=True
|
game_messages=True
|
||||||
normal_packets=True
|
normal_packets=True
|
||||||
|
retry_with_script_component=True
|
||||||
|
@ -160,6 +160,7 @@ class CaptureViewer(viewer.Viewer):
|
|||||||
else:
|
else:
|
||||||
self.parse_game_messages = BooleanVar(value=False)
|
self.parse_game_messages = BooleanVar(value=False)
|
||||||
self.parse_normal_packets = BooleanVar(value=config["parse"]["normal_packets"])
|
self.parse_normal_packets = BooleanVar(value=config["parse"]["normal_packets"])
|
||||||
|
self.retry_with_script_component = BooleanVar(value=config["parse"]["retry_with_script_component"])
|
||||||
self.create_widgets()
|
self.create_widgets()
|
||||||
|
|
||||||
def create_widgets(self):
|
def create_widgets(self):
|
||||||
@ -172,6 +173,7 @@ class CaptureViewer(viewer.Viewer):
|
|||||||
if self.enable_game_messages:
|
if self.enable_game_messages:
|
||||||
parse_menu.add_checkbutton(label="Parse Game Messages", variable=self.parse_game_messages)
|
parse_menu.add_checkbutton(label="Parse Game Messages", variable=self.parse_game_messages)
|
||||||
parse_menu.add_checkbutton(label="Parse Normal Packets", variable=self.parse_normal_packets)
|
parse_menu.add_checkbutton(label="Parse Normal Packets", variable=self.parse_normal_packets)
|
||||||
|
parse_menu.add_checkbutton(label="Retry parsing with script component if failed", variable=self.retry_with_script_component)
|
||||||
menubar.add_cascade(label="Parse", menu=parse_menu)
|
menubar.add_cascade(label="Parse", menu=parse_menu)
|
||||||
self.master.config(menu=menubar)
|
self.master.config(menu=menubar)
|
||||||
|
|
||||||
@ -227,7 +229,7 @@ class CaptureViewer(viewer.Viewer):
|
|||||||
packet = BitStream(capture.read(packet_name))
|
packet = BitStream(capture.read(packet_name))
|
||||||
self.parse_normal_packet(packet_name, packet)
|
self.parse_normal_packet(packet_name, packet)
|
||||||
|
|
||||||
def parse_creation(self, packet_name, packet):
|
def parse_creation(self, packet_name, packet, is_retry=False):
|
||||||
packet.skip_read(1)
|
packet.skip_read(1)
|
||||||
has_network_id = packet.read(c_bit)
|
has_network_id = packet.read(c_bit)
|
||||||
assert has_network_id
|
assert has_network_id
|
||||||
@ -244,6 +246,8 @@ class CaptureViewer(viewer.Viewer):
|
|||||||
print("Name for lot", lot, "not found")
|
print("Name for lot", lot, "not found")
|
||||||
lot_name = str(lot)
|
lot_name = str(lot)
|
||||||
component_types = [i[0] for i in self.db.execute("select component_type from ComponentsRegistry where id == "+str(lot)).fetchall()]
|
component_types = [i[0] for i in self.db.execute("select component_type from ComponentsRegistry where id == "+str(lot)).fetchall()]
|
||||||
|
if is_retry:
|
||||||
|
component_types.append(5) # script component
|
||||||
parsers = OrderedDict()
|
parsers = OrderedDict()
|
||||||
try:
|
try:
|
||||||
component_types.sort(key=comp_ids.index)
|
component_types.sort(key=comp_ids.index)
|
||||||
@ -268,7 +272,18 @@ class CaptureViewer(viewer.Viewer):
|
|||||||
parser_output.text = error+"\n"+parser_output.text
|
parser_output.text = error+"\n"+parser_output.text
|
||||||
parser_output.tags.append("error")
|
parser_output.tags.append("error")
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
self.parse_serialization(packet, parser_output, parsers, is_creation=True)
|
self.parse_serialization(packet, parser_output, parsers, is_creation=True)
|
||||||
|
except (AssertionError, IndexError):
|
||||||
|
if self.retry_with_script_component and not is_retry:
|
||||||
|
print("retrying", packet_name)
|
||||||
|
del self.lot_data[lot]
|
||||||
|
packet._read_offset = 0
|
||||||
|
self.parse_creation(packet_name, packet, is_retry=True)
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
print("retry was not able to resolve parsing error")
|
||||||
|
raise
|
||||||
|
|
||||||
obj = CaptureObject(network_id=network_id, object_id=object_id, lot=lot)
|
obj = CaptureObject(network_id=network_id, object_id=object_id, lot=lot)
|
||||||
self.objects.append(obj)
|
self.objects.append(obj)
|
||||||
|
Loading…
Reference in New Issue
Block a user