From 11ec6bfe49b0eb90a6d70b83799be0acc4533834 Mon Sep 17 00:00:00 2001 From: A_D Date: Mon, 31 May 2021 11:33:05 +0200 Subject: [PATCH 01/15] Start implementing addCommanderTravelLand --- plugins/inara.py | 80 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 2 deletions(-) diff --git a/plugins/inara.py b/plugins/inara.py index 5e08cf74..4c713d65 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -20,6 +20,8 @@ import timeout_session from companion import CAPIData from config import applongname, appversion, config from EDMCLogging import get_main_logger +# Yes I know. Im using it for `monitor.planet` Which probably should be rolled into state as a body and bodyType pair +from monitor import monitor from ttkHyperlinkLabel import HyperlinkLabel logger = get_main_logger() @@ -975,7 +977,76 @@ def journal_entry( # noqa: C901, CCR001 } ) - # Community Goals + # New Odyssey features + elif event_name == 'DropshipDeploy': + new_add_event( + 'addCommanderTravelLand', + entry['timestamp'], + { + 'starsystemName': entry['StarSystem'], + 'starsystemBodyName': entry['Body'], + 'isTaxiDropship': True, + } + ) + + elif event_name == 'Touchdown': + # Touchdown has FAR more info available on Odyssey vs Horizons: + # Horizons: + # {"timestamp":"2021-05-31T09:10:54Z","event":"Touchdown", + # "PlayerControlled":true,"Latitude":46.691929,"Longitude":-92.679977} + # + # Odyssey: + # {"timestamp":"2021-05-31T08:48:08Z","event":"Touchdown","PlayerControlled":true,"Taxi":false, + # "Multicrew":false,"StarSystem":"Gateway","SystemAddress":2832631665362,"Body":"Saunder's Rock","BodyID":2, + # "OnStation":false,"OnPlanet":true,"Latitude":54.79665,"Longitude":-99.498253} + # + # So we're going to do a lot of checking here and bail out if we dont like the look of ANYTHING here + + to_send_data: Optional[Dict[str, Any]] = {} # This is a glorified sentinel until lower down. + # On Horizons, neither of these exist on TouchDown + star_system_name = entry.get('StarSystem', this.system) + body_name = entry.get('Body', monitor.planet) + + if star_system_name is None: + logger.warning('Refusing to update addCommanderTravelLand as we dont have a StarSystem!') + to_send_data = None + + if body_name is None: + logger.warning('Refusing to update addCommanderTravelLand as we dont have a Body!') + to_send_data = None + + if (op := entry.get('OnPlanet')) is not None and not op: + logger.warning('Refusing to update addCommanderTravelLand when OnPlanet is False!') + logger.warning(f'{entry=}') + to_send_data = None + + if not entry['PlayerControlled']: + logger.info("Not updating inara addCommanderTravelLand for autonomous recall landing") + to_send_data = None + + if to_send_data is not None: + # Above checks passed. Lets build and send this! + to_send_data['starsystemName'] = star_system_name # Required + to_send_data['starsystemBodyName'] = body_name # Required + + # Following are optional + + # lat/long is always there unless its an automated (recall) landing. Thus as we're sure its _not_ + # we can assume this exists. If it doesn't its a bug anyway. + to_send_data['starsystemBodyCoords'] = [entry['Latitude'], entry['Longitude']] + if state.get('ShipID') is not None: + to_send_data['shipGameID'] = state['ShipID'] + + if state.get('ShipType') is not None: + to_send_data['shipType'] = state['ShipType'] + + # TODO: Can Touchdown ever show for either of these? I dont think so + to_send_data['isTaxiShuttle'] = False + to_send_data['isTaxiDropShip'] = False + + new_add_event('addCommanderTravelLand', entry['timestamp'], to_send_data) + + # Community Goals if event_name == 'CommunityGoal': # Remove any unsent this.filter_events( @@ -1250,7 +1321,8 @@ def new_worker(): 'appVersion': str(appversion()), 'APIkey': creds.api_key, 'commanderName': creds.cmdr, - 'commanderFrontierID': creds.fid + 'commanderFrontierID': creds.fid, + 'isBeingDeveloped': True, # TODO: Remove once update is complete }, 'events': [ {'eventName': e.name, 'eventTimestamp': e.timestamp, 'eventData': e.data} for e in event_list @@ -1307,6 +1379,10 @@ def send_data(url: str, data: Mapping[str, Any]) -> bool: # noqa: CCR001 :param data: the data to POST :return: success state """ + # TODO: Remove this. Its here to ensure we dont forget that we're running test code + for x in range(20): + logger.info("INARA IS SENDING HEADERS THAT INDICATE DEV MODE!!!!!!!!!!!!!!!!!!!!!!!!!") + r = this.session.post(url, data=json.dumps(data, separators=(',', ':')), timeout=_TIMEOUT) r.raise_for_status() reply = r.json() From a7a9de77d7a32e1fa0a118cd744d4cdcec0978d3 Mon Sep 17 00:00:00 2001 From: A_D Date: Mon, 31 May 2021 12:58:20 +0200 Subject: [PATCH 02/15] Added rudimentry taxi status tracking --- monitor.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/monitor.py b/monitor.py index eff8799f..5138cba2 100644 --- a/monitor.py +++ b/monitor.py @@ -160,6 +160,8 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below 'Suits': {}, 'SuitLoadoutCurrent': None, 'SuitLoadouts': {}, + 'Taxi': None, # True whenever we are _in_ a taxi. ie, this is reset on Disembark etc. + 'Dropship': None, # Best effort as to whether or not the above taxi is a dropship. } def start(self, root: 'tkinter.Tk') -> bool: # noqa: CCR001 @@ -535,6 +537,8 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below 'Reputation': {}, 'Statistics': {}, 'Role': None, + 'Taxi': None, + 'Dropship': None, }) if entry.get('Ship') is not None and self._RE_SHIP_ONFOOT.search(entry['Ship']): self.state['OnFoot'] = True @@ -668,6 +672,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.station = entry.get('StationName', '') self.state['OnFoot'] = False + self.state['Taxi'] = entry['Taxi'] elif event_type == 'Disembark': # This event is logged when the player steps out of a ship or SRV @@ -694,10 +699,17 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.station = None self.state['OnFoot'] = True + if self.state['Taxi'] is not None and not self.state['Taxi']: + logger.warning('Disembarked from a taxi but we didn\'t know we were in a taxi?') + + self.state['Taxi'] = False + self.state['Dropship'] = False elif event_type == 'DropshipDeploy': # We're definitely on-foot now self.state['OnFoot'] = True + self.state['Taxi'] = False + self.state['Dropship'] = False elif event_type == 'Docked': self.station = entry.get('StationName') # May be None @@ -705,6 +717,8 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.stationtype = entry.get('StationType') # May be None self.stationservices = entry.get('StationServices') # None under E:D < 2.4 + # No need to set self.state['Taxi'] or Dropship here, if its those, the next event is a Disembark anyway + elif event_type in ('Location', 'FSDJump', 'CarrierJump'): # alpha4 - any changes ? # Location: @@ -742,6 +756,10 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.stationtype = entry.get('StationType') # May be None self.stationservices = entry.get('StationServices') # None in Odyssey for on-foot 'Location' + self.state['Taxi'] = entry.get('Taxi', None) + if not self.state['Taxi']: + self.state['Dropship'] = None + elif event_type == 'ApproachBody': self.planet = entry['Body'] @@ -1284,6 +1302,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below elif event_type == 'BookDropship': self.state['Credits'] -= entry.get('Cost', 0) + self.state['Dropship'] = True # Technically we *might* now not be OnFoot. # The problem is that this event is recorded both for signing up for # an on-foot CZ, and when you use the Dropship to return after the @@ -1297,12 +1316,16 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below elif event_type == 'BookTaxi': self.state['Credits'] -= entry.get('Cost', 0) + # Dont set taxi state here, as we're not IN a taxi yet. Set it on Embark elif event_type == 'CancelDropship': self.state['Credits'] += entry.get('Refund', 0) + self.state['Dropship'] = False + self.state['Taxi'] = False elif event_type == 'CancelTaxi': self.state['Credits'] += entry.get('Refund', 0) + self.state['Taxi'] = False elif event_type == 'NavRoute': # Added in ED 3.7 - multi-hop route details in NavRoute.json From 0322fd37b12dead6d9e0e960ff1fc67fed0527f3 Mon Sep 17 00:00:00 2001 From: A_D Date: Mon, 31 May 2021 12:58:37 +0200 Subject: [PATCH 03/15] Started updating existing events with taxi info --- plugins/inara.py | 58 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/plugins/inara.py b/plugins/inara.py index 4c713d65..d76e6ea8 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -567,15 +567,32 @@ def journal_entry( # noqa: C901, CCR001 this.suppress_docked = False else: + to_send = { + 'starsystemName': system, + 'stationName': station, + 'shipType': state['ShipType'], + 'shipGameID': state['ShipID'], + } + + if entry.get('Taxi'): + # we're in a taxi, dont store ShipType or shipGameID + del to_send['shipType'] + del to_send['shipGameID'] + + # We were in a taxi. What kind? + if state['Dropship'] is not None and state['Dropship']: + to_send['isTaxiDropship'] = True + + elif state['Taxi'] is not None and state['Taxi']: + to_send['isTaxiShuttle'] = True + + else: # we dont know one way or another. Given we were told it IS a taxi, assume its a shuttle. + to_send['isTaxiShuttle'] = True + new_add_event( 'addCommanderTravelDock', entry['timestamp'], - { - 'starsystemName': system, - 'stationName': station, - 'shipType': state['ShipType'], - 'shipGameID': state['ShipID'], - } + to_send ) elif event_name == 'Undocked': @@ -599,15 +616,29 @@ def journal_entry( # noqa: C901, CCR001 elif event_name == 'FSDJump': this.undocked = False + to_send = { + 'starsystemName': entry['StarSystem'], + 'jumpDistance': entry['JumpDist'], + 'shipType': state['ShipType'], + 'shipGameID': state['ShipID'], + # TODO: coords for the starsystem + } + + if state['Taxi'] is not None and state['Taxi']: + del to_send['shipType'] + del to_send['shipGameID'] + + # taxi. What kind? + if state['Dropship'] is not None and state['Dropship']: + to_send['isTaxiDropship'] = True + + else: + to_send['isTaxiShuttle'] = True + new_add_event( 'addCommanderTravelFSDJump', entry['timestamp'], - { - 'starsystemName': entry['StarSystem'], - 'jumpDistance': entry['JumpDist'], - 'shipType': state['ShipType'], - 'shipGameID': state['ShipID'], - } + to_send ) if entry.get('Factions'): @@ -1040,13 +1071,12 @@ def journal_entry( # noqa: C901, CCR001 if state.get('ShipType') is not None: to_send_data['shipType'] = state['ShipType'] - # TODO: Can Touchdown ever show for either of these? I dont think so to_send_data['isTaxiShuttle'] = False to_send_data['isTaxiDropShip'] = False new_add_event('addCommanderTravelLand', entry['timestamp'], to_send_data) - # Community Goals + # Community Goals if event_name == 'CommunityGoal': # Remove any unsent this.filter_events( From d69d0245f21dbcef55de1d9a0f40533e0f43cd47 Mon Sep 17 00:00:00 2001 From: A_D Date: Mon, 31 May 2021 16:51:38 +0200 Subject: [PATCH 04/15] Implemented ship locker materials --- plugins/inara.py | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/plugins/inara.py b/plugins/inara.py index d76e6ea8..152864ce 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -589,6 +589,11 @@ def journal_entry( # noqa: C901, CCR001 else: # we dont know one way or another. Given we were told it IS a taxi, assume its a shuttle. to_send['isTaxiShuttle'] = True + if entry.get('MarketID') is not None: + to_send['marketID'] = entry['MarketID'] + + # TODO: we _can_ include a Body name here, but I'm not entirely sure how best to go about doing that + new_add_event( 'addCommanderTravelDock', entry['timestamp'], @@ -618,10 +623,10 @@ def journal_entry( # noqa: C901, CCR001 this.undocked = False to_send = { 'starsystemName': entry['StarSystem'], + 'starsystemCoords': entry['StarPos'], 'jumpDistance': entry['JumpDist'], 'shipType': state['ShipType'], 'shipGameID': state['ShipID'], - # TODO: coords for the starsystem } if state['Taxi'] is not None and state['Taxi']: @@ -652,16 +657,21 @@ def journal_entry( # noqa: C901, CCR001 ) elif event_name == 'CarrierJump': + to_send = { + 'starsystemName': entry['StarSystem'], + 'stationName': entry['StationName'], + 'marketID': entry['MarketID'], + 'shipType': state['ShipType'], + 'shipGameID': state['ShipID'], + } + + if entry.get('StarPos') is not None: + to_send['starsystemCoords'] = entry['StarPos'] + new_add_event( 'addCommanderTravelCarrierJump', entry['timestamp'], - { - 'starsystemName': entry['StarSystem'], - 'stationName': entry['StationName'], - 'marketID': entry['MarketID'], - 'shipType': state['ShipType'], - 'shipGameID': state['ShipID'], - } + to_send ) if entry.get('Factions'): @@ -1076,6 +1086,19 @@ def journal_entry( # noqa: C901, CCR001 new_add_event('addCommanderTravelLand', entry['timestamp'], to_send_data) + elif event_name == 'ShipLockerMaterials': + TYPES = ('Items', 'Components', 'Data', 'Consumables') + # we're getting new data here. so reset it on inara's side just to be sure that we set everything right + reset_data = [{'itemType': t} for t in TYPES] + set_data = [] + for typ in TYPES: + set_data.extend([ + {'itemName': thing['Name'], 'itemCount': thing['Count'], 'itemType': typ} for thing in entry[typ] + ]) + + new_add_event('resetCommanderInventory', entry['timestamp'], reset_data) + new_add_event('setCommanderInventory', entry['timestamp'], set_data) + # Community Goals if event_name == 'CommunityGoal': # Remove any unsent From a06095aba0de2fc44282ee2fb645af5c87650b48 Mon Sep 17 00:00:00 2001 From: A_D Date: Tue, 1 Jun 2021 09:42:41 +0200 Subject: [PATCH 05/15] Start on setCommanderSuitLoadout --- plugins/inara.py | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/plugins/inara.py b/plugins/inara.py index 152864ce..ee9e8cee 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -1087,11 +1087,11 @@ def journal_entry( # noqa: C901, CCR001 new_add_event('addCommanderTravelLand', entry['timestamp'], to_send_data) elif event_name == 'ShipLockerMaterials': - TYPES = ('Items', 'Components', 'Data', 'Consumables') + odyssey_nonplural_microresource_types = ('Items', 'Components', 'Data', 'Consumables') # we're getting new data here. so reset it on inara's side just to be sure that we set everything right - reset_data = [{'itemType': t} for t in TYPES] + reset_data = [{'itemType': t} for t in odyssey_nonplural_microresource_types] set_data = [] - for typ in TYPES: + for typ in odyssey_nonplural_microresource_types: set_data.extend([ {'itemName': thing['Name'], 'itemCount': thing['Count'], 'itemType': typ} for thing in entry[typ] ]) @@ -1099,6 +1099,33 @@ def journal_entry( # noqa: C901, CCR001 new_add_event('resetCommanderInventory', entry['timestamp'], reset_data) new_add_event('setCommanderInventory', entry['timestamp'], set_data) + elif event_name in ('CreateSuitLoadout', 'SuitLoadout'): + # CreateSuitLoadout and SuitLoadout are pretty much the same event: + # ╙─╴% cat Journal.* | jq 'select(.event == "SuitLoadout" or .event == "CreateSuitLoadout") | keys' -c \ + # | uniq + # + # ["LoadoutID","LoadoutName","Modules","SuitID","SuitMods","SuitName","SuitName_Localised","event", + # "timestamp"] + + to_send = { + 'loadoutGameID': entry['LoadoutID'], + 'loadoutName': entry['LoadoutName'], + 'suitGameID': entry['SuitID'], + 'suitType': entry['SuitName'], + 'suitMods': entry['SuitMods'], + 'suitLoadout': [ + { + 'slotName': x['SlotName'], + 'itemName': x['ModuleName'], + 'itemClass': x['Class'], + 'itemGameID': x['SuitModuleID'], + 'engineering': x['WeaponMods'], # TODO: Verify. + } for x in entry['Modules'] + ], + } + + new_add_event('setCommanderSuitLoadout', entry['timestamp'], to_send) + # Community Goals if event_name == 'CommunityGoal': # Remove any unsent From 41c826f53667ae5f0d4c65f91517f0821987b75a Mon Sep 17 00:00:00 2001 From: A_D Date: Tue, 1 Jun 2021 14:31:34 +0200 Subject: [PATCH 06/15] delCommanderSuitLoadout done, update in-progress --- plugins/inara.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/plugins/inara.py b/plugins/inara.py index ee9e8cee..f6cbdf2c 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -1126,7 +1126,38 @@ def journal_entry( # noqa: C901, CCR001 new_add_event('setCommanderSuitLoadout', entry['timestamp'], to_send) - # Community Goals + elif event_name == 'DeleteSuitLoadout': + new_add_event('delCommanderSuitLoadout', entry['timestamp'], {'loadoutGameID': entry['LoadoutID']}) + + elif event_name == 'RenameSuitLoadout': + to_send = { + 'loadoutGameID': entry['LoadoutID'], + 'loadoutName': entry['LoadoutName'], + # may as well... + 'suitType': entry['SuitName'], + 'suitGameID': entry['SuitID'] + } + new_add_event('updateCommanderSuitLoadout', entry['timestamp'], {}) + + elif event_name == 'LoadoutEquipModule': + to_send = { + 'loadoutGameID': entry['LoadoutID'], + 'loadoutName': entry['LoadoutName'], + 'suitType': entry['SuitName'], + 'suitGameID': entry['SuitID'], + 'suitLoadout': [ + { + 'slotName': entry['SlotName'], + 'itemName': entry['ModuleName'], + 'itemGameID': entry['SuitModuleID'], + # TODO: As of 4.0.0.200, this event does *NOT* include the class + } + ], + } + + new_add_event('updateCommanderSuitLoadout', entry['timestamp'], to_send) + + # Community Goals if event_name == 'CommunityGoal': # Remove any unsent this.filter_events( From c737753a8b534df05859b61040758c7e5f068fda Mon Sep 17 00:00:00 2001 From: A_D Date: Tue, 1 Jun 2021 14:32:17 +0200 Subject: [PATCH 07/15] Fixed comment --- plugins/inara.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/inara.py b/plugins/inara.py index f6cbdf2c..e5b4f53f 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -1157,7 +1157,7 @@ def journal_entry( # noqa: C901, CCR001 new_add_event('updateCommanderSuitLoadout', entry['timestamp'], to_send) - # Community Goals + # Community Goals if event_name == 'CommunityGoal': # Remove any unsent this.filter_events( From 2f684a91e3777e08ea25c451e8256af964687178 Mon Sep 17 00:00:00 2001 From: A_D Date: Wed, 2 Jun 2021 11:57:28 +0200 Subject: [PATCH 08/15] removed monitor.planet use --- monitor.py | 24 ++++++++++++++++++++++++ plugins/inara.py | 7 +++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/monitor.py b/monitor.py index 5138cba2..56144c03 100644 --- a/monitor.py +++ b/monitor.py @@ -162,6 +162,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below 'SuitLoadouts': {}, 'Taxi': None, # True whenever we are _in_ a taxi. ie, this is reset on Disembark etc. 'Dropship': None, # Best effort as to whether or not the above taxi is a dropship. + 'Body': None, } def start(self, root: 'tkinter.Tk') -> bool: # noqa: CCR001 @@ -263,6 +264,8 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.systemaddress = None self.is_beta = False self.state['OnFoot'] = False + self.state['Body'] = None + self.state['BodyType'] = None if self.observed: logger.debug('self.observed: Calling unschedule_all()') @@ -539,6 +542,8 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below 'Role': None, 'Taxi': None, 'Dropship': None, + 'Body': None, + 'BodyType': None, }) if entry.get('Ship') is not None and self._RE_SHIP_ONFOOT.search(entry['Ship']): self.state['OnFoot'] = True @@ -729,12 +734,16 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below # • OnFoot: bool if event_type in ('Location', 'CarrierJump'): self.planet = entry.get('Body') if entry.get('BodyType') == 'Planet' else None + self.state['Body'] = entry.get('Body') + self.state['BodyType'] = entry.get('BodyType') # if event_type == 'Location': # logger.trace('"Location" event') elif event_type == 'FSDJump': self.planet = None + self.state['Body'] = None + self.state['BodyType'] = None if 'StarPos' in entry: self.coordinates = tuple(entry['StarPos']) # type: ignore @@ -762,9 +771,13 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below elif event_type == 'ApproachBody': self.planet = entry['Body'] + self.state['Body'] = entry['Body'] + self.state['BodyType'] = 'Planet' # Best guess. Journal says always planet. elif event_type in ('LeaveBody', 'SupercruiseEntry'): self.planet = None + self.state['Body'] = None + self.state['BodyType'] = None elif event_type in ('Rank', 'Promotion'): payload = dict(entry) @@ -1516,6 +1529,9 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.systemaddress = None self.state['OnFoot'] = False + self.state['Body'] = None + self.state['BodyType'] = None + elif event_type == 'ChangeCrewRole': self.state['Role'] = entry['Role'] @@ -1530,6 +1546,9 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.stationservices = None self.coordinates = None self.systemaddress = None + + self.state['Body'] = None + self.state['BodyType'] = None # TODO: on_foot: Will we get an event after this to know ? elif event_type == 'Friends': @@ -1611,6 +1630,11 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below elif event_type == 'Resurrect': self.state['Credits'] -= entry.get('Cost', 0) + # HACK (not game related / 2021-06-2): self.planet is moved into a more general self.state['Body']. + # This exists to help plugins doing what they SHOULDN'T BE cope. It will be removed at some point. + if self.state['Body'] is None or self.state['BodyType'] == 'Planet': + self.planet = self.state['Body'] + return entry except Exception as ex: diff --git a/plugins/inara.py b/plugins/inara.py index e5b4f53f..2893de8c 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -20,8 +20,6 @@ import timeout_session from companion import CAPIData from config import applongname, appversion, config from EDMCLogging import get_main_logger -# Yes I know. Im using it for `monitor.planet` Which probably should be rolled into state as a body and bodyType pair -from monitor import monitor from ttkHyperlinkLabel import HyperlinkLabel logger = get_main_logger() @@ -1046,7 +1044,7 @@ def journal_entry( # noqa: C901, CCR001 to_send_data: Optional[Dict[str, Any]] = {} # This is a glorified sentinel until lower down. # On Horizons, neither of these exist on TouchDown star_system_name = entry.get('StarSystem', this.system) - body_name = entry.get('Body', monitor.planet) + body_name = entry.get('Body', state['Body'] if state['BodyType'] == 'Planet' else None) if star_system_name is None: logger.warning('Refusing to update addCommanderTravelLand as we dont have a StarSystem!') @@ -1150,7 +1148,8 @@ def journal_entry( # noqa: C901, CCR001 'slotName': entry['SlotName'], 'itemName': entry['ModuleName'], 'itemGameID': entry['SuitModuleID'], - # TODO: As of 4.0.0.200, this event does *NOT* include the class + 'itemClass': entry['Class'], + 'engineering': [], # TODO: Check casing of names for this } ], } From 71afdf0bdb2afd444c6b6cbd9134eaf97b143500 Mon Sep 17 00:00:00 2001 From: A_D Date: Wed, 2 Jun 2021 11:58:33 +0200 Subject: [PATCH 09/15] Added missing BodyType init --- monitor.py | 1 + 1 file changed, 1 insertion(+) diff --git a/monitor.py b/monitor.py index 56144c03..f9085eee 100644 --- a/monitor.py +++ b/monitor.py @@ -163,6 +163,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below 'Taxi': None, # True whenever we are _in_ a taxi. ie, this is reset on Disembark etc. 'Dropship': None, # Best effort as to whether or not the above taxi is a dropship. 'Body': None, + 'BodyType': None, } def start(self, root: 'tkinter.Tk') -> bool: # noqa: CCR001 From 571db432578ccbc97c36fbeba3a44d8a27dc657d Mon Sep 17 00:00:00 2001 From: A_D Date: Wed, 2 Jun 2021 12:28:06 +0200 Subject: [PATCH 10/15] Update Engineering for suits --- plugins/inara.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/inara.py b/plugins/inara.py index 2893de8c..5fb27f4f 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -1110,14 +1110,14 @@ def journal_entry( # noqa: C901, CCR001 'loadoutName': entry['LoadoutName'], 'suitGameID': entry['SuitID'], 'suitType': entry['SuitName'], - 'suitMods': entry['SuitMods'], + 'suitMods': [{'blueprintName': mod} for mod in entry['SuitMods']], 'suitLoadout': [ { 'slotName': x['SlotName'], 'itemName': x['ModuleName'], 'itemClass': x['Class'], 'itemGameID': x['SuitModuleID'], - 'engineering': x['WeaponMods'], # TODO: Verify. + 'engineering': [{'blueprintName': mod} for mod in x['WeaponMods']], } for x in entry['Modules'] ], } @@ -1149,7 +1149,7 @@ def journal_entry( # noqa: C901, CCR001 'itemName': entry['ModuleName'], 'itemGameID': entry['SuitModuleID'], 'itemClass': entry['Class'], - 'engineering': [], # TODO: Check casing of names for this + 'engineering': [{'blueprintName': mod} for mod in entry['WeaponMods']], } ], } From 2a68b81170d7997cec0fc4cc285f648840361fe6 Mon Sep 17 00:00:00 2001 From: A_D Date: Wed, 2 Jun 2021 12:32:32 +0200 Subject: [PATCH 11/15] Fixed broken suitMods field --- plugins/inara.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/inara.py b/plugins/inara.py index 5fb27f4f..1c30cee8 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -587,7 +587,7 @@ def journal_entry( # noqa: C901, CCR001 else: # we dont know one way or another. Given we were told it IS a taxi, assume its a shuttle. to_send['isTaxiShuttle'] = True - if entry.get('MarketID') is not None: + if 'MarketID' in entry: to_send['marketID'] = entry['MarketID'] # TODO: we _can_ include a Body name here, but I'm not entirely sure how best to go about doing that @@ -663,7 +663,7 @@ def journal_entry( # noqa: C901, CCR001 'shipGameID': state['ShipID'], } - if entry.get('StarPos') is not None: + if 'StarPos' in entry: to_send['starsystemCoords'] = entry['StarPos'] new_add_event( @@ -1110,7 +1110,7 @@ def journal_entry( # noqa: C901, CCR001 'loadoutName': entry['LoadoutName'], 'suitGameID': entry['SuitID'], 'suitType': entry['SuitName'], - 'suitMods': [{'blueprintName': mod} for mod in entry['SuitMods']], + 'suitMods': entry['SuitMods'], 'suitLoadout': [ { 'slotName': x['SlotName'], From 6a02b6efc750323f4fd6e5664bec297a1836f5b0 Mon Sep 17 00:00:00 2001 From: A_D Date: Wed, 2 Jun 2021 13:00:49 +0200 Subject: [PATCH 12/15] Fixed taxi log --- monitor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitor.py b/monitor.py index f9085eee..215b76bb 100644 --- a/monitor.py +++ b/monitor.py @@ -705,7 +705,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.station = None self.state['OnFoot'] = True - if self.state['Taxi'] is not None and not self.state['Taxi']: + if self.state['Taxi'] is not None and self.state['Taxi'] != entry.get('Taxi', False): logger.warning('Disembarked from a taxi but we didn\'t know we were in a taxi?') self.state['Taxi'] = False From 86de3769d2661b715921fd46c5ae639e79066023 Mon Sep 17 00:00:00 2001 From: A_D Date: Wed, 2 Jun 2021 13:15:57 +0200 Subject: [PATCH 13/15] Fixed nonplural var containing plural names --- plugins/inara.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/inara.py b/plugins/inara.py index 1c30cee8..f9b202de 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -1085,11 +1085,11 @@ def journal_entry( # noqa: C901, CCR001 new_add_event('addCommanderTravelLand', entry['timestamp'], to_send_data) elif event_name == 'ShipLockerMaterials': - odyssey_nonplural_microresource_types = ('Items', 'Components', 'Data', 'Consumables') + odyssey_plural_microresource_types = ('Items', 'Components', 'Data', 'Consumables') # we're getting new data here. so reset it on inara's side just to be sure that we set everything right - reset_data = [{'itemType': t} for t in odyssey_nonplural_microresource_types] + reset_data = [{'itemType': t} for t in odyssey_plural_microresource_types] set_data = [] - for typ in odyssey_nonplural_microresource_types: + for typ in odyssey_plural_microresource_types: set_data.extend([ {'itemName': thing['Name'], 'itemCount': thing['Count'], 'itemType': typ} for thing in entry[typ] ]) From 8a94a57e781d73641531d18316dda787ceffb2ef Mon Sep 17 00:00:00 2001 From: A_D Date: Wed, 2 Jun 2021 21:46:52 +0200 Subject: [PATCH 14/15] Removed debug warnings and bool --- plugins/inara.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugins/inara.py b/plugins/inara.py index f9b202de..0577d626 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -1432,7 +1432,6 @@ def new_worker(): 'APIkey': creds.api_key, 'commanderName': creds.cmdr, 'commanderFrontierID': creds.fid, - 'isBeingDeveloped': True, # TODO: Remove once update is complete }, 'events': [ {'eventName': e.name, 'eventTimestamp': e.timestamp, 'eventData': e.data} for e in event_list @@ -1489,9 +1488,6 @@ def send_data(url: str, data: Mapping[str, Any]) -> bool: # noqa: CCR001 :param data: the data to POST :return: success state """ - # TODO: Remove this. Its here to ensure we dont forget that we're running test code - for x in range(20): - logger.info("INARA IS SENDING HEADERS THAT INDICATE DEV MODE!!!!!!!!!!!!!!!!!!!!!!!!!") r = this.session.post(url, data=json.dumps(data, separators=(',', ':')), timeout=_TIMEOUT) r.raise_for_status() From 607729b77bfd91ed72bbdc5e8a999ee289a6dddc Mon Sep 17 00:00:00 2001 From: A_D Date: Fri, 4 Jun 2021 00:15:57 +0200 Subject: [PATCH 15/15] added setCommanderTravelLocation from Location event --- plugins/inara.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/plugins/inara.py b/plugins/inara.py index 0577d626..c6795bd0 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -1156,6 +1156,27 @@ def journal_entry( # noqa: C901, CCR001 new_add_event('updateCommanderSuitLoadout', entry['timestamp'], to_send) + elif event_name == "Location": + to_send = { + 'starsystemName': entry['StarSystem'], + 'starsystemCoords': entry['StarPos'], + } + + if entry['Docked']: + to_send['stationName'] = entry['StationName'] + to_send['marketID'] = entry['MarketID'] + + if entry['Docked'] and entry['BodyType'] == 'Planet': + # we're Docked, but we're not on a Station, thus we're docked at a planetary base of some kind + # and thus, we SHOULD include starsystemBodyName + to_send['starsystemBodyName'] = entry['Body'] + + if 'Longitude' in entry and 'Latitude' in entry: + # These were included thus we are landed + to_send['starsystemBodyCoords'] = [entry['Latitude'], entry['Longitude']] + + new_add_event('setCommanderTravelLocation', entry['timestamp'], to_send) + # Community Goals if event_name == 'CommunityGoal': # Remove any unsent