v0.8.0b: added a few safety checks to prevent rare crashes

This commit is contained in:
Evan Debenham 2020-05-05 12:17:29 -04:00
parent 9912c5e1ee
commit f2d0aa959a
3 changed files with 20 additions and 11 deletions

View File

@ -54,6 +54,13 @@ public class DM201 extends DM200 {
@Override @Override
protected boolean act() { protected boolean act() {
//in case DM-201 hasn't been able to act yet
if (fieldOfView == null || fieldOfView.length != Dungeon.level.length()){
fieldOfView = new boolean[Dungeon.level.length()];
Dungeon.level.updateFieldOfView( this, fieldOfView );
}
GameScene.add(Blob.seed(pos, 0, CorrosiveGas.class)); GameScene.add(Blob.seed(pos, 0, CorrosiveGas.class));
if (state == HUNTING && enemy != null && enemySeen if (state == HUNTING && enemy != null && enemySeen
&& threatened && !Dungeon.level.adjacent(pos, enemy.pos)){ && threatened && !Dungeon.level.adjacent(pos, enemy.pos)){

View File

@ -45,7 +45,7 @@ public class AttackIndicator extends Tag {
private CharSprite sprite = null; private CharSprite sprite = null;
private static Mob lastTarget; private Mob lastTarget;
private ArrayList<Mob> candidates = new ArrayList<>(); private ArrayList<Mob> candidates = new ArrayList<>();
public AttackIndicator() { public AttackIndicator() {
@ -74,7 +74,7 @@ public class AttackIndicator extends Tag {
super.layout(); super.layout();
if (sprite != null) { if (sprite != null) {
sprite.x = x + (width - sprite.width()) / 2; sprite.x = x + (width - sprite.width()) / 2 + 1;
sprite.y = y + (height - sprite.height()) / 2; sprite.y = y + (height - sprite.height()) / 2;
PixelScene.align(sprite); PixelScene.align(sprite);
} }
@ -148,9 +148,7 @@ public class AttackIndicator extends Tag {
sprite.paused = true; sprite.paused = true;
add( sprite ); add( sprite );
sprite.x = x + (width - sprite.width()) / 2 + 1; layout();
sprite.y = y + (height - sprite.height()) / 2;
PixelScene.align(sprite);
} }
private boolean enabled = true; private boolean enabled = true;
@ -178,10 +176,12 @@ public class AttackIndicator extends Tag {
} }
public static void target( Char target ) { public static void target( Char target ) {
lastTarget = (Mob)target; synchronized (instance) {
instance.lastTarget = (Mob) target;
instance.updateImage(); instance.updateImage();
TargetHealthIndicator.instance.target( target ); TargetHealthIndicator.instance.target(target);
}
} }
public static void updateState() { public static void updateState() {

View File

@ -125,8 +125,10 @@ public class WndStartGame extends Window {
ShatteredPixelDungeon.scene().addToFront(new WndChallenges(SPDSettings.challenges(), true) { ShatteredPixelDungeon.scene().addToFront(new WndChallenges(SPDSettings.challenges(), true) {
public void onBackPressed() { public void onBackPressed() {
super.onBackPressed(); super.onBackPressed();
icon( Icons.get( SPDSettings.challenges() > 0 ? if (parent != null) {
Icons.CHALLENGE_ON :Icons.CHALLENGE_OFF ) ); icon(Icons.get(SPDSettings.challenges() > 0 ?
Icons.CHALLENGE_ON : Icons.CHALLENGE_OFF));
}
} }
} ); } );
} }