OSDN Git Service

W.I.P. Inelegant fixes for a thorny problem...apparently working
authormelchior <melchior@users.osdn.me>
Sat, 10 Oct 2020 22:12:59 +0000 (18:12 -0400)
committermelchior <melchior@users.osdn.me>
Sat, 10 Oct 2020 22:12:59 +0000 (18:12 -0400)
Automap/Renderers/AChunkRenderer.cs
Automap/Subsystems/AutomapSystem.cs
ShardProcessor/Program.cs [new file with mode: 0644]
ShardProcessor/Properties/AssemblyInfo.cs [new file with mode: 0644]
ShardProcessor/ShardProcessor.csproj [new file with mode: 0644]

index 392e43d..d44427f 100644 (file)
@@ -41,10 +41,21 @@ namespace Automap
 
                this.PngWriter = FileHelper.CreatePngWriter(filename, imageInf, true);
                PngMetadata meta = this.PngWriter.GetMetadata( );
-               meta.SetTimeNow( );
+               meta.SetTimeYMDHMS(
+                               DateTime.UtcNow.Year,
+                               DateTime.UtcNow.Month,
+                               DateTime.UtcNow.Day,
+                               DateTime.UtcNow.Hour,
+                               DateTime.UtcNow.Minute,
+                               DateTime.UtcNow.Second);
                meta.SetText("Chunk_X", coord.X.ToString("D"));
                meta.SetText("Chunk_Y", coord.Y.ToString("D"));
                meta.SetText("PxSz", "1");
+               var transparencyChunk = meta.CreateTRNSChunk( );
+               transparencyChunk.SetRGB(0, 0, 0);//Same as Snapshots
+               string gameDate = $"{ClientAPI.World.Calendar.DayOfYear:D3}-{ClientAPI.World.Calendar.Year}";
+               meta.SetText("GameDY", gameDate);
+
                //Setup specialized meta-data PNG chunks here...
                PngMetadataChunk pngChunkMeta = new PngMetadataChunk(this.PngWriter.ImgInfo) {
                        ChunkMetadata = metadata
index c1b3956..11b573a 100644 (file)
@@ -1,4 +1,5 @@
 using System;
+using System.Collections;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.IO;
@@ -194,6 +195,7 @@ namespace Automap
 
                                                if (mapChunk == null)
                                                {
+                                                       //TODO: REVISIT THIS CHUNK!
                                                        Logger.Warning("SKIP CHUNK: ({0}) - Map Chunk NULL!", mostActiveCol.Key);
                                                        nullMapCount++;
                                                        columnCounter.TryRemove(mostActiveCol.Key, out ejectedItem);
@@ -204,16 +206,16 @@ namespace Automap
                                                if (chunkTopMetadata.Contains(mostActiveCol.Key))
                                                {
                                                        chunkMeta = chunkTopMetadata[mostActiveCol.Key];
-#if DEBUG
-                                                       Logger.VerboseDebug("Loaded chunk {0}", mostActiveCol.Key);
-#endif
+                                                       #if DEBUG
+                                                       Logger.VerboseDebug("Loaded meta-chunk {0}", mostActiveCol.Key);
+                                                       #endif
                                                }
                                                else
                                                {
                                                        chunkMeta = CreateColumnMetadata(mostActiveCol, mapChunk);
-#if DEBUG
-                                                       Logger.VerboseDebug("Created chunk {0}", mostActiveCol.Key);
-#endif
+                                                       #if DEBUG
+                                                       Logger.VerboseDebug("Created meta-chunk {0}", mostActiveCol.Key);
+                                                       #endif
                                                }
                                                ProcessChunkBlocks(mostActiveCol.Key, mapChunk, ref chunkMeta);
 
@@ -222,9 +224,9 @@ namespace Automap
 
                                                if (updatedPixels > 0)
                                                {
-#if DEBUG
-                                                       Logger.VerboseDebug("Wrote chunk shard: ({0}) - Edits#:{1}, Pixels#:{2}", mostActiveCol.Key, mostActiveCol.Value, updatedPixels);
-#endif
+                                                       #if DEBUG
+                                                       Logger.VerboseDebug("Wrote top-chunk shard: ({0}) - Edits#:{1}, Pixels#:{2}", mostActiveCol.Key, mostActiveCol.Value, updatedPixels);
+                                                       #endif
                                                        updatedChunks++;
                                                        chunkTopMetadata.Update(chunkMeta);
                                                        columnCounter.TryRemove(mostActiveCol.Key, out ejectedItem);
@@ -232,9 +234,9 @@ namespace Automap
                                                else
                                                {
                                                        columnCounter.TryRemove(mostActiveCol.Key, out ejectedItem);
-#if DEBUG
-                                                       Logger.VerboseDebug("Un-painted chunk: ({0}) ", mostActiveCol.Key);
-#endif
+                                                       #if DEBUG
+                                                       Logger.VerboseDebug("Un-painted chun shard: ({0}) ", mostActiveCol.Key);
+                                                       #endif
                                                }
                                        }
                                        //Cleanup persisted Metadata...
@@ -549,14 +551,18 @@ namespace Automap
                                        nullChunkCount++;
                                        continue;
                                }
-                               worldChunk.Unpack( );//RESEARCH: Thread Unsafe?
 
+                               if (worldChunk.IsPacked()) 
+                               {
+                               Logger.VerboseDebug("WORLD chunk: Compressed: X{0} Y{1} Z{2}", key.X, targetChunkY, key.Y);
+                               worldChunk.Unpack( );//RESEARCH: Thread Unsafe? 
+                               }
 
                                /*************** Chunk Entities Scanning *********************/
                                if (worldChunk.BlockEntities != null && worldChunk.BlockEntities.Count > 0)
                                {
                                        #if DEBUG
-                                       Logger.VerboseDebug("Surface@ {0} = BlockEntities: {1}", key, worldChunk.BlockEntities.Count);
+                                       Logger.VerboseDebug("Scan pos.({0}) for BlockEntities# {1}", key, worldChunk.BlockEntities.Count);
                                        #endif
 
                                        foreach (var blockEnt in worldChunk.BlockEntities)
@@ -569,6 +575,8 @@ namespace Automap
                                        }
                                }
 
+                               //NOTE: Temporary; remove - replace later
+                               if (chunkMeta.ColumnPresense == null) { chunkMeta.ColumnPresense = new BitArray((ClientAPI.World.BlockAccessor.MapSizeY / chunkSize), false); }
                                chunkMeta.ColumnPresense[targetChunkY] = true;
 
                                /********************* Chunk/Column BLOCKs scanning ****************/
@@ -580,44 +588,56 @@ namespace Automap
                                if (chunkMeta.HeightMap == null) { chunkMeta.HeightMap = new ushort[chunkSize, chunkSize]; }
                                if (chunkMeta.RockRatio == null) { chunkMeta.RockRatio = new Dictionary<int, uint>(10); }
 
+                               //First Chance fail-safe;
+                               if (worldChunk.Blocks == null || worldChunk.Blocks.Length <= 0) {
+                               Logger.VerboseDebug("WORLD chunk; Missing block DATA⁈ X{0} Y{1} Z{2} ⁈", key.X, targetChunkY, key.Y);
+                               continue;
+                               }               
+
                                for (Y_index = 0; Y_index < chunkSize - 1; Y_index++)
                                {
                                        for (Z_index = 0; Z_index < chunkSize - 1; Z_index++)
                                        {
                                                for (X_index = 0; X_index < chunkSize - 1; X_index++)
                                                {
-                                                       /* Encode packed indicie
-                                                       (y * chunksize + z) * chunksize + x
-                                                       */
-                                                       var indicie = Helpers.ChunkBlockIndicie16(X_index, Y_index, Z_index);
-                                                       int aBlockId = worldChunk.Blocks[indicie];
-
-                                                       if (aBlockId == 0)
-                                                       {//Air
-                                                               chunkMeta.AirBlocks++;
-                                                               continue;
-                                                       }
-
-                                                       if (RockIdCodes.ContainsKey(aBlockId))
-                                                       {
-                                                               if (chunkMeta.RockRatio.ContainsKey(aBlockId))
-                                                                       chunkMeta.RockRatio[aBlockId]++;
-                                                               else
-                                                                       chunkMeta.RockRatio.Add(aBlockId, 1);
-                                                       }
-
-                                                       chunkMeta.NonAirBlocks++;
-
-                                                       //Heightmap 
-                                                       if (chunkMeta.HeightMap[X_index, Z_index] == 0)
-                                                       {
-                                                       chunkMeta.HeightMap[X_index, Z_index] = (ushort) (Y_index + (targetChunkY * chunkSize));
-                                                       }
+                                               /* Encode packed indicie
+                                               (y * chunksize + z) * chunksize + x
+                                               */
+                                               var indicie = Helpers.ChunkBlockIndicie16(X_index, Y_index, Z_index);
+
+                                               //'Last' Chance fail-safe;
+                                               if (worldChunk.Blocks == null || worldChunk.Blocks.Length <= 0) {
+                                               Logger.VerboseDebug("Processing Block: Missing block DATA⁈ X{0} Y{1} Z{2} ⁈", X_index, Y_index, Z_index);
+                                               goto loop_bustout;;
                                                }
-                                       }
+                                               
+                                               int aBlockId = worldChunk.Blocks[indicie];
 
-                               }
+                                               if (aBlockId == 0)
+                                               {//Air
+                                                       chunkMeta.AirBlocks++;
+                                                       continue;
+                                               }
+
+                                               if (RockIdCodes.ContainsKey(aBlockId))
+                                               {
+                                                       if (chunkMeta.RockRatio.ContainsKey(aBlockId))
+                                                               chunkMeta.RockRatio[aBlockId]++;
+                                                       else
+                                                               chunkMeta.RockRatio.Add(aBlockId, 1);
+                                               }
 
+                                               chunkMeta.NonAirBlocks++;
+
+                                               //Heightmap 
+                                               if (chunkMeta.HeightMap[X_index, Z_index] == 0)
+                                               {
+                                               chunkMeta.HeightMap[X_index, Z_index] = (ushort) (Y_index + (targetChunkY * chunkSize));
+                                               }
+                                               }
+                                       }
+                               }
+                               loop_bustout:;
                        }
                }
 
diff --git a/ShardProcessor/Program.cs b/ShardProcessor/Program.cs
new file mode 100644 (file)
index 0000000..1db0de8
--- /dev/null
@@ -0,0 +1,12 @@
+using System;
+
+namespace ShardProcessor
+{
+       class MainClass
+       {
+               public static void Main(string[ ] args)
+               {
+               Console.WriteLine("Hello World!");
+               }
+       }
+}
diff --git a/ShardProcessor/Properties/AssemblyInfo.cs b/ShardProcessor/Properties/AssemblyInfo.cs
new file mode 100644 (file)
index 0000000..d0a4cad
--- /dev/null
@@ -0,0 +1,27 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes. 
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("ShardProcessor")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("librarian")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly, 
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
+
diff --git a/ShardProcessor/ShardProcessor.csproj b/ShardProcessor/ShardProcessor.csproj
new file mode 100644 (file)
index 0000000..992af68
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <PropertyGroup>\r
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+    <ProjectGuid>{837EE90B-7C03-413B-B54D-B50B2ED1EC00}</ProjectGuid>\r
+    <OutputType>Exe</OutputType>\r
+    <RootNamespace>ShardProcessor</RootNamespace>\r
+    <AssemblyName>ShardProcessor</AssemblyName>\r
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+    <DebugSymbols>true</DebugSymbols>\r
+    <DebugType>full</DebugType>\r
+    <Optimize>false</Optimize>\r
+    <OutputPath>bin\Debug</OutputPath>\r
+    <DefineConstants>DEBUG;</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+    <ExternalConsole>true</ExternalConsole>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+    <Optimize>true</Optimize>\r
+    <OutputPath>bin\Release</OutputPath>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+    <ExternalConsole>true</ExternalConsole>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Reference Include="System" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="Program.cs" />\r
+    <Compile Include="Properties\AssemblyInfo.cs" />\r
+  </ItemGroup>\r
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />\r
+</Project>
\ No newline at end of file