• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

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

Révisiona5cf48106e5ad88de4153de6393b122c5096c3fb (tree)
l'heure2021-08-27 05:14:57
Auteurmelchior <melchior@user...>
Commitermelchior

Message de Log

Assorted fixes

Unicode fix (normalization), extra-constructor for S.P. use

Change Summary

Modification

--- a/Automap/Data/ColumnMeta.cs
+++ b/Automap/Data/ColumnMeta.cs
@@ -118,6 +118,26 @@ namespace Automap
118118 ColumnPresense = new BitArray(maxChunkHeight, false);//TODO: get real chunk height MAX
119119 }
120120
121+ public ColumnMeta(Vec2i loc, byte chunkSize = 32, int maxChunkHeight = 16)
122+ {
123+ Location = loc;
124+ PrettyLocation = string.Empty;
125+ ChunkAge = TimeSpan.Zero;
126+ Temperature = 0f;
127+ YMax = 0;
128+ RockRatio = new Dictionary<int, uint>(10);
129+ Fertility = 0f;
130+ ForestDensity = 0f;
131+ Rainfall = 0f;
132+ ShrubDensity = 0f;
133+ AirBlocks = 0;
134+ NonAirBlocks = 0;
135+ ChunkSize = chunkSize;
136+ HeightMap = new ushort[ChunkSize, ChunkSize];
137+ _flattened_HeightMap = null;
138+ ColumnPresense = new BitArray(maxChunkHeight, false);
139+ }
140+
121141 internal void UpdateFieldsFrom(ClimateCondition climate, IMapChunk mapChunk, TimeSpan chunkAge)
122142 {
123143 this.ChunkAge = chunkAge;
--- a/Automap/Designators/DefaultDesignators.cs
+++ b/Automap/Designators/DefaultDesignators.cs
@@ -3,7 +3,9 @@ using System.Collections.Generic;
33 using System.Drawing;
44 using System.Text;
55 using System.Text.RegularExpressions;
6+
67 using HarmonyLib;
8+
79 using Vintagestory.API.Client;
810 using Vintagestory.API.Common;
911 using Vintagestory.API.Common.Entities;
@@ -123,6 +125,10 @@ namespace Automap
123125 }
124126 }
125127
128+ internal static Encoding SaferUnicodeEncoding = Encoding.GetEncoding(Encoding.UTF8.WebName,
129+ new EncoderReplacementFallback(@" "),
130+ new DecoderReplacementFallback(@" "));
131+
126132 #endregion
127133
128134
@@ -130,20 +136,22 @@ namespace Automap
130136
131137 internal static void DecodeSign(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block)
132138 {
133-#if DEBUG
139+ #if DEBUG
134140 clientAPI.Logger.VerboseDebug("Sign Designator Invoked!");
135-#endif
141+ #endif
136142 //sign Text into a POI field...
137143 BlockEntitySign signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySign;
138144
139145 if (signEntity != null && !String.IsNullOrEmpty(signEntity.text)) {
140146
147+ var textTemp = SaferUnicodeEncoding.GetBytes(signEntity.text);
148+
141149 poi.AddReplace(
142150 new PointOfInterest {
143151 Name = "Sign",
144152 PrettyLocation = posn.PrettyCoords(clientAPI),
145153 Location = posn.Copy( ),
146- Notes = signEntity.text,
154+ Notes = SaferUnicodeEncoding.GetString(textTemp).Normalize(),
147155 Timestamp = DateTime.UtcNow,
148156 }
149157 );
@@ -161,12 +169,14 @@ namespace Automap
161169
162170 if (signEntity != null && signEntity.textByCardinalDirection?.Length > 0) {
163171
172+ var textTemp = SaferUnicodeEncoding.GetBytes(string.Join(",", signEntity.textByCardinalDirection));
173+
164174 poi.AddReplace(
165175 new PointOfInterest {
166176 Name = "Signpost",
167177 PrettyLocation = posn.PrettyCoords(clientAPI),
168178 Location = posn.Copy( ),
169- Notes = string.Join(",", signEntity.textByCardinalDirection),
179+ Notes = SaferUnicodeEncoding.GetString(textTemp).Normalize(),
170180 Timestamp = DateTime.UtcNow,
171181 }
172182 );
--- a/Automap/Subsystems/AutomapSystem.cs
+++ b/Automap/Subsystems/AutomapSystem.cs
@@ -204,7 +204,9 @@ namespace Automap
204204 if (mapChunk == null)
205205 {
206206 //TODO: REVISIT THIS CHUNK!
207+ #if DEBUG
207208 Logger.Warning("SKIP CHUNK: ({0}) - Map Chunk NULL!", mostActiveCol.Key);
209+ #endif
208210 nullMapCount++;
209211 columnCounters.TryRemove(mostActiveCol.Key, out ejectedItem);
210212 continue;
@@ -400,17 +402,19 @@ namespace Automap
400402
401403 if (this.POIs.Count > 0)
402404 {
403- using (var poiFile = File.Open(poiPath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
405+ using (var poiFile = File.Open(poiPath, FileMode.Create, FileAccess.Write, FileShare.None))
404406 {
405407 Serializer.Serialize<PointsOfInterest>(poiFile, this.POIs);
408+ poiFile.Flush(true);
406409 }
407410 }
408411
409412 if (this.EOIs.Count > 0)
410413 {
411- using (var eoiFile = File.Open(eoiPath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
414+ using (var eoiFile = File.Open(eoiPath, FileMode.Create, FileAccess.Write, FileShare.None))
412415 {
413416 Serializer.Serialize<EntitiesOfInterest>(eoiFile, this.EOIs);
417+ eoiFile.Flush(true);
414418 }
415419 }
416420