mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-08-25 18:33:44 +03:00
Change monitor.state['on_foot'] to 'OnFoot' for consistency
This commit is contained in:
parent
4be52fd259
commit
5edf8d5b59
@ -694,7 +694,7 @@ class AppWindow(object):
|
||||
:return: True if all OK, else False to trigger play_bad in caller.
|
||||
"""
|
||||
if config.get_int('output') & (config.OUT_STATION_ANY):
|
||||
if not data['commander'].get('docked') and not monitor.state['on_foot']:
|
||||
if not data['commander'].get('docked') and not monitor.state['OnFoot']:
|
||||
if not self.status['text']:
|
||||
# Signal as error because the user might actually be docked
|
||||
# but the server hosting the Companion API hasn't caught up
|
||||
@ -781,7 +781,7 @@ class AppWindow(object):
|
||||
# Companion API Commander doesn't match Journal
|
||||
raise companion.CmdrError()
|
||||
|
||||
elif auto_update and not monitor.state['on_foot'] and not data['commander'].get('docked'):
|
||||
elif auto_update and not monitor.state['OnFoot'] and not data['commander'].get('docked'):
|
||||
# auto update is only when just docked
|
||||
raise companion.ServerLagging()
|
||||
|
||||
@ -790,7 +790,7 @@ class AppWindow(object):
|
||||
raise companion.ServerLagging()
|
||||
|
||||
elif data['lastStarport']['name'] != monitor.station:
|
||||
if monitor.state['on_foot'] and monitor.station:
|
||||
if monitor.state['OnFoot'] and monitor.station:
|
||||
raise companion.ServerLagging()
|
||||
|
||||
else:
|
||||
@ -802,11 +802,11 @@ class AppWindow(object):
|
||||
# CAPI lastStarport must match
|
||||
raise companion.ServerLagging()
|
||||
|
||||
elif not monitor.state['on_foot'] and data['ship']['id'] != monitor.state['ShipID']:
|
||||
elif not monitor.state['OnFoot'] and data['ship']['id'] != monitor.state['ShipID']:
|
||||
# CAPI ship must match
|
||||
raise companion.ServerLagging()
|
||||
|
||||
elif not monitor.state['on_foot'] and data['ship']['name'].lower() != monitor.state['ShipType']:
|
||||
elif not monitor.state['OnFoot'] and data['ship']['name'].lower() != monitor.state['ShipType']:
|
||||
# CAPI ship type must match
|
||||
raise companion.ServerLagging()
|
||||
|
||||
|
@ -530,7 +530,7 @@ Content of `state` (updated to the current journal entry):
|
||||
| `Modules` | `dict` | Currently fitted modules |
|
||||
| `NavRoute` | `dict` | Last plotted multi-hop route |
|
||||
| `ModuleInfo` | `dict` | Last loaded ModulesInfo.json data |
|
||||
| `on_foot` | `bool` | Whether you're on_foot |
|
||||
| `OnFoot` | `bool` | Whether the Cmdr is on foot |
|
||||
|
||||
New in version 4.1.6:
|
||||
|
||||
@ -550,7 +550,7 @@ journal `NavRoute` event.
|
||||
`ModuleInfo` contains the `json.load()` of `ModulesInfo.json` as indicated by a
|
||||
Journal `ModuleInfo` event.
|
||||
|
||||
`on_foot` is an indication as to if the player is on-foot, rather than in a
|
||||
`OnFoot` is an indication as to if the player is on-foot, rather than in a
|
||||
vehicle.
|
||||
|
||||
##### Synthetic Events
|
||||
|
14
monitor.py
14
monitor.py
@ -133,7 +133,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
||||
'Modules': None,
|
||||
'CargoJSON': None, # The raw data from the last time cargo.json was read
|
||||
'Route': None, # Last plotted route from Route.json file
|
||||
'on_foot': False, # Whether we think you're on-foot
|
||||
'OnFoot': False, # Whether we think you're on-foot
|
||||
}
|
||||
|
||||
def start(self, root: 'tkinter.Tk') -> bool: # noqa: CCR001
|
||||
@ -234,7 +234,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
||||
self.coordinates = None
|
||||
self.systemaddress = None
|
||||
self.is_beta = False
|
||||
self.state['on_foot'] = False
|
||||
self.state['OnFoot'] = False
|
||||
|
||||
if self.observed:
|
||||
logger.debug('self.observed: Calling unschedule_all()')
|
||||
@ -497,7 +497,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
||||
'Modules': None,
|
||||
'Route': None,
|
||||
}
|
||||
self.state['on_foot'] = False
|
||||
self.state['OnFoot'] = False
|
||||
|
||||
elif event_type == 'Commander':
|
||||
self.live = True # First event in 3.0
|
||||
@ -530,7 +530,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
||||
'Role': None,
|
||||
})
|
||||
if self._RE_SHIP_ONFOOT.search(entry['Ship']):
|
||||
self.state['on_foot'] = True
|
||||
self.state['OnFoot'] = True
|
||||
|
||||
elif event_type == 'NewCommander':
|
||||
self.cmdr = entry['Name']
|
||||
@ -628,12 +628,12 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
||||
elif event_type == 'Embark':
|
||||
# If we've embarked then we're no longer on the station.
|
||||
self.station = None
|
||||
self.state['on_foot'] = False
|
||||
self.state['OnFoot'] = False
|
||||
|
||||
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.
|
||||
self.station = None
|
||||
self.state['on_foot'] = True
|
||||
self.state['OnFoot'] = True
|
||||
|
||||
elif event_type in ('Location', 'FSDJump', 'Docked', 'CarrierJump'):
|
||||
if event_type in ('Location', 'CarrierJump'):
|
||||
@ -896,7 +896,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
||||
self.stationservices = None
|
||||
self.coordinates = None
|
||||
self.systemaddress = None
|
||||
self.state['on_foot'] = False
|
||||
self.state['OnFoot'] = False
|
||||
|
||||
elif event_type == 'ChangeCrewRole':
|
||||
self.state['Role'] = entry['Role']
|
||||
|
@ -103,7 +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}')
|
||||
return
|
||||
|
||||
this.on_foot = state['on_foot']
|
||||
this.on_foot = state['OnFoot']
|
||||
# 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
|
||||
if entry['event'] in ('Location', 'Docked', 'CarrierJump', 'FSDJump'):
|
||||
|
@ -42,6 +42,8 @@ class This:
|
||||
"""Holds module globals."""
|
||||
|
||||
def __init__(self):
|
||||
# Track if we're on foot
|
||||
self.on_foot = False
|
||||
# Track location to add to Journal events
|
||||
self.systemaddress: Optional[str] = None
|
||||
self.coordinates: Optional[Tuple] = None
|
||||
@ -766,6 +768,7 @@ def journal_entry( # noqa: C901, CCR001
|
||||
|
||||
return filtered
|
||||
|
||||
this.on_foot = state['OnFoot']
|
||||
# Track location
|
||||
if entry['event'] in ('Location', 'FSDJump', 'Docked', 'CarrierJump'):
|
||||
if entry['event'] in ('Location', 'CarrierJump'):
|
||||
@ -908,7 +911,7 @@ def cmdr_data(data: CAPIData, is_beta: bool) -> Optional[str]: # noqa: CCR001
|
||||
:param is_beta: bool - True if this is a beta version of the Game.
|
||||
:return: str - Error message, or `None` if no errors.
|
||||
"""
|
||||
if (data['commander'].get('docked') or (monitor.on_foot and monitor.station)
|
||||
if (data['commander'].get('docked') or (this.on_foot and monitor.station)
|
||||
and config.get_int('output') & config.OUT_MKT_EDDN):
|
||||
try:
|
||||
if this.marketId != data['lastStarport']['id']:
|
||||
|
@ -350,7 +350,7 @@ def journal_entry(
|
||||
logger.warning(f'Handling of event {entry["event"]} has been disabled via killswitch: {ks.reason}')
|
||||
return
|
||||
|
||||
this.on_foot = state['on_foot']
|
||||
this.on_foot = state['OnFoot']
|
||||
if entry['event'] in ('CarrierJump', 'FSDJump', 'Location', 'Docked'):
|
||||
logger.trace(f'''{entry["event"]}
|
||||
Commander: {cmdr}
|
||||
|
@ -331,7 +331,7 @@ def journal_entry(
|
||||
elif (ks := killswitch.get_disabled(f'plugins.inara.journal.event.{entry["event"]}')).disabled:
|
||||
logger.warning(f'event {entry["event"]} processing has been disabled via killswitch: {ks.reason}')
|
||||
|
||||
this.on_foot = state['on_foot']
|
||||
this.on_foot = state['OnFoot']
|
||||
event_name: str = entry['event']
|
||||
this.cmdr = cmdr
|
||||
this.FID = state['FID']
|
||||
|
Loading…
x
Reference in New Issue
Block a user