Revert "Make sure that modules are put onto their proper place during EFT import, not to the end"
This reverts commit fe063cf19a.
This commit is contained in:
@@ -116,58 +116,30 @@ class HandledList(list):
|
||||
class HandledModuleList(HandledList):
|
||||
|
||||
def append(self, mod):
|
||||
"""
|
||||
Add module to list, replacing first seen empty slot for
|
||||
its rack by passed module.
|
||||
"""
|
||||
|
||||
# Get first seen empty position
|
||||
emptyPosition = None
|
||||
for currMod in self:
|
||||
if currMod.isEmpty and currMod.slot == mod.slot:
|
||||
currPos = mod.position
|
||||
if emptyPosition is None or currPos < emptyPosition:
|
||||
emptyPosition = float("Inf")
|
||||
for i in range(len(self)):
|
||||
currMod = self[i]
|
||||
if currMod.isEmpty and not mod.isEmpty and currMod.slot == mod.slot:
|
||||
currPos = mod.position or i
|
||||
if currPos < emptyPosition:
|
||||
emptyPosition = currPos
|
||||
|
||||
# Replacing empty by empty
|
||||
if emptyPosition is not None and mod.isEmpty:
|
||||
if emptyPosition < len(self):
|
||||
del self[emptyPosition]
|
||||
mod.position = emptyPosition
|
||||
HandledList.insert(self, emptyPosition, mod)
|
||||
if mod.isInvalid:
|
||||
self.remove(mod)
|
||||
return
|
||||
|
||||
# Replacing empty by non-empty
|
||||
if emptyPosition is not None and not mod.isEmpty:
|
||||
self.__replace(mod, emptyPosition)
|
||||
self.appendIgnoreEmpty(mod)
|
||||
|
||||
self.__appendToEnd(mod)
|
||||
|
||||
def __appendToEnd(self, mod):
|
||||
def appendIgnoreEmpty(self, mod):
|
||||
mod.position = len(self)
|
||||
HandledList.append(self, mod)
|
||||
if mod.isInvalid:
|
||||
self.remove(mod)
|
||||
|
||||
def __replace(self, mod, position):
|
||||
if mod.isEmpty and self[position].isEmpty:
|
||||
return
|
||||
old = self[position]
|
||||
del self[position]
|
||||
mod.position = position
|
||||
HandledList.insert(self, position, mod)
|
||||
if mod.isInvalid:
|
||||
self.remove(mod)
|
||||
self.insert(position, old)
|
||||
|
||||
def replaceRackPosition(self, rackPosition, mod):
|
||||
rackPositions = []
|
||||
for currMod in self:
|
||||
if currMod.slot == mod.slot:
|
||||
rackPositions.append(currMod.position)
|
||||
rackPositions.sort()
|
||||
try:
|
||||
modPosition = rackPositions[rackPosition]
|
||||
except IndexError:
|
||||
self.__appendToEnd(mod)
|
||||
else:
|
||||
self.__replace(mod, modPosition)
|
||||
|
||||
def insert(self, index, mod):
|
||||
mod.position = index
|
||||
|
||||
@@ -251,14 +251,14 @@ def importEft(eftString):
|
||||
aFit.addCargo(itemSpec)
|
||||
|
||||
# Subsystems first because they modify slot amount
|
||||
for i, m in enumerate(aFit.subsystems):
|
||||
for m in aFit.subsystems:
|
||||
if m is None:
|
||||
dummy = Module.buildEmpty(aFit.getSlotByContainer(aFit.subsystems))
|
||||
dummy.owner = fit
|
||||
fit.modules.replaceRackPosition(i, dummy)
|
||||
fit.modules.appendIgnoreEmpty(dummy)
|
||||
elif m.fits(fit):
|
||||
m.owner = fit
|
||||
fit.modules.replaceRackPosition(i, m)
|
||||
fit.modules.appendIgnoreEmpty(m)
|
||||
svcFit.getInstance().recalc(fit)
|
||||
|
||||
# Other stuff
|
||||
@@ -269,16 +269,16 @@ def importEft(eftString):
|
||||
aFit.modulesMed,
|
||||
aFit.modulesLow,
|
||||
):
|
||||
for i, m in enumerate(modRack):
|
||||
for m in modRack:
|
||||
if m is None:
|
||||
dummy = Module.buildEmpty(aFit.getSlotByContainer(modRack))
|
||||
dummy.owner = fit
|
||||
fit.modules.replaceRackPosition(i, dummy)
|
||||
fit.modules.appendIgnoreEmpty(dummy)
|
||||
elif m.fits(fit):
|
||||
m.owner = fit
|
||||
if not m.isValidState(m.state):
|
||||
pyfalog.warning('service.port.eft.importEft: module {} cannot have state {}', m, m.state)
|
||||
fit.modules.replaceRackPosition(i, m)
|
||||
fit.modules.appendIgnoreEmpty(m)
|
||||
for implant in aFit.implants:
|
||||
fit.implants.append(implant)
|
||||
for booster in aFit.boosters:
|
||||
|
||||
Reference in New Issue
Block a user