using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
-using System.Collections.ObjectModel;
-
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
-using System.Web.UI;
using Hjg.Pngcs;
using Hjg.Pngcs.Chunks;
using Vintagestory.API.Client;
using Vintagestory.API.Common;
-using Vintagestory.API.Common.Entities;
using Vintagestory.API.Config;
using Vintagestory.API.Datastructures;
using Vintagestory.API.MathTools;
UpdateEntityMetadata();
ProcessChunkBlocks(mostActiveCol.Key, mapChunk, chunkMeta);
- uint updatedPixels = 0;
- ChunkRenderer.GenerateChunkPngShard(mostActiveCol.Key, mapChunk, chunkMeta, pngWriter, out updatedPixels);
+ ChunkRenderer.GenerateChunkPngShard(mostActiveCol.Key, mapChunk, chunkMeta, pngWriter, out uint updatedPixels);
if (updatedPixels > 0)
{
jsonWriter.Write("{");
jsonWriter.Write("prettyCoord:'{0}',", shard.Location.PrettyCoords(ClientAPI));
jsonWriter.Write("chunkAge:'{0}',", shard.ChunkAge.ToString("g"));//World age - relative? or last edit ??
- jsonWriter.Write("temp:{0},", shard.Temperature.ToString("F1"));
- jsonWriter.Write("YMax:{0},", shard.YMax);
- jsonWriter.Write("fert:{0},", shard.Fertility.ToString("F1"));
- jsonWriter.Write("forestDens:{0},", shard.ForestDensity.ToString("F1"));
- jsonWriter.Write("rain:{0},", shard.Rainfall.ToString("F1"));
- jsonWriter.Write("shrubDens:{0},", shard.ShrubDensity.ToString("F1"));
- jsonWriter.Write("airBlocks:{0},", shard.AirBlocks);
- jsonWriter.Write("nonAirBlocks:{0},", shard.NonAirBlocks);
+ jsonWriter.Write("temp:'{0}',", shard.Temperature.ToString("F1"));
+ jsonWriter.Write("YMax:'{0}',", shard.YMax);
+ jsonWriter.Write("fert:'{0}',", shard.Fertility.ToString("F1"));
+ jsonWriter.Write("forestDens:'{0}',", shard.ForestDensity.ToString("F1"));
+ jsonWriter.Write("rain:'{0}',", shard.Rainfall.ToString("F1"));
+ jsonWriter.Write("shrubDens:'{0}',", shard.ShrubDensity.ToString("F1"));
+ jsonWriter.Write("airBlocks:'{0}',", shard.AirBlocks);
+ jsonWriter.Write("nonAirBlocks:'{0}',", shard.NonAirBlocks);
//TODO: Heightmap
//TODO: Rock-ratio
jsonWriter.Write("}],");
int Z_chunk_pos = int.Parse(result.Groups["Z"].Value);
//Parse PNG chunks for METADATA in shard
- using (var fileStream = shardFile.OpenRead())
- {
- //TODO: Add corrupted PNG Exception handing HERE !
- PngReader pngRead = new PngReader(fileStream);
- pngRead.ReadSkippingAllRows();
- pngRead.End();
+ using var fileStream = shardFile.OpenRead();
+ //TODO: Add corrupted PNG Exception handing HERE !
+ PngReader pngRead = new PngReader(fileStream);
+ pngRead.ReadSkippingAllRows();
+ pngRead.End();
- PngMetadataChunk metadataFromPng = pngRead.GetChunksList().GetById1(PngMetadataChunk.ID) as PngMetadataChunk;
+ PngMetadataChunk metadataFromPng = pngRead.GetChunksList().GetById1(PngMetadataChunk.ID) as PngMetadataChunk;
- chunkTopMetadata.Add(metadataFromPng.ChunkMetadata);
- }
+ chunkTopMetadata.Add(metadataFromPng.ChunkMetadata);
}
}
meta.SetText("Chunk_X", coord.X.ToString("D"));
meta.SetText("Chunk_Y", coord.Y.ToString("D"));
//Setup specialized meta-data PNG chunks here...
- PngMetadataChunk pngChunkMeta = new PngMetadataChunk(pngWriter.ImgInfo);
- pngChunkMeta.ChunkMetadata = metadata;
+ PngMetadataChunk pngChunkMeta = new PngMetadataChunk(pngWriter.ImgInfo)
+ {
+ ChunkMetadata = metadata
+ };
pngWriter.GetChunksList().Queue(pngChunkMeta);
return pngWriter;
int targetChunkY = mapChunk.YMax / chunkSize;//Surface ...
for (; targetChunkY > 0; targetChunkY--)
{
- WorldChunk chunkData = ClientAPI.World.BlockAccessor.GetChunk(key.X, targetChunkY, key.Y) as WorldChunk;
-
- if (chunkData == null || chunkData.BlockEntities == null)
+ if (!(ClientAPI.World.BlockAccessor.GetChunk(key.X, targetChunkY, key.Y) is WorldChunk chunkData) || chunkData.BlockEntities == null)
{
#if DEBUG
Logger.VerboseDebug("Chunk null or empty X{0} Y{1} Z{2}", key.X, targetChunkY, key.Y);