diff --git a/Substrate/SubstrateCS/Properties/AssemblyInfo.cs b/Substrate/SubstrateCS/Properties/AssemblyInfo.cs index d6f6d3b..e0236b5 100644 --- a/Substrate/SubstrateCS/Properties/AssemblyInfo.cs +++ b/Substrate/SubstrateCS/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("0.2.0.0")] -[assembly: AssemblyFileVersion("0.2.0.0")] +[assembly: AssemblyVersion("0.3.0.0")] +[assembly: AssemblyFileVersion("0.3.0.0")] diff --git a/Substrate/SubstrateCS/Source/ChunkManager.cs b/Substrate/SubstrateCS/Source/ChunkManager.cs index 2157f54..a0b2c0d 100644 --- a/Substrate/SubstrateCS/Source/ChunkManager.cs +++ b/Substrate/SubstrateCS/Source/ChunkManager.cs @@ -245,7 +245,10 @@ namespace Substrate _region = _enum.Current; } if (MoveNextInRegion()) { - _chunk = _cm.GetChunkRefInRegion(_region, _x, _z); + _chunk = _region.GetChunkRef(_x, _z, _cm); + if (_chunk == null) { + throw new Exception(); + } return true; } } diff --git a/Substrate/SubstrateCS/Source/Region.cs b/Substrate/SubstrateCS/Source/Region.cs index 40f0dd2..8d2ae56 100644 --- a/Substrate/SubstrateCS/Source/Region.cs +++ b/Substrate/SubstrateCS/Source/Region.cs @@ -264,7 +264,7 @@ namespace Substrate DeleteChunk(lcx, lcz); - Chunk c = new Chunk(ChunkGlobalX(lcx), ChunkGlobalZ(lcz)); + Chunk c = new Chunk(lcx, lcz); c.Save(GetChunkOutStream(lcx, lcz)); ChunkRef cr = new ChunkRef(this, cache, lcx, lcz); @@ -356,8 +356,10 @@ namespace Substrate { int saved = 0; foreach (ChunkRef c in _dirty.Values) { - int lcx = c.LocalX; - int lcz = c.LocalZ; + int cx = c.X; + int cz = c.Z; + int lcx = cx - _rx * ChunkManager.REGION_XLEN; + int lcz = cz - _rz * ChunkManager.REGION_ZLEN; if (!ChunkExists(lcx, lcz)) { throw new MissingChunkException(); @@ -384,8 +386,10 @@ namespace Substrate public bool MarkChunkDirty (ChunkRef chunk) { - int lcx = chunk.LocalX; - int lcz = chunk.LocalZ; + int cx = chunk.X; + int cz = chunk.Z; + int lcx = cx - _rx * ChunkManager.REGION_XLEN; + int lcz = cz - _rz * ChunkManager.REGION_ZLEN; ChunkKey k = new ChunkKey(lcx, lcz); if (!_dirty.ContainsKey(k)) { @@ -397,10 +401,12 @@ namespace Substrate public bool MarkChunkClean (ChunkRef chunk) { - int lcx = chunk.LocalX; - int lcz = chunk.LocalZ; + int cx = chunk.X; + int cz = chunk.Z; + int lcx = cx - _rx * ChunkManager.REGION_XLEN; + int lcz = cz - _rz * ChunkManager.REGION_ZLEN; - ChunkKey k = new ChunkKey(lcx, lcz); + ChunkKey k = new ChunkKey(lcx, lcx); if (_dirty.ContainsKey(k)) { _dirty.Remove(k); return true;