From 3f0f1fe39f1ea611e43c56f0888a4099d250e317 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Wed, 20 Oct 2021 14:50:03 +0100 Subject: [PATCH] CAPI: Avoid '... EDO Settlement?' for 'Update' in space 1. Logged out in space 2. Logged back in 3. Run EDMC 4. Hit Update button, get "Docked but unknown station: EDO Settlement?" In investigating this I realised that the entire else needed to be "if docked according to CAPI". Then it became clear that there was a redundant conditional, as the enclosing one is already testing: `capi_response.capi_data['lastStarport']['name'] != monitor.station:` Making the: `if last_station != monitor.station` conditional un-necessary. --- EDMarketConnector.py | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index 4c480f47..c0614bdc 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -1072,24 +1072,13 @@ class AppWindow(object): f"{monitor.state['OnFoot']!r} and {monitor.station!r}") raise companion.ServerLagging() - else: - last_station = None - if capi_response.capi_data['commander']['docked']: - last_station = capi_response.capi_data['lastStarport']['name'] - - if monitor.station is None: - # Likely (re-)Embarked on ship docked at an EDO settlement. - # Both Disembark and Embark have `"Onstation": false` in Journal. - # So there's nothing to tell us which settlement we're (still, - # or now, if we came here in Apex and then recalled ship) docked at. - logger.debug("monitor.station is None - so EDO settlement?") - raise companion.NoMonitorStation() - - if last_station != monitor.station: - # CAPI lastStarport must match - logger.warning(f"({capi_response.capi_data['lastStarport']['name']!r} != {monitor.station!r})" - f" AND {last_station!r} != {monitor.station!r}") - raise companion.ServerLagging() + elif capi_response.capi_data['commander']['docked'] and monitor.station is None: + # Likely (re-)Embarked on ship docked at an EDO settlement. + # Both Disembark and Embark have `"Onstation": false` in Journal. + # So there's nothing to tell us which settlement we're (still, + # or now, if we came here in Apex and then recalled ship) docked at. + logger.debug("docked AND monitor.station is None - so EDO settlement?") + raise companion.NoMonitorStation() self.capi_query_holdoff_time = capi_response.query_time + companion.capi_query_cooldown