fix: Fixes map item iteration when multis are moved (#1562)
This commit is contained in:
parent
f6491c0fe5
commit
4d8e9fc515
2 changed files with 25 additions and 7 deletions
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue