fix: Fixes link list not crashing when broken. (#1877)

This commit is contained in:
Kamron Batman 2024-07-20 17:38:22 -07:00 committed by GitHub
parent 3cb688a2fb
commit b4611ab7eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 16 deletions

View file

@ -212,6 +212,11 @@ public partial class Map
return false;
}
if (!Unsafe.IsNullRef(in _linkList) && _linkList.Version != _currentVersion)
{
throw new InvalidOperationException(CollectionThrowStrings.InvalidOperation_EnumFailedVersion);
}
Mobile m;
NetState current = _current;
ref Rectangle2D bounds = ref _bounds;
@ -247,11 +252,6 @@ public partial class Map
current = _linkList._first;
}
if (_linkList.Version != _currentVersion)
{
throw new InvalidOperationException(CollectionThrowStrings.InvalidOperation_EnumFailedVersion);
}
m = current.Mobile;
if (m?.Deleted == false && bounds.Contains(m.Location))
{

View file

@ -243,6 +243,11 @@ public partial class Map
return false;
}
if (!Unsafe.IsNullRef(in _linkList) && _linkList.Version != _currentVersion)
{
throw new InvalidOperationException(CollectionThrowStrings.InvalidOperation_EnumFailedVersion);
}
Item current = _current;
ref Rectangle2D bounds = ref _bounds;
var currentSectorX = _currentSectorX;
@ -277,11 +282,6 @@ public partial class Map
current = _linkList._first;
}
if (_linkList.Version != _currentVersion)
{
throw new InvalidOperationException(CollectionThrowStrings.InvalidOperation_EnumFailedVersion);
}
if (current is T { Deleted: false, Parent: null } o && bounds.Contains(o.Location))
{
_current = o;

View file

@ -242,6 +242,11 @@ public partial class Map
return false;
}
if (!Unsafe.IsNullRef(in _linkList) && _linkList.Version != _currentVersion)
{
throw new InvalidOperationException(CollectionThrowStrings.InvalidOperation_EnumFailedVersion);
}
Mobile current = _current;
ref Rectangle2D bounds = ref _bounds;
var currentSectorX = _currentSectorX;
@ -276,11 +281,6 @@ public partial class Map
current = _linkList._first;
}
if (_linkList.Version != _currentVersion)
{
throw new InvalidOperationException(CollectionThrowStrings.InvalidOperation_EnumFailedVersion);
}
if (current is T { Deleted: false } o && bounds.Contains(o.Location))
{
_current = o;