From c867d4c282186b76335a0caeafbd74c3c9143ffa Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sat, 1 May 2021 10:14:35 +0100 Subject: [PATCH 01/12] CAPI: Don't auto-update on Taxi `Docked`, but do on `Disembark` in-station Closes #1016 --- EDMarketConnector.py | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index 30ddc857..8c11b1fd 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -1109,14 +1109,29 @@ class AppWindow(object): if not config.get_int('hotkey_mute'): hotkeymgr.play_bad() - # Auto-Update after docking, but not if auth callback is pending - if ( - entry['event'] in ('StartUp', 'Location', 'Docked') - and monitor.station - and not config.get_int('output') & config.OUT_MKT_MANUAL - and config.get_int('output') & config.OUT_STATION_ANY - and companion.session.state != companion.Session.STATE_AUTH - ): + auto_update = False + # Only if auth callback is not pending + if companion.session.state != companion.Session.STATE_AUTH: + # Only if configured to do so + if (not config.get_int('output') & config.OUT_MKT_MANUAL + and config.get_int('output') & config.OUT_STATION_ANY): + if entry['event'] in ('StartUp', 'Location', 'Docked') and monitor.station: + # TODO: Can you log out in a docked Taxi and then back in to + # the taxi, so 'Location' should be covered here too ? + if entry['event'] == 'Docked' and entry.get('Taxi'): + # In Odyssey there's a 'Docked' event for an Apex taxi, + # but the CAPI data isn't updated until you Disembark. + auto_update = False + + else: + auto_update = True + + # In Odyssey if you are in a Taxi the `Docked` event for it is before + # the CAPI data is updated, but CAPI *is* updated after you `Disembark`. + elif entry['event'] == 'Disembark' and entry.get('Taxi') and entry.get('OnStation'): + auto_update = True + + if auto_update: self.w.after(int(SERVER_RETRY * 1000), self.getandsend) if entry['event'] == 'ShutDown': From 3ab8b97562d8da81adf499cc181361e65c39f59b Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sat, 1 May 2021 10:19:10 +0100 Subject: [PATCH 02/12] Suits: We might not know about SuitLoadout being switched to --- monitor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitor.py b/monitor.py index d7714d53..f7ebc937 100644 --- a/monitor.py +++ b/monitor.py @@ -947,7 +947,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.state['SuitLoadoutCurrent'] = self.state['SuitLoadouts'][f'{new_slot}'] except KeyError: - logger.exception(f"Getting suit loadout after switch, bad slot: {new_slot} ({loadoutid})") + logger.debug(f"Getting suit loadout after switch, bad slot: {new_slot} ({loadoutid})") # Might mean that a new suit loadout was created and we need a new CAPI fetch ? self.state['SuitCurrent'] = None self.state['SuitLoadoutCurrent'] = None From 0e18666054835cd481af39246febe4fe3bb900a9 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sat, 1 May 2021 10:25:39 +0100 Subject: [PATCH 03/12] Suits: Only process `SwitchSuitLoadout` if we know about Suits and Loadouts --- monitor.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/monitor.py b/monitor.py index f7ebc937..d80262f0 100644 --- a/monitor.py +++ b/monitor.py @@ -943,28 +943,30 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below # ◦ ModuleName loadoutid = entry['LoadoutID'] new_slot = self.suit_loadout_id_from_loadoutid(loadoutid) - try: - self.state['SuitLoadoutCurrent'] = self.state['SuitLoadouts'][f'{new_slot}'] - - except KeyError: - logger.debug(f"Getting suit loadout after switch, bad slot: {new_slot} ({loadoutid})") - # Might mean that a new suit loadout was created and we need a new CAPI fetch ? - self.state['SuitCurrent'] = None - self.state['SuitLoadoutCurrent'] = None - - else: + # If this application is run with the latest Journal showing such an event then we won't + # yet have the CAPI data, so no idea about Suits or Loadouts. + if self.state['Suits'] and self.state['SuitLoadouts']: try: - new_suitid = self.state['SuitLoadoutCurrent']['suit']['suitId'] + self.state['SuitLoadoutCurrent'] = self.state['SuitLoadouts'][f'{new_slot}'] except KeyError: - logger.exception(f"Getting switched-to suit ID from slot {new_slot} ({loadoutid})") + logger.debug(f"KeyError getting suit loadout after switch, bad slot: {new_slot} ({loadoutid})") + self.state['SuitCurrent'] = None + self.state['SuitLoadoutCurrent'] = None else: try: - self.state['SuitCurrent'] = self.state['Suits'][f'{new_suitid}'] + new_suitid = self.state['SuitLoadoutCurrent']['suit']['suitId'] except KeyError: - logger.exception(f"Getting switched-to suit from slot {new_slot} ({loadoutid}") + logger.debug(f"KeyError getting switched-to suit ID from slot {new_slot} ({loadoutid})") + + else: + try: + self.state['SuitCurrent'] = self.state['Suits'][f'{new_suitid}'] + + except KeyError: + logger.debug(f"KeyError getting switched-to suit from slot {new_slot} ({loadoutid}") elif event_type == 'CreateSuitLoadout': # We know we won't have data for this new one From 81104ca973f21093ea5365186985504a7d330752 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sat, 1 May 2021 10:31:08 +0100 Subject: [PATCH 04/12] Suits: Only debug log if we can't find loadout for DeleteSuitLoadout --- monitor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitor.py b/monitor.py index d80262f0..666301b8 100644 --- a/monitor.py +++ b/monitor.py @@ -1014,7 +1014,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below except KeyError: # This should no longer happen, as we're now handling CreateSuitLoadout properly - logger.exception(f"loadout slot id {loadout_id} doesn't exist, not in last CAPI pull ?") + logger.debug(f"loadout slot id {loadout_id} doesn't exist, not in last CAPI pull ?") elif event_type == 'RenameSuitLoadout': # alpha4 From 751002bf1a0f35454801f9e0744fab7e90a53f4e Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sat, 1 May 2021 10:42:54 +0100 Subject: [PATCH 05/12] Suits: Guards for if we don't have CAPI data yet We still need each try/except in case: 1. Journal has you buying a suit, or creating a SuitLoadout. 2. It then has you selling/deleting a different one. 3. But no CAPI data yet, so we don't know about that different one. --- monitor.py | 86 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/monitor.py b/monitor.py index 666301b8..58f975c8 100644 --- a/monitor.py +++ b/monitor.py @@ -929,18 +929,6 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.state['BackPack']['Consumable'][c] = 0 elif event_type == 'SwitchSuitLoadout': - # alpha4 - # This event is logged when a player selects a different flight suit from the ship’s locker - # - # Parameters: - # • SuitID - # • SuitName - # • LoadoutID - # • LoadoutName - # • Modules: array of objects - # ◦ SlotName - # ◦ SuitModuleID - # ◦ ModuleName loadoutid = entry['LoadoutID'] new_slot = self.suit_loadout_id_from_loadoutid(loadoutid) # If this application is run with the latest Journal showing such an event then we won't @@ -1008,13 +996,14 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below # "SuitName":"explorationsuit_class1", "SuitName_Localised":"Artemis Suit", "LoadoutID":4293000003, # "LoadoutName":"Loadout 1" } - loadout_id = self.suit_loadout_id_from_loadoutid(entry['LoadoutID']) - try: - self.state['SuitLoadouts'].pop(f'{loadout_id}') + if self.state['SuitLoadouts']: + loadout_id = self.suit_loadout_id_from_loadoutid(entry['LoadoutID']) + try: + self.state['SuitLoadouts'].pop(f'{loadout_id}') - except KeyError: - # This should no longer happen, as we're now handling CreateSuitLoadout properly - logger.debug(f"loadout slot id {loadout_id} doesn't exist, not in last CAPI pull ?") + except KeyError: + # This should no longer happen, as we're now handling CreateSuitLoadout properly + logger.debug(f"loadout slot id {loadout_id} doesn't exist, not in last CAPI pull ?") elif event_type == 'RenameSuitLoadout': # alpha4 @@ -1027,12 +1016,13 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below # { "timestamp":"2021-04-29T10:35:55Z", "event":"RenameSuitLoadout", "SuitID":1698365752966423, # "SuitName":"explorationsuit_class1", "SuitName_Localised":"Artemis Suit", "LoadoutID":4293000003, # "LoadoutName":"Art L/K" } - loadout_id = self.suit_loadout_id_from_loadoutid(entry['LoadoutID']) - try: - self.state['SuitLoadouts'][loadout_id]['name'] = entry['LoadoutName'] + if self.state['SuitLoadouts']: + loadout_id = self.suit_loadout_id_from_loadoutid(entry['LoadoutID']) + try: + self.state['SuitLoadouts'][loadout_id]['name'] = entry['LoadoutName'] - except KeyError: - logger.exception(f"loadout slot id {loadout_id} doesn't exist, not in last CAPI pull ?") + except KeyError: + logger.debug(f"loadout slot id {loadout_id} doesn't exist, not in last CAPI pull ?") elif event_type == 'BuySuit': # alpha4 : @@ -1067,18 +1057,19 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below # alpha4: # { "timestamp":"2021-04-29T09:15:51Z", "event":"SellSuit", "SuitID":1698364937435505, # "Name":"explorationsuit_class1", "Name_Localised":"Artemis Suit", "Price":90000 } - try: - self.state['Suits'].pop(entry['SuitID']) + if self.state['Suits']: + try: + self.state['Suits'].pop(entry['SuitID']) - except KeyError: - logger.exception(f"SellSuit for a suit we didn't know about? {entry['SuitID']}") + except KeyError: + logger.debug(f"SellSuit for a suit we didn't know about? {entry['SuitID']}") - # update credits total - if price := entry.get('Price') is None: - logger.error(f"SellSuit didn't contain Price: {entry}") + # update credits total + if price := entry.get('Price') is None: + logger.error(f"SellSuit didn't contain Price: {entry}") - else: - self.state['Credits'] += price + else: + self.state['Credits'] += price elif event_type == 'UpgradeSuit': # alpha4 @@ -1091,6 +1082,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below # • Cost # Update credits total ? It shouldn't even involve credits! # Actual alpha4 - need to grind mats + # if self.state['Suits']: pass elif event_type == 'LoadoutEquipModule': @@ -1099,14 +1091,19 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below # "SuitID":1698364940285172, "SuitName":"tacticalsuit_class1", "SuitName_Localised":"Dominator Suit", # "LoadoutID":4293000001, "SlotName":"PrimaryWeapon2", "ModuleName":"wpn_m_assaultrifle_laser_fauto", # "ModuleName_Localised":"TK Aphelion", "SuitModuleID":1698372938719590 } - loadout_id = self.suit_loadout_id_from_loadoutid(entry['LoadoutID']) - self.state['SuitLoadouts'][loadout_id]['slots'][entry['SlotName']] = { - 'name': entry['ModuleName'], - 'locName': entry.get('ModuleName_Localised', entry['ModuleName']), - 'id': None, - 'weaponrackId': entry['SuitModuleID'], - 'locDescription': '', - } + if self.state['SuitLoadouts']: + loadout_id = self.suit_loadout_id_from_loadoutid(entry['LoadoutID']) + try: + self.state['SuitLoadouts'][loadout_id]['slots'][entry['SlotName']] = { + 'name': entry['ModuleName'], + 'locName': entry.get('ModuleName_Localised', entry['ModuleName']), + 'id': None, + 'weaponrackId': entry['SuitModuleID'], + 'locDescription': '', + } + + except KeyError: + logger.error(f"LoadoutEquipModule: {entry}") elif event_type == 'LoadoutRemoveModule': # alpha4 - triggers if selecting an already-equipped weapon into a different slot @@ -1114,8 +1111,13 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below # "SuitID":1698364940285172, "SuitName":"tacticalsuit_class1", "SuitName_Localised":"Dominator Suit", # "LoadoutID":4293000001, "SlotName":"PrimaryWeapon1", "ModuleName":"wpn_m_assaultrifle_laser_fauto", # "ModuleName_Localised":"TK Aphelion", "SuitModuleID":1698372938719590 } - loadout_id = self.suit_loadout_id_from_loadoutid(entry['LoadoutID']) - self.state['SuitLoadouts'][loadout_id]['slots'].pop(entry['SlotName']) + if self.state['SuitLoadouts']: + loadout_id = self.suit_loadout_id_from_loadoutid(entry['LoadoutID']) + try: + self.state['SuitLoadouts'][loadout_id]['slots'].pop(entry['SlotName']) + + except KeyError: + logger.error(f"LoadoutRemoveModule: {entry}") elif event_type == 'BuyWeapon': # alpha4 From d74b88658702554baa099e0b20331b83adb9e2bc Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sat, 1 May 2021 10:46:25 +0100 Subject: [PATCH 06/12] Update credits for `SellOrganicData` --- monitor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monitor.py b/monitor.py index 58f975c8..b1a8f987 100644 --- a/monitor.py +++ b/monitor.py @@ -1165,8 +1165,8 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below pass elif event_type == 'SellOrganicData': - # alpha4 - update current credits ? - pass + for bd in entry['BioData']: + self.state['Credits'] += bd['Value'] + bd['Bonus'] # alpha4 - Credits updates elif event_type == 'BookDropship': From 77d96f61c7a1205d81a04da1f0b66b7954e78a0a Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sat, 1 May 2021 10:50:20 +0100 Subject: [PATCH 07/12] Odyssey Credits: Update for book/cancel Taxi/Dropship --- monitor.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/monitor.py b/monitor.py index b1a8f987..28d19317 100644 --- a/monitor.py +++ b/monitor.py @@ -1168,15 +1168,17 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below for bd in entry['BioData']: self.state['Credits'] += bd['Value'] + bd['Bonus'] - # alpha4 - Credits updates elif event_type == 'BookDropship': - pass + self.state['Credits'] -= entry['Cost'] + elif event_type == 'BookTaxi': - pass + self.state['Credits'] -= entry['Cost'] + elif event_type == 'CancelDropship': - pass + self.state['Credits'] += entry['Refund'] + elif event_type == 'CancelTaxi': - pass + self.state['Credits'] += entry['Refund'] elif event_type == 'NavRoute': # Added in ED 3.7 - multi-hop route details in NavRoute.json From 812398ee0d46ce13bfe86bf2a5bd4d398626311e Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sat, 1 May 2021 12:03:45 +0100 Subject: [PATCH 08/12] Credits: Review and add/tweak code for all Journal events There are a few where either the v30 Journal doc is wrong/has an ommision, or we genuinely don't get the required information. --- monitor.py | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 108 insertions(+), 3 deletions(-) diff --git a/monitor.py b/monitor.py index 28d19317..e6a873e8 100644 --- a/monitor.py +++ b/monitor.py @@ -552,6 +552,8 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.state['Rebuy'] = None self.state['Modules'] = None + self.state['Credits'] -= entry['ShipPrice'] + elif event_type == 'ShipyardSwap': self.state['ShipID'] = entry['ShipID'] self.state['ShipIdent'] = None @@ -602,8 +604,21 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below 'Value': entry['BuyPrice'], } + self.state['Credits'] -= entry['BuyPrice'] + + elif event_type == 'ModuleRetrieve': + self.state['Credits'] -= entry['Cost'] + elif event_type == 'ModuleSell': self.state['Modules'].pop(entry['Slot'], None) + self.state['Credits'] += entry['SellPrice'] + + elif event_type == 'ModuleSellRemote': + self.state['Credits'] += entry['SellPrice'] + + elif event_type == 'ModuleStore': + self.state['Modules'].pop(entry['Slot'], None) + self.state['Credits'] -= entry['Cost'] elif event_type == 'ModuleSwap': to_item = self.state['Modules'].get(entry['ToSlot']) @@ -767,6 +782,10 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.state['Cargo'].update({self.canonicalise(x['Name']): x['Count'] for x in clean}) + elif event_type == 'CargoTransfer': + # TODO: Transfers between ship and FC/SRV + pass + elif event_type == 'ShipLockerMaterials': # This event has the current totals, so drop any current data self.state['Component'] = defaultdict(int) @@ -836,15 +855,16 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below elif event_type == 'BuyMicroResources': # Buying from a Pioneer Supplies, goes directly to ShipLocker. # One event per Item, not an array. - # alpha4 - update current credits ? category = self.category(entry['Category']) name = self.canonicalise(entry['Name']) self.state[category][name] += entry['Count'] + self.state['Credits'] -= entry['Price'] + elif event_type == 'SellMicroResources': # Selling to a Bar Tender on-foot. + self.state['Credits'] += entry['Price'] # One event per whole sale, so it's an array. - # alpha4 - update current credits ? for mr in entry['MicroResources']: category = self.category(mr['Category']) name = self.canonicalise(mr['Name']) @@ -1157,7 +1177,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below elif event_type == 'UpgradeWeapon': # We're not actually keeping track of all owned weapons, only those in # Suit Loadouts. - # alpha4 + # alpha4 - credits? Shouldn't cost any! pass elif event_type == 'ScanOrganic': @@ -1207,6 +1227,12 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below commodity = self.canonicalise(entry['Type']) self.state['Cargo'][commodity] += entry.get('Count', 1) + if event_type == 'BuyDrones': + self.state['Credits'] -= entry['TotalCost'] + + elif event_type == 'MarketBuy': + self.state['Credits'] -= entry['TotalCost'] + elif event_type in ('EjectCargo', 'MarketSell', 'SellDrones'): commodity = self.canonicalise(entry['Type']) cargo = self.state['Cargo'] @@ -1214,6 +1240,12 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below if cargo[commodity] <= 0: cargo.pop(commodity) + if event_type == 'MarketSell': + self.state['Credits'] += entry['TotalSale'] + + elif event_type == 'SellDrones': + self.state['Credits'] += entry['TotalSale'] + elif event_type == 'SearchAndRescue': for item in entry.get('Items', []): commodity = self.canonicalise(item['Name']) @@ -1295,6 +1327,8 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below module['Engineering'].pop('ExperimentalEffect_Localised', None) elif event_type == 'MissionCompleted': + self.state['Credits'] += entry['Reward'] + for reward in entry.get('CommodityReward', []): commodity = self.canonicalise(reward['Name']) self.state['Cargo'][commodity] += reward.get('Count', 1) @@ -1378,6 +1412,77 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below else: self.state['Friends'].discard(entry['Name']) + # Try to keep Credits total updated + elif event_type in ('MultiSellExplorationData', 'SellExplorationData'): + self.state['Credits'] += entry['TotalEarnings'] + + elif event_type == 'BuyExplorationData': + self.state['Credits'] -= entry['Cost'] + + elif event_type == 'BuyTradeData': + self.state['Credits'] -= entry['Cost'] + + elif event_type == 'BuyAmmo': + self.state['Credits'] -= entry['Cost'] + + elif event_type == 'CommunityGoalReward': + self.state['Credits'] += entry['Reward'] + + elif event_type == 'CrewHire': + self.state['Credits'] -= entry['Cost'] + + elif event_type == 'FetchRemoteModule': + self.state['Credits'] -= entry['TransferCost'] + + elif event_type == 'MissionAbandoned': + # Is this paid at this point, or just a fine to pay later ? + # self.state['Credits'] -= entry['Fine'] + pass + + elif event_type in ('PayBounties', 'PayFines', 'PayLegacyFines'): + self.state['Credits'] -= entry['Amount'] + + elif event_type == 'RedeemVoucher': + self.state['Credits'] += entry['Amount'] + + elif event_type in ('RefuelAll', 'RefuelPartial', 'Repair', 'RepairAll', 'RestockVehicle'): + self.state['Credits'] -= entry['Cost'] + + elif event_type == 'SellShipOnRebuy': + self.state['Credits'] += entry['ShipPrice'] + + elif event_type == 'ShipyardSell': + self.state['Credits'] += entry['ShipPrice'] + + elif event_type == 'ShipyardTransfer': + self.state['Credits'] -= entry['TransferPrice'] + + elif event_type == 'PowerplayFastTrack': + self.state['Credits'] -= entry['Cost'] + + elif event_type == 'PowerplaySalary': + self.state['Credits'] += entry['Amount'] + + elif event_type == 'SquadronCreated': + # v30 docs don't actually say anything about credits cost + pass + + elif event_type == 'CarrierBuy': + self.state['Credits'] -= entry['Price'] + + elif event_type == 'CarrierBankTransfer': + self.state['Credits'] = entry['PlayerBalance'] + + elif event_type == 'CarrierDecommission': + # v30 doc says nothing about citing the refund amount + pass + + elif event_type == 'NpcCrewPaidWage': + self.state['Credits'] -= entry['Amount'] + + elif event_type == 'Resurrect': + self.state['Credits'] -= entry['Cost'] + return entry except Exception as ex: From 7c7609f2ee70750ba5f44192a76c1d434d4d87cb Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sat, 1 May 2021 12:15:57 +0100 Subject: [PATCH 09/12] Cargo: Update ship cargo on `CargoTransfer` event We missed this when it was brought in with Fleet Carriers in 2020. --- monitor.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/monitor.py b/monitor.py index e6a873e8..8bb9cd8b 100644 --- a/monitor.py +++ b/monitor.py @@ -783,8 +783,14 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.state['Cargo'].update({self.canonicalise(x['Name']): x['Count'] for x in clean}) elif event_type == 'CargoTransfer': - # TODO: Transfers between ship and FC/SRV - pass + for c in entry['Transfers']: + name = self.canonicalise(c['Type']) + if c['Direction'] == 'toship': + self.state['Cargo'][name] += c['Count'] + + else: + # So it's *from* the ship + self.state['Cargo'][name] -= c['Count'] elif event_type == 'ShipLockerMaterials': # This event has the current totals, so drop any current data From f6cb69ebadb2d8d60d2a47ec6d9a5de0bea22de9 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sat, 1 May 2021 13:12:14 +0100 Subject: [PATCH 10/12] Embark: Keep monitor.station set when Embarking OnStation. --- monitor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/monitor.py b/monitor.py index 8bb9cd8b..4f52ea06 100644 --- a/monitor.py +++ b/monitor.py @@ -639,9 +639,6 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.stationservices = None elif event_type == 'Embark': - # If we've embarked then we're no longer on the station. - - # alpha4 # This event is logged when a player (on foot) gets into a ship or SRV # Parameters: # • SRV: true if getting into SRV, false if getting into a ship @@ -658,6 +655,9 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below # • StationType # • MarketID self.station = None + if entry.get('OnStation'): + self.station = entry.get('StationName', '') + self.state['OnFoot'] = False elif event_type == 'Disembark': From 02052dd90ef1538e2b819664d984ab9fb5cc786c Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sat, 1 May 2021 13:47:52 +0100 Subject: [PATCH 11/12] EDDB: Don't blank station when Embarking OnStation to own ship. --- plugins/eddb.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/eddb.py b/plugins/eddb.py index 2c926152..e5e9f81c 100644 --- a/plugins/eddb.py +++ b/plugins/eddb.py @@ -123,7 +123,13 @@ def journal_entry(cmdr, is_beta, system, station, entry, state): this.station_marketid = entry.get('MarketID') or this.station_marketid # We might pick up StationName in DockingRequested, make sure we clear it if leaving - if entry['event'] in ('Undocked', 'FSDJump', 'SupercruiseEntry', 'Embark'): + if entry['event'] in ('Undocked', 'FSDJump', 'SupercruiseEntry'): + this.station = None + this.station_marketid = None + + if entry['event'] == 'Embark' and not entry.get('OnStation'): + # If we're embarking OnStation to a Taxi/Dropship we'll also get an + # Undocked event. this.station = None this.station_marketid = None From 844e6115e31cf1a15adef6c584f25ae012b11fb7 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sat, 1 May 2021 13:50:45 +0100 Subject: [PATCH 12/12] Also handle Embark (properly) in EDSM and Inara plugins. --- plugins/edsm.py | 6 ++++++ plugins/inara.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/plugins/edsm.py b/plugins/edsm.py index 0f6ed269..f4118f56 100644 --- a/plugins/edsm.py +++ b/plugins/edsm.py @@ -382,6 +382,12 @@ def journal_entry( this.station = None this.station_marketid = None + if entry['event'] == 'Embark' and not entry.get('OnStation'): + # If we're embarking OnStation to a Taxi/Dropship we'll also get an + # Undocked event. + this.station = None + this.station_marketid = None + if config.get_str('station_provider') == 'EDSM': to_set = this.station if not this.station: diff --git a/plugins/inara.py b/plugins/inara.py index 28b19959..c8110ff0 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -395,6 +395,12 @@ def journal_entry( # noqa: C901, CCR001 this.station = None this.station_marketid = None + if entry['event'] == 'Embark' and not entry.get('OnStation'): + # If we're embarking OnStation to a Taxi/Dropship we'll also get an + # Undocked event. + this.station = None + this.station_marketid = None + if config.get_int('inara_out') and not is_beta and not this.multicrew and credentials(cmdr): current_creds = Credentials(this.cmdr, this.FID, str(credentials(this.cmdr))) try: