using System;
using System.Collections.Generic;
using System.Collections.Specialized;
-
+using System.Diagnostics;
+using System.IO;
+using System.Collections.ObjectModel;
+using System.Text;
using Vintagestory.API.MathTools;
using Vintagestory.API.Common;
+using Vintagestory.API.Client;
using ProtoBuf;
-using System.IO;
-using System.Collections.ObjectModel;
-using System.Text;
-using Vintagestory.API.Client;
-using Newtonsoft.Json.Linq;
namespace Automap
{
- [ProtoContract]
+ [ProtoContract(ImplicitFields = ImplicitFields.None)]
public struct ColumnMeta
{
[ProtoMember(1)]
public Vec2i Location;
[DisplayName(0, "Coords.")]
+ [ProtoIgnore]
public string PrettyLocation;
[ProtoMember(2)]
public TimeSpan ChunkAge;//OLDEST CHUNK. from chunk last edit
[DisplayName(1, "Age")]
+ [ProtoIgnore]
public string ShortChunkAge { get => ChunkAge.ToString("c"); }
- [ProtoMember(3)]
[DisplayName(2, "Temp.")]
+ [ProtoMember(3)]
public float Temperature;// Temperature - surface
- [ProtoMember(4)]
[DisplayName(3, "Y Max.")]
+ [ProtoMember(4)]
public ushort YMax;// Y feature height
[ProtoMember(5)]
//}
- [ProtoMember(6)]
[DisplayName(4, "Fert.")]
+ [ProtoMember(6)]
public float Fertility;
- [ProtoMember(7)]
//[DisplayName(5, "Forest")]
+ [ProtoMember(7)]
public float ForestDensity; // not given to client
- [ProtoMember(8)]
[DisplayName(6, "Rain")]
+ [ProtoMember(8)]
public float Rainfall;
- [ProtoMember(9)]
//[DisplayName(7, "Shrub")]
+ [ProtoMember(9)]
public float ShrubDensity; // not given to client
- [ProtoMember(10)]
[DisplayName(8, "Air blocks")]
+ [ProtoMember(10)]
public uint AirBlocks;
- [ProtoMember(11)]
[DisplayName(9, "Non-air")]
+ [ProtoMember(11)]
public uint NonAirBlocks;
[ProtoMember(12)]
internal ColumnMeta Reload(ICoreClientAPI clientAPI)
{
this.PrettyLocation = Location.PrettyCoords(clientAPI);
- Console.Write(PrettyLocation == null ? "*" : ",");
+ Debug.Write(PrettyLocation == null ? "*" : ",");
return this;
}
}
/// <summary>
/// Basically the same as a POI but for an entity
/// </summary>
- [ProtoContract]
+ [ProtoContract(ImplicitFields = ImplicitFields.None)]
public struct EntityOfInterest
{
public string Notes;
[DisplayName(1, "Loc.")]
+ [ProtoIgnore]
public string PrettyLocation;
[ProtoMember(3)]
using System;
-
-using Vintagestory.API.Util;
+using System.Diagnostics;
+using System.IO;
using Hjg.Pngcs;
using Hjg.Pngcs.Chunks;
+using ProtoBuf;
+
namespace Automap
{
/// <summary>
public override ChunkRaw CreateRawChunk()
{
- var datas = SerializerUtil.Serialize<ColumnMeta>(ChunkMetadata);
+ using (MemoryStream outputStream = new MemoryStream( ))
+ {
+ Serializer.Serialize<ColumnMeta>(outputStream, this.ChunkMetadata);
- ChunkRaw rawChunk = createEmptyChunk(datas.Length, true);
- rawChunk.Data = datas;
+ ChunkRaw pngChunk = createEmptyChunk(( int )outputStream.Length, true);
+ pngChunk.Data = outputStream.ToArray();
- return rawChunk;
+ return pngChunk;
+ }
}
- public override void ParseFromRaw(ChunkRaw rawChunk)
- {
- this.ChunkMetadata = SerializerUtil.Deserialize<ColumnMeta>(rawChunk.Data);
+ public override void ParseFromRaw(ChunkRaw pngChunk)
+ {
+ using (MemoryStream inputStream = new MemoryStream(pngChunk.Data, false))
+ {
+ this.ChunkMetadata = Serializer.Deserialize<ColumnMeta>(inputStream);
+ }
}
public override void CloneDataFromRead(PngChunk other)
/// <summary>
/// Actual Physical Point in space - that is interesting.
/// </summary>
- [ProtoContract]
+ [ProtoContract(ImplicitFields = ImplicitFields.None)]
public struct PointOfInterest
{
[DisplayName(0, "Name")]
public string Notes;
[DisplayName(1, "Loc.")]
+ [ProtoIgnore]
public string PrettyLocation;
[ProtoMember(3)]
if (te != null)
{
-
+ //FIXME: Delayed rescan ?
StringBuilder textTarget = new StringBuilder();
//translocatorEntity.GetBlockInfo(clientAPI.World.Player, textTarget);
- textTarget.Append(te.FullyRepaired ? "Functional " : "Broken ");
- textTarget.Append(te.Activated ? "Online " : "Offline ");
- textTarget.Append(" Target: ");
- textTarget.Append(te.TargetLocation != null ? "Set" : "Invalid");//Or ABS coords?
- textTarget.AppendFormat(" Range ({0} ~ {1})", te.MinTeleporterRangeInBlocks, te.MaxTeleporterRangeInBlocks);
+ textTarget.Append(te.FullyRepaired ? "Functional, " : "Broken, ");
+ textTarget.Append(te.Activated ? "Online, " : "Offline, ");
+ textTarget.Append(" Target: [ ");
+ textTarget.Append(te.TargetLocation != null ? "Set ]" : "Invalid ]");//Or ABS coords?
+ textTarget.AppendFormat(", Range ({0} ~ {1})", te.MinTeleporterRangeInBlocks, te.MaxTeleporterRangeInBlocks);
poi.AddReplace(
new PointOfInterest
{
Location = posn.Copy(),
Notes = textTarget.ToString(),
Timestamp = DateTime.UtcNow,
- Destination = te.TargetLocation != null ? new BlockPosJson(te.TargetLocation) : null//FIXME: Delayed rescan
+ Destination = te.TargetLocation != null ? new BlockPosJson(te.TargetLocation.Copy()) : null
}
);
-
}
}
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using Hjg.Pngcs;
using Hjg.Pngcs.Chunks;
-using Newtonsoft.Json;
-
using ProtoBuf;
using Vintagestory.API.Client;
Logger.Error("PNG Corruption file '{0}' - Reason: {1}", shardFile.Name, someEx);
continue;
}
+ catch (ProtoException protoEx)
+ {
+ Logger.Error("ProtoBuf invalid! file:'{0}' - Reason: {1}", shardFile.Name, protoEx);
+ continue;
+ }
}
}
var t = new Stopwatch();
t.Start();
- Console.WriteLine("snapshot started");
+ Debug.WriteLine("snapshot started");
ImageInfo info = new ImageInfo(Width * chunkSize, Height * chunkSize, 8, false);
PngWriter snapWriter = FileHelper.CreatePngWriter(fileName, info, true);
}
catch (Exception)
{
- Console.WriteLine("Snapshot exception!");
+ Debug.WriteLine("Snapshot exception!");
}
- Console.WriteLine($"snapshot finished in {t.ElapsedMilliseconds}");
+ Debug.WriteLine($"snapshot finished in {t.ElapsedMilliseconds}");
}
private async Task<Dictionary<int, byte[][]>> ReadAllInGroup(IGrouping<int, ColumnMeta> group)
}
catch (Exception e)
{
- Console.WriteLine(e.Message);
+ Debug.WriteLine(e.Message);
return null;
} // do nothing on error
}