v2.0.0: added a couple of safety checks to prevent rare crashes

This commit is contained in:
Evan Debenham
2023-02-13 14:41:37 -05:00
parent 22d83665ce
commit 412627bd00
2 changed files with 13 additions and 6 deletions
@@ -631,12 +631,14 @@ public abstract class Char extends Actor {
dmg = (int)Math.ceil(dmg / (float)(links.size()+1)); dmg = (int)Math.ceil(dmg / (float)(links.size()+1));
for (LifeLink link : links){ for (LifeLink link : links){
Char ch = (Char)Actor.findById(link.object); Char ch = (Char)Actor.findById(link.object);
if (ch != null) {
ch.damage(dmg, link); ch.damage(dmg, link);
if (!ch.isAlive()){ if (!ch.isAlive()) {
link.detach(); link.detach();
} }
} }
} }
}
Terror t = buff(Terror.class); Terror t = buff(Terror.class);
if (t != null){ if (t != null){
@@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.hero;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress; import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.ArtifactRecharge; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.ArtifactRecharge;
@@ -875,10 +876,14 @@ public enum Talent {
for (String tName : tierBundle.getKeys()){ for (String tName : tierBundle.getKeys()){
int points = tierBundle.getInt(tName); int points = tierBundle.getInt(tName);
if (renamedTalents.containsKey(tName)) tName = renamedTalents.get(tName); if (renamedTalents.containsKey(tName)) tName = renamedTalents.get(tName);
try {
Talent talent = Talent.valueOf(tName); Talent talent = Talent.valueOf(tName);
if (tier.containsKey(talent)){ if (tier.containsKey(talent)) {
tier.put(talent, Math.min(points, talent.maxPoints())); tier.put(talent, Math.min(points, talent.maxPoints()));
} }
} catch (Exception e){
ShatteredPixelDungeon.reportException(e);
}
} }
} }
} }