diff --git a/pom.xml b/pom.xml
index 3d11bee..1ed287e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
org.dynmap
Dynmap-Factions
- 0.10
+ 0.11
diff --git a/src/main/java/org/dynmap/factions/DynmapFactionsPlugin.java b/src/main/java/org/dynmap/factions/DynmapFactionsPlugin.java
index 322db97..19342ac 100644
--- a/src/main/java/org/dynmap/factions/DynmapFactionsPlugin.java
+++ b/src/main/java/org/dynmap/factions/DynmapFactionsPlugin.java
@@ -1,5 +1,6 @@
package org.dynmap.factions;
+import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -181,14 +182,26 @@ public class DynmapFactionsPlugin extends JavaPlugin {
*/
private int floodFillTarget(TileFlags src, TileFlags dest, int x, int y) {
int cnt = 0;
- if(src.getFlag(x, y)) { /* Set in src */
- src.setFlag(x, y, false); /* Clear source */
- dest.setFlag(x, y, true); /* Set in destination */
- cnt++;
- cnt += floodFillTarget(src, dest, x+1, y); /* Fill adjacent blocks */
- cnt += floodFillTarget(src, dest, x-1, y);
- cnt += floodFillTarget(src, dest, x, y+1);
- cnt += floodFillTarget(src, dest, x, y-1);
+ ArrayDeque stack = new ArrayDeque();
+ stack.push(new int[] { x, y });
+
+ while(stack.isEmpty() == false) {
+ int[] nxt = stack.pop();
+ x = nxt[0];
+ y = nxt[1];
+ if(src.getFlag(x, y)) { /* Set in src */
+ src.setFlag(x, y, false); /* Clear source */
+ dest.setFlag(x, y, true); /* Set in destination */
+ cnt++;
+ if(src.getFlag(x+1, y))
+ stack.push(new int[] { x+1, y });
+ if(src.getFlag(x-1, y))
+ stack.push(new int[] { x-1, y });
+ if(src.getFlag(x, y+1))
+ stack.push(new int[] { x, y+1 });
+ if(src.getFlag(x, y-1))
+ stack.push(new int[] { x, y-1 });
+ }
}
return cnt;
}
diff --git a/src/main/java/org/dynmap/factions/TileFlags.java b/src/main/java/org/dynmap/factions/TileFlags.java
index 7978ac9..0c180fb 100644
--- a/src/main/java/org/dynmap/factions/TileFlags.java
+++ b/src/main/java/org/dynmap/factions/TileFlags.java
@@ -12,7 +12,7 @@ import java.util.HashMap;
*/
public class TileFlags {
private HashMap chunkmap = new HashMap();
- private long last_key = Long.MIN_VALUE;
+ private long last_key = Long.MAX_VALUE;
private long[] last_row;
public TileFlags() {
@@ -62,6 +62,6 @@ public class TileFlags {
public void clear() {
chunkmap.clear();
last_row = null;
- last_key = Long.MIN_VALUE;
+ last_key = Long.MAX_VALUE;
}
}