From 9dc324f00ad380fb85a41c8a4bdd7dd61e1f48b5 Mon Sep 17 00:00:00 2001 From: sk89q Date: Thu, 14 Oct 2010 12:06:14 -0700 Subject: [PATCH] Fill routine is now no longer dependent on the state of a block as reported by the server (infinite recursion fixed on non-block items). --- src/EditSession.java | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/EditSession.java b/src/EditSession.java index a02faedcb..362281dd7 100644 --- a/src/EditSession.java +++ b/src/EditSession.java @@ -23,6 +23,7 @@ import com.sk89q.worldedit.blocks.SignBlock; import com.sk89q.worldedit.blocks.BaseBlock; import java.util.Map; import java.util.HashMap; +import java.util.Set; import java.util.HashSet; import java.util.Stack; import com.sk89q.worldedit.*; @@ -328,8 +329,37 @@ public class EditSession { * @param depth * @return number of blocks affected */ - public int fillXZ(int x, int z, Vector origin, BaseBlock block, int radius, int depth) + public int fillXZ(int x, int z, Vector origin, BaseBlock block, + int radius, int depth) throws MaxChangedBlocksException { + return _fillXZ(x, z, origin, block, radius, depth, + new HashSet()); + } + + /** + * Fills an area recursively in the X/Z directions. + * + * @param x + * @param z + * @param origin + * @param block + * @param radius + * @param depth + * @param visited + * @return + * @throws MaxChangedBlocksException + */ + private int _fillXZ(int x, int z, Vector origin, BaseBlock block, int radius, + int depth, Set visited) + throws MaxChangedBlocksException { + BlockVector pt = new BlockVector(x, 0, z); + + if (visited.contains(pt)) { + return 0; + } + + visited.add(pt); + double dist = Math.sqrt(Math.pow(origin.getX() - x, 2) + Math.pow(origin.getZ() - z, 2)); int minY = origin.getBlockY() - depth + 1; int affected = 0;