From 8e8c9fa3fff655a27a557b7301ea3da49b8aa044 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Fri, 30 Apr 2021 13:50:52 +0100 Subject: [PATCH 1/7] Items: `Data` is now in `BackPackMaterials` as well --- monitor.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/monitor.py b/monitor.py index dbaaa05b..0dd229a8 100644 --- a/monitor.py +++ b/monitor.py @@ -805,6 +805,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.state['BackPack']['Component'] = defaultdict(int) self.state['BackPack']['Consumable'] = defaultdict(int) self.state['BackPack']['Item'] = defaultdict(int) + self.state['BackPack']['Data'] = defaultdict(int) clean_components = self.coalesce_cargo(entry['Components']) self.state['BackPack']['Component'].update( @@ -821,6 +822,11 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below {self.canonicalise(x['Name']): x['Count'] for x in clean_items} ) + clean_data = self.coalesce_cargo(entry['Data']) + self.state['BackPack']['Data'].update( + {self.canonicalise(x['Name']): x['Count'] for x in clean_data} + ) + elif event_type == 'BuyMicroResources': # Buying from a Pioneer Supplies, goes directly to ShipLocker. # One event per Item, not an array. From 1f8215ed92134530a9fee3fc97fe3bcd7d36ac1a Mon Sep 17 00:00:00 2001 From: Athanasius Date: Fri, 30 Apr 2021 13:56:26 +0100 Subject: [PATCH 2/7] Items: `ShipLockerMaterials` now has `Data` But also, we're not getting a `BackPackMaterials` at the same time to be sure of the state of things. --- monitor.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/monitor.py b/monitor.py index 0dd229a8..d2e0e635 100644 --- a/monitor.py +++ b/monitor.py @@ -772,15 +772,16 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.state['Component'] = defaultdict(int) self.state['Consumable'] = defaultdict(int) self.state['Item'] = defaultdict(int) + self.state['Data'] = defaultdict(int) # TODO: Really we need a full BackPackMaterials event at the same time. # In lieu of that, empty the backpack. This will explicitly # be wrong if Cmdr relogs at a Settlement with anything in - # backpack. We can't track when they use/pick up items - # anyway (Odyssey Alpha Phase 1 Hotfix 2). - # alpha4 - This should be changed + # backpack. + # Still no BackPackMaterials at the same time in 4.0.0.31 self.state['BackPack']['Component'] = defaultdict(int) self.state['BackPack']['Consumable'] = defaultdict(int) self.state['BackPack']['Item'] = defaultdict(int) + self.state['BackPack']['Data'] = defaultdict(int) clean_components = self.coalesce_cargo(entry['Components']) self.state['Component'].update( @@ -797,6 +798,11 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below {self.canonicalise(x['Name']): x['Count'] for x in clean_items} ) + clean_data = self.coalesce_cargo(entry['Data']) + self.state['Data'].update( + {self.canonicalise(x['Name']): x['Count'] for x in clean_data} + ) + elif event_type == 'BackPackMaterials': # alpha4 - # Lists the contents of the backpack, eg when disembarking from ship From 422b766586b29401b4c9dda8391a84ca497b7fff Mon Sep 17 00:00:00 2001 From: Athanasius Date: Fri, 30 Apr 2021 14:30:37 +0100 Subject: [PATCH 3/7] Items: Decrement BackPack Consumable on `UseConsumable` --- monitor.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/monitor.py b/monitor.py index d2e0e635..cf6552cb 100644 --- a/monitor.py +++ b/monitor.py @@ -914,7 +914,9 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below # Parameters: # • Name # • Type - pass + for c in self.state['BackPackMaterials']['Consumables']: + if c['Name'] == entry['Name']: + c['Count'] -= 1 elif event_type == 'SwitchSuitLoadout': # alpha4 @@ -1144,8 +1146,8 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below # alpha4 pass - # alpha4 elif event_type == 'ScanOrganic': + # Nothing of interest to our state. pass elif event_type == 'SellOrganicData': From f89ed7999e1cc2b43e0e75aa47b59d85105a3335 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Fri, 30 Apr 2021 14:44:20 +0100 Subject: [PATCH 4/7] Items: Implement `CollectItems`, `DropItems` and `UseConsumable` The paranoia when subtracting from counts is because of the lack of fresh `BackPackMaterials` if relogging whilst on foot. --- monitor.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/monitor.py b/monitor.py index cf6552cb..172c6196 100644 --- a/monitor.py +++ b/monitor.py @@ -895,7 +895,9 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below # • Name # • Type # • OwnerID - pass + for i in self.state['BackPackMaterials'][entry['Type']]: + if i['Name'] == entry['Name']: + i['Count'] += entry['Count'] elif event_type == 'DropItems': # alpha4 @@ -905,7 +907,12 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below # • OwnerID # • MissionID # • Count - pass + for i in self.state['BackPackMaterials'][entry['Type']]: + if i['Name'] == entry['Name']: + i['Count'] -= entry['Count'] + # Paranoia in case we lost track + if i['Count'] < 0: + i['Count'] = 0 elif event_type == 'UseConsumable': # alpha4 @@ -914,9 +921,12 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below # Parameters: # • Name # • Type - for c in self.state['BackPackMaterials']['Consumables']: + for c in self.state['BackPackMaterials']['Consumable']: if c['Name'] == entry['Name']: c['Count'] -= 1 + # Paranoia in case we lost track + if i['Count'] < 0: + i['Count'] = 0 elif event_type == 'SwitchSuitLoadout': # alpha4 From e1a63c2879011311ff99fcf86faa233f239e8dd5 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Fri, 30 Apr 2021 15:12:12 +0100 Subject: [PATCH 5/7] Items: Correct `UseConsumable` code --- monitor.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/monitor.py b/monitor.py index 172c6196..6a0b42dd 100644 --- a/monitor.py +++ b/monitor.py @@ -921,12 +921,12 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below # Parameters: # • Name # • Type - for c in self.state['BackPackMaterials']['Consumable']: - if c['Name'] == entry['Name']: - c['Count'] -= 1 + for c in self.state['BackPack']['Consumable']: + if c == entry['Name']: + self.state['BackPack']['Consumable'][c] -= 1 # Paranoia in case we lost track - if i['Count'] < 0: - i['Count'] = 0 + if self.state['BackPack']['Consumable'][c] < 0: + self.state['BackPack']['Consumable'][c] = 0 elif event_type == 'SwitchSuitLoadout': # alpha4 From 60b2045ea4293e2408e7189792621952b78cab81 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Fri, 30 Apr 2021 15:21:47 +0100 Subject: [PATCH 6/7] Items: Fix `DropItems` and `CollectItems` Tested as actually working. --- monitor.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/monitor.py b/monitor.py index 6a0b42dd..584ece48 100644 --- a/monitor.py +++ b/monitor.py @@ -895,9 +895,9 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below # • Name # • Type # • OwnerID - for i in self.state['BackPackMaterials'][entry['Type']]: - if i['Name'] == entry['Name']: - i['Count'] += entry['Count'] + for i in self.state['BackPack'][entry['Type']]: + if i == entry['Name']: + self.state['BackPack'][entry['Type']][i] += entry['Count'] elif event_type == 'DropItems': # alpha4 @@ -907,12 +907,12 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below # • OwnerID # • MissionID # • Count - for i in self.state['BackPackMaterials'][entry['Type']]: - if i['Name'] == entry['Name']: - i['Count'] -= entry['Count'] + for i in self.state['BackPack'][entry['Type']]: + if i == entry['Name']: + self.state['BackPack'][entry['Type']][i] -= entry['Count'] # Paranoia in case we lost track - if i['Count'] < 0: - i['Count'] = 0 + if self.state['BackPack'][entry['Type']][i] < 0: + self.state['BackPack'][entry['Type']][i] = 0 elif event_type == 'UseConsumable': # alpha4 From 6d58863a40a2e1504486a49f8595c240c8a370f7 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Fri, 30 Apr 2021 15:42:10 +0100 Subject: [PATCH 7/7] Suits: Fix 'mame' typo --- monitor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitor.py b/monitor.py index 584ece48..d7714d53 100644 --- a/monitor.py +++ b/monitor.py @@ -995,7 +995,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below 'locName': entry.get('SuitName_Localised', entry['SuitName']), 'suitId': entry['SuitID'], }, - 'mame': entry['LoadoutName'], + 'name': entry['LoadoutName'], 'slots': self.suit_loadout_slots_array_to_dict(entry['Modules']), } self.state['SuitLoadouts'][new_loadout['loadoutSlotId']] = new_loadout