• R/O
  • HTTP
  • SSH
  • HTTPS

automap: Commit

Automap (OSS) GIT software repository


Commit MetaInfo

Revisión1c8849af29a916822885541c010ffc4b7bb90d5a (tree)
Tiempo2022-05-02 03:22:25
Autormelchior <melchior@user...>
Commitermelchior

Log Message

2nd Entity processing fix attempt

Cambiar Resumen

Diferencia incremental

--- a/Automap/Subsystems/AutomapSystem.cs
+++ b/Automap/Subsystems/AutomapSystem.cs
@@ -9,11 +9,12 @@ using System.Text.RegularExpressions;
99 using System.Threading;
1010
1111 using Hjg.Pngcs;
12-
12+using Mono.Collections.Generic;
1313 using ProtoBuf;
1414
1515 using Vintagestory.API.Client;
1616 using Vintagestory.API.Common;
17+using Vintagestory.API.Common.Entities;
1718 using Vintagestory.API.Config;
1819 using Vintagestory.API.Datastructures;
1920 using Vintagestory.API.MathTools;
@@ -728,21 +729,26 @@ namespace Automap
728729 Logger.Debug("Presently {0} Entities", ClientAPI.World.LoadedEntities.Count);
729730 #endif
730731
731- //Handles mutations better than a plain Iterator
732- for (int entIndex = 0; entIndex < ClientAPI.World.LoadedEntities.Count; entIndex++ )
732+ var keyList = new long[ClientAPI.World.LoadedEntities.Keys.Count];
733+ ClientAPI.World.LoadedEntities.Keys.CopyTo(keyList, 0);
734+
735+ //'ElementAt'; worse! instead; walk fixed list...
736+ Entity loadedEntity;
737+ foreach (var key in keyList)
733738 {
734- var loadedEntity = ClientAPI.World.LoadedEntities.Values.ElementAt(entIndex);
735-
736- #if DEBUG
737- //Logger.VerboseDebug($"ENTITY: ({loadedEntity.Value.Code}) = #{loadedEntity.Value.EntityId} {loadedEntity.Value.State} {loadedEntity.Value.LocalPos} <<<<<<<<<<<<");
738- #endif
739+ if (ClientAPI.World.LoadedEntities.TryGetValue(key, out loadedEntity))
740+ {
741+ #if DEBUG
742+ //Logger.VerboseDebug($"ENTITY: ({loadedEntity.Value.Code}) = #{loadedEntity.Value.EntityId} {loadedEntity.Value.State} {loadedEntity.Value.LocalPos} <<<<<<<<<<<<");
743+ #endif
739744
740- var dMatch = Entity_Designators.SingleOrDefault(se => se.Key.Equals(loadedEntity.Code));
741- if (dMatch.Value != null)
742- {
743- dMatch.Value.SpecialAction(ClientAPI, this.EOIs, loadedEntity.Pos.AsBlockPos.Copy( ), loadedEntity);
744- }
745- }
745+ var dMatch = Entity_Designators.SingleOrDefault(se => se.Key.Equals(loadedEntity.Code));
746+ if (dMatch.Value != null)
747+ {
748+ dMatch.Value.SpecialAction(ClientAPI, this.EOIs, loadedEntity.Pos.AsBlockPos.Copy( ), loadedEntity);
749+ }
750+ }
751+ }
746752 }
747753
748754 private void AddNote(string notation)
Show on old repository browser