Skip to content

Commit

Permalink
Handle self projections by creating a copy of the fit. Due to the way…
Browse files Browse the repository at this point in the history
… effects are calculated, we would have double effects implemented if not for the copy
  • Loading branch information
blitzmann committed Jul 11, 2015
1 parent 86ee529 commit 63fce4b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
16 changes: 15 additions & 1 deletion eos/saveddata/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from eos.saveddata.mode import Mode
import eos.db
import time
import copy
from utils.timer import Timer

import logging
Expand Down Expand Up @@ -414,14 +415,23 @@ def __calculateGangBoosts(self, runTime):
pass

def calculateModifiedAttributes(self, targetFit=None, withBoosters=False, dirtyStorage=None):
timer = Timer('Fit: %d, %s'%(self.ID, self.name), logger)
timer = Timer('Fit: {}, {}'.format(self.ID, self.name), logger)
logger.debug("Starting fit calculation on: %d %s (%s)" %
(self.ID, self.name, self.ship.item.name))
shadow = False
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: %s", ', '.join("%s: %s" % item for item in vars(projectionInfo).items()))
if self == targetFit:
shadow = True
self = copy.deepcopy(self)
logger.debug("Handling self projection - making shadow copy of fit. %s => %s", projectionInfo.source_fit, self)
# we rollback because when we copy a fit, flush() is called to
# properly handle projection updates. However, we do not want to
# save this fit to the database, so we can immediately rollback
eos.db.saveddata_session.rollback()

refreshBoosts = False
if withBoosters is True:
Expand Down Expand Up @@ -495,6 +505,10 @@ def calculateModifiedAttributes(self, targetFit=None, withBoosters=False, dirtyS

timer.checkpoint('Done with fit calculation')

if shadow:
logger.debug("Delete shadow fit object")
del self

def fill(self):
"""
Fill this fit's module slots with enough dummy slots so that all slots are used.
Expand Down
3 changes: 0 additions & 3 deletions service/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,6 @@ def project(self, fitID, thing):
eager=("attributes", "group.category"))

if isinstance(thing, eos.types.Fit):
if thing.ID == fitID:
return

if thing in fit.projectedFits:
return

Expand Down

0 comments on commit 63fce4b

Please sign in to comment.