fix: Fixes map item iteration when multis are moved (#1562)

This commit is contained in:
Kamron Batman 2023-10-22 13:22:11 -07:00 committed by GitHub
parent f6491c0fe5
commit 4d8e9fc515
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 7 deletions

View file

@ -85,6 +85,11 @@ public struct ValueLinkList<T> where T : class, IValueLinkListNode<T>
node.Previous = null;
node.OnLinkList = false;
Count--;
if (Count < 0)
{
throw new Exception("Count is negative!");
}
}
// Remove all entries before this node, not including this node.
@ -117,6 +122,11 @@ public struct ValueLinkList<T> where T : class, IValueLinkListNode<T>
current.Previous = null;
Count--;
if (Count < 0)
{
throw new Exception("Count is negative!");
}
current = previous;
}
@ -153,6 +163,11 @@ public struct ValueLinkList<T> where T : class, IValueLinkListNode<T>
current.Previous = null;
Count--;
if (Count < 0)
{
throw new Exception("Count is negative!");
}
current = next;
}
@ -179,10 +194,9 @@ public struct ValueLinkList<T> where T : class, IValueLinkListNode<T>
{
First = e;
Last = e;
Count++;
Count = 1;
e.OnLinkList = true;
}
e.OnLinkList = true;
}
public void AddFirst(T e)
@ -205,10 +219,9 @@ public struct ValueLinkList<T> where T : class, IValueLinkListNode<T>
{
First = e;
Last = e;
Count++;
Count = 1;
e.OnLinkList = true;
}
e.OnLinkList = true;
}
public void AddBefore(T existing, T node)
@ -340,6 +353,11 @@ public struct ValueLinkList<T> where T : class, IValueLinkListNode<T>
otherList.Count -= count;
if (otherList.Count < 0)
{
throw new Exception("Count is negative!");
}
if (Last != null)
{
Last.Next = start;

View file

@ -789,7 +789,7 @@ public sealed partial class Map : IComparable<Map>, ISpanFormattable, ISpanParsa
{
if (IsIteratingItems)
{
_delayedItemActions.Add((MapAction.Enter, oldLocation, item));
_delayedItemActions.Add((MapAction.Move, oldLocation, item));
return;
}