1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-17 17:42:20 +03:00

Correct event and file name to NavRoute(.json) & expand docs

* Despite what section 4.18 of v28 Journal docs say, the event is
  `NavRoute`, not `Route`, and the file is `NavRoute.json`.  The array
  of hops is still keyed as `Route` though.

* Calls out that both `NavRoute` and `Cargo` events, as passed to
  plugins, are augmented with the data from their respective files, and
  are not simply the 'bare' event as seen in the Journal.
This commit is contained in:
Athanasius 2021-03-10 11:42:06 +00:00
parent ef891fa8bd
commit b3a1b0492e
2 changed files with 23 additions and 5 deletions

View File

@ -426,7 +426,9 @@ Content of `state` (updated to the current journal entry):
| `ModulesValue` | `int` | Value of the current ship's modules |
| `Rebuy` | `int` | Current ship's rebuy cost |
| `Modules` | `dict` | Currently fitted modules |
| `Route` | `dict` | Last plotted multi-hop route |
| `NavRoute` | `dict` | Last plotted multi-hop route |
##### Synthetic Events
A special "StartUp" entry is sent if EDMC is started while the game is already
running. In this case you won't receive initial events such as "LoadGame",
@ -445,6 +447,22 @@ between the two scenarios.
This event is not sent when EDMC is running on a different
machine so you should not *rely* on receiving this event.
##### Augmented Events
In some cases we augment the events, as seen in the Journal, with extra data.
Examples of this are:
1. Every `Cargo` event passed to plugins contains the data from
`Cargo.json` (but see above for caveats).
1. Every `NavRoute` event contains the full `Route` array as loaded from
`NavRoute.json`. You do not need to access this via
`monitor.state['NavRoute']`, although it is available there.
*NB: There is no indication available when a player cancels a route.* The
game itself does not provide any such, not in a Journal event, not in a
`Status.json` flag.
#### Player Dashboard
```python
@ -478,8 +496,8 @@ contains all the data), this will not be populated at login.**
New in version 5.0.0:
`Route` contains the `json.load()` of `Route.json` as indicated by a journal
`Route` event.
`NavRoute` contains the `json.load()` of `NavRoute.json` as indicated by a journal
`NavRoute` event.
#### Getting Commander Data

View File

@ -668,9 +668,9 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
self.state['Cargo'].update({self.canonicalise(x['Name']): x['Count'] for x in clean})
elif event_type == 'Route':
elif event_type == 'NavRoute':
# Added in ED 3.7 - multi-hop route details in Route.json
with open(join(self.currentdir, 'Route.json'), 'rb') as rf: # type: ignore
with open(join(self.currentdir, 'NavRoute.json'), 'rb') as rf: # type: ignore
entry = json.load(rf)
self.state['Route'] = entry