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

Send "Location" Journal events to EDDN

This commit is contained in:
Jonathan Harris 2017-08-08 17:54:52 +01:00
parent d223770af8
commit 2e7ca6bd18
3 changed files with 22 additions and 17 deletions

View File

@ -658,19 +658,21 @@ class AppWindow:
# Send interesting events to EDDN
try:
if (config.getint('output') & config.OUT_SYS_EDDN and monitor.cmdr and monitor.mode and
(entry['event'] == 'FSDJump' or
(entry['event'] == 'Location' or
entry['event'] == 'FSDJump' or
entry['event'] == 'Docked' or
entry['event'] == 'Scan' and monitor.system and monitor.coordinates)):
# strip out properties disallowed by the schema
for thing in ['CockpitBreach', 'BoostUsed', 'FuelLevel', 'FuelUsed', 'JumpDist']:
for thing in ['CockpitBreach', 'BoostUsed', 'FuelLevel', 'FuelUsed', 'JumpDist', 'Latitude', 'Longitude']:
entry.pop(thing, None)
for thing in entry.keys():
if thing.endswith('_Localised'):
entry.pop(thing, None)
# add planet to Docked event for planetary stations if known
if entry['event'] == 'Docked' and monitor.body:
entry['BodyName'] = monitor.body
if entry['event'] == 'Docked' and monitor.planet:
entry['Body'] = monitor.planet
entry['BodyType'] = 'Planet'
# add mandatory StarSystem and StarPos properties to Scan events
if 'StarSystem' not in entry:

View File

@ -218,9 +218,10 @@ class EDDN:
self.replaylog.append(json.dumps([cmdr.encode('utf-8'), msg]))
replayfile.write('%s\n' % self.replaylog[-1])
if entry['event'] == 'Docked' or not (config.getint('output') & config.OUT_SYS_DELAY):
# Try to send this and previous entries
self.sendreplay()
if (entry['event'] == 'Docked' or
(entry['event'] == 'Location' and entry['Docked']) or
not (config.getint('output') & config.OUT_SYS_DELAY)):
self.sendreplay() # Try to send this and previous entries
else:
# Can't access replay file! Send immediately.
self.parent.status['text'] = _('Sending data to EDDN...')

View File

@ -125,7 +125,7 @@ class EDLogs(FileSystemEventHandler):
self.mode = None
self.group = None
self.cmdr = None
self.body = None
self.planet = None
self.system = None
self.station = None
self.stationtype = None
@ -201,7 +201,7 @@ class EDLogs(FileSystemEventHandler):
if __debug__:
print 'Stopping monitoring Journal'
self.currentdir = None
self.version = self.mode = self.group = self.cmdr = self.body = self.system = self.station = self.stationtype = self.coordinates = None
self.version = self.mode = self.group = self.cmdr = self.planet = self.system = self.station = self.stationtype = self.coordinates = None
self.is_beta = False
if self.observed:
self.observed = None
@ -305,7 +305,7 @@ class EDLogs(FileSystemEventHandler):
self.cmdr = None
self.mode = None
self.group = None
self.body = None
self.planet = None
self.system = None
self.station = None
self.stationtype = None
@ -332,7 +332,7 @@ class EDLogs(FileSystemEventHandler):
self.cmdr = entry['Commander']
self.mode = entry.get('GameMode') # 'Open', 'Solo', 'Group', or None for CQC (and Training - but no LoadGame event)
self.group = entry.get('Group')
self.body = None
self.planet = None
self.system = None
self.station = None
self.stationtype = None
@ -382,8 +382,10 @@ class EDLogs(FileSystemEventHandler):
self.station = None
self.stationtype = None
elif entry['event'] in ['Location', 'FSDJump', 'Docked']:
if entry['event'] != 'Docked':
self.body = None
if entry['event'] == 'Location':
self.planet = entry.get('Body') if entry.get('BodyType') == 'Planet' else None
elif entry['event'] == 'FSDJump':
self.planet = None
if 'StarPos' in entry:
self.coordinates = tuple(entry['StarPos'])
elif self.system != entry['StarSystem']:
@ -392,9 +394,9 @@ class EDLogs(FileSystemEventHandler):
self.station = entry.get('StationName') # May be None
self.stationtype = entry.get('StationType') # May be None
elif entry['event'] == 'SupercruiseExit':
self.body = entry.get('BodyType') == 'Planet' and entry.get('Body')
self.planet = entry.get('Body') if entry.get('BodyType') == 'Planet' else None
elif entry['event'] == 'SupercruiseEntry':
self.body = None
self.planet = None
elif entry['event'] in ['Rank', 'Promotion']:
for k,v in entry.iteritems():
if k in self.state['Rank']:
@ -459,7 +461,7 @@ class EDLogs(FileSystemEventHandler):
elif entry['event'] == 'JoinACrew':
self.state['Captain'] = entry['Captain']
self.state['Role'] = 'Idle'
self.body = None
self.planet = None
self.system = None
self.station = None
self.stationtype = None
@ -469,7 +471,7 @@ class EDLogs(FileSystemEventHandler):
elif entry['event'] == 'QuitACrew':
self.state['Captain'] = None
self.state['Role'] = None
self.body = None
self.planet = None
self.system = None
self.station = None
self.stationtype = None