Gracefully handle invalid boosters in database (both itemIDs that don't exist as well as non-booster items). Implants need a little more work

This commit is contained in:
blitzmann
2015-06-30 13:51:15 -04:00
parent 646f3afd27
commit aaa5a6ae18
2 changed files with 15 additions and 7 deletions

View File

@@ -233,10 +233,14 @@ class HandledImplantBoosterList(HandledList):
self.__slotCache = {}
def append(self, implant):
if self.__slotCache.has_key(implant.slot):
raise ValueError("Implant/Booster slot already in use, remove the old one first or set replace = True")
self.__slotCache[implant.slot] = implant
HandledList.append(self, implant)
try:
if self.__slotCache.has_key(implant.slot):
raise ValueError("Implant/Booster slot already in use, remove the old one first or set replace = True")
self.__slotCache[implant.slot] = implant
HandledList.append(self, implant)
except:
# if anything goes wrong, simply remove the item
eos.db.remove(implant)
def remove(self, implant):
HandledList.remove(self, implant)