diff --git a/MCGalaxy/Database/BlockDB/BlockDB.cs b/MCGalaxy/Database/BlockDB/BlockDB.cs index d18c71b31..9242767dc 100644 --- a/MCGalaxy/Database/BlockDB/BlockDB.cs +++ b/MCGalaxy/Database/BlockDB/BlockDB.cs @@ -48,7 +48,7 @@ namespace MCGalaxy.DB { ReadDimensions(); Locker = new IReaderWriterLock(); - if (Dims.X < lvl.Width) Dims.X = lvl.Width; + if (Dims.X < lvl.Width) Dims.X = lvl.Width; if (Dims.Y < lvl.Height) Dims.Y = lvl.Height; if (Dims.Z < lvl.Length) Dims.Z = lvl.Length; Cache.Dims = Dims; diff --git a/MCGalaxy/MCGalaxy_.csproj b/MCGalaxy/MCGalaxy_.csproj index 583a5ab5e..f2cbed841 100644 --- a/MCGalaxy/MCGalaxy_.csproj +++ b/MCGalaxy/MCGalaxy_.csproj @@ -51,7 +51,7 @@ PdbOnly True ..\bin\Release\ - TRACE;TEN_BIT_BLOCKS + TRACE prompt 4 ..\..\Source\General.ruleset @@ -64,10 +64,6 @@ - - False - obj\ - ..\LibNoise.dll diff --git a/MCGalaxy/util/SparseBitSet.cs b/MCGalaxy/util/SparseBitSet.cs index 719ba7ed9..c6c322cb5 100644 --- a/MCGalaxy/util/SparseBitSet.cs +++ b/MCGalaxy/util/SparseBitSet.cs @@ -18,11 +18,15 @@ using System; namespace MCGalaxy.Util { + /// Sparsely represents 1 bit of data per voxel in a 3D volume. + /// Typically this means 1 bit per block in a level. + /// Does NOT perform any bounds checking. public sealed class SparseBitSet { int chunksX, chunksY, chunksZ; byte[][] bits; + /// Initialises a sparse bit set for the given 3D volume. public SparseBitSet(int width, int height, int length) { chunksX = Utils.CeilDiv16(width); chunksY = Utils.CeilDiv16(height); @@ -30,6 +34,8 @@ namespace MCGalaxy.Util { bits = new byte[chunksX * chunksY * chunksZ][]; } + /// Returns the 1 bit of data associated with the given coordinates. + /// If Set() was never called before at the given coordinates, returns false. public bool Get(int x, int y, int z) { int index = (x >> 4) + chunksX * ((z >> 4) + (y >> 4) * chunksZ); byte[] chunk = bits[index]; @@ -39,6 +45,7 @@ namespace MCGalaxy.Util { return (chunk[index >> 3] & (1 << (index & 0x7))) != 0; } + /// Sets the 1 bit of data associated with the given coordinates. public void Set(int x, int y, int z, bool bit) { int index = (x >> 4) + chunksX * ((z >> 4) + (y >> 4) * chunksZ); byte[] chunk = bits[index]; @@ -52,6 +59,8 @@ namespace MCGalaxy.Util { chunk[index >> 3] |= (byte)((bit ? 1 : 0) << (index & 0x7)); // set new bit } + /// Attempts to sets the 1 bit of data associated with the given coordinates to true. + /// true if the 1 bit of data was not already set to true, false if it was. public bool TrySetOn(int x, int y, int z) { int index = (x >> 4) + chunksX * ((z >> 4) + (y >> 4) * chunksZ); byte[] chunk = bits[index]; @@ -67,6 +76,7 @@ namespace MCGalaxy.Util { return true; } + /// Resets all bits of data to false. public void Clear() { for (int i = 0; i < bits.Length; i++) bits[i] = null;