v2.0.1: added various safety checks for rare crashes

This commit is contained in:
Evan Debenham
2023-03-20 17:00:05 -04:00
parent 1685809d9f
commit 1ce9b5d1d5
3 changed files with 11 additions and 2 deletions

View File

@@ -1992,6 +1992,12 @@ public class Hero extends Char {
@Override
public void onAttackComplete() {
if (enemy == null){
curAction = null;
super.onAttackComplete();
return;
}
AttackIndicator.target(enemy);
boolean wasEnemy = enemy.alignment == Alignment.ENEMY

View File

@@ -698,7 +698,7 @@ public abstract class Mob extends Char {
public boolean surprisedBy( Char enemy, boolean attacking ){
return enemy == Dungeon.hero
&& (enemy.invisible > 0 || !enemySeen || (fieldOfView != null && !fieldOfView[enemy.pos]))
&& (enemy.invisible > 0 || !enemySeen || (fieldOfView != null && fieldOfView.length == Dungeon.level.length() && !fieldOfView[enemy.pos]))
&& (!attacking || enemy.canSurpriseAttack());
}

View File

@@ -172,7 +172,10 @@ public class Item implements Bundlable {
}
public void execute( Hero hero ) {
execute( hero, defaultAction() );
String action = defaultAction();
if (action != null) {
execute(hero, defaultAction());
}
}
protected void onThrow( int cell ) {