From 1d56399e1688b8947939f26783aecfef51bdd6f6 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 1 Jun 2013 16:13:33 +1000 Subject: [PATCH] [Testing] improve oreobf performance / potentially fix errors --- CraftBukkit-Patches/0015-Orebfuscator.patch | 33 +++++---------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/CraftBukkit-Patches/0015-Orebfuscator.patch b/CraftBukkit-Patches/0015-Orebfuscator.patch index 1a22e122a9..fbb41e4d58 100644 --- a/CraftBukkit-Patches/0015-Orebfuscator.patch +++ b/CraftBukkit-Patches/0015-Orebfuscator.patch @@ -1,4 +1,4 @@ -From 1f02c5a6aeba3f32a2a162437d3a43d589f2f96d Mon Sep 17 00:00:00 2001 +From 920d39b5cabeb00b96713ff75df69d576c906283 Mon Sep 17 00:00:00 2001 From: md_5 Date: Thu, 16 May 2013 18:51:05 +1000 Subject: [PATCH] Orebfuscator @@ -173,10 +173,10 @@ index 67477f4..e5004b3 100644 } diff --git a/src/main/java/org/spigotmc/OrebfuscatorManager.java b/src/main/java/org/spigotmc/OrebfuscatorManager.java new file mode 100644 -index 0000000..2adfb86 +index 0000000..ab4d409 --- /dev/null +++ b/src/main/java/org/spigotmc/OrebfuscatorManager.java -@@ -0,0 +1,205 @@ +@@ -0,0 +1,186 @@ +package org.spigotmc; + +import gnu.trove.set.TByteSet; @@ -261,8 +261,6 @@ index 0000000..2adfb86 + // If the world is marked as obfuscated + if ( world.getWorld().obfuscated ) + { -+ // Initial radius to search around for air -+ int initialRadius = 1; + // Which block in the buffer we are looking at, anywhere from 0 to 16^4 + int index = 0; + // The iterator marking which random ore we should use next @@ -291,13 +289,8 @@ index 0000000..2adfb86 + // Check if the block should be obfuscated + if ( obfuscateBlocks[blockId] ) + { -+ // TODO: Don't really understand this, but if radius is not 0 and the world isn't loaded, bail out -+ if ( initialRadius != 0 && !isLoaded( world, startX + x, ( i << 4 ) + y, startZ + z, initialRadius ) ) -+ { -+ continue; -+ } -+ // On the otherhand, if radius is 0, or the nearby blocks are all non air, we can obfuscate -+ if ( initialRadius == 0 || !hasTransparentBlockAdjacent( world, startX + x, ( i << 4 ) + y, startZ + z, initialRadius ) ) ++ // If the nearby blocks are all non air / transparent, we can obfuscate ++ if ( !hasTransparentBlockAdjacent( world, startX + x, ( i << 4 ) + y, startZ + z, 1 ) ) + { + switch ( world.getServer().orebfuscatorEngineMode ) + { @@ -358,21 +351,9 @@ index 0000000..2adfb86 + } + } + -+ private static boolean isLoaded(World world, int x, int y, int z, int radius) -+ { -+ return world.isLoaded( x, y, z ) -+ || ( radius > 0 -+ && ( isLoaded( world, x + 1, y, z, radius - 1 ) -+ || isLoaded( world, x - 1, y, z, radius - 1 ) -+ || isLoaded( world, x, y + 1, z, radius - 1 ) -+ || isLoaded( world, x, y - 1, z, radius - 1 ) -+ || isLoaded( world, x, y, z + 1, radius - 1 ) -+ || isLoaded( world, x, y, z - 1, radius - 1 ) ) ); -+ } -+ + private static boolean hasTransparentBlockAdjacent(World world, int x, int y, int z, int radius) + { -+ return !Block.l( world.getTypeId( x, y, z ) ) /* isSolidBlock */ ++ return world.isLoaded( x, y, z ) && !Block.l( world.getTypeId( x, y, z ) ) /* isSolidBlock */ + || ( radius > 0 + && ( hasTransparentBlockAdjacent( world, x + 1, y, z, radius - 1 ) + || hasTransparentBlockAdjacent( world, x - 1, y, z, radius - 1 ) @@ -397,5 +378,5 @@ index 10ef7f2..e08325d 100644 + - world_the_end + blocks: [1, 5, 14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130] -- -1.8.2.1 +1.8.1.2