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

This commit is contained in:
Evan Debenham 2020-09-18 01:35:33 -04:00
parent 9e6a349f2a
commit 023f746df7
3 changed files with 12 additions and 6 deletions

View File

@ -93,7 +93,7 @@ public class Camera extends Gizmo {
int length = all.size(); int length = all.size();
for (int i=0; i < length; i++) { for (int i=0; i < length; i++) {
Camera c = all.get( i ); Camera c = all.get( i );
if (c.exists && c.active) { if (c != null && c.exists && c.active) {
c.update(); c.update();
} }
} }

View File

@ -62,7 +62,8 @@ public class MovieClip extends Image {
frameTimer += Game.elapsed; frameTimer += Game.elapsed;
while (frameTimer > curAnim.delay) { while (frameTimer > curAnim.delay) {
frameTimer -= curAnim.delay; frameTimer -= curAnim.delay;
if (curFrame == curAnim.frames.length - 1) { if (curFrame >= curAnim.frames.length - 1) {
curFrame = curAnim.frames.length - 1;
if (curAnim.looped) { if (curAnim.looped) {
curFrame = 0; curFrame = 0;
} }

View File

@ -1319,14 +1319,19 @@ public class Hero extends Char {
return false; return false;
} }
Char ch; if (fieldOfView == null || fieldOfView.length != Dungeon.level.length()){
Heap heap; fieldOfView = new boolean[Dungeon.level.length()];
Dungeon.level.updateFieldOfView( this, fieldOfView );
}
Char ch = Actor.findChar( cell );
Heap heap = Dungeon.level.heaps.get( cell );
if (Dungeon.level.map[cell] == Terrain.ALCHEMY && cell != pos) { if (Dungeon.level.map[cell] == Terrain.ALCHEMY && cell != pos) {
curAction = new HeroAction.Alchemy( cell ); curAction = new HeroAction.Alchemy( cell );
} else if (fieldOfView[cell] && (ch = Actor.findChar( cell )) instanceof Mob) { } else if (fieldOfView[cell] && ch instanceof Mob) {
if (ch.alignment != Alignment.ENEMY && ch.buff(Amok.class) == null) { if (ch.alignment != Alignment.ENEMY && ch.buff(Amok.class) == null) {
curAction = new HeroAction.Interact( ch ); curAction = new HeroAction.Interact( ch );
@ -1334,7 +1339,7 @@ public class Hero extends Char {
curAction = new HeroAction.Attack( ch ); curAction = new HeroAction.Attack( ch );
} }
} else if ((heap = Dungeon.level.heaps.get( cell )) != null } else if (heap != null
//moving to an item doesn't auto-pickup when enemies are near... //moving to an item doesn't auto-pickup when enemies are near...
&& (visibleEnemies.size() == 0 || cell == pos || && (visibleEnemies.size() == 0 || cell == pos ||
//...but only for standard heaps, chests and similar open as normal. //...but only for standard heaps, chests and similar open as normal.