diff --git a/NBTModel/Data/CubicRegionFile.cs b/NBTModel/Data/CubicRegionFile.cs index c54cf7a..c3d2483 100644 --- a/NBTModel/Data/CubicRegionFile.cs +++ b/NBTModel/Data/CubicRegionFile.cs @@ -1,9 +1,13 @@ -using Substrate.Core; +using System; +using System.Text.RegularExpressions; +using Substrate.Core; namespace NBTExplorer.Model { public class CubicRegionFile : RegionFile { + private static Regex _namePattern = new Regex("r2\\.(-?[0-9]+)\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mc[ar]$"); + private const int _sectorBytes = 256; private static byte[] _emptySector = new byte[_sectorBytes]; @@ -20,5 +24,21 @@ namespace NBTExplorer.Model { get { return _emptySector; } } + + public override RegionKey parseCoordinatesFromName () + { + int x = 0; + int z = 0; + + Match match = _namePattern.Match(fileName); + if (!match.Success) { + return RegionKey.InvalidRegion; + } + + x = Convert.ToInt32(match.Groups[1].Value); + z = Convert.ToInt32(match.Groups[3].Value); + + return new RegionKey(x, z); + } } } diff --git a/NBTModel/Data/Nodes/RegionChunkDataNode.cs b/NBTModel/Data/Nodes/RegionChunkDataNode.cs index a074d33..2587934 100644 --- a/NBTModel/Data/Nodes/RegionChunkDataNode.cs +++ b/NBTModel/Data/Nodes/RegionChunkDataNode.cs @@ -53,7 +53,15 @@ namespace NBTExplorer.Model public override string NodeDisplay { - get { return "Chunk [" + _x + ", " + _z + "]"; } + get + { + RegionKey key = _regionFile.parseCoordinatesFromName(); + string absChunk = ""; + if (key != RegionKey.InvalidRegion) + absChunk = " in world at (" + (key.X * 32 + _x) + ", " + (key.Z * 32 + _z) + ")"; + + return "Chunk [" + _x + ", " + _z + "]" + absChunk; + } } protected override void ExpandCore () diff --git a/References/Substrate.dll b/References/Substrate.dll index 1e77d6c..c079643 100644 Binary files a/References/Substrate.dll and b/References/Substrate.dll differ