public RegionChunkData(DataNode parent, RegionFile file, int x, int z) : base(parent) { Region = file; X = x; Z = z; }
public RegionChunkDataNode(RegionFile regionFile, int x, int z) { _regionFile = regionFile; _x = x; _z = z; _container = new CompoundTagContainer(new TagNodeCompound()); }
public ChunkBuffer(RegionFile r, int x, int z) : base(8096) { this.region = r; this.x = x; this.z = z; }
private RegionFile GetRegionFile() { RegionFile rf = _regionFile.Target as RegionFile; if (rf == null) { rf = new RegionFile(GetFilePath()); _regionFile.Target = rf; } return(rf); }
/// <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)); }
/// <summary> /// Checks if a chunk exists at the given local coordinates relative to this region. /// </summary> /// <param name="lcx">The local X-coordinate of a chunk relative to this region.</param> /// <param name="lcz">The local Z-coordinate of a chunk relative to this region.</param> /// <returns>True if there is a chunk at the given coordinates; false otherwise.</returns> /// <remarks>If the local coordinates are out of bounds for this region, the action will be forwarded to the correct region /// transparently.</remarks> public bool ChunkExists(int lcx, int lcz) { if (!LocalBoundsCheck(lcx, lcz)) { IRegion alt = GetForeignRegion(lcx, lcz); return((alt == null) ? false : alt.ChunkExists(ForeignX(lcx), ForeignZ(lcz))); } RegionFile rf = GetRegionFile(); return(rf.HasChunk(lcx, lcz)); }
/// <inherits /> public int GetChunkTimestamp(int lcx, int lcz) { if (!LocalBoundsCheck(lcx, lcz)) { IRegion alt = GetForeignRegion(lcx, lcz); return((alt == null) ? 0 : alt.GetChunkTimestamp(ForeignX(lcx), ForeignZ(lcz))); } RegionFile rf = GetRegionFile(); return(rf.GetTimestamp(lcx, lcz)); }
/// <inherits /> public void SetChunkTimestamp(int lcx, int lcz, int timestamp) { if (!LocalBoundsCheck(lcx, lcz)) { IRegion alt = GetForeignRegion(lcx, lcz); if (alt != null) { alt.SetChunkTimestamp(ForeignX(lcx), ForeignZ(lcz), timestamp); } } RegionFile rf = GetRegionFile(); rf.SetTimestamp(lcx, lcz, timestamp); }
/// <inherits /> public IRegion CreateRegion(int rx, int rz) { IRegion r = GetRegion(rx, rz); if (r == null) { string fp = "r." + rx + "." + rz + ".mca"; using (RegionFile rf = CreateRegionFileCore(rx, rz)) { } r = CreateRegionCore(rx, rz); RegionKey k = new RegionKey(rx, rz); _cache[k] = r; } return(r); }
/// <inherits /> public int ChunkCount() { RegionFile rf = GetRegionFile(); int count = 0; for (int x = 0; x < XDIM; x++) { for (int z = 0; z < ZDIM; z++) { if (rf.HasChunk(x, z)) { count++; } } } return(count); }
/// <summary> /// Conditionally dispose managed or unmanaged resources. /// </summary> /// <param name="disposing">True if the call to Dispose was explicit.</param> protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { // Cleanup managed resources RegionFile rf = _regionFile.Target as RegionFile; if (rf != null) { rf.Dispose(); rf = null; } } // Cleanup unmanaged resources } _disposed = true; }
protected override void ExpandCore() { try { if (_region == null) _region = new RegionFile(_path); for (int x = 0; x < 32; x++) { for (int z = 0; z < 32; z++) { if (_region.HasChunk(x, z)) { Nodes.Add(new RegionChunkDataNode(_region, x, z)); } } } } catch { if (FormRegistry.MessageBox != null) FormRegistry.MessageBox("Not a valid region file."); } }
/// <inherits /> public NbtTree GetChunkTree(int lcx, int lcz) { if (!LocalBoundsCheck(lcx, lcz)) { IRegion alt = GetForeignRegion(lcx, lcz); return((alt == null) ? null : alt.GetChunkTree(ForeignX(lcx), ForeignZ(lcz))); } RegionFile rf = GetRegionFile(); Stream nbtstr = rf.GetChunkDataInputStream(lcx, lcz); if (nbtstr == null) { return(null); } NbtTree tree = new NbtTree(nbtstr); nbtstr.Close(); return(tree); }
private bool SaveChunkTree(int lcx, int lcz, NbtTree tree, int?timestamp) { if (!LocalBoundsCheck(lcx, lcz)) { IRegion alt = GetForeignRegion(lcx, lcz); return((alt == null) ? false : alt.SaveChunkTree(ForeignX(lcx), ForeignZ(lcz), tree)); } RegionFile rf = GetRegionFile(); Stream zipstr = (timestamp == null) ? rf.GetChunkDataOutputStream(lcx, lcz) : rf.GetChunkDataOutputStream(lcx, lcz, (int)timestamp); if (zipstr == null) { return(false); } tree.WriteTo(zipstr); zipstr.Close(); return(true); }
public ChunkBuffer(RegionFile r, int x, int z, int timestamp) : this(r, x, z) { _timestamp = timestamp; }
private RegionFile GetRegionFile() { RegionFile rf = _regionFile.Target as RegionFile; if (rf == null) { rf = new RegionFile(GetFilePath()); _regionFile.Target = rf; } return rf; }
protected override void ReleaseCore() { if (_region != null) _region.Close(); _region = null; Nodes.Clear(); }
internal static TreeNode CreateLazyChunk(RegionFile rf, int x, int z) { return InitializeParentNode(9, "Chunk [" + x + ", " + z + "]", new RegionChunkData(rf, x, z)); }
internal static void LoadRegion(TreeNode node, string path) { RegionFile rf = new RegionFile(path); for (int x = 0; x < 32; x++) { for (int y = 0; y < 32; y++) { if (rf.HasChunk(x, y)) { TreeNode child = CreateLazyChunk(rf, x, y); node.Nodes.Add(child); LinkDataNodeParent(child, node); } } } }
public RegionChunkData(RegionFile file, int x, int z) : this(null, file, x, z) { }
public ChunkBuffer(RegionFile r, int x, int z) : base(8096) { // super(8096); // initialize to 8KB this.region = r; this.x = x; this.z = z; }