Fix for init projected fit. Took a long time to figure out what was happening.

This commit is contained in:
blitzmann
2015-07-10 11:58:15 -04:00
parent c17e03d8d0
commit 68dddf2810
3 changed files with 26 additions and 24 deletions

View File

@@ -53,26 +53,23 @@ projectedFits_table = Table("projectedFits", saveddata_meta,
class ProjectedFit(object):
def __init__(self, source_fit, k, amount=1, active=True):
print "init projected: ", k, source_fit.name, active, amount
#print "init projected: source fit: ", source_fit.name, source_fit, "key (fit ID)", key, "active:", active, "amount:",amount
self.sourceID = k
self.source_item = source_fit
self.victim_item = None
self.source_fit = source_fit
#self.victim_item = None
self.amount = amount
self.active = active
#self.dest_item.setProjectionInfo(self.source_item.ID, self)
@reconstructor
def init(self):
print "db init"
print "\t source:", self.source_fit
print "\t dest:", self.victim_fit
#self.dest_item.setProjectionInfo(self.source_item.ID, self)
#print self.dest_item.ship.item.name, ">", self.source_item.ship.item.name,self
Fit._Fit__projectedFits = association_proxy(
"victimOf", # look at the victimOf association...
"source_fit", # .. and return the source fits
creator=lambda k, victim_fit: ProjectedFit(victim_fit, k)
creator=lambda k, source_fit: ProjectedFit(source_fit, k)
)
mapper(Fit, fits_table,

View File

@@ -63,7 +63,7 @@ class Fit(object):
self.__cargo = HandledDroneCargoList()
self.__implants = HandledImplantBoosterList()
self.__boosters = HandledImplantBoosterList()
self.__projectedFits = HandledProjectedFitList()
#self.__projectedFits = {}
self.__projectedModules = HandledProjectedModList()
self.__projectedDrones = HandledProjectedDroneList()
self.__character = None
@@ -119,7 +119,6 @@ class Fit(object):
self.__capUsed = None
self.__capRecharge = None
self.__calculatedTargets = []
self.__projectionMap = {}
self.factorReload = False
self.fleet = None
self.boostsFits = set()
@@ -208,9 +207,11 @@ class Fit(object):
@property
def projectedFits(self):
#print "get projected fits for :", self.name
return self.__projectedFits.values()
def getProjectionInfo(self, fitID):
print "get projection info for fitID: ", fitID
return self.projectedOnto.get(fitID, None)
@property
@@ -416,13 +417,15 @@ class Fit(object):
timer = Timer('Fit: %d, %s'%(self.ID, self.name), logger)
logger.debug("Starting fit calculation on: %d %s (%s)" %
(self.ID, self.name, self.ship.item.name))
print self
#print self.__projectedFits
#print self.projectedFits
if targetFit:
logger.debug("Applying projections to target: %d %s (%s)",
targetFit.ID, targetFit.name, targetFit.ship.item.name)
projectionInfo = self.getProjectionInfo(targetFit.ID)
logger.debug("ProjectionInfo: amount=%s, active=%s, instance=%s",
projectionInfo.amount, projectionInfo.active, projectionInfo)
#projectionInfo = self.getProjectionInfo(targetFit.ID)
#logger.debug("ProjectionInfo: amount=%s, active=%s, instance=%s",
# projectionInfo.amount, projectionInfo.active, projectionInfo)
refreshBoosts = False
if withBoosters is True:
@@ -447,23 +450,21 @@ class Fit(object):
if targetFit is None:
targetFit = self
projected = False
# Else, we're checking all target projectee fits
elif targetFit not in self.__calculatedTargets:
logger.debug("Target fit has not been calculated, calculating first")
# target fit is required to be calculated before we do projections
# @todo: is there any situation where a projected ship would get here and the targte fit not be calculated already? See if we can get rid of this block of code
self.__calculatedTargets.append(targetFit)
targetFit.calculateModifiedAttributes(dirtyStorage=dirtyStorage)
projected = True
# Or do nothing if target fit is calculated
else:
return
projected = True
# If fit is calculated and we have nothing to do here, get out
if self.__calculated and not projected:
logger.debug("Fit has already been calculated and is not projected, returning")
return
print
print "******** projected fits ********"
print self.__projectedFits
print "******** projectedOnto ********"
print self.projectedOnto
print "******** victimOf ********"
print self.victimOf
print
# Mark fit as calculated
self.__calculated = True

View File

@@ -327,6 +327,10 @@ class Fit(object):
return
fit.__projectedFits[thing.ID] = thing
# this bit is required -- see GH issue
eos.db.saveddata_session.flush()
eos.db.saveddata_session.refresh(thing)
elif thing.category.name == "Drone":
drone = None
for d in fit.projectedDrones.find(thing):
@@ -939,7 +943,7 @@ class Fit(object):
self.recalc(fit)
def recalc(self, fit, withBoosters=False):
logger.debug("="*10+"recalc"+"="*10)
logger.debug("="*10+"recalc"+"="*10)
if fit.factorReload is not self.serviceFittingOptions["useGlobalForceReload"]:
fit.factorReload = self.serviceFittingOptions["useGlobalForceReload"]
fit.clear()