v0.8.1a: fixed a variety of rare crashes caused by:

- shields rarely failing to apply (having no target)
- ghouls dieing while over pits
- Tengu having nowhere to jump in rare cases
- multiplicity when the attacker is the hero
- talisman buffs not always respecting floor differences
- null pointers in reflection
This commit is contained in:
Evan Debenham 2020-06-30 20:18:55 -04:00
parent b3783295bf
commit bc757ed57b
8 changed files with 17 additions and 17 deletions

View File

@ -39,7 +39,7 @@ public class Reflection {
public static <T> T newInstance( Class<T> cls ){ public static <T> T newInstance( Class<T> cls ){
try { try {
return ClassReflection.newInstance(cls); return ClassReflection.newInstance(cls);
} catch (ReflectionException e) { } catch (Exception e) {
Game.reportException(e); Game.reportException(e);
return null; return null;
} }
@ -52,7 +52,7 @@ public class Reflection {
public static Class forName( String name ){ public static Class forName( String name ){
try { try {
return ClassReflection.forName( name ); return ClassReflection.forName( name );
} catch (ReflectionException e) { } catch (Exception e) {
Game.reportException(e); Game.reportException(e);
return null; return null;
} }

View File

@ -801,6 +801,7 @@ public class Dungeon {
} }
for (TalismanOfForesight.CharAwareness c : hero.buffs(TalismanOfForesight.CharAwareness.class)){ for (TalismanOfForesight.CharAwareness c : hero.buffs(TalismanOfForesight.CharAwareness.class)){
if (Dungeon.depth != c.depth) continue;
Char ch = (Char) Actor.findById(c.charID); Char ch = (Char) Actor.findById(c.charID);
if (ch == null) continue; if (ch == null) continue;
BArray.or( level.visited, level.heroFOV, ch.pos - 1 - level.width(), 3, level.visited ); BArray.or( level.visited, level.heroFOV, ch.pos - 1 - level.width(), 3, level.visited );
@ -810,6 +811,7 @@ public class Dungeon {
} }
for (TalismanOfForesight.HeapAwareness h : hero.buffs(TalismanOfForesight.HeapAwareness.class)){ for (TalismanOfForesight.HeapAwareness h : hero.buffs(TalismanOfForesight.HeapAwareness.class)){
if (Dungeon.depth != h.depth) continue;
BArray.or( level.visited, level.heroFOV, h.pos - 1 - level.width(), 3, level.visited ); BArray.or( level.visited, level.heroFOV, h.pos - 1 - level.width(), 3, level.visited );
BArray.or( level.visited, level.heroFOV, h.pos - 1, 3, level.visited ); BArray.or( level.visited, level.heroFOV, h.pos - 1, 3, level.visited );
BArray.or( level.visited, level.heroFOV, h.pos - 1 + level.width(), 3, level.visited ); BArray.or( level.visited, level.heroFOV, h.pos - 1 + level.width(), 3, level.visited );

View File

@ -50,7 +50,7 @@ public abstract class ShieldBuff extends Buff {
public void setShield( int shield ) { public void setShield( int shield ) {
this.shielding = shield; this.shielding = shield;
target.needsShieldUpdate = true; if (target != null) target.needsShieldUpdate = true;
} }
public void incShield(){ public void incShield(){
@ -59,7 +59,7 @@ public abstract class ShieldBuff extends Buff {
public void incShield( int amt ){ public void incShield( int amt ){
shielding += amt; shielding += amt;
target.needsShieldUpdate = true; if (target != null) target.needsShieldUpdate = true;
} }
public void decShield(){ public void decShield(){
@ -68,7 +68,7 @@ public abstract class ShieldBuff extends Buff {
public void decShield( int amt ){ public void decShield( int amt ){
shielding -= amt; shielding -= amt;
target.needsShieldUpdate = true; if (target != null) target.needsShieldUpdate = true;
} }
//returns the amount of damage leftover //returns the amount of damage leftover
@ -83,7 +83,7 @@ public abstract class ShieldBuff extends Buff {
if (shielding == 0){ if (shielding == 0){
detach(); detach();
} }
target.needsShieldUpdate = true; if (target != null) target.needsShieldUpdate = true;
return dmg; return dmg;
} }

View File

@ -138,7 +138,7 @@ public class Ghoul extends Mob {
@Override @Override
public void die(Object cause) { public void die(Object cause) {
if (cause != Chasm.class && cause != GhoulLifeLink.class){ if (cause != Chasm.class && cause != GhoulLifeLink.class && !Dungeon.level.pit[pos]){
Ghoul nearby = GhoulLifeLink.searchForHost(this); Ghoul nearby = GhoulLifeLink.searchForHost(this);
if (nearby != null){ if (nearby != null){
beingLifeLinked = true; beingLifeLinked = true;

View File

@ -868,13 +868,10 @@ public abstract class Mob extends Char {
} else { } else {
//if moving towards an enemy isn't possible, try to switch targets to another enemy that is closer //if moving towards an enemy isn't possible, try to switch targets to another enemy that is closer
Char oldEnemy = enemy; Char newEnemy = chooseEnemy();
enemy = null; if (newEnemy != null && enemy != newEnemy){
enemy = chooseEnemy(); enemy = newEnemy;
if (enemy != null && enemy != oldEnemy){
return act(enemyInFOV, justAlerted); return act(enemyInFOV, justAlerted);
} else {
enemy = oldEnemy;
} }
spend( TICK ); spend( TICK );

View File

@ -244,8 +244,8 @@ public class NewTengu extends Mob {
do { do {
newPos = ((NewPrisonBossLevel)Dungeon.level).randomTenguCellPos(); newPos = ((NewPrisonBossLevel)Dungeon.level).randomTenguCellPos();
} while ( level.trueDistance(newPos, enemy.pos) <= 4 } while ( level.trueDistance(newPos, enemy.pos) <= 3.5f
|| level.trueDistance(newPos, Dungeon.hero.pos) <= 4 || level.trueDistance(newPos, Dungeon.hero.pos) <= 3.5f
|| Actor.findChar(newPos) != null); || Actor.findChar(newPos) != null);
if (level.heroFOV[pos]) CellEmitter.get( pos ).burst( Speck.factory( Speck.WOOL ), 6 ); if (level.heroFOV[pos]) CellEmitter.get( pos ).burst( Speck.factory( Speck.WOOL ), 6 );

View File

@ -114,7 +114,7 @@ public class Warlock extends Mob implements Callback {
int dmg = Random.NormalIntRange( 12, 18 ); int dmg = Random.NormalIntRange( 12, 18 );
enemy.damage( dmg, new DarkBolt() ); enemy.damage( dmg, new DarkBolt() );
if (!enemy.isAlive() && enemy == Dungeon.hero) { if (enemy == Dungeon.hero && !enemy.isAlive()) {
Dungeon.fail( getClass() ); Dungeon.fail( getClass() );
GLog.n( Messages.get(this, "bolt_kill") ); GLog.n( Messages.get(this, "bolt_kill") );
} }

View File

@ -68,7 +68,8 @@ public class Multiplicity extends Armor.Glyph {
} else { } else {
//FIXME should probably have a mob property for this //FIXME should probably have a mob property for this
if (attacker.properties().contains(Char.Property.BOSS) || attacker.properties().contains(Char.Property.MINIBOSS) if (!(attacker instanceof Mob)
|| attacker.properties().contains(Char.Property.BOSS) || attacker.properties().contains(Char.Property.MINIBOSS)
|| attacker instanceof Mimic || attacker instanceof Statue){ || attacker instanceof Mimic || attacker instanceof Statue){
m = Dungeon.level.createMob(); m = Dungeon.level.createMob();
} else { } else {