Skip to content

Commit 63fce4b

Browse files
committed
Handle self projections by creating a copy of the fit. Due to the way effects are calculated, we would have double effects implemented if not for the copy
1 parent 86ee529 commit 63fce4b

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

eos/saveddata/fit.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from eos.saveddata.mode import Mode
3030
import eos.db
3131
import time
32+
import copy
3233
from utils.timer import Timer
3334

3435
import logging
@@ -414,14 +415,23 @@ def __calculateGangBoosts(self, runTime):
414415
pass
415416

416417
def calculateModifiedAttributes(self, targetFit=None, withBoosters=False, dirtyStorage=None):
417-
timer = Timer('Fit: %d, %s'%(self.ID, self.name), logger)
418+
timer = Timer('Fit: {}, {}'.format(self.ID, self.name), logger)
418419
logger.debug("Starting fit calculation on: %d %s (%s)" %
419420
(self.ID, self.name, self.ship.item.name))
421+
shadow = False
420422
if targetFit:
421423
logger.debug("Applying projections to target: %d %s (%s)",
422424
targetFit.ID, targetFit.name, targetFit.ship.item.name)
423425
projectionInfo = self.getProjectionInfo(targetFit.ID)
424426
logger.debug("ProjectionInfo: %s", ', '.join("%s: %s" % item for item in vars(projectionInfo).items()))
427+
if self == targetFit:
428+
shadow = True
429+
self = copy.deepcopy(self)
430+
logger.debug("Handling self projection - making shadow copy of fit. %s => %s", projectionInfo.source_fit, self)
431+
# we rollback because when we copy a fit, flush() is called to
432+
# properly handle projection updates. However, we do not want to
433+
# save this fit to the database, so we can immediately rollback
434+
eos.db.saveddata_session.rollback()
425435

426436
refreshBoosts = False
427437
if withBoosters is True:
@@ -495,6 +505,10 @@ def calculateModifiedAttributes(self, targetFit=None, withBoosters=False, dirtyS
495505

496506
timer.checkpoint('Done with fit calculation')
497507

508+
if shadow:
509+
logger.debug("Delete shadow fit object")
510+
del self
511+
498512
def fill(self):
499513
"""
500514
Fill this fit's module slots with enough dummy slots so that all slots are used.

service/fit.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,6 @@ def project(self, fitID, thing):
320320
eager=("attributes", "group.category"))
321321

322322
if isinstance(thing, eos.types.Fit):
323-
if thing.ID == fitID:
324-
return
325-
326323
if thing in fit.projectedFits:
327324
return
328325

0 commit comments

Comments
 (0)