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.Previous = null;
|
||||||
node.OnLinkList = false;
|
node.OnLinkList = false;
|
||||||
Count--;
|
Count--;
|
||||||
|
|
||||||
|
if (Count < 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Count is negative!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove all entries before this node, not including this node.
|
// 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;
|
current.Previous = null;
|
||||||
Count--;
|
Count--;
|
||||||
|
|
||||||
|
if (Count < 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Count is negative!");
|
||||||
|
}
|
||||||
|
|
||||||
current = previous;
|
current = previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -153,6 +163,11 @@ public struct ValueLinkList<T> where T : class, IValueLinkListNode<T>
|
||||||
current.Previous = null;
|
current.Previous = null;
|
||||||
Count--;
|
Count--;
|
||||||
|
|
||||||
|
if (Count < 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Count is negative!");
|
||||||
|
}
|
||||||
|
|
||||||
current = next;
|
current = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -179,10 +194,9 @@ public struct ValueLinkList<T> where T : class, IValueLinkListNode<T>
|
||||||
{
|
{
|
||||||
First = e;
|
First = e;
|
||||||
Last = e;
|
Last = e;
|
||||||
Count++;
|
Count = 1;
|
||||||
|
e.OnLinkList = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
e.OnLinkList = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddFirst(T e)
|
public void AddFirst(T e)
|
||||||
|
|
@ -205,10 +219,9 @@ public struct ValueLinkList<T> where T : class, IValueLinkListNode<T>
|
||||||
{
|
{
|
||||||
First = e;
|
First = e;
|
||||||
Last = e;
|
Last = e;
|
||||||
Count++;
|
Count = 1;
|
||||||
|
e.OnLinkList = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
e.OnLinkList = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddBefore(T existing, T node)
|
public void AddBefore(T existing, T node)
|
||||||
|
|
@ -340,6 +353,11 @@ public struct ValueLinkList<T> where T : class, IValueLinkListNode<T>
|
||||||
|
|
||||||
otherList.Count -= count;
|
otherList.Count -= count;
|
||||||
|
|
||||||
|
if (otherList.Count < 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Count is negative!");
|
||||||
|
}
|
||||||
|
|
||||||
if (Last != null)
|
if (Last != null)
|
||||||
{
|
{
|
||||||
Last.Next = start;
|
Last.Next = start;
|
||||||
|
|
@ -789,7 +789,7 @@ public sealed partial class Map : IComparable<Map>, ISpanFormattable, ISpanParsa
|
||||||
{
|
{
|
||||||
if (IsIteratingItems)
|
if (IsIteratingItems)
|
||||||
{
|
{
|
||||||
_delayedItemActions.Add((MapAction.Enter, oldLocation, item));
|
_delayedItemActions.Add((MapAction.Move, oldLocation, item));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue