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

View File

@@ -631,9 +631,11 @@ public abstract class Char extends Actor {
dmg = (int)Math.ceil(dmg / (float)(links.size()+1));
for (LifeLink link : links){
Char ch = (Char)Actor.findById(link.object);
ch.damage(dmg, link);
if (!ch.isAlive()){
link.detach();
if (ch != null) {
ch.damage(dmg, link);
if (!ch.isAlive()) {
link.detach();
}
}
}
}

View File

@@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.hero;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.ArtifactRecharge;
@@ -875,9 +876,13 @@ public enum Talent {
for (String tName : tierBundle.getKeys()){
int points = tierBundle.getInt(tName);
if (renamedTalents.containsKey(tName)) tName = renamedTalents.get(tName);
Talent talent = Talent.valueOf(tName);
if (tier.containsKey(talent)){
tier.put(talent, Math.min(points, talent.maxPoints()));
try {
Talent talent = Talent.valueOf(tName);
if (tier.containsKey(talent)) {
tier.put(talent, Math.min(points, talent.maxPoints()));
}
} catch (Exception e){
ShatteredPixelDungeon.reportException(e);
}
}
}