diff --git a/SubstrateCS/Properties/AssemblyInfo.cs b/SubstrateCS/Properties/AssemblyInfo.cs index 6e19494..94b4191 100644 --- a/SubstrateCS/Properties/AssemblyInfo.cs +++ b/SubstrateCS/Properties/AssemblyInfo.cs @@ -30,8 +30,8 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("0.7.3.0")] -[assembly: AssemblyFileVersion("0.7.3.0")] +[assembly: AssemblyVersion("0.8.0.0")] +[assembly: AssemblyFileVersion("0.8.0.0")] // This library is compatible with all CLS-compliant .NET programming languages. [assembly: CLSCompliant(true)] \ No newline at end of file diff --git a/SubstrateCS/Source/BetaWorld.cs b/SubstrateCS/Source/BetaWorld.cs index b8c8ac5..05e66f2 100644 --- a/SubstrateCS/Source/BetaWorld.cs +++ b/SubstrateCS/Source/BetaWorld.cs @@ -27,6 +27,8 @@ namespace Substrate private PlayerManager _playerMan; + private int _prefCacheSize = 256; + private BetaWorld () { _regionMgrs = new Dictionary(); @@ -149,6 +151,20 @@ namespace Substrate return new BetaWorld().OpenWorld(path) as BetaWorld; } + /// + /// Opens an existing Beta-compatible Minecraft world and returns a new to represent it. + /// + /// The path to the directory containing the world's level.dat, or the path to level.dat itself. + /// The preferred cache size in chunks for each opened dimension in this world. + /// A new object representing an existing world on disk. + public static new BetaWorld Open (string path, int cacheSize) + { + BetaWorld world = new BetaWorld().OpenWorld(path); + world._prefCacheSize = cacheSize; + + return world; + } + /// /// Creates a new Beta-compatible Minecraft world and returns a new to represent it. /// @@ -161,6 +177,22 @@ namespace Substrate return new BetaWorld().CreateWorld(path) as BetaWorld; } + /// + /// Creates a new Beta-compatible Minecraft world and returns a new to represent it. + /// + /// The path to the directory where the new world should be stored. + /// The preferred cache size in chunks for each opened dimension in this world. + /// A new object representing a new world. + /// This method will attempt to create the specified directory immediately if it does not exist, but will not + /// write out any world data unless it is explicitly saved at a later time. + public static BetaWorld Create (string path, int cacheSize) + { + BetaWorld world = new BetaWorld().CreateWorld(path); + world._prefCacheSize = cacheSize; + + return world; + } + /// protected override IBlockManager GetBlockManagerVirt (int dim) { @@ -213,7 +245,7 @@ namespace Substrate Directory.CreateDirectory(path); } - ChunkCache cc = new ChunkCache(); + ChunkCache cc = new ChunkCache(_prefCacheSize); RegionManager rm = new RegionManager(path, cc); BetaChunkManager cm = new BetaChunkManager(rm, cc); diff --git a/SubstrateCS/Source/Core/ChunkCache.cs b/SubstrateCS/Source/Core/ChunkCache.cs index 807e3b7..801ac4e 100644 --- a/SubstrateCS/Source/Core/ChunkCache.cs +++ b/SubstrateCS/Source/Core/ChunkCache.cs @@ -9,8 +9,13 @@ namespace Substrate.Core private Dictionary _dirty; public ChunkCache () + : this(256) { - _cache = new LRUCache(256); + } + + public ChunkCache (int cacheSize) + { + _cache = new LRUCache(cacheSize); _dirty = new Dictionary(); _cache.RemoveCacheValue += EvictionHandler;