Archiviert
13
0

[Testing] improve oreobf performance / potentially fix errors

Dieser Commit ist enthalten in:
md_5 2013-06-01 16:13:33 +10:00
Ursprung 53d9d1734b
Commit 1d56399e16

Datei anzeigen

@ -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 <md_5@live.com.au> From: md_5 <md_5@live.com.au>
Date: Thu, 16 May 2013 18:51:05 +1000 Date: Thu, 16 May 2013 18:51:05 +1000
Subject: [PATCH] Orebfuscator 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 diff --git a/src/main/java/org/spigotmc/OrebfuscatorManager.java b/src/main/java/org/spigotmc/OrebfuscatorManager.java
new file mode 100644 new file mode 100644
index 0000000..2adfb86 index 0000000..ab4d409
--- /dev/null --- /dev/null
+++ b/src/main/java/org/spigotmc/OrebfuscatorManager.java +++ b/src/main/java/org/spigotmc/OrebfuscatorManager.java
@@ -0,0 +1,205 @@ @@ -0,0 +1,186 @@
+package org.spigotmc; +package org.spigotmc;
+ +
+import gnu.trove.set.TByteSet; +import gnu.trove.set.TByteSet;
@ -261,8 +261,6 @@ index 0000000..2adfb86
+ // If the world is marked as obfuscated + // If the world is marked as obfuscated
+ if ( world.getWorld().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 + // Which block in the buffer we are looking at, anywhere from 0 to 16^4
+ int index = 0; + int index = 0;
+ // The iterator marking which random ore we should use next + // The iterator marking which random ore we should use next
@ -291,13 +289,8 @@ index 0000000..2adfb86
+ // Check if the block should be obfuscated + // Check if the block should be obfuscated
+ if ( obfuscateBlocks[blockId] ) + if ( obfuscateBlocks[blockId] )
+ { + {
+ // TODO: Don't really understand this, but if radius is not 0 and the world isn't loaded, bail out + // If the nearby blocks are all non air / transparent, we can obfuscate
+ if ( initialRadius != 0 && !isLoaded( world, startX + x, ( i << 4 ) + y, startZ + z, initialRadius ) ) + if ( !hasTransparentBlockAdjacent( world, startX + x, ( i << 4 ) + y, startZ + z, 1 ) )
+ {
+ 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 ) )
+ { + {
+ switch ( world.getServer().orebfuscatorEngineMode ) + 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) + 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 + || ( radius > 0
+ && ( hasTransparentBlockAdjacent( world, x + 1, y, z, radius - 1 ) + && ( hasTransparentBlockAdjacent( world, x + 1, y, z, radius - 1 )
+ || 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 + - world_the_end
+ blocks: [1, 5, 14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130] + blocks: [1, 5, 14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130]
-- --
1.8.2.1 1.8.1.2