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:
lcdr 2016-08-30 10:32:09 +02:00
parent dd914f7f5e
commit 8498b35ca5
2 changed files with 18 additions and 2 deletions

View File

@ -5,3 +5,4 @@ creations=True
serializations=True
game_messages=True
normal_packets=True
retry_with_script_component=True

View File

@ -160,6 +160,7 @@ class CaptureViewer(viewer.Viewer):
else:
self.parse_game_messages = BooleanVar(value=False)
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()
def create_widgets(self):
@ -172,6 +173,7 @@ class CaptureViewer(viewer.Viewer):
if self.enable_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="Retry parsing with script component if failed", variable=self.retry_with_script_component)
menubar.add_cascade(label="Parse", menu=parse_menu)
self.master.config(menu=menubar)
@ -227,7 +229,7 @@ class CaptureViewer(viewer.Viewer):
packet = BitStream(capture.read(packet_name))
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)
has_network_id = packet.read(c_bit)
assert has_network_id
@ -244,6 +246,8 @@ class CaptureViewer(viewer.Viewer):
print("Name for lot", lot, "not found")
lot_name = str(lot)
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()
try:
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.tags.append("error")
else:
self.parse_serialization(packet, parser_output, parsers, is_creation=True)
try:
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)
self.objects.append(obj)