From e872e172bf4468414151947d070ad05c4cb596be Mon Sep 17 00:00:00 2001 From: melchior Date: Tue, 10 Dec 2019 19:25:37 -0500 Subject: [PATCH] FIX: Temporary chunks list to avoid Enumerator mutation --- Automap/Automap_Internals.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Automap/Automap_Internals.cs b/Automap/Automap_Internals.cs index a0a763e..6110a8e 100644 --- a/Automap/Automap_Internals.cs +++ b/Automap/Automap_Internals.cs @@ -45,7 +45,7 @@ namespace Automap private void StartAutomap( ) { path = ClientAPI.GetOrCreateDataPath(_mapPath); - path = ClientAPI.GetOrCreateDataPath(Path.Combine(path, "World_" + ClientAPI.World.Seed)); + path = ClientAPI.GetOrCreateDataPath(Path.Combine(path, "World_" + ClientAPI.World.Seed));//Add name of World too! stylesFile = ClientAPI.World.AssetManager.Get(new AssetLocation(_domain, "config/automap_format.css")); Logger.VerboseDebug("CSS loaded: {0} size: {1}",stylesFile.IsLoaded() ,stylesFile.ToText( ).Length); @@ -107,11 +107,12 @@ namespace Automap uint ejectedItem = 0; uint updatedChunks = 0; - while (columnCounter.Count > 0) { - //BUG:WIN crash here; Possibly "First()", edit race-cond? - var mostActiveCol = columnCounter.OrderByDescending(kvp => kvp.Value).First( );//FIX? - var mapChunk = ClientAPI.World.BlockAccessor.GetMapChunk(mostActiveCol.Key); + //-- Should dodge enumerator changing underfoot....at a cost. + if (!columnCounter.IsEmpty) { + var tempSet = columnCounter.ToArray( ).OrderByDescending(kvp => kvp.Value); + foreach (var mostActiveCol in tempSet) { + var mapChunk = ClientAPI.World.BlockAccessor.GetMapChunk(mostActiveCol.Key); if (mapChunk == null) { Logger.Warning("SKIP CHUNK: ({0}) - Map Chunk NULL!", mostActiveCol.Key); @@ -141,6 +142,7 @@ namespace Automap } } + } if (updatedChunks > 0) { lastUpdate = updatedChunks; -- 2.11.0