mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-02 08:31:16 +03:00
Adjust batching for new startup event order
This commit is contained in:
parent
4e674f85d5
commit
d8dd7af2e2
@ -328,8 +328,9 @@ class EDLogs(FileSystemEventHandler):
|
|||||||
'ShipName' : None,
|
'ShipName' : None,
|
||||||
'ShipType' : None,
|
'ShipType' : None,
|
||||||
}
|
}
|
||||||
|
elif entry['event'] == 'Commander':
|
||||||
|
self.live = True # First event in 3.0
|
||||||
elif entry['event'] == 'LoadGame':
|
elif entry['event'] == 'LoadGame':
|
||||||
self.live = True
|
|
||||||
self.cmdr = entry['Commander']
|
self.cmdr = entry['Commander']
|
||||||
self.mode = entry.get('GameMode') # 'Open', 'Solo', 'Group', or None for CQC (and Training - but no LoadGame event)
|
self.mode = entry.get('GameMode') # 'Open', 'Solo', 'Group', or None for CQC (and Training - but no LoadGame event)
|
||||||
self.group = entry.get('Group')
|
self.group = entry.get('Group')
|
||||||
@ -413,7 +414,6 @@ class EDLogs(FileSystemEventHandler):
|
|||||||
self.state['Rank'][k] = (self.state['Rank'][k][0], min(v, 100)) # perhaps not taken promotion mission yet
|
self.state['Rank'][k] = (self.state['Rank'][k][0], min(v, 100)) # perhaps not taken promotion mission yet
|
||||||
|
|
||||||
elif entry['event'] == 'Cargo':
|
elif entry['event'] == 'Cargo':
|
||||||
self.live = True # First event in 2.3
|
|
||||||
self.state['Cargo'] = defaultdict(int)
|
self.state['Cargo'] = defaultdict(int)
|
||||||
self.state['Cargo'].update({ self.canonicalise(x['Name']): x['Count'] for x in entry['Inventory'] })
|
self.state['Cargo'].update({ self.canonicalise(x['Name']): x['Count'] for x in entry['Inventory'] })
|
||||||
elif entry['event'] in ['CollectCargo', 'MarketBuy', 'BuyDrones', 'MiningRefined']:
|
elif entry['event'] in ['CollectCargo', 'MarketBuy', 'BuyDrones', 'MiningRefined']:
|
||||||
|
@ -39,6 +39,8 @@ this.lastlookup = False # whether the last lookup succeeded
|
|||||||
# Game state
|
# Game state
|
||||||
this.multicrew = False # don't send captain's ship info to EDSM while on a crew
|
this.multicrew = False # don't send captain's ship info to EDSM while on a crew
|
||||||
this.coordinates = None
|
this.coordinates = None
|
||||||
|
this.newgame = False # starting up - batch initial burst of events
|
||||||
|
this.newgame_docked = False # starting up while docked
|
||||||
|
|
||||||
def plugin_start():
|
def plugin_start():
|
||||||
# Can't be earlier since can only call PhotoImage after window is created
|
# Can't be earlier since can only call PhotoImage after window is created
|
||||||
@ -198,6 +200,16 @@ def journal_entry(cmdr, is_beta, system, station, entry, state):
|
|||||||
elif entry['event'] == 'LoadGame':
|
elif entry['event'] == 'LoadGame':
|
||||||
this.coordinates = None
|
this.coordinates = None
|
||||||
|
|
||||||
|
if entry['event'] in ['LoadGame', 'Commander', 'NewCommander']:
|
||||||
|
this.newgame = True
|
||||||
|
this.newgame_docked = False
|
||||||
|
elif entry['event'] == 'StartUp':
|
||||||
|
this.newgame = False
|
||||||
|
this.newgame_docked = False
|
||||||
|
elif entry['event'] == 'Location':
|
||||||
|
this.newgame = True
|
||||||
|
this.newgame_docked = entry.get('Docked', False)
|
||||||
|
|
||||||
# Send interesting events to EDSM
|
# Send interesting events to EDSM
|
||||||
if config.getint('edsm_out') and not is_beta and not this.multicrew and credentials(cmdr) and entry['event'] not in this.discardedEvents:
|
if config.getint('edsm_out') and not is_beta and not this.multicrew and credentials(cmdr) and entry['event'] not in this.discardedEvents:
|
||||||
# Introduce transient states into the event
|
# Introduce transient states into the event
|
||||||
@ -210,15 +222,7 @@ def journal_entry(cmdr, is_beta, system, station, entry, state):
|
|||||||
entry.update(transient)
|
entry.update(transient)
|
||||||
|
|
||||||
if entry['event'] == 'LoadGame':
|
if entry['event'] == 'LoadGame':
|
||||||
# Synthesise Cargo and Materials events on LoadGame since we will have missed them because Cmdr was unknown
|
# Synthesise Materials events on LoadGame since we will have missed it
|
||||||
cargo = {
|
|
||||||
'timestamp': entry['timestamp'],
|
|
||||||
'event': 'Cargo',
|
|
||||||
'Inventory': [ { 'Name': k, 'Count': v } for k,v in state['Cargo'].iteritems() ],
|
|
||||||
}
|
|
||||||
cargo.update(transient)
|
|
||||||
this.queue.put((cmdr, cargo))
|
|
||||||
|
|
||||||
materials = {
|
materials = {
|
||||||
'timestamp': entry['timestamp'],
|
'timestamp': entry['timestamp'],
|
||||||
'event': 'Materials',
|
'event': 'Materials',
|
||||||
@ -311,7 +315,7 @@ def worker():
|
|||||||
print('EDSM\t%s %s\t%s' % (msgnum, msg, json.dumps(pending, separators = (',', ': '))))
|
print('EDSM\t%s %s\t%s' % (msgnum, msg, json.dumps(pending, separators = (',', ': '))))
|
||||||
plug.show_error(_('Error: EDSM {MSG}').format(MSG=msg))
|
plug.show_error(_('Error: EDSM {MSG}').format(MSG=msg))
|
||||||
else:
|
else:
|
||||||
for e, r in zip(pending, reply):
|
for e, r in zip(pending, reply['events']):
|
||||||
if not closing and e['event'] in ['StartUp', 'Location', 'FSDJump']:
|
if not closing and e['event'] in ['StartUp', 'Location', 'FSDJump']:
|
||||||
# Update main window's system status
|
# Update main window's system status
|
||||||
this.lastlookup = r
|
this.lastlookup = r
|
||||||
@ -337,10 +341,16 @@ def worker():
|
|||||||
# Whether any of the entries should be sent immediately
|
# Whether any of the entries should be sent immediately
|
||||||
def should_send(entries):
|
def should_send(entries):
|
||||||
for entry in entries:
|
for entry in entries:
|
||||||
if (entry['event'] not in ['CommunityGoal', # Spammed periodically
|
if (entry['event'] == 'Cargo' and not this.newgame_docked) or entry['event'] == 'Docked':
|
||||||
'Cargo', 'Loadout', 'Materials', 'LoadGame', 'Rank', 'Progress', # Will be followed by 'Docked' or 'Location'
|
# Cargo is the last event on startup, unless starting when docked in which case Docked is the last event
|
||||||
'ShipyardBuy', 'ShipyardNew', 'ShipyardSwap'] and # "
|
this.newgame = False
|
||||||
not (entry['event'] == 'Location' and entry.get('Docked'))): # "
|
this.newgame_docked = False
|
||||||
|
return True
|
||||||
|
elif this.newgame:
|
||||||
|
pass
|
||||||
|
elif entry['event'] not in ['CommunityGoal', # Spammed periodically
|
||||||
|
'ModuleBuy', 'ModuleSell', 'ModuleSwap', # will be shortly followed by "Loadout"
|
||||||
|
'ShipyardBuy', 'ShipyardNew', 'ShipyardSwap']: # "
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ this.cmdr = None
|
|||||||
this.multicrew = False # don't send captain's ship info to Inara while on a crew
|
this.multicrew = False # don't send captain's ship info to Inara while on a crew
|
||||||
this.newuser = False # just entered API Key
|
this.newuser = False # just entered API Key
|
||||||
this.undocked = False # just undocked
|
this.undocked = False # just undocked
|
||||||
this.suppress_docked = False # Skip Docked event after Location if started docked
|
this.suppress_docked = False # Skip initial Docked event if started docked
|
||||||
this.cargo = None
|
this.cargo = None
|
||||||
this.materials = None
|
this.materials = None
|
||||||
this.lastcredits = 0 # Send credit update soon after Startup / new game
|
this.lastcredits = 0 # Send credit update soon after Startup / new game
|
||||||
@ -163,7 +163,7 @@ def journal_entry(cmdr, is_beta, system, station, entry, state):
|
|||||||
this.suppress_docked = True
|
this.suppress_docked = True
|
||||||
|
|
||||||
|
|
||||||
# Send location and status on new game or StartUp. Assumes Location is the last event on a new game (other than Docked).
|
# Send location and status on new game or StartUp. Assumes Cargo is the last event on a new game (other than Docked).
|
||||||
# Always send an update on Docked, FSDJump, Undocked+SuperCruise, Promotion and EngineerProgress.
|
# Always send an update on Docked, FSDJump, Undocked+SuperCruise, Promotion and EngineerProgress.
|
||||||
# Also send material and cargo (if changed) whenever we send an update.
|
# Also send material and cargo (if changed) whenever we send an update.
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ def journal_entry(cmdr, is_beta, system, station, entry, state):
|
|||||||
old_events = len(this.events) # Will only send existing events if we add a new event below
|
old_events = len(this.events) # Will only send existing events if we add a new event below
|
||||||
|
|
||||||
# Send rank info to Inara on startup or change
|
# Send rank info to Inara on startup or change
|
||||||
if (entry['event'] in ['StartUp', 'Location'] or this.newuser) and state['Rank']:
|
if (entry['event'] in ['StartUp', 'Cargo'] or this.newuser):
|
||||||
for k,v in state['Rank'].iteritems():
|
for k,v in state['Rank'].iteritems():
|
||||||
if v is not None:
|
if v is not None:
|
||||||
add_event('setCommanderRankPilot', entry['timestamp'],
|
add_event('setCommanderRankPilot', entry['timestamp'],
|
||||||
@ -227,7 +227,7 @@ def journal_entry(cmdr, is_beta, system, station, entry, state):
|
|||||||
]))
|
]))
|
||||||
|
|
||||||
# Update ship
|
# Update ship
|
||||||
if (entry['event'] in ['StartUp', 'Location', 'ShipyardNew'] or
|
if (entry['event'] in ['StartUp', 'Cargo'] or
|
||||||
(entry['event'] == 'Loadout' and this.shipswap) or
|
(entry['event'] == 'Loadout' and this.shipswap) or
|
||||||
this.newuser):
|
this.newuser):
|
||||||
if entry['event'] == 'ShipyardNew':
|
if entry['event'] == 'ShipyardNew':
|
||||||
@ -247,7 +247,7 @@ def journal_entry(cmdr, is_beta, system, station, entry, state):
|
|||||||
this.shipswap = False
|
this.shipswap = False
|
||||||
|
|
||||||
# Update location
|
# Update location
|
||||||
if (entry['event'] in ['StartUp', 'Location'] or this.newuser) and system:
|
if (entry['event'] in ['StartUp', 'Cargo'] or this.newuser) and system:
|
||||||
this.undocked = False
|
this.undocked = False
|
||||||
add_event('setCommanderTravelLocation', entry['timestamp'],
|
add_event('setCommanderTravelLocation', entry['timestamp'],
|
||||||
OrderedDict([
|
OrderedDict([
|
||||||
@ -262,7 +262,7 @@ def journal_entry(cmdr, is_beta, system, station, entry, state):
|
|||||||
# Undocked and now docking again. Don't send.
|
# Undocked and now docking again. Don't send.
|
||||||
this.undocked = False
|
this.undocked = False
|
||||||
elif this.suppress_docked:
|
elif this.suppress_docked:
|
||||||
# Don't send Docked event on new game - i.e. following 'Location' event
|
# Don't send initial Docked event on new game
|
||||||
this.suppress_docked = False
|
this.suppress_docked = False
|
||||||
else:
|
else:
|
||||||
add_event('addCommanderTravelDock', entry['timestamp'],
|
add_event('addCommanderTravelDock', entry['timestamp'],
|
||||||
@ -603,7 +603,7 @@ def worker():
|
|||||||
# Log individual errors and warnings
|
# Log individual errors and warnings
|
||||||
for data_event, reply_event in zip(data['events'], reply['events']):
|
for data_event, reply_event in zip(data['events'], reply['events']):
|
||||||
if reply_event['eventStatus'] != 200:
|
if reply_event['eventStatus'] != 200:
|
||||||
print 'Inara\t%s %s\t%s' % (reply_event['eventStatus'], reply_event.get('eventStatusText', ''), json.dumps(data_event, separators = (',', ': ')))
|
print 'Inara\t%s %s\t%s' % (reply_event['eventStatus'], reply_event.get('eventStatusText', ''), json.dumps(data_event))
|
||||||
if reply_event['eventStatus'] // 100 != 2:
|
if reply_event['eventStatus'] // 100 != 2:
|
||||||
plug.show_error(_('Error: Inara {MSG}').format(MSG = '%s, %s' % (data_event['eventName'], reply_event.get('eventStatusText', reply_event['eventStatus']))))
|
plug.show_error(_('Error: Inara {MSG}').format(MSG = '%s, %s' % (data_event['eventName'], reply_event.get('eventStatusText', reply_event['eventStatus']))))
|
||||||
if data_event['eventName'] in ['addCommanderTravelDock', 'addCommanderTravelFSDJump', 'setCommanderTravelLocation']:
|
if data_event['eventName'] in ['addCommanderTravelDock', 'addCommanderTravelFSDJump', 'setCommanderTravelLocation']:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user