mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-17 17:42:20 +03:00
Merge pull request #1086 from EDCD/enhancement/1083/edsm-backpack
Fix BackPack event support to actually work.
This commit is contained in:
commit
bd56948f7d
@ -599,6 +599,7 @@ Content of `state` (updated to the current journal entry):
|
||||
| `Consumable` | `dict` | 'Consumable' MicroResources in Odyssey, `int` count each. |
|
||||
| `Data` | `dict` | 'Data' MicroResources in Odyssey, `int` count each. |
|
||||
| `BackPack` | `dict` | `dict` of Odyssey MicroResources in backpack. |
|
||||
| `BackpackJSON` | `dict` | Content of Backpack.json as of last read. |
|
||||
| `SuitCurrent` | `dict` | CAPI-returned data of currently worn suit. NB: May be `None` if no data. |
|
||||
| `Suits` | `dict`[1] | CAPI-returned data of owned suits. NB: May be `None` if no data. |
|
||||
| `SuitLoadoutCurrent` | `dict` | CAPI-returned data of current Suit Loadout. NB: May be `None` if no data. |
|
||||
|
@ -151,6 +151,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
||||
'Item': defaultdict(int), # BackPack Items
|
||||
'Data': defaultdict(int), # Backpack Data
|
||||
},
|
||||
'BackpackJSON': None, # Raw JSON from `Backpack.json` file, if available
|
||||
'SuitCurrent': None,
|
||||
'Suits': {},
|
||||
'SuitLoadoutCurrent': None,
|
||||
@ -866,17 +867,21 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
||||
{self.canonicalise(x['Name']): x['Count'] for x in clean_data}
|
||||
)
|
||||
|
||||
elif event_type == 'Backpack':
|
||||
elif event_type == 'BackPack':
|
||||
# TODO: v31 doc says this is`backpack.json` ... but Howard Chalkley
|
||||
# said it's `Backpack.json`
|
||||
with open(join(self.currentdir, 'Backpack.json'), 'rb') as backpack: # type: ignore
|
||||
try:
|
||||
entry = json.load(backpack)
|
||||
# Preserve property order because why not?
|
||||
entry = json.load(backpack, object_pairs_hook=OrderedDict)
|
||||
|
||||
except json.JSONDecodeError:
|
||||
logger.exception('Failed decoding Backpack.json', exc_info=True)
|
||||
|
||||
else:
|
||||
# Store in monitor.state
|
||||
self.state['BackpackJSON'] = entry
|
||||
|
||||
# Assume this reflects the current state when written
|
||||
self.state['BackPack']['Component'] = defaultdict(int)
|
||||
self.state['BackPack']['Consumable'] = defaultdict(int)
|
||||
|
@ -432,6 +432,11 @@ def journal_entry(
|
||||
elif entry['event'] == 'NavBeaconScan':
|
||||
this.navbeaconscan = entry['NumBodies']
|
||||
|
||||
elif entry['event'] == 'BackPack':
|
||||
# Use the stored file contents, not the empty journal event
|
||||
if state['BackpackJSON']:
|
||||
entry = state['BackpackJSON']
|
||||
|
||||
# Send interesting events to EDSM
|
||||
if (
|
||||
config.get_int('edsm_out') and not is_beta and not this.multicrew and credentials(cmdr) and
|
||||
|
Loading…
x
Reference in New Issue
Block a user