Automap (client) [VS plugin mod]
Revision | e872e172bf4468414151947d070ad05c4cb596be (tree) |
---|---|
Time | 2019-12-11 09:25:37 |
Author | melchior <melchior@user...> |
Commiter | melchior |
FIX: Temporary chunks list to avoid Enumerator mutation
@@ -45,7 +45,7 @@ namespace Automap | ||
45 | 45 | private void StartAutomap( ) |
46 | 46 | { |
47 | 47 | path = ClientAPI.GetOrCreateDataPath(_mapPath); |
48 | - path = ClientAPI.GetOrCreateDataPath(Path.Combine(path, "World_" + ClientAPI.World.Seed)); | |
48 | + path = ClientAPI.GetOrCreateDataPath(Path.Combine(path, "World_" + ClientAPI.World.Seed));//Add name of World too! | |
49 | 49 | |
50 | 50 | stylesFile = ClientAPI.World.AssetManager.Get(new AssetLocation(_domain, "config/automap_format.css")); |
51 | 51 | Logger.VerboseDebug("CSS loaded: {0} size: {1}",stylesFile.IsLoaded() ,stylesFile.ToText( ).Length); |
@@ -107,11 +107,12 @@ namespace Automap | ||
107 | 107 | uint ejectedItem = 0; |
108 | 108 | uint updatedChunks = 0; |
109 | 109 | |
110 | - while (columnCounter.Count > 0) { | |
111 | - //BUG:WIN crash here; Possibly "First()", edit race-cond? | |
112 | - var mostActiveCol = columnCounter.OrderByDescending(kvp => kvp.Value).First( );//FIX? | |
113 | - var mapChunk = ClientAPI.World.BlockAccessor.GetMapChunk(mostActiveCol.Key); | |
110 | + //-- Should dodge enumerator changing underfoot....at a cost. | |
111 | + if (!columnCounter.IsEmpty) { | |
112 | + var tempSet = columnCounter.ToArray( ).OrderByDescending(kvp => kvp.Value); | |
113 | + foreach (var mostActiveCol in tempSet) { | |
114 | 114 | |
115 | + var mapChunk = ClientAPI.World.BlockAccessor.GetMapChunk(mostActiveCol.Key); | |
115 | 116 | |
116 | 117 | if (mapChunk == null) { |
117 | 118 | Logger.Warning("SKIP CHUNK: ({0}) - Map Chunk NULL!", mostActiveCol.Key); |
@@ -141,6 +142,7 @@ namespace Automap | ||
141 | 142 | } |
142 | 143 | |
143 | 144 | } |
145 | + } | |
144 | 146 | |
145 | 147 | if (updatedChunks > 0) { |
146 | 148 | lastUpdate = updatedChunks; |