columnCounters.AddOrUpdate(topPosition,
new ColumnCounter(chunkSize, newOrEdit, chunkCoord),
(chkPos, chkChng) => chkChng.Update(chunkCoord, chunkSize, newOrEdit)
- );
-
+ );
}
/// <summary>
Logger.VerboseDebug("(re)Created meta-chunk {0}", revisitCoord);
#endif
}
-
+ //TODO: Double validation of....?
ProcessChunkBlocks(revisitCoord, rv_mapChunk, ref rv_chunkMeta);
ChunkRenderer.SetupPngImage(revisitCoord, path, _chunkPath, ref rv_chunkMeta);
}//*********** REVISIT'd ******************
if (!columnCounters.IsEmpty)
- {//-- Should dodge enumerator changing underfoot....at a cost.
- var tempSet = columnCounters.ToArray().Where(cks => cks.Value.WeightedSum > editThreshold) .OrderByDescending(kvp => kvp.Value.WeightedSum);
+ {//Resulting snapshot keys mabey NON-UNIQUE!!! a *FEATURE* of ConcurrentDict !
+ var columnsSnapshot = columnCounters.Where(cks => cks.Value.WeightedSum > editThreshold).OrderByDescending(kvp => kvp.Value.WeightedSum).ToArray( );
UpdateEntityMetadata();
- foreach (var mostActiveCol in tempSet)
+ foreach (var mostActiveCol in columnsSnapshot)
{
var mapChunk = ClientAPI.World.BlockAccessor.GetMapChunk(mostActiveCol.Key);
Logger.VerboseDebug("Created meta-chunk {0}", mostActiveCol.Key);
#endif
}
+
+ /********* Special Interlock with C.D. *************/
+ if (columnCounters.TryRemove(mostActiveCol.Key, out ejectedItem)) {
ProcessChunkBlocks(mostActiveCol.Key, mapChunk, ref chunkMeta);
- mostActiveCol.Value.SetCutoff(chunkMeta.YMax / chunkSize);
+ ejectedItem.SetCutoff(chunkMeta.YMax / chunkSize);
ChunkRenderer.SetupPngImage(mostActiveCol.Key, path, _chunkPath, ref chunkMeta);
ChunkRenderer.GenerateChunkPngShard(mostActiveCol.Key, mapChunk, chunkMeta, ref chunkTopMetadata, out updatedPixels);
+ }
+ else {
+ #if DEBUG
+ Logger.Warning("Prevented duplicate processing of: {0}",mostActiveCol.Key );
+ #endif
+ }
if (updatedPixels > 0)
{
#endif
updatedChunks++;
chunkTopMetadata.Update(chunkMeta);
- columnCounters.TryRemove(mostActiveCol.Key, out ejectedItem);
+ //columnCounters.TryRemove(mostActiveCol.Key, out ejectedItem);
}
else
{
- columnCounters.TryRemove(mostActiveCol.Key, out ejectedItem);
+ //columnCounters.TryRemove(mostActiveCol.Key, out ejectedItem);
#if DEBUG
Logger.VerboseDebug("Un-painted chunk shard: ({0}) ", mostActiveCol.Key);
#endif
{
WorldChunk worldChunk = ClientAPI.World.BlockAccessor.GetChunk(key.X, targetChunkY, key.Y) as WorldChunk;
- if (worldChunk == null || worldChunk.BlockEntities == null)
+ if (worldChunk == null || worldChunk.BlockEntities == null || worldChunk.Disposed)
{
#if DEBUG
- Logger.VerboseDebug("WORLD chunk: null, B.E. null X{0} Y{1} Z{2} !", key.X, targetChunkY, key.Y);
+ Logger.VerboseDebug("WORLD chunk, null/disposed OR B.E. null: X{0} Y{1} Z{2} !", key.X, targetChunkY, key.Y);
#endif
nullChunkCount++;
continue;
if (worldChunk.BlockEntities != null && worldChunk.BlockEntities.Count > 0)
{
#if DEBUG
- Logger.VerboseDebug("Scan pos.({0}) for BlockEntities# {1}", key, worldChunk.BlockEntities.Count);
+ Logger.VerboseDebug("Scan in Chunk:({0}, Y {2}): found {1} BlockEntities", key, worldChunk.BlockEntities.Count,targetChunkY);
#endif
foreach (var blockEnt in worldChunk.BlockEntities)
{
- if (blockEnt.Key != null && blockEnt.Value != null && blockEnt.Value.Block != null && blockEnt.Value.Pos != null && BlockID_Designators.ContainsKey(blockEnt.Value.Block.BlockId))
+ var blockEntityPos = blockEnt.Key;
+ var blockEntity = blockEnt.Value;
+ if (blockEntityPos == null || blockEntity == null ) continue;
+ if (blockEntity.Block != null && !blockEntity.Block.IsMissing && BlockID_Designators.ContainsKey(blockEntity.Block.BlockId))
{
var designator = BlockID_Designators[blockEnt.Value.Block.BlockId];
- designator?.SpecialAction(ClientAPI, POIs, blockEnt.Value.Pos.Copy(), blockEnt.Value.Block);
+ if (designator != null && designator.SpecialAction != null) designator.SpecialAction(ClientAPI, POIs, blockEnt.Value.Pos.Copy(), blockEnt.Value.Block);
}
}
}