Parcourir la source

Correct bug in SquidIterators.RectangleFromBottomLeftToTopRight when dealing with cells on the dungeon's edge, which was affecting Zone's Rectangle::getAll!

smelc il y a 7 ans
Parent
commit
fd3f326305

+ 1 - 1
.settings/org.eclipse.buildship.core.prefs

@@ -1,3 +1,3 @@
 connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
-connection.project.dir=
+connection.project.dir=../gradle
 eclipse.preferences.version=1

+ 1 - 1
squidlib-util/src/main/java/squidpony/squidgrid/iterator/SquidIterators.java

@@ -338,7 +338,7 @@ public class SquidIterators {
 
 				if (previous.x == xstart + width - 1) {
 					/* Need to go up and left (one column up, go left) */
-					if (previous.y == ystart - (height - 1) || previous.y == 0) {
+					if (previous.y == ystart - (height - 1)) {
 						/* We're done */
 						return null;
 					} else

+ 4 - 1
squidlib-util/src/main/java/squidpony/squidgrid/mapping/Rectangle.java

@@ -152,6 +152,7 @@ public interface Rectangle extends Zone {
 			final Iterator<Coord> it = cells(r);
 			while (it.hasNext())
 				result.add(it.next());
+			assert result.size() == size(r);
 			return result;
 		}
 
@@ -406,7 +407,9 @@ public interface Rectangle extends Zone {
 
 		@Override
 		public List<Coord> getAll() {
-			return Utils.cellsList(this);
+			final List<Coord> result = Utils.cellsList(this);
+			assert result.size() == size();
+			return result;
 		}
 
 		@Override