OSDN Git Service

Merge branch 'Split_renderers' into vgd
authorThe Grand Dog <alex.h@me.com>
Mon, 27 Apr 2020 14:36:53 +0000 (10:36 -0400)
committerThe Grand Dog <alex.h@me.com>
Mon, 27 Apr 2020 14:36:53 +0000 (10:36 -0400)
Automap/Data/ColumnMeta.cs
Automap/Data/EntitiesOfInterest.cs
Automap/Data/PointOfInterest.cs
Automap/Subsystems/AutomapSystem.cs

index 93cb85e..77daaf4 100644 (file)
@@ -147,18 +147,22 @@ namespace Automap
                [ProtoAfterDeserialization]
                private void PostProcess()
                {
-                       if (this.HeightMap == null) this.HeightMap = new ushort[ChunkSize, ChunkSize];
+                       ChunkSize = (ChunkSize == byte.MinValue) ? (byte)32 : ChunkSize;//Not good - if chunk wasn't 32 orignally!
+
+                       if (this.HeightMap == null || this.HeightMap.Length != (ChunkSize * ChunkSize)) {
+                       this.HeightMap = new ushort[ChunkSize, ChunkSize];
+                       }
 
                        if (_flattened_HeightMap != null)
                        {
                                int col, row;
-                               _ = new BitVector32(0);
+                               var bitMasker = new BitVector32(0);
                                var rowSection = BitVector32.CreateSection((short) (ChunkSize - 1));
                                var colSection = BitVector32.CreateSection((short) (ChunkSize - 1), rowSection);
 
                                for (uint rowcol = 0; rowcol < (ChunkSize * ChunkSize); rowcol++)
                                {
-                                       BitVector32 bitMasker = new BitVector32(data: (int) rowcol);
+                                       bitMasker = new BitVector32(data: (int) rowcol);
                                        row = bitMasker[rowSection];
                                        col = bitMasker[colSection];
                                        HeightMap[col, row] = _flattened_HeightMap[rowcol];
@@ -256,5 +260,14 @@ namespace Automap
                        base.Add(newItem);
                }
 
+               public void ClearMetadata( )
+               {
+               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...
+               }
+               }
+
        }
-}
\ No newline at end of file
+}
index 7eb1253..d22f328 100644 (file)
@@ -20,25 +20,26 @@ namespace Automap
        [ProtoContract]
        public struct EntityOfInterest
        {
-               
+
+               [DisplayName(0, "Name")]
                [ProtoMember(1)]
                public string Name;
                
-               [DisplayName(1, "Notes")]
+               [DisplayName(2, "Notes")]
                [ProtoMember(2)]
                public string Notes;
 
-               [DisplayName(0, "Loc.")]
+               [DisplayName(1, "Loc.")]
                public string PrettyLocation;
 
                [ProtoMember(3)]
                public BlockPos Location;
 
-               [DisplayName(2, "Time")]
+               [DisplayName(3, "Time")]
                [ProtoMember(4)]
                public DateTime Timestamp;
 
-               [DisplayName(3, "ID")]
+               [DisplayName(4, "ID")]
                [ProtoMember(5)]
                public long EntityId;
 
index ef27476..3ad779b 100644 (file)
@@ -18,20 +18,21 @@ namespace Automap
        [ProtoContract]
        public struct PointOfInterest
        {
+               [DisplayName(0, "Name")]
                [ProtoMember(1)]
                public string Name;
 
-               [DisplayName(1, "Notes")]
+               [DisplayName(2, "Notes")]
                [ProtoMember(2)]
                public string Notes;
 
-               [DisplayName(0, "Loc.")]
+               [DisplayName(1, "Loc.")]
                public string PrettyLocation;
 
                [ProtoMember(3)]
                public BlockPos Location;
 
-               [DisplayName(2, "Time")]
+               [DisplayName(3, "Time")]
                [ProtoMember(4)]
                public DateTime Timestamp;
 
index 8cc81d7..20af359 100644 (file)
@@ -52,7 +52,7 @@ namespace Automap
 
                internal CommandType CurrentState { get; set; }
                //Run status, Chunks processed, stats, center of map....
-               private uint nullChunkCount, updatedChunksTotal;
+               private uint nullChunkCount, nullMapCount, updatedChunksTotal;
                private Vec2i startChunkColumn;
 
                private readonly int chunkSize;
@@ -182,7 +182,7 @@ namespace Automap
                                                if (mapChunk == null)
                                                {
                                                        Logger.Warning("SKIP CHUNK: ({0}) - Map Chunk NULL!", mostActiveCol.Key);
-                                                       nullChunkCount++;
+                                                       nullMapCount++;
                                                        columnCounter.TryRemove(mostActiveCol.Key, out ejectedItem);
                                                        continue;
                                                }
@@ -224,8 +224,9 @@ namespace Automap
                                                        columnCounter.TryRemove(mostActiveCol.Key, out ejectedItem);
                                                        Logger.VerboseDebug("Un-painted chunk: ({0}) ", mostActiveCol.Key);
                                                }
-
                                        }
+                               //Cleanup persisted Metadata...
+                               chunkTopMetadata.ClearMetadata( );
                                }
 
                                UpdateStatus(this.updatedChunksTotal, this.nullChunkCount, updatedChunks);
@@ -504,13 +505,13 @@ namespace Automap
                        {
                                WorldChunk chunkData = ClientAPI.World.BlockAccessor.GetChunk(key.X, targetChunkY, key.Y) as WorldChunk;
 
-                               if (chunkData == null || chunkData.BlockEntities == null)
-                               {
-#if DEBUG
-                                       Logger.VerboseDebug("Chunk null or empty X{0} Y{1} Z{2}", key.X, targetChunkY, key.Y);
-#endif
-                                       continue;
-                               }
+                       if (chunkData == null || chunkData.BlockEntities == null) {
+                       #if DEBUG
+                       Logger.VerboseDebug("Chunk null or empty X{0} Y{1} Z{2}", key.X, targetChunkY, key.Y);
+                       #endif
+                       nullChunkCount++;
+                       continue;
+                       }
 
                                /*************** Chunk Entities Scanning *********************/
                                if (chunkData.BlockEntities != null && chunkData.BlockEntities.Length > 0)
@@ -521,14 +522,12 @@ namespace Automap
 
                                        foreach (var blockEnt in chunkData.BlockEntities)
                                        {
-
                                                if (blockEnt != null && blockEnt.Block != null && BlockID_Designators.ContainsKey(blockEnt.Block.BlockId))
                                                {
                                                        var designator = BlockID_Designators[blockEnt.Block.BlockId];
                                                        designator.SpecialAction(ClientAPI, POIs, blockEnt.Pos.Copy(), blockEnt.Block);
                                                }
                                        }
-
                                }
                                /********************* Chunk/Column BLOCKs scanning ****************/
                                //Heightmap, Stats, block tally
@@ -537,6 +536,10 @@ namespace Automap
                                int X_index, Y_index, Z_index;
                                X_index = Y_index = Z_index = 0;
 
+                               //Ensure ChunkData Metadata fields arn't null...due to being tossed out
+                               if (chunkMeta.HeightMap == null) { chunkMeta.HeightMap = new ushort[chunkSize, chunkSize]; }
+                               if (chunkMeta.RockRatio == null) { chunkMeta.RockRatio = new Dictionary<int, uint>(10); }
+
                                do
                                {
                                        do