OSDN Git Service

W.I.P. Fixes for several issues - plus better Shard processing
[automap/automap.git] / Automap / Data / ColumnMeta.cs
index f571df0..f1e9681 100644 (file)
@@ -90,8 +90,7 @@ namespace Automap
                public ushort[,] HeightMap;//Needs to be 'flattened' for Protocol-Buffer serialization
 
                [ProtoMember(13)]
-               private ushort[] _flattened_HeightMap;
-
+               private ushort[] _flattened_HeightMap;                  
 
                /// <summary>
                /// Column Presense Bitmap
@@ -131,6 +130,18 @@ namespace Automap
                        this.YMax = mapChunk.YMax;
                }
 
+               internal void ResetMetadata(int mapSizeY )
+               {
+               if (this.ColumnPresense == null) { this.ColumnPresense = new BitArray((mapSizeY / this.ChunkSize), false); }            
+
+               //Start fresh...
+               HeightMap = new ushort[ChunkSize, ChunkSize]; 
+               RockRatio = new Dictionary<int, uint>(this.RockRatio.Count);
+               AirBlocks = 0;
+               NonAirBlocks = 0;
+               YMax = 0;
+               }
+
                [ProtoBeforeSerialization]
                private void PrepareData()
                {
@@ -182,6 +193,12 @@ namespace Automap
 
                }
 
+               internal void ClearMetadata( )
+               {
+               this.HeightMap = null;
+               this.RockRatio = null;
+               this._flattened_HeightMap = null;
+               }
 
                internal ColumnMeta Reload(ICoreClientAPI clientAPI)
                {
@@ -274,8 +291,7 @@ namespace Automap
                {
                for (int i = 0, maxItemsCount = this.Items.Count; i < maxItemsCount; i++) {
                ColumnMeta entry = this.Items[i];
-               entry.HeightMap = null;
-               entry.RockRatio = null;//Also regenerated when any chunk in a column is changed...
+               entry.ClearMetadata( );
                }
                }