Skip to content

Commit

Permalink
Track whether trades have been loaded per station
Browse files Browse the repository at this point in the history
This may break some functionality that assumes tradingWith will always be a valid dictionary
  • Loading branch information
kfsone committed Nov 17, 2014
1 parent 456a866 commit 0392552
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tradedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Station(object):

def __init__(self, ID, system, dbname, lsFromStar, itemCount):
self.ID, self.system, self.dbname, self.lsFromStar, self.itemCount = ID, system, dbname, lsFromStar, itemCount
self.tradingWith = {} # dict[tradingPartnerStation] -> [ available trades ]
self.tradingWith = None # dict[tradingPartnerStation] -> [ available trades ]
system.stations.append(self)


Expand Down Expand Up @@ -816,6 +816,8 @@ def loadTrades(self):
for (itemID, srcStnID, dstStnID, srcPriceCr, profit, stock, stockLevel, demand, demandLevel, srcAge, dstAge) in self.cur:
if srcStnID != prevSrcStnID:
srcStn, prevSrcStnID, prevDstStnID = stations[srcStnID], srcStnID, None
assert srcStn.tradingWith is None
srcStn.tradingWith = {}
if dstStnID != prevDstStnID:
dstStn, prevDstStnID = stations[dstStnID], dstStnID
tradingWith = srcStn.tradingWith[dstStn] = []
Expand Down

0 comments on commit 0392552

Please sign in to comment.