• R/O
  • HTTP
  • SSH
  • HTTPS

automap: Commit

Automap (OSS) GIT software repository


Commit MetaInfo

Revisión8ed1a1e5a9e3a9699b2aae545bd2cfe2ca02d659 (tree)
Tiempo2022-06-04 08:59:42
Autormelchior <melchior@user...>
Commitermelchior

Log Message

Fix for B.E error invoke, Anti-Duplication

prevent ConcurrentDict; duplicate on platforms that happen to make no
assurace of unique keyswhen Enum'ing,
plus assorted minor fixes...

Cambiar Resumen

Diferencia incremental

--- a/Automap/Designators/DefaultDesignators.cs
+++ b/Automap/Designators/DefaultDesignators.cs
@@ -167,7 +167,7 @@ namespace Automap
167167 //sign post Text into a POI field...
168168 BlockEntitySignPost signEntity = clientAPI.World.BlockAccessor.GetBlockEntity(posn) as BlockEntitySignPost;
169169
170- if (signEntity != null && signEntity.textByCardinalDirection?.Length > 0) {
170+ if (signEntity != null && signEntity.textByCardinalDirection != null && signEntity.textByCardinalDirection?.Length > 0) {
171171
172172 var textTemp = SaferUnicodeEncoding.GetBytes(string.Join(",", signEntity.textByCardinalDirection));
173173
@@ -191,7 +191,9 @@ namespace Automap
191191 //clientAPI.Logger.VerboseDebug("Trader: {0} @ {1}", entity.GetName(), posn);
192192
193193 var traderJoe = entity as EntityTrader;
194- var traderName = entity.GetBehavior<EntityBehaviorNameTag>( )?.DisplayName;
194+ if (traderJoe == null) return;
195+
196+ var traderName = entity.GetBehavior<EntityBehaviorNameTag>( )?.DisplayName ?? @"?";
195197 string code;
196198 // this makes me ill
197199 switch (entity.Code.Path) {
--- a/Automap/Renderers/StandardRenderer.cs
+++ b/Automap/Renderers/StandardRenderer.cs
@@ -152,6 +152,7 @@ namespace Automap
152152 #if DEBUG
153153 Logger.VerboseDebug("Gap in chunk-column at render time Chunk-Y:{0}", localChunkY);
154154 #endif
155+ if (localChunkY == 0 ) break;
155156 continue;
156157 }
157158
--- a/Automap/Subsystems/AutomapSystem.cs
+++ b/Automap/Subsystems/AutomapSystem.cs
@@ -134,8 +134,7 @@ namespace Automap
134134 columnCounters.AddOrUpdate(topPosition,
135135 new ColumnCounter(chunkSize, newOrEdit, chunkCoord),
136136 (chkPos, chkChng) => chkChng.Update(chunkCoord, chunkSize, newOrEdit)
137- );
138-
137+ );
139138 }
140139
141140 /// <summary>
@@ -220,7 +219,7 @@ namespace Automap
220219 Logger.VerboseDebug("(re)Created meta-chunk {0}", revisitCoord);
221220 #endif
222221 }
223-
222+ //TODO: Double validation of....?
224223 ProcessChunkBlocks(revisitCoord, rv_mapChunk, ref rv_chunkMeta);
225224
226225 ChunkRenderer.SetupPngImage(revisitCoord, path, _chunkPath, ref rv_chunkMeta);
@@ -237,12 +236,12 @@ namespace Automap
237236 }//*********** REVISIT'd ******************
238237
239238 if (!columnCounters.IsEmpty)
240- {//-- Should dodge enumerator changing underfoot....at a cost.
241- var tempSet = columnCounters.ToArray().Where(cks => cks.Value.WeightedSum > editThreshold) .OrderByDescending(kvp => kvp.Value.WeightedSum);
239+ {//Resulting snapshot keys mabey NON-UNIQUE!!! a *FEATURE* of ConcurrentDict !
240+ var columnsSnapshot = columnCounters.Where(cks => cks.Value.WeightedSum > editThreshold).OrderByDescending(kvp => kvp.Value.WeightedSum).ToArray( );
242241
243242 UpdateEntityMetadata();
244243
245- foreach (var mostActiveCol in tempSet)
244+ foreach (var mostActiveCol in columnsSnapshot)
246245 {
247246 var mapChunk = ClientAPI.World.BlockAccessor.GetMapChunk(mostActiveCol.Key);
248247
@@ -272,11 +271,20 @@ namespace Automap
272271 Logger.VerboseDebug("Created meta-chunk {0}", mostActiveCol.Key);
273272 #endif
274273 }
274+
275+ /********* Special Interlock with C.D. *************/
276+ if (columnCounters.TryRemove(mostActiveCol.Key, out ejectedItem)) {
275277 ProcessChunkBlocks(mostActiveCol.Key, mapChunk, ref chunkMeta);
276- mostActiveCol.Value.SetCutoff(chunkMeta.YMax / chunkSize);
278+ ejectedItem.SetCutoff(chunkMeta.YMax / chunkSize);
277279
278280 ChunkRenderer.SetupPngImage(mostActiveCol.Key, path, _chunkPath, ref chunkMeta);
279281 ChunkRenderer.GenerateChunkPngShard(mostActiveCol.Key, mapChunk, chunkMeta, ref chunkTopMetadata, out updatedPixels);
282+ }
283+ else {
284+ #if DEBUG
285+ Logger.Warning("Prevented duplicate processing of: {0}",mostActiveCol.Key );
286+ #endif
287+ }
280288
281289 if (updatedPixels > 0)
282290 {
@@ -285,11 +293,11 @@ namespace Automap
285293 #endif
286294 updatedChunks++;
287295 chunkTopMetadata.Update(chunkMeta);
288- columnCounters.TryRemove(mostActiveCol.Key, out ejectedItem);
296+ //columnCounters.TryRemove(mostActiveCol.Key, out ejectedItem);
289297 }
290298 else
291299 {
292- columnCounters.TryRemove(mostActiveCol.Key, out ejectedItem);
300+ //columnCounters.TryRemove(mostActiveCol.Key, out ejectedItem);
293301 #if DEBUG
294302 Logger.VerboseDebug("Un-painted chunk shard: ({0}) ", mostActiveCol.Key);
295303 #endif
@@ -678,10 +686,10 @@ namespace Automap
678686 {
679687 WorldChunk worldChunk = ClientAPI.World.BlockAccessor.GetChunk(key.X, targetChunkY, key.Y) as WorldChunk;
680688
681- if (worldChunk == null || worldChunk.BlockEntities == null)
689+ if (worldChunk == null || worldChunk.BlockEntities == null || worldChunk.Disposed)
682690 {
683691 #if DEBUG
684- Logger.VerboseDebug("WORLD chunk: null, B.E. null X{0} Y{1} Z{2} !", key.X, targetChunkY, key.Y);
692+ Logger.VerboseDebug("WORLD chunk, null/disposed OR B.E. null: X{0} Y{1} Z{2} !", key.X, targetChunkY, key.Y);
685693 #endif
686694 nullChunkCount++;
687695 continue;
@@ -705,15 +713,18 @@ namespace Automap
705713 if (worldChunk.BlockEntities != null && worldChunk.BlockEntities.Count > 0)
706714 {
707715 #if DEBUG
708- Logger.VerboseDebug("Scan pos.({0}) for BlockEntities# {1}", key, worldChunk.BlockEntities.Count);
716+ Logger.VerboseDebug("Scan in Chunk:({0}, Y {2}): found {1} BlockEntities", key, worldChunk.BlockEntities.Count,targetChunkY);
709717 #endif
710718
711719 foreach (var blockEnt in worldChunk.BlockEntities)
712720 {
713- if (blockEnt.Key != null && blockEnt.Value != null && blockEnt.Value.Block != null && blockEnt.Value.Pos != null && BlockID_Designators.ContainsKey(blockEnt.Value.Block.BlockId))
721+ var blockEntityPos = blockEnt.Key;
722+ var blockEntity = blockEnt.Value;
723+ if (blockEntityPos == null || blockEntity == null ) continue;
724+ if (blockEntity.Block != null && !blockEntity.Block.IsMissing && BlockID_Designators.ContainsKey(blockEntity.Block.BlockId))
714725 {
715726 var designator = BlockID_Designators[blockEnt.Value.Block.BlockId];
716- designator?.SpecialAction(ClientAPI, POIs, blockEnt.Value.Pos.Copy(), blockEnt.Value.Block);
727+ if (designator != null && designator.SpecialAction != null) designator.SpecialAction(ClientAPI, POIs, blockEnt.Value.Pos.Copy(), blockEnt.Value.Block);
717728 }
718729 }
719730 }
Show on old repository browser