Make sure it's impossible to add extra cap boosters via dragging too

This commit is contained in:
DarkPhoenix
2020-04-15 15:40:54 +03:00
parent db4c56be8e
commit 8c25b2b8f5
2 changed files with 12 additions and 15 deletions

View File

@@ -54,9 +54,7 @@ class CalcAddLocalModuleCommand(wx.Command):
# 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

View File

@@ -39,7 +39,17 @@ class CalcReplaceLocalModuleCommand(wx.Command):
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()
@@ -52,17 +62,6 @@ class CalcReplaceLocalModuleCommand(wx.Command):
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):