diff --git a/ValheimPlus/GameClasses/Minimap.cs b/ValheimPlus/GameClasses/Minimap.cs index 1693c193..9cfb51a3 100644 --- a/ValheimPlus/GameClasses/Minimap.cs +++ b/ValheimPlus/GameClasses/Minimap.cs @@ -414,6 +414,8 @@ public static void Postfix(ref Minimap __instance, Player player, float dt, bool } } } + + List toRemove = new List(); // clear pins for destroyed objects foreach (KeyValuePair pin in customPins) @@ -421,9 +423,13 @@ public static void Postfix(ref Minimap __instance, Player player, float dt, bool if (!pin.Key.IsValid()) { __instance.RemovePin(pin.Value); - customPins.Remove(pin.Key); + toRemove.Add(pin.Key); } } + + foreach (ZDO zdo in toRemove) { + customPins.Remove(zdo); + } } } } diff --git a/ValheimPlus/UI/HotkeyBar.cs b/ValheimPlus/UI/HotkeyBar.cs index 9a8c3de0..8be3b6dc 100644 --- a/ValheimPlus/UI/HotkeyBar.cs +++ b/ValheimPlus/UI/HotkeyBar.cs @@ -37,7 +37,7 @@ private static void DisplayAmmoCountsUnderBowHotbarIcon(HotkeyBar __instance, Pl } // If there is no bow or it is not equipped, remove the text element - if (bow == null || (Configuration.Current.Hud.displayBowAmmoCounts == 1 && !player.IsItemEquiped(bow))) + if (bow == null || (Configuration.Current.Hud.displayBowAmmoCounts == 1 && player != null && !player.IsItemEquiped(bow))) { if (ammoCounter != null) {