From 567cfdb9cae10bc9ba34a6338773d47b2f2847e8 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Tue, 30 Mar 2021 16:26:06 +0100 Subject: [PATCH] Will now send data to EDDN when on-foot in-station. NB: No shipyard in tests because data['ships']['shipyard_list'] is an empty list. This might be the bug not having been fixed, or the station might genuinely have no ships for sale. We have no way to check in Odyssey Alpha Phase 1. --- companion.py | 3 ++- monitor.py | 4 ++++ plugins/eddn.py | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/companion.py b/companion.py index 51834b08..3e6c6993 100644 --- a/companion.py +++ b/companion.py @@ -28,6 +28,7 @@ import requests from config import appname, appversion, config from EDMCLogging import get_main_logger +from monitor import monitor from protocol import protocolhandler logger = get_main_logger() @@ -563,7 +564,7 @@ class Session(object): logger.error('No commander in returned data') return data - if not data['commander'].get('docked'): + if not data['commander'].get('docked') and not monitor.on_foot: return data services = data['lastStarport'].get('services', {}) diff --git a/monitor.py b/monitor.py index 13cb59ba..b50213ad 100644 --- a/monitor.py +++ b/monitor.py @@ -626,9 +626,13 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.stationservices = None elif event_type == 'Embark': + # If we've embarked then we're no longer on the station. + self.station = None self.on_foot = False elif event_type == 'Disembark': + # We don't yet have a way, other than LoadGame+Location, to detect if we *are* on a station on-foot. + self.station = None self.on_foot = True elif event_type in ('Location', 'FSDJump', 'Docked', 'CarrierJump'): diff --git a/plugins/eddn.py b/plugins/eddn.py index 0655bf80..b67fd3f0 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -22,6 +22,7 @@ import plug from companion import CAPIData, category_map from config import applongname, appversion_nobuild, config from EDMCLogging import get_main_logger +from monitor import monitor from myNotebook import Frame from prefs import prefsVersion from ttkHyperlinkLabel import HyperlinkLabel @@ -907,7 +908,8 @@ def cmdr_data(data: CAPIData, is_beta: bool) -> Optional[str]: # noqa: CCR001 :param is_beta: bool - True if this is a beta version of the Game. :return: str - Error message, or `None` if no errors. """ - if data['commander'].get('docked') and config.get_int('output') & config.OUT_MKT_EDDN: + if (data['commander'].get('docked') or (monitor.on_foot and monitor.station) + and config.get_int('output') & config.OUT_MKT_EDDN): try: if this.marketId != data['lastStarport']['id']: this.commodities = this.outfitting = this.shipyard = None