From 090a55f8de1fd14286ad3ed1067bcfb92d190bab Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Sat, 12 Nov 2016 12:43:59 +0000 Subject: [PATCH] Add "BodyName" property to Docked event For planetary stations (if known) --- EDMarketConnector.py | 4 ++++ monitor.py | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index e1dfb064..c820daf0 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -598,6 +598,10 @@ class AppWindow: if thing.endswith('_Localised'): entry.pop(thing, None) + # add planet to Docked event for planetary stations if known + if entry['event'] == 'Docked' and monitor.body: + entry['BodyName'] = monitor.body + # add mandatory StarSystem and StarPos properties to Scan events if 'StarSystem' not in entry: entry['StarSystem'] = monitor.system diff --git a/monitor.py b/monitor.py index ea736d33..64c00d0d 100644 --- a/monitor.py +++ b/monitor.py @@ -80,6 +80,7 @@ class EDLogs(FileSystemEventHandler): self.shipid = None self.shiptype = None self.shippaint = None + self.body = None self.system = None self.station = None self.coordinates = None @@ -138,7 +139,7 @@ class EDLogs(FileSystemEventHandler): if __debug__: print 'Stopping monitoring' self.currentdir = None - self.version = self.mode = self.cmdr = self.system = self.station = self.coordinates = None + self.version = self.mode = self.cmdr = self.body = self.system = self.station = self.coordinates = None self.is_beta = False if self.observed: self.observed = None @@ -236,6 +237,7 @@ class EDLogs(FileSystemEventHandler): self.shipid = entry.get('ShipID') # None in CQC self.shiptype = 'Ship' in entry and entry['Ship'].lower() or None # None in CQC self.shippaint = None + self.body = None self.system = None self.station = None self.coordinates = None @@ -257,12 +259,18 @@ class EDLogs(FileSystemEventHandler): elif entry['event'] in ['Undocked']: self.station = None elif entry['event'] in ['Location', 'FSDJump', 'Docked']: + if entry['event'] != 'Docked': + self.body = None if 'StarPos' in entry: self.coordinates = tuple(entry['StarPos']) elif self.system != entry['StarSystem']: self.coordinates = None # Docked event doesn't include coordinates self.system = entry['StarSystem'] == 'ProvingGround' and 'CQC' or entry['StarSystem'] self.station = entry.get('StationName') # May be None + elif entry['event'] == 'SupercruiseExit': + self.body = entry.get('BodyType') == 'Planet' and entry.get('Body') + elif entry['event'] == 'SupercruiseEntry': + self.body = None elif entry['event'] in ['Rank', 'Promotion'] and self.ranks: for k,v in entry.iteritems(): if k in self.ranks: