/// <inheritdoc/>
        public int Save()
        {
            _cache.SyncDirty();

            int saved = 0;
            IEnumerator <ChunkRef> en = _cache.GetDirtyEnumerator();

            while (en.MoveNext())
            {
                ChunkRef chunk = en.Current;

                IRegion r = GetRegion(chunk.X, chunk.Z);
                if (r == null)
                {
                    continue;
                }
                using (Stream chunkOutStream = r.GetChunkOutStream(chunk.LocalX, chunk.LocalZ))
                {
                    chunk.Save(chunkOutStream);
                    saved++;
                }
            }

            _cache.ClearDirty();
            return(saved);
        }
Beispiel #2
0
        /// <inherits />
        public Stream GetChunkOutStream(int lcx, int lcz)
        {
            if (!LocalBoundsCheck(lcx, lcz))
            {
                IRegion alt = GetForeignRegion(lcx, lcz);
                return((alt == null) ? null : alt.GetChunkOutStream(ForeignX(lcx), ForeignZ(lcz)));
            }

            RegionFile rf = GetRegionFile();

            return(rf.GetChunkDataOutputStream(lcx, lcz));
        }