v0.4.2a: fixed additional map bounds errors relating to blobs

This commit is contained in:
Evan Debenham 2016-09-10 23:28:37 -04:00
parent 184993936e
commit cb1f63890b
2 changed files with 42 additions and 42 deletions

View File

@ -149,6 +149,7 @@ public class Blob extends Actor {
for (int i=area.top-1; i <= area.bottom; i++) { for (int i=area.top-1; i <= area.bottom; i++) {
for (int j = area.left-1; j <= area.right; j++) { for (int j = area.left-1; j <= area.right; j++) {
cell = j + i*Dungeon.level.width(); cell = j + i*Dungeon.level.width();
if (Dungeon.level.insideMap(cell)) {
if (!blocking[cell]) { if (!blocking[cell]) {
int count = 1; int count = 1;
@ -192,6 +193,7 @@ public class Blob extends Actor {
} }
} }
} }
}
public void seed( Level level, int cell, int amount ) { public void seed( Level level, int cell, int amount ) {
if (cur == null) cur = new int[level.length()]; if (cur == null) cur = new int[level.length()];

View File

@ -1001,12 +1001,10 @@ public abstract class Level implements Bundlable {
//returns true if the input is a valid tile within the level //returns true if the input is a valid tile within the level
public boolean insideMap( int tile ){ public boolean insideMap( int tile ){
//outside map array //top and bottom row and beyond
return !((tile < 0 || tile >= length()) || return !((tile < width || tile >= length - width) ||
//top and bottom row
(tile < width() || tile >= length() - width()) ||
//left and right column //left and right column
(tile % width() == 0 || tile % width() == width()-1)); (tile % width == 0 || tile % width == width-1));
} }
public Point cellToPoint( int cell ){ public Point cellToPoint( int cell ){