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,9 +631,11 @@ 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);
ch.damage(dmg, link); if (ch != null) {
if (!ch.isAlive()){ ch.damage(dmg, link);
link.detach(); if (!ch.isAlive()) {
link.detach();
}
} }
} }
} }
@@ -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,9 +876,13 @@ 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);
Talent talent = Talent.valueOf(tName); try {
if (tier.containsKey(talent)){ Talent talent = Talent.valueOf(tName);
tier.put(talent, Math.min(points, talent.maxPoints())); if (tier.containsKey(talent)) {
tier.put(talent, Math.min(points, talent.maxPoints()));
}
} catch (Exception e){
ShatteredPixelDungeon.reportException(e);
} }
} }
} }