diff --git a/eos/effectHandlerHelpers.py b/eos/effectHandlerHelpers.py index 42efc7cc4..63e8a371a 100644 --- a/eos/effectHandlerHelpers.py +++ b/eos/effectHandlerHelpers.py @@ -161,20 +161,27 @@ class HandledModuleList(HandledList): def replaceRackPosition(self, rackPosition, mod): listPositions = [] - for currMod in self: + for currPos in range(len(self)): + currMod = self[currPos] if currMod.slot == mod.slot: - listPositions.append(currMod.position) + listPositions.append(currPos) listPositions.sort() try: modListPosition = listPositions[rackPosition] except IndexError: self.appendIgnoreEmpty(mod) else: - self.__toDummy(modListPosition) - if not mod.isEmpty: + oldMod = self[modListPosition] + if mod.isEmpty: + self.__toDummy(modListPosition) + else: self.__toModule(modListPosition, mod) + # If new module cannot be appended, restore old state if mod.isInvalid: - self.__toDummy(modListPosition) + if oldMod.isEmpty: + self.__toDummy(modListPosition) + else: + self.__toModule(modListPosition, oldMod) raise HandledListActionError(mod) def insert(self, idx, mod): @@ -192,7 +199,6 @@ class HandledModuleList(HandledList): def remove(self, mod): HandledList.remove(self, mod) oldPos = mod.position - mod.position = None for i in range(oldPos, len(self)): self[i].position -= 1 @@ -214,14 +220,6 @@ class HandledModuleList(HandledList): self[index] = mod oldMod.position = None - @deprecated - def freeSlot(self, slot): - for i in range(len(self)): - mod = self[i] - if mod.getModifiedItemAttr("subSystemSlot") == slot: - self.__toDummy(i) - break - class HandledDroneCargoList(HandledList): diff --git a/service/fitDeprecated.py b/service/fitDeprecated.py index fee1783e7..dd57b94c8 100644 --- a/service/fitDeprecated.py +++ b/service/fitDeprecated.py @@ -283,39 +283,6 @@ class FitDeprecated(object): eos.db.commit() self.recalc(fit) - @deprecated - def appendModule(self, fitID, itemID): - pyfalog.debug("Appending module for fit ({0}) using item: {1}", fitID, itemID) - fit = eos.db.getFit(fitID) - item = eos.db.getItem(itemID, eager=("attributes", "group.category")) - try: - m = es_Module(item) - except ValueError: - pyfalog.warning("Invalid item: {0}", itemID) - return False - - if m.item.category.name == "Subsystem": - fit.modules.freeSlot(m.getModifiedItemAttr("subSystemSlot")) - - if m.fits(fit): - m.owner = fit - numSlots = len(fit.modules) - fit.modules.append(m) - if m.isValidState(FittingModuleState.ACTIVE): - m.state = FittingModuleState.ACTIVE - - # As some items may affect state-limiting attributes of the ship, calculate new attributes first - self.recalc(fit) - # Then, check states of all modules and change where needed. This will recalc if needed - self.checkStates(fit, m) - - fit.fill() - eos.db.commit() - - return numSlots != len(fit.modules), m.modPosition - else: - return None, None - @deprecated def removeModule(self, fitID, positions): """Removes modules based on a number of positions."""