From a2d2723f491d94f7b7a4fc419a40759e3e138a6d Mon Sep 17 00:00:00 2001 From: Athanasius Date: Tue, 22 Nov 2022 15:29:05 +0000 Subject: [PATCH] monitor: Add an 'IsDocked' flag to monitor.state. * This is cleaner than starting to track it in `plugins/eddn.py` specifically. * This is literally only about if we're piloting a ship that is docked, so not even trying to resolve "on-foot, in a station, 'Location' said not docked though". --- monitor.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/monitor.py b/monitor.py index 859b2a50..040afa82 100644 --- a/monitor.py +++ b/monitor.py @@ -166,6 +166,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below 'Modules': None, 'CargoJSON': None, # The raw data from the last time cargo.json was read 'Route': None, # Last plotted route from Route.json file + 'IsDocked': False, # Whether we think cmdr is docked 'OnFoot': False, # Whether we think you're on-foot 'Component': defaultdict(int), # Odyssey Components in Ship Locker 'Item': defaultdict(int), # Odyssey Items in Ship Locker @@ -306,6 +307,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.systemaddress = None self.is_beta = False self.state['OnFoot'] = False + self.state['IsDocked'] = False self.state['Body'] = None self.state['BodyType'] = None @@ -725,6 +727,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.station_marketid = None self.stationtype = None self.stationservices = None + self.state['IsDocked'] = False elif event_type == 'embark': # This event is logged when a player (on foot) gets into a ship or SRV @@ -791,6 +794,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.state['Dropship'] = False elif event_type == 'docked': + self.state['IsDocked'] = True self.station = entry.get('StationName') # May be None self.station_marketid = entry.get('MarketID') # May be None self.stationtype = entry.get('StationType') # May be None @@ -813,6 +817,8 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below if event_type == 'location': logger.trace_if('journal.locations', '"Location" event') + if entry.get('Docked'): + self.state['IsDocked'] = True elif event_type == 'fsdjump': self.planet = None