1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-15 08:40:34 +03:00

Add paranoia check for BackPack material counts going negative.

Reset them to zero if they're negative.  It's probably from an
Embark-related TransferMicroResources event, so they should now be
zeroes anyway.
This commit is contained in:
Athanasius 2021-04-05 15:56:20 +01:00
parent 5f59487a7b
commit 112525c31e

View File

@ -803,6 +803,14 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
else:
logger.warning(f'TransferMicroResources with unexpected Direction {mr["Direction"]=}: {mr=}')
# Paranoia check to see if anything has gone negative.
# As of Odyssey Alpha Phase 1 Hotfix 2 keeping track of BackPack
# materials is impossible when used/picked up anyway.
for c in self.state['BackPack']:
for m in self.state['BackPack'][c]:
if self.state['BackPack'][c][m] < 0:
self.state['BackPack'][c][m] = 0
elif event_type == 'NavRoute':
# Added in ED 3.7 - multi-hop route details in NavRoute.json
with open(join(self.currentdir, 'NavRoute.json'), 'rb') as rf: # type: ignore