v0.6.2a: added safety and sync checks for a number of rare crashes

This commit is contained in:
Evan Debenham 2017-11-01 02:14:46 -04:00
parent 3a6ae784f7
commit 4a9ce5dae1
8 changed files with 15 additions and 13 deletions

View File

@ -989,7 +989,7 @@ public class Hero extends Char {
boolean newMob = false; boolean newMob = false;
Mob target = null; Mob target = null;
for (Mob m : Dungeon.level.mobs) { for (Mob m : Dungeon.level.mobs.toArray(new Mob[0])) {
if (fieldOfView[ m.pos ] && m.alignment == Alignment.ENEMY) { if (fieldOfView[ m.pos ] && m.alignment == Alignment.ENEMY) {
visible.add(m); visible.add(m);
if (!visibleEnemies.contains( m )) { if (!visibleEnemies.contains( m )) {

View File

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

View File

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

View File

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

View File

@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap; import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap; import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
import com.watabou.input.Touchscreen.Touch; import com.watabou.input.Touchscreen.Touch;
@ -57,7 +58,7 @@ public class CellSelector extends TouchArea {
} else { } else {
PointF p = Camera.main.screenToCamera( (int)touch.current.x, (int)touch.current.y ); PointF p = Camera.main.screenToCamera( (int)touch.current.x, (int)touch.current.y );
for (Char mob : Dungeon.level.mobs){ for (Char mob : Dungeon.level.mobs.toArray(new Mob[0])){
if (mob.sprite != null && mob.sprite.overlapsPoint( p.x, p.y)){ if (mob.sprite != null && mob.sprite.overlapsPoint( p.x, p.y)){
select( mob.pos ); select( mob.pos );
return; return;

View File

@ -208,7 +208,7 @@ public class ItemSprite extends MovieClip {
} }
} }
public void glow( Glowing glowing ){ public synchronized void glow( Glowing glowing ){
this.glowing = glowing; this.glowing = glowing;
if (glowing == null) resetColor(); if (glowing == null) resetColor();
} }
@ -269,7 +269,7 @@ public class ItemSprite extends MovieClip {
} }
@Override @Override
public void update() { public synchronized void update() {
super.update(); super.update();
visible = (heap == null || heap.seen); visible = (heap == null || heap.seen);

View File

@ -63,7 +63,7 @@ public class AttackIndicator extends Tag {
} }
@Override @Override
protected void layout() { protected synchronized void layout() {
super.layout(); super.layout();
if (sprite != null) { if (sprite != null) {
@ -127,7 +127,7 @@ public class AttackIndicator extends Tag {
enable( bg.visible ); enable( bg.visible );
} }
private void updateImage() { private synchronized void updateImage() {
if (sprite != null) { if (sprite != null) {
sprite.killAndErase(); sprite.killAndErase();
@ -151,14 +151,14 @@ public class AttackIndicator extends Tag {
} }
private boolean enabled = true; private boolean enabled = true;
private void enable( boolean value ) { private synchronized void enable( boolean value ) {
enabled = value; enabled = value;
if (sprite != null) { if (sprite != null) {
sprite.alpha( value ? ENABLED : DISABLED ); sprite.alpha( value ? ENABLED : DISABLED );
} }
} }
private void visible( boolean value ) { private synchronized void visible( boolean value ) {
bg.visible = value; bg.visible = value;
if (sprite != null) { if (sprite != null) {
sprite.visible = value; sprite.visible = value;

View File

@ -39,8 +39,9 @@ import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
public class BuffIndicator extends Component { public class BuffIndicator extends Component {
public static final int NONE = -1; //transparent icon
public static final int NONE = 63;
//TODO consider creating an enum to store both index, and tint. Saves making separate images for color differences. //TODO consider creating an enum to store both index, and tint. Saves making separate images for color differences.
public static final int MIND_VISION = 0; public static final int MIND_VISION = 0;