Skip to content

Commit

Permalink
Make sure it's impossible to add extra cap boosters via dragging too
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkFenX committed Apr 15, 2020
1 parent db4c56b commit 8c25b2b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
4 changes: 1 addition & 3 deletions gui/fitCommands/calc/module/localAdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ def Do(self):
# module if the check has failed
if not newMod.fits(fit):
pyfalog.warning('Module does not fit')
from .localRemove import CalcRemoveLocalModulesCommand
cmd = CalcRemoveLocalModulesCommand(fitID=self.fitID, positions=[self.savedPosition], recalc=False)
cmd.Do()
self.Undo()
return False
self.savedStateCheckChanges = sFit.checkStates(fit, newMod)
return True
Expand Down
23 changes: 11 additions & 12 deletions gui/fitCommands/calc/module/localReplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,17 @@ def Do(self):
if newMod.slot != oldMod.slot:
return False
# Dummy it out in case the next bit fails
fit.modules.free(self.position)
fit.modules.replace(self.position, newMod)
if newMod not in fit.modules:
pyfalog.warning('Failed to replace in list')
self.Undo()
return False
if self.recalc:
# Need to flush because checkStates sometimes relies on module->fit
# relationship via .owner attribute, which is handled by SQLAlchemy
eos.db.flush()
sFit.recalc(fit)
self.savedStateCheckChanges = sFit.checkStates(fit, newMod)
if not self.ignoreRestrictions and not newMod.fits(fit):
pyfalog.warning('Module does not fit')
self.Undo()
Expand All @@ -52,17 +62,6 @@ def Do(self):
pyfalog.warning('Invalid charge')
self.Undo()
return False
fit.modules.replace(self.position, newMod)
if newMod not in fit.modules:
pyfalog.warning('Failed to replace in list')
self.Undo()
return False
if self.recalc:
# Need to flush because checkStates sometimes relies on module->fit
# relationship via .owner attribute, which is handled by SQLAlchemy
eos.db.flush()
sFit.recalc(fit)
self.savedStateCheckChanges = sFit.checkStates(fit, newMod)
return True

def Undo(self):
Expand Down

0 comments on commit 8c25b2b

Please sign in to comment.