|
29 | 29 | from eos.saveddata.mode import Mode |
30 | 30 | import eos.db |
31 | 31 | import time |
| 32 | +import copy |
32 | 33 | from utils.timer import Timer |
33 | 34 |
|
34 | 35 | import logging |
@@ -414,14 +415,23 @@ def __calculateGangBoosts(self, runTime): |
414 | 415 | pass |
415 | 416 |
|
416 | 417 | 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) |
418 | 419 | logger.debug("Starting fit calculation on: %d %s (%s)" % |
419 | 420 | (self.ID, self.name, self.ship.item.name)) |
| 421 | + shadow = False |
420 | 422 | if targetFit: |
421 | 423 | logger.debug("Applying projections to target: %d %s (%s)", |
422 | 424 | targetFit.ID, targetFit.name, targetFit.ship.item.name) |
423 | 425 | projectionInfo = self.getProjectionInfo(targetFit.ID) |
424 | 426 | 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() |
425 | 435 |
|
426 | 436 | refreshBoosts = False |
427 | 437 | if withBoosters is True: |
@@ -495,6 +505,10 @@ def calculateModifiedAttributes(self, targetFit=None, withBoosters=False, dirtyS |
495 | 505 |
|
496 | 506 | timer.checkpoint('Done with fit calculation') |
497 | 507 |
|
| 508 | + if shadow: |
| 509 | + logger.debug("Delete shadow fit object") |
| 510 | + del self |
| 511 | + |
498 | 512 | def fill(self): |
499 | 513 | """ |
500 | 514 | Fill this fit's module slots with enough dummy slots so that all slots are used. |
|
0 commit comments