• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Automap (client) [VS plugin mod]


Commit MetaInfo

Revision8bde879f2fb8ad66dbafc2b4e4e246e2ab66856b (tree)
Time2020-02-27 03:51:20
AuthorThe Grand Dog <alex.h@me.c...>
CommiterThe Grand Dog

Log Message

bug fix with international use, simplification

Change Summary

Incremental Difference

--- a/Automap/Subsystems/AutomapSystem.cs
+++ b/Automap/Subsystems/AutomapSystem.cs
@@ -1,21 +1,17 @@
11 using System;
22 using System.Collections.Concurrent;
33 using System.Collections.Generic;
4-using System.Collections.ObjectModel;
5-
64 using System.IO;
75 using System.Linq;
86 using System.Text;
97 using System.Text.RegularExpressions;
108 using System.Threading;
11-using System.Web.UI;
129
1310 using Hjg.Pngcs;
1411 using Hjg.Pngcs.Chunks;
1512
1613 using Vintagestory.API.Client;
1714 using Vintagestory.API.Common;
18-using Vintagestory.API.Common.Entities;
1915 using Vintagestory.API.Config;
2016 using Vintagestory.API.Datastructures;
2117 using Vintagestory.API.MathTools;
@@ -176,9 +172,8 @@ namespace Automap
176172 UpdateEntityMetadata();
177173 ProcessChunkBlocks(mostActiveCol.Key, mapChunk, chunkMeta);
178174
179- uint updatedPixels = 0;
180175
181- ChunkRenderer.GenerateChunkPngShard(mostActiveCol.Key, mapChunk, chunkMeta, pngWriter, out updatedPixels);
176+ ChunkRenderer.GenerateChunkPngShard(mostActiveCol.Key, mapChunk, chunkMeta, pngWriter, out uint updatedPixels);
182177
183178 if (updatedPixels > 0)
184179 {
@@ -315,14 +310,14 @@ namespace Automap
315310 jsonWriter.Write("{");
316311 jsonWriter.Write("prettyCoord:'{0}',", shard.Location.PrettyCoords(ClientAPI));
317312 jsonWriter.Write("chunkAge:'{0}',", shard.ChunkAge.ToString("g"));//World age - relative? or last edit ??
318- jsonWriter.Write("temp:{0},", shard.Temperature.ToString("F1"));
319- jsonWriter.Write("YMax:{0},", shard.YMax);
320- jsonWriter.Write("fert:{0},", shard.Fertility.ToString("F1"));
321- jsonWriter.Write("forestDens:{0},", shard.ForestDensity.ToString("F1"));
322- jsonWriter.Write("rain:{0},", shard.Rainfall.ToString("F1"));
323- jsonWriter.Write("shrubDens:{0},", shard.ShrubDensity.ToString("F1"));
324- jsonWriter.Write("airBlocks:{0},", shard.AirBlocks);
325- jsonWriter.Write("nonAirBlocks:{0},", shard.NonAirBlocks);
313+ jsonWriter.Write("temp:'{0}',", shard.Temperature.ToString("F1"));
314+ jsonWriter.Write("YMax:'{0}',", shard.YMax);
315+ jsonWriter.Write("fert:'{0}',", shard.Fertility.ToString("F1"));
316+ jsonWriter.Write("forestDens:'{0}',", shard.ForestDensity.ToString("F1"));
317+ jsonWriter.Write("rain:'{0}',", shard.Rainfall.ToString("F1"));
318+ jsonWriter.Write("shrubDens:'{0}',", shard.ShrubDensity.ToString("F1"));
319+ jsonWriter.Write("airBlocks:'{0}',", shard.AirBlocks);
320+ jsonWriter.Write("nonAirBlocks:'{0}',", shard.NonAirBlocks);
326321 //TODO: Heightmap
327322 //TODO: Rock-ratio
328323 jsonWriter.Write("}],");
@@ -405,17 +400,15 @@ namespace Automap
405400 int Z_chunk_pos = int.Parse(result.Groups["Z"].Value);
406401
407402 //Parse PNG chunks for METADATA in shard
408- using (var fileStream = shardFile.OpenRead())
409- {
410- //TODO: Add corrupted PNG Exception handing HERE !
411- PngReader pngRead = new PngReader(fileStream);
412- pngRead.ReadSkippingAllRows();
413- pngRead.End();
403+ using var fileStream = shardFile.OpenRead();
404+ //TODO: Add corrupted PNG Exception handing HERE !
405+ PngReader pngRead = new PngReader(fileStream);
406+ pngRead.ReadSkippingAllRows();
407+ pngRead.End();
414408
415- PngMetadataChunk metadataFromPng = pngRead.GetChunksList().GetById1(PngMetadataChunk.ID) as PngMetadataChunk;
409+ PngMetadataChunk metadataFromPng = pngRead.GetChunksList().GetById1(PngMetadataChunk.ID) as PngMetadataChunk;
416410
417- chunkTopMetadata.Add(metadataFromPng.ChunkMetadata);
418- }
411+ chunkTopMetadata.Add(metadataFromPng.ChunkMetadata);
419412
420413 }
421414 }
@@ -446,8 +439,10 @@ namespace Automap
446439 meta.SetText("Chunk_X", coord.X.ToString("D"));
447440 meta.SetText("Chunk_Y", coord.Y.ToString("D"));
448441 //Setup specialized meta-data PNG chunks here...
449- PngMetadataChunk pngChunkMeta = new PngMetadataChunk(pngWriter.ImgInfo);
450- pngChunkMeta.ChunkMetadata = metadata;
442+ PngMetadataChunk pngChunkMeta = new PngMetadataChunk(pngWriter.ImgInfo)
443+ {
444+ ChunkMetadata = metadata
445+ };
451446 pngWriter.GetChunksList().Queue(pngChunkMeta);
452447
453448 return pngWriter;
@@ -465,9 +460,7 @@ namespace Automap
465460 int targetChunkY = mapChunk.YMax / chunkSize;//Surface ...
466461 for (; targetChunkY > 0; targetChunkY--)
467462 {
468- WorldChunk chunkData = ClientAPI.World.BlockAccessor.GetChunk(key.X, targetChunkY, key.Y) as WorldChunk;
469-
470- if (chunkData == null || chunkData.BlockEntities == null)
463+ if (!(ClientAPI.World.BlockAccessor.GetChunk(key.X, targetChunkY, key.Y) is WorldChunk chunkData) || chunkData.BlockEntities == null)
471464 {
472465 #if DEBUG
473466 Logger.VerboseDebug("Chunk null or empty X{0} Y{1} Z{2}", key.X, targetChunkY, key.Y);