v0.7.5d: added various safety checks

This commit is contained in:
Evan Debenham 2019-10-19 11:59:15 -04:00
parent 2c2cae01b5
commit 9c652273a5
3 changed files with 20 additions and 9 deletions

View File

@ -22,6 +22,7 @@
package com.watabou.noosa.audio;
import com.badlogic.gdx.Gdx;
import com.watabou.noosa.Game;
public enum Music {
@ -50,10 +51,15 @@ public enum Music {
return;
}
player = Gdx.audio.newMusic(Gdx.files.internal(assetName));
player.setLooping(looping);
player.setVolume(volume);
player.play();
try {
player = Gdx.audio.newMusic(Gdx.files.internal(assetName));
player.setLooping(looping);
player.setVolume(volume);
player.play();
} catch (Exception e){
Game.reportException(e);
player = null;
}
}

View File

@ -52,10 +52,15 @@ public class Ballistica {
public Ballistica( int from, int to, int params ){
sourcePos = from;
build(from, to, (params & STOP_TARGET) > 0, (params & STOP_CHARS) > 0, (params & STOP_TERRAIN) > 0);
if (collisionPos != null)
dist = path.indexOf( collisionPos );
else
collisionPos = path.get( dist=path.size()-1 );
if (collisionPos != null) {
dist = path.indexOf(collisionPos);
} else if (!path.isEmpty()) {
collisionPos = path.get(dist = path.size() - 1);
} else {
path.add(from);
collisionPos = from;
dist = 0;
}
}
private void build( int from, int to, boolean stopTarget, boolean stopChars, boolean stopTerrain ) {

View File

@ -67,7 +67,7 @@ public class WndGame extends Window {
}
// Restart
if (!Dungeon.hero.isAlive()) {
if (Dungeon.hero == null || !Dungeon.hero.isAlive()) {
RedButton btnStart;
addButton( btnStart = new RedButton( Messages.get(this, "start") ) {