Automap (client) [VS plugin mod]
Revisão | 0dac6be4bc39d85b3c19c8fe644b62630dea452f (tree) |
---|---|
Hora | 2020-10-11 07:12:59 |
Autor | melchior <melchior@user...> |
Commiter | melchior |
W.I.P. Inelegant fixes for a thorny problem...apparently working
@@ -41,10 +41,21 @@ namespace Automap | ||
41 | 41 | |
42 | 42 | this.PngWriter = FileHelper.CreatePngWriter(filename, imageInf, true); |
43 | 43 | PngMetadata meta = this.PngWriter.GetMetadata( ); |
44 | - meta.SetTimeNow( ); | |
44 | + meta.SetTimeYMDHMS( | |
45 | + DateTime.UtcNow.Year, | |
46 | + DateTime.UtcNow.Month, | |
47 | + DateTime.UtcNow.Day, | |
48 | + DateTime.UtcNow.Hour, | |
49 | + DateTime.UtcNow.Minute, | |
50 | + DateTime.UtcNow.Second); | |
45 | 51 | meta.SetText("Chunk_X", coord.X.ToString("D")); |
46 | 52 | meta.SetText("Chunk_Y", coord.Y.ToString("D")); |
47 | 53 | meta.SetText("PxSz", "1"); |
54 | + var transparencyChunk = meta.CreateTRNSChunk( ); | |
55 | + transparencyChunk.SetRGB(0, 0, 0);//Same as Snapshots | |
56 | + string gameDate = $"{ClientAPI.World.Calendar.DayOfYear:D3}-{ClientAPI.World.Calendar.Year}"; | |
57 | + meta.SetText("GameDY", gameDate); | |
58 | + | |
48 | 59 | //Setup specialized meta-data PNG chunks here... |
49 | 60 | PngMetadataChunk pngChunkMeta = new PngMetadataChunk(this.PngWriter.ImgInfo) { |
50 | 61 | ChunkMetadata = metadata |
@@ -1,4 +1,5 @@ | ||
1 | 1 | using System; |
2 | +using System.Collections; | |
2 | 3 | using System.Collections.Concurrent; |
3 | 4 | using System.Collections.Generic; |
4 | 5 | using System.IO; |
@@ -194,6 +195,7 @@ namespace Automap | ||
194 | 195 | |
195 | 196 | if (mapChunk == null) |
196 | 197 | { |
198 | + //TODO: REVISIT THIS CHUNK! | |
197 | 199 | Logger.Warning("SKIP CHUNK: ({0}) - Map Chunk NULL!", mostActiveCol.Key); |
198 | 200 | nullMapCount++; |
199 | 201 | columnCounter.TryRemove(mostActiveCol.Key, out ejectedItem); |
@@ -204,16 +206,16 @@ namespace Automap | ||
204 | 206 | if (chunkTopMetadata.Contains(mostActiveCol.Key)) |
205 | 207 | { |
206 | 208 | chunkMeta = chunkTopMetadata[mostActiveCol.Key]; |
207 | -#if DEBUG | |
208 | - Logger.VerboseDebug("Loaded chunk {0}", mostActiveCol.Key); | |
209 | -#endif | |
209 | + #if DEBUG | |
210 | + Logger.VerboseDebug("Loaded meta-chunk {0}", mostActiveCol.Key); | |
211 | + #endif | |
210 | 212 | } |
211 | 213 | else |
212 | 214 | { |
213 | 215 | chunkMeta = CreateColumnMetadata(mostActiveCol, mapChunk); |
214 | -#if DEBUG | |
215 | - Logger.VerboseDebug("Created chunk {0}", mostActiveCol.Key); | |
216 | -#endif | |
216 | + #if DEBUG | |
217 | + Logger.VerboseDebug("Created meta-chunk {0}", mostActiveCol.Key); | |
218 | + #endif | |
217 | 219 | } |
218 | 220 | ProcessChunkBlocks(mostActiveCol.Key, mapChunk, ref chunkMeta); |
219 | 221 |
@@ -222,9 +224,9 @@ namespace Automap | ||
222 | 224 | |
223 | 225 | if (updatedPixels > 0) |
224 | 226 | { |
225 | -#if DEBUG | |
226 | - Logger.VerboseDebug("Wrote chunk shard: ({0}) - Edits#:{1}, Pixels#:{2}", mostActiveCol.Key, mostActiveCol.Value, updatedPixels); | |
227 | -#endif | |
227 | + #if DEBUG | |
228 | + Logger.VerboseDebug("Wrote top-chunk shard: ({0}) - Edits#:{1}, Pixels#:{2}", mostActiveCol.Key, mostActiveCol.Value, updatedPixels); | |
229 | + #endif | |
228 | 230 | updatedChunks++; |
229 | 231 | chunkTopMetadata.Update(chunkMeta); |
230 | 232 | columnCounter.TryRemove(mostActiveCol.Key, out ejectedItem); |
@@ -232,9 +234,9 @@ namespace Automap | ||
232 | 234 | else |
233 | 235 | { |
234 | 236 | columnCounter.TryRemove(mostActiveCol.Key, out ejectedItem); |
235 | -#if DEBUG | |
236 | - Logger.VerboseDebug("Un-painted chunk: ({0}) ", mostActiveCol.Key); | |
237 | -#endif | |
237 | + #if DEBUG | |
238 | + Logger.VerboseDebug("Un-painted chun shard: ({0}) ", mostActiveCol.Key); | |
239 | + #endif | |
238 | 240 | } |
239 | 241 | } |
240 | 242 | //Cleanup persisted Metadata... |
@@ -549,14 +551,18 @@ namespace Automap | ||
549 | 551 | nullChunkCount++; |
550 | 552 | continue; |
551 | 553 | } |
552 | - worldChunk.Unpack( );//RESEARCH: Thread Unsafe? | |
553 | 554 | |
555 | + if (worldChunk.IsPacked()) | |
556 | + { | |
557 | + Logger.VerboseDebug("WORLD chunk: Compressed: X{0} Y{1} Z{2}", key.X, targetChunkY, key.Y); | |
558 | + worldChunk.Unpack( );//RESEARCH: Thread Unsafe? | |
559 | + } | |
554 | 560 | |
555 | 561 | /*************** Chunk Entities Scanning *********************/ |
556 | 562 | if (worldChunk.BlockEntities != null && worldChunk.BlockEntities.Count > 0) |
557 | 563 | { |
558 | 564 | #if DEBUG |
559 | - Logger.VerboseDebug("Surface@ {0} = BlockEntities: {1}", key, worldChunk.BlockEntities.Count); | |
565 | + Logger.VerboseDebug("Scan pos.({0}) for BlockEntities# {1}", key, worldChunk.BlockEntities.Count); | |
560 | 566 | #endif |
561 | 567 | |
562 | 568 | foreach (var blockEnt in worldChunk.BlockEntities) |
@@ -569,6 +575,8 @@ namespace Automap | ||
569 | 575 | } |
570 | 576 | } |
571 | 577 | |
578 | + //NOTE: Temporary; remove - replace later | |
579 | + if (chunkMeta.ColumnPresense == null) { chunkMeta.ColumnPresense = new BitArray((ClientAPI.World.BlockAccessor.MapSizeY / chunkSize), false); } | |
572 | 580 | chunkMeta.ColumnPresense[targetChunkY] = true; |
573 | 581 | |
574 | 582 | /********************* Chunk/Column BLOCKs scanning ****************/ |
@@ -580,44 +588,56 @@ namespace Automap | ||
580 | 588 | if (chunkMeta.HeightMap == null) { chunkMeta.HeightMap = new ushort[chunkSize, chunkSize]; } |
581 | 589 | if (chunkMeta.RockRatio == null) { chunkMeta.RockRatio = new Dictionary<int, uint>(10); } |
582 | 590 | |
591 | + //First Chance fail-safe; | |
592 | + if (worldChunk.Blocks == null || worldChunk.Blocks.Length <= 0) { | |
593 | + Logger.VerboseDebug("WORLD chunk; Missing block DATA⁈ X{0} Y{1} Z{2} ⁈", key.X, targetChunkY, key.Y); | |
594 | + continue; | |
595 | + } | |
596 | + | |
583 | 597 | for (Y_index = 0; Y_index < chunkSize - 1; Y_index++) |
584 | 598 | { |
585 | 599 | for (Z_index = 0; Z_index < chunkSize - 1; Z_index++) |
586 | 600 | { |
587 | 601 | for (X_index = 0; X_index < chunkSize - 1; X_index++) |
588 | 602 | { |
589 | - /* Encode packed indicie | |
590 | - (y * chunksize + z) * chunksize + x | |
591 | - */ | |
592 | - var indicie = Helpers.ChunkBlockIndicie16(X_index, Y_index, Z_index); | |
593 | - int aBlockId = worldChunk.Blocks[indicie]; | |
594 | - | |
595 | - if (aBlockId == 0) | |
596 | - {//Air | |
597 | - chunkMeta.AirBlocks++; | |
598 | - continue; | |
599 | - } | |
600 | - | |
601 | - if (RockIdCodes.ContainsKey(aBlockId)) | |
602 | - { | |
603 | - if (chunkMeta.RockRatio.ContainsKey(aBlockId)) | |
604 | - chunkMeta.RockRatio[aBlockId]++; | |
605 | - else | |
606 | - chunkMeta.RockRatio.Add(aBlockId, 1); | |
607 | - } | |
608 | - | |
609 | - chunkMeta.NonAirBlocks++; | |
610 | - | |
611 | - //Heightmap | |
612 | - if (chunkMeta.HeightMap[X_index, Z_index] == 0) | |
613 | - { | |
614 | - chunkMeta.HeightMap[X_index, Z_index] = (ushort) (Y_index + (targetChunkY * chunkSize)); | |
615 | - } | |
603 | + /* Encode packed indicie | |
604 | + (y * chunksize + z) * chunksize + x | |
605 | + */ | |
606 | + var indicie = Helpers.ChunkBlockIndicie16(X_index, Y_index, Z_index); | |
607 | + | |
608 | + //'Last' Chance fail-safe; | |
609 | + if (worldChunk.Blocks == null || worldChunk.Blocks.Length <= 0) { | |
610 | + Logger.VerboseDebug("Processing Block: Missing block DATA⁈ X{0} Y{1} Z{2} ⁈", X_index, Y_index, Z_index); | |
611 | + goto loop_bustout;; | |
616 | 612 | } |
617 | - } | |
613 | + | |
614 | + int aBlockId = worldChunk.Blocks[indicie]; | |
618 | 615 | |
619 | - } | |
616 | + if (aBlockId == 0) | |
617 | + {//Air | |
618 | + chunkMeta.AirBlocks++; | |
619 | + continue; | |
620 | + } | |
621 | + | |
622 | + if (RockIdCodes.ContainsKey(aBlockId)) | |
623 | + { | |
624 | + if (chunkMeta.RockRatio.ContainsKey(aBlockId)) | |
625 | + chunkMeta.RockRatio[aBlockId]++; | |
626 | + else | |
627 | + chunkMeta.RockRatio.Add(aBlockId, 1); | |
628 | + } | |
620 | 629 | |
630 | + chunkMeta.NonAirBlocks++; | |
631 | + | |
632 | + //Heightmap | |
633 | + if (chunkMeta.HeightMap[X_index, Z_index] == 0) | |
634 | + { | |
635 | + chunkMeta.HeightMap[X_index, Z_index] = (ushort) (Y_index + (targetChunkY * chunkSize)); | |
636 | + } | |
637 | + } | |
638 | + } | |
639 | + } | |
640 | + loop_bustout:; | |
621 | 641 | } |
622 | 642 | } |
623 | 643 |
@@ -0,0 +1,12 @@ | ||
1 | +using System; | |
2 | + | |
3 | +namespace ShardProcessor | |
4 | +{ | |
5 | + class MainClass | |
6 | + { | |
7 | + public static void Main(string[ ] args) | |
8 | + { | |
9 | + Console.WriteLine("Hello World!"); | |
10 | + } | |
11 | + } | |
12 | +} |
@@ -0,0 +1,27 @@ | ||
1 | +using System.Reflection; | |
2 | +using System.Runtime.CompilerServices; | |
3 | + | |
4 | +// Information about this assembly is defined by the following attributes. | |
5 | +// Change them to the values specific to your project. | |
6 | + | |
7 | +[assembly: AssemblyTitle("ShardProcessor")] | |
8 | +[assembly: AssemblyDescription("")] | |
9 | +[assembly: AssemblyConfiguration("")] | |
10 | +[assembly: AssemblyCompany("")] | |
11 | +[assembly: AssemblyProduct("")] | |
12 | +[assembly: AssemblyCopyright("librarian")] | |
13 | +[assembly: AssemblyTrademark("")] | |
14 | +[assembly: AssemblyCulture("")] | |
15 | + | |
16 | +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". | |
17 | +// The form "{Major}.{Minor}.*" will automatically update the build and revision, | |
18 | +// and "{Major}.{Minor}.{Build}.*" will update just the revision. | |
19 | + | |
20 | +[assembly: AssemblyVersion("1.0.*")] | |
21 | + | |
22 | +// The following attributes are used to specify the signing key for the assembly, | |
23 | +// if desired. See the Mono documentation for more information about signing. | |
24 | + | |
25 | +//[assembly: AssemblyDelaySign(false)] | |
26 | +//[assembly: AssemblyKeyFile("")] | |
27 | + |
@@ -0,0 +1,37 @@ | ||
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
3 | + <PropertyGroup> | |
4 | + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |
5 | + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |
6 | + <ProjectGuid>{837EE90B-7C03-413B-B54D-B50B2ED1EC00}</ProjectGuid> | |
7 | + <OutputType>Exe</OutputType> | |
8 | + <RootNamespace>ShardProcessor</RootNamespace> | |
9 | + <AssemblyName>ShardProcessor</AssemblyName> | |
10 | + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | |
11 | + </PropertyGroup> | |
12 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |
13 | + <DebugSymbols>true</DebugSymbols> | |
14 | + <DebugType>full</DebugType> | |
15 | + <Optimize>false</Optimize> | |
16 | + <OutputPath>bin\Debug</OutputPath> | |
17 | + <DefineConstants>DEBUG;</DefineConstants> | |
18 | + <ErrorReport>prompt</ErrorReport> | |
19 | + <WarningLevel>4</WarningLevel> | |
20 | + <ExternalConsole>true</ExternalConsole> | |
21 | + </PropertyGroup> | |
22 | + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |
23 | + <Optimize>true</Optimize> | |
24 | + <OutputPath>bin\Release</OutputPath> | |
25 | + <ErrorReport>prompt</ErrorReport> | |
26 | + <WarningLevel>4</WarningLevel> | |
27 | + <ExternalConsole>true</ExternalConsole> | |
28 | + </PropertyGroup> | |
29 | + <ItemGroup> | |
30 | + <Reference Include="System" /> | |
31 | + </ItemGroup> | |
32 | + <ItemGroup> | |
33 | + <Compile Include="Program.cs" /> | |
34 | + <Compile Include="Properties\AssemblyInfo.cs" /> | |
35 | + </ItemGroup> | |
36 | + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | |
37 | +</Project> | |
\ No newline at end of file |