v0.6.2b: fixed bugs and added several safety checks

This commit is contained in:
Evan Debenham
2017-11-09 17:39:55 -05:00
committed by Evan Debenham
parent 38e712cc50
commit 4ee449c918
5 changed files with 13 additions and 4 deletions

View File

@@ -44,7 +44,7 @@ public enum Music implements MediaPlayer.OnPreparedListener, MediaPlayer.OnError
public void play( String assetName, boolean looping ) {
if (isPlaying() && lastPlayed.equals( assetName )) {
if (isPlaying() && lastPlayed != null && lastPlayed.equals( assetName )) {
return;
}

View File

@@ -165,6 +165,13 @@ public class Tengu extends Mob {
private void jump() {
Level level = Dungeon.level;
//incase tengu hasn't had a chance to act yet
if (fieldOfView == null || fieldOfView.length != Dungeon.level.length()){
fieldOfView = new boolean[Dungeon.level.length()];
Dungeon.level.updateFieldOfView( this, fieldOfView );
}
if (enemy == null) enemy = chooseEnemy();
if (enemy == null) return;

View File

@@ -56,7 +56,9 @@ public class BlobEmitter extends Emitter {
for (int i = blob.area.left; i < blob.area.right; i++) {
for (int j = blob.area.top; j < blob.area.bottom; j++) {
cell = i + j*Dungeon.level.width();
if (map[cell] > 0 && Dungeon.level.heroFOV[cell]) {
if (map[cell] > 0
&& cell < Dungeon.level.heroFOV.length
&& Dungeon.level.heroFOV[cell]) {
float x = (i + Random.Float()) * size;
float y = (j + Random.Float()) * size;
factory.emit(this, index, x, y);

View File

@@ -96,7 +96,7 @@ public class FlowParticle extends PixelParticle {
@Override
public void update() {
if (visible = Dungeon.level.heroFOV[pos]) {
if (visible = (pos < Dungeon.level.heroFOV.length && Dungeon.level.heroFOV[pos])) {
super.update();

View File

@@ -902,7 +902,7 @@ public class GameScene extends PixelScene {
}
static boolean cancel() {
if (Dungeon.hero.curAction != null || Dungeon.hero.resting) {
if (Dungeon.hero != null || Dungeon.hero.curAction != null || Dungeon.hero.resting) {
Dungeon.hero.curAction = null;
Dungeon.hero.resting = false;