1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-06-02 16:41:04 +03:00

Merge pull request #1636 from EDCD/fix/1634/naverouteclear

Handle NavRouteClear
This commit is contained in:
Athanasius 2022-08-10 12:09:06 +01:00 committed by GitHub
commit 1296159532
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 6 deletions

View File

@ -698,6 +698,18 @@ New in version 5.1.1:
`state` now has a `ShipLockerJSON` member containing the un-changed, loaded, `state` now has a `ShipLockerJSON` member containing the un-changed, loaded,
JSON from the `ShipLockerJSON.json` file. JSON from the `ShipLockerJSON.json` file.
New in version 5.4.2+:
We now handle the 'Update 13' `NavRouteClear` event by detecting if that's what
is in the `NavRoute.json` file. If this is the case then we log that, **but
do NOT clear `state['NavRoute']`**. Plugins will get sent the Journal
`NavRouteClear` event anyway, and there might be some value to them retaining
access to the prior plotted route.
NB: It *is* possible, if a player is quick enough, to plot and clear a route
before we load it, in which case we'd be retaining the *previous* plotted
route.
___ ___
##### Synthetic Events ##### Synthetic Events

View File

@ -1469,7 +1469,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
self.state[category].pop(material) self.state[category].pop(material)
module = self.state['Modules'][entry['Slot']] module = self.state['Modules'][entry['Slot']]
assert(module['Item'] == self.canonicalise(entry['Module'])) assert module['Item'] == self.canonicalise(entry['Module'])
module['Engineering'] = { module['Engineering'] = {
'Engineer': entry['Engineer'], 'Engineer': entry['Engineer'],
'EngineerID': entry['EngineerID'], 'EngineerID': entry['EngineerID'],
@ -2300,9 +2300,15 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
) )
return False return False
# Handle it being `NavRouteClear`d already
if file['event'].lower() == 'navrouteclear':
logger.info('NavRoute file contained a NavRouteClear')
# We do *NOT* copy into/clear the `self.state['NavRoute']`
else:
# everything is good, lets set what we need to and make sure we dont try again # everything is good, lets set what we need to and make sure we dont try again
logger.info('Successfully read NavRoute file for last NavRoute event.') logger.info('Successfully read NavRoute file for last NavRoute event.')
self.state['NavRoute'] = file self.state['NavRoute'] = file
self._navroute_retries_remaining = 0 self._navroute_retries_remaining = 0
self._last_navroute_journal_timestamp = None self._last_navroute_journal_timestamp = None
return True return True

View File

@ -1111,8 +1111,10 @@ class EDDN:
# Sanity check - Ref Issue 1342 # Sanity check - Ref Issue 1342
if 'Route' not in entry: if 'Route' not in entry:
logger.warning(f"NavRoute didn't contain a Route array!\n{entry!r}") logger.warning(f"NavRoute didn't contain a Route array!\n{entry!r}")
# LANG: No 'Route' found in NavRoute.json file # This can happen if first-load of the file failed, and we're simply
return _("No 'Route' array in NavRoute.json contents") # passing through the bare Journal event, so no need to alert
# the user.
return None
####################################################################### #######################################################################
# Elisions # Elisions