mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-18 09:57:40 +03:00
EDDB plugin now setting Station name correctly on_foot
* monitor.on_foot is now monitor.state['on_foot'] as plugins need to access it. * EDDB:journal_entry() now stores that in this.on_foot to check later. * this.on_foot checked in cmdr_data() to actually set station name from that data if needs be. This avoids setting it to STATION_UNDOCKED if data['commander']['docked'] is False, when we're on_foot.
This commit is contained in:
parent
567cfdb9ca
commit
f45f817fa2
@ -690,7 +690,7 @@ class AppWindow(object):
|
|||||||
:return: True if all OK, else False to trigger play_bad in caller.
|
:return: True if all OK, else False to trigger play_bad in caller.
|
||||||
"""
|
"""
|
||||||
if config.get_int('output') & (config.OUT_STATION_ANY):
|
if config.get_int('output') & (config.OUT_STATION_ANY):
|
||||||
if not data['commander'].get('docked') and not monitor.on_foot:
|
if not data['commander'].get('docked') and not monitor.state['on_foot']:
|
||||||
if not self.status['text']:
|
if not self.status['text']:
|
||||||
# Signal as error because the user might actually be docked
|
# Signal as error because the user might actually be docked
|
||||||
# but the server hosting the Companion API hasn't caught up
|
# but the server hosting the Companion API hasn't caught up
|
||||||
@ -777,7 +777,7 @@ class AppWindow(object):
|
|||||||
# Companion API Commander doesn't match Journal
|
# Companion API Commander doesn't match Journal
|
||||||
raise companion.CmdrError()
|
raise companion.CmdrError()
|
||||||
|
|
||||||
elif auto_update and not monitor.on_foot and not data['commander'].get('docked'):
|
elif auto_update and not monitor.state['on_foot'] and not data['commander'].get('docked'):
|
||||||
# auto update is only when just docked
|
# auto update is only when just docked
|
||||||
raise companion.ServerLagging()
|
raise companion.ServerLagging()
|
||||||
|
|
||||||
@ -786,7 +786,7 @@ class AppWindow(object):
|
|||||||
raise companion.ServerLagging()
|
raise companion.ServerLagging()
|
||||||
|
|
||||||
elif data['lastStarport']['name'] != monitor.station:
|
elif data['lastStarport']['name'] != monitor.station:
|
||||||
if monitor.on_foot and monitor.station:
|
if monitor.state['on_foot'] and monitor.station:
|
||||||
raise companion.ServerLagging()
|
raise companion.ServerLagging()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@ -798,11 +798,11 @@ class AppWindow(object):
|
|||||||
# CAPI lastStarport must match
|
# CAPI lastStarport must match
|
||||||
raise companion.ServerLagging()
|
raise companion.ServerLagging()
|
||||||
|
|
||||||
elif not monitor.on_foot and data['ship']['id'] != monitor.state['ShipID']:
|
elif not monitor.state['on_foot'] and data['ship']['id'] != monitor.state['ShipID']:
|
||||||
# CAPI ship must match
|
# CAPI ship must match
|
||||||
raise companion.ServerLagging()
|
raise companion.ServerLagging()
|
||||||
|
|
||||||
elif not monitor.on_foot and data['ship']['name'].lower() != monitor.state['ShipType']:
|
elif not monitor.state['on_foot'] and data['ship']['name'].lower() != monitor.state['ShipType']:
|
||||||
# CAPI ship type must match
|
# CAPI ship type must match
|
||||||
raise companion.ServerLagging()
|
raise companion.ServerLagging()
|
||||||
|
|
||||||
@ -909,6 +909,7 @@ class AppWindow(object):
|
|||||||
|
|
||||||
self.ship_label['text'] = _('Ship') + ':' # Main window
|
self.ship_label['text'] = _('Ship') + ':' # Main window
|
||||||
|
|
||||||
|
# TODO: Show something else when on_foot
|
||||||
if monitor.state['ShipName']:
|
if monitor.state['ShipName']:
|
||||||
ship_text = monitor.state['ShipName']
|
ship_text = monitor.state['ShipName']
|
||||||
|
|
||||||
|
@ -564,7 +564,7 @@ class Session(object):
|
|||||||
logger.error('No commander in returned data')
|
logger.error('No commander in returned data')
|
||||||
return data
|
return data
|
||||||
|
|
||||||
if not data['commander'].get('docked') and not monitor.on_foot:
|
if not data['commander'].get('docked') and not monitor.state['on_foot']:
|
||||||
return data
|
return data
|
||||||
|
|
||||||
services = data['lastStarport'].get('services', {})
|
services = data['lastStarport'].get('services', {})
|
||||||
|
14
monitor.py
14
monitor.py
@ -104,7 +104,6 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
|||||||
self.coordinates: Optional[Tuple[float, float, float]] = None
|
self.coordinates: Optional[Tuple[float, float, float]] = None
|
||||||
self.systemaddress: Optional[int] = None
|
self.systemaddress: Optional[int] = None
|
||||||
self.started: Optional[int] = None # Timestamp of the LoadGame event
|
self.started: Optional[int] = None # Timestamp of the LoadGame event
|
||||||
self.on_foot: bool = False
|
|
||||||
|
|
||||||
# Cmdr state shared with EDSM and plugins
|
# Cmdr state shared with EDSM and plugins
|
||||||
# If you change anything here update PLUGINS.md documentation!
|
# If you change anything here update PLUGINS.md documentation!
|
||||||
@ -134,6 +133,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
|||||||
'Modules': None,
|
'Modules': None,
|
||||||
'CargoJSON': None, # The raw data from the last time cargo.json was read
|
'CargoJSON': None, # The raw data from the last time cargo.json was read
|
||||||
'Route': None, # Last plotted route from Route.json file
|
'Route': None, # Last plotted route from Route.json file
|
||||||
|
'on_foot': False, # Whether we think you're on-foot
|
||||||
}
|
}
|
||||||
|
|
||||||
def start(self, root: 'tkinter.Tk') -> bool: # noqa: CCR001
|
def start(self, root: 'tkinter.Tk') -> bool: # noqa: CCR001
|
||||||
@ -234,7 +234,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
|||||||
self.coordinates = None
|
self.coordinates = None
|
||||||
self.systemaddress = None
|
self.systemaddress = None
|
||||||
self.is_beta = False
|
self.is_beta = False
|
||||||
self.on_foot = False
|
self.state['on_foot'] = False
|
||||||
|
|
||||||
if self.observed:
|
if self.observed:
|
||||||
logger.debug('self.observed: Calling unschedule_all()')
|
logger.debug('self.observed: Calling unschedule_all()')
|
||||||
@ -497,7 +497,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
|||||||
'Modules': None,
|
'Modules': None,
|
||||||
'Route': None,
|
'Route': None,
|
||||||
}
|
}
|
||||||
self.on_foot = False
|
self.state['on_foot'] = False
|
||||||
|
|
||||||
elif event_type == 'Commander':
|
elif event_type == 'Commander':
|
||||||
self.live = True # First event in 3.0
|
self.live = True # First event in 3.0
|
||||||
@ -530,7 +530,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
|||||||
'Role': None,
|
'Role': None,
|
||||||
})
|
})
|
||||||
if self._RE_SHIP_ONFOOT.search(entry['Ship']):
|
if self._RE_SHIP_ONFOOT.search(entry['Ship']):
|
||||||
self.on_foot = True
|
self.state['on_foot'] = True
|
||||||
|
|
||||||
elif event_type == 'NewCommander':
|
elif event_type == 'NewCommander':
|
||||||
self.cmdr = entry['Name']
|
self.cmdr = entry['Name']
|
||||||
@ -628,12 +628,12 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
|||||||
elif event_type == 'Embark':
|
elif event_type == 'Embark':
|
||||||
# If we've embarked then we're no longer on the station.
|
# If we've embarked then we're no longer on the station.
|
||||||
self.station = None
|
self.station = None
|
||||||
self.on_foot = False
|
self.state['on_foot'] = False
|
||||||
|
|
||||||
elif event_type == 'Disembark':
|
elif event_type == 'Disembark':
|
||||||
# We don't yet have a way, other than LoadGame+Location, to detect if we *are* on a station on-foot.
|
# We don't yet have a way, other than LoadGame+Location, to detect if we *are* on a station on-foot.
|
||||||
self.station = None
|
self.station = None
|
||||||
self.on_foot = True
|
self.state['on_foot'] = True
|
||||||
|
|
||||||
elif event_type in ('Location', 'FSDJump', 'Docked', 'CarrierJump'):
|
elif event_type in ('Location', 'FSDJump', 'Docked', 'CarrierJump'):
|
||||||
if event_type in ('Location', 'CarrierJump'):
|
if event_type in ('Location', 'CarrierJump'):
|
||||||
@ -896,7 +896,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
|||||||
self.stationservices = None
|
self.stationservices = None
|
||||||
self.coordinates = None
|
self.coordinates = None
|
||||||
self.systemaddress = None
|
self.systemaddress = None
|
||||||
self.on_foot = False
|
self.state['on_foot'] = False
|
||||||
|
|
||||||
elif event_type == 'ChangeCrewRole':
|
elif event_type == 'ChangeCrewRole':
|
||||||
self.state['Role'] = entry['Role']
|
self.state['Role'] = entry['Role']
|
||||||
|
@ -53,6 +53,7 @@ this.system_population: Optional[int] = None
|
|||||||
this.station_link: 'Optional[Tk]' = None
|
this.station_link: 'Optional[Tk]' = None
|
||||||
this.station: Optional[str] = None
|
this.station: Optional[str] = None
|
||||||
this.station_marketid: Optional[int] = None
|
this.station_marketid: Optional[int] = None
|
||||||
|
this.on_foot = False
|
||||||
|
|
||||||
|
|
||||||
def system_url(system_name: str) -> str:
|
def system_url(system_name: str) -> str:
|
||||||
@ -102,6 +103,7 @@ def journal_entry(cmdr, is_beta, system, station, entry, state):
|
|||||||
logger.warning(f'Processing of event {entry["event"]} has been disabled: {ks.reason}')
|
logger.warning(f'Processing of event {entry["event"]} has been disabled: {ks.reason}')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
this.on_foot = state['on_foot']
|
||||||
# Always update our system address even if we're not currently the provider for system or station, but dont update
|
# Always update our system address even if we're not currently the provider for system or station, but dont update
|
||||||
# on events that contain "future" data, such as FSDTarget
|
# on events that contain "future" data, such as FSDTarget
|
||||||
if entry['event'] in ('Location', 'Docked', 'CarrierJump', 'FSDJump'):
|
if entry['event'] in ('Location', 'Docked', 'CarrierJump', 'FSDJump'):
|
||||||
@ -115,9 +117,13 @@ def journal_entry(cmdr, is_beta, system, station, entry, state):
|
|||||||
this.system_population = pop
|
this.system_population = pop
|
||||||
|
|
||||||
this.station = entry.get('StationName') or this.station
|
this.station = entry.get('StationName') or this.station
|
||||||
|
# on_foot station detection
|
||||||
|
if not this.station and entry['event'] == 'Location' and entry['BodyType'] == 'Station':
|
||||||
|
this.station = entry['Body']
|
||||||
|
|
||||||
this.station_marketid = entry.get('MarketID') or this.station_marketid
|
this.station_marketid = entry.get('MarketID') or this.station_marketid
|
||||||
# We might pick up StationName in DockingRequested, make sure we clear it if leaving
|
# We might pick up StationName in DockingRequested, make sure we clear it if leaving
|
||||||
if entry['event'] in ('Undocked', 'FSDJump', 'SupercruiseEntry'):
|
if entry['event'] in ('Undocked', 'FSDJump', 'SupercruiseEntry', 'Embark'):
|
||||||
this.station = None
|
this.station = None
|
||||||
this.station_marketid = None
|
this.station_marketid = None
|
||||||
|
|
||||||
@ -164,7 +170,7 @@ def cmdr_data(data: CAPIData, is_beta):
|
|||||||
this.system_link.update_idletasks()
|
this.system_link.update_idletasks()
|
||||||
|
|
||||||
if config.get_str('station_provider') == 'eddb':
|
if config.get_str('station_provider') == 'eddb':
|
||||||
if data['commander']['docked']:
|
if data['commander']['docked'] or this.on_foot and this.station:
|
||||||
this.station_link['text'] = this.station
|
this.station_link['text'] = this.station
|
||||||
|
|
||||||
elif data['lastStarport']['name'] and data['lastStarport']['name'] != "":
|
elif data['lastStarport']['name'] and data['lastStarport']['name'] != "":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user