Revert to old way for now.

This commit is contained in:
Alexander 2015-08-08 22:53:39 -04:00
parent 9b1dfba315
commit 1d4caa84e9

View file

@ -184,7 +184,7 @@ class DistributedBuildingMgrAI:
def save(self): def save(self):
backups = {} backups = {}
buildings = [] #buildings = []
for blockNumber in self.getSuitBlocks(): for blockNumber in self.getSuitBlocks():
building = self.getBuilding(blockNumber) building = self.getBuilding(blockNumber)
backup = { backup = {
@ -198,22 +198,24 @@ class DistributedBuildingMgrAI:
} }
backups[blockNumber] = backup backups[blockNumber] = backup
for i in backups.values(): #for i in self.__buildings.values():
if isinstance(i, HQBuildingAI.HQBuildingAI): # if isinstance(i, HQBuildingAI.HQBuildingAI):
continue # continue
buildings.append(i.getPickleData()) # buildings.append(i.getPickleData())
if not self.air.dbConn: simbase.backups.save('block-info', (self.air.districtId, self.branchId), backups)
'''if not self.air.dbConn:
simbase.backups.save('block-info', (self.air.districtId, self.branchId), backups) simbase.backups.save('block-info', (self.air.districtId, self.branchId), backups)
else: else:
street = {'district': self.air.districtId, 'branch': self.branchId} street = {'district': self.air.districtId, 'branch': self.branchId}
try: try:
self.air.dbGlobalCursor.blockInfo.update(street, {'$setOnInsert': street, '$set': {'buildings': buildings}}, upsert=True) self.air.dbGlobalCursor.blockInfo.update(street, {'$setOnInsert': street, '$set': {'buildings': buildings}}, upsert=True)
except AutoReconnect: except AutoReconnect:
taskMgr.doMethodLater(config.GetInt('mongodb-retry-time', 2), self.save, 'retrySave', extraArgs=[]) taskMgr.doMethodLater(config.GetInt('mongodb-retry-time', 2), self.save, 'retrySave', extraArgs=[])'''
def load(self): def load(self):
blocks = {} blocks = simbase.backups.load('block-info', (self.air.districtId, self.branchId), default={})
if not self.air.dbConn: return blocks
'''if not self.air.dbConn:
blocks = simbase.backups.load('block-info', (self.air.districtId, self.branchId), default={}) blocks = simbase.backups.load('block-info', (self.air.districtId, self.branchId), default={})
return blocks return blocks
self.air.dbGlobalCursor.blockInfo.ensure_index([('district', 1), ('branch', 1)]) self.air.dbGlobalCursor.blockInfo.ensure_index([('district', 1), ('branch', 1)])
@ -226,4 +228,4 @@ class DistributedBuildingMgrAI:
return blocks return blocks
for building in doc.get('buildings', []): for building in doc.get('buildings', []):
blocks[int(building['block'])] = building blocks[int(building['block'])] = building
return blocks return blocks'''