Do not store item-specific resistance attrs on effects
This commit is contained in:
@@ -29,6 +29,7 @@ from eos.db.gamedata.queries import getAttributeInfo
|
|||||||
|
|
||||||
defaultValuesCache = {}
|
defaultValuesCache = {}
|
||||||
cappingAttrKeyCache = {}
|
cappingAttrKeyCache = {}
|
||||||
|
resistanceCache = {}
|
||||||
|
|
||||||
|
|
||||||
def getAttrDefault(key, fallback=None):
|
def getAttrDefault(key, fallback=None):
|
||||||
@@ -46,19 +47,23 @@ def getAttrDefault(key, fallback=None):
|
|||||||
|
|
||||||
|
|
||||||
def getResistanceAttrID(modifyingItem, effect):
|
def getResistanceAttrID(modifyingItem, effect):
|
||||||
# If it doesn't exist on the effect, check the modifying modules attributes. If it's there, set it on the
|
# If it doesn't exist on the effect, check the modifying module's attributes.
|
||||||
# effect for this session so that we don't have to look here again (won't always work when it's None, but
|
# If it's there, cache it and return
|
||||||
# will catch most)
|
if effect.resistanceID:
|
||||||
if not effect.resistanceID and not effect.getattr('resistanceCalculated'):
|
return effect.resistanceID
|
||||||
|
cacheKey = (modifyingItem.item.ID, effect.ID)
|
||||||
|
try:
|
||||||
|
return resistanceCache[cacheKey]
|
||||||
|
except KeyError:
|
||||||
attrPrefix = effect.getattr('prefix')
|
attrPrefix = effect.getattr('prefix')
|
||||||
if attrPrefix:
|
if attrPrefix:
|
||||||
effect.resistanceID = int(modifyingItem.getModifiedItemAttr('{}ResistanceID'.format(attrPrefix))) or None
|
resistanceID = int(modifyingItem.getModifiedItemAttr('{}ResistanceID'.format(attrPrefix))) or None
|
||||||
if not effect.resistanceID:
|
if not resistanceID:
|
||||||
effect.resistanceID = int(modifyingItem.getModifiedItemAttr('{}RemoteResistanceID'.format(attrPrefix))) or None
|
resistanceID = int(modifyingItem.getModifiedItemAttr('{}RemoteResistanceID'.format(attrPrefix))) or None
|
||||||
else:
|
else:
|
||||||
effect.resistanceID = int(modifyingItem.getModifiedItemAttr("remoteResistanceID")) or None
|
resistanceID = int(modifyingItem.getModifiedItemAttr("remoteResistanceID")) or None
|
||||||
effect.resistanceCalculated = True
|
resistanceCache[cacheKey] = resistanceID
|
||||||
return effect.resistanceID
|
return resistanceID
|
||||||
|
|
||||||
|
|
||||||
class ItemAttrShortcut:
|
class ItemAttrShortcut:
|
||||||
|
|||||||
Reference in New Issue
Block a user