From dbca0f9dea603f3c1e1ea865635b4f7e0c463c4c Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Fri, 19 Apr 2019 12:29:49 +0300 Subject: [PATCH] Limit drone stacks by ship bandwidth too --- eos/saveddata/fit.py | 8 ++++---- gui/fitCommands/calc/drone/localAdd.py | 4 ++-- gui/fitCommands/helpers.py | 9 +++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/eos/saveddata/fit.py b/eos/saveddata/fit.py index e666e3339..ebeb17e8f 100644 --- a/eos/saveddata/fit.py +++ b/eos/saveddata/fit.py @@ -1507,19 +1507,19 @@ class Fit(object): return True - def howManyDronesRelease(self, item): + def getReleaseLimitForDrone(self, item): if not item.isDrone: return 0 bw = round(self.ship.getModifiedItemAttr("droneBandwidth")) - volume = round(item.attribsWithOverrides['volume']) + volume = round(item.attribsWithOverrides['volume'].value) return int(bw / volume) - def howManyDronesStore(self, item): + def getStoreLimitForDrone(self, item): if not item.isDrone: return 0 bayTotal = round(self.ship.getModifiedItemAttr("droneCapacity")) bayUsed = round(self.droneBayUsed) - volume = item.attribsWithOverrides['volume'] + volume = item.attribsWithOverrides['volume'].value return int((bayTotal - bayUsed) / volume) def __deepcopy__(self, memo=None): diff --git a/gui/fitCommands/calc/drone/localAdd.py b/gui/fitCommands/calc/drone/localAdd.py index 8b0842ff4..146cf869a 100644 --- a/gui/fitCommands/calc/drone/localAdd.py +++ b/gui/fitCommands/calc/drone/localAdd.py @@ -4,7 +4,7 @@ from logbook import Logger import eos.db from eos.exception import HandledListActionError -from gui.fitCommands.helpers import DroneInfo +from gui.fitCommands.helpers import DroneInfo, droneStackLimit from service.fit import Fit from service.market import Market @@ -30,8 +30,8 @@ class CalcAddLocalDroneCommand(wx.Command): # If we're not adding any active drones, check if there's an inactive stack # with enough space for new drones and use it if not self.forceNewStack and self.droneInfo.amountActive == 0: + maxStack = droneStackLimit(fit, item) for drone in fit.drones.find(item): - maxStack = max(5, fit.extraAttributes["maxActiveDrones"]) if ( drone is not None and drone.amountActive == 0 and drone.amount + self.droneInfo.amount <= maxStack diff --git a/gui/fitCommands/helpers.py b/gui/fitCommands/helpers.py index 5918f16de..a7ce2d738 100644 --- a/gui/fitCommands/helpers.py +++ b/gui/fitCommands/helpers.py @@ -1,3 +1,5 @@ +import math + import wx from logbook import Logger @@ -322,6 +324,13 @@ def stateLimit(itemIdentity): return FittingModuleState.ACTIVE +def droneStackLimit(fit, item): + hardLimit = max(5, fit.extraAttributes["maxActiveDrones"]) + releaseLimit = fit.getReleaseLimitForDrone(item) + limit = min(hardLimit, releaseLimit if releaseLimit > 0 else math.inf) + return limit + + def restoreCheckedStates(fit, stateInfo): if stateInfo is None: return