Limit drone stacks by ship bandwidth too

This commit is contained in:
DarkPhoenix
2019-04-19 12:29:49 +03:00
parent 7380244cd9
commit dbca0f9dea
3 changed files with 15 additions and 6 deletions

View File

@@ -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

View File

@@ -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