Do not crash on None value in damage pattern editor

This commit is contained in:
DarkPhoenix
2019-08-20 21:48:06 +03:00
parent cf6f884b3b
commit 9572a51f28
2 changed files with 3 additions and 6 deletions

View File

@@ -141,9 +141,6 @@ class CapSimulator:
awaitingInjectorsCounterWrap = Counter()
self.reset()
#if len(self.state) == 0:
push = heapq.heappush
pop = heapq.heappop

View File

@@ -208,12 +208,12 @@ class DmgPatternEditor(AuxiliaryFrame):
if self.block:
return
p = self.entityEditor.getActiveEntity()
total = sum([getattr(self, "%sEdit" % attr).GetValueFloat() for attr in self.DAMAGE_TYPES])
total = sum([(getattr(self, "%sEdit" % attr).GetValueFloat() or 0) for attr in self.DAMAGE_TYPES])
for type_ in self.DAMAGE_TYPES:
editBox = getattr(self, "%sEdit" % type_)
percLabel = getattr(self, "%sPerc" % type_)
setattr(p, "%sAmount" % type_, editBox.GetValueFloat())
percLabel.SetLabel("%.1f%%" % (float(editBox.GetValueFloat()) * 100 / total if total > 0 else 0))
setattr(p, "%sAmount" % type_, editBox.GetValueFloat() or 0)
percLabel.SetLabel("%.1f%%" % ((editBox.GetValueFloat() or 0) * 100 / total if total > 0 else 0))
self.totSizer.Layout()
DamagePattern.getInstance().saveChanges(p)