Skip to content

Commit

Permalink
fix: Fixes link list not crashing when broken. (#1877)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman authored Jul 21, 2024
1 parent 3cb688a commit b4611ab
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
10 changes: 5 additions & 5 deletions Projects/Server/Maps/Map.ClientEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ public bool MoveNext()
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;
Expand Down Expand Up @@ -247,11 +252,6 @@ public bool MoveNext()
current = _linkList._first;
}

if (_linkList.Version != _currentVersion)
{
throw new InvalidOperationException(CollectionThrowStrings.InvalidOperation_EnumFailedVersion);
}

m = current.Mobile;
if (m?.Deleted == false && bounds.Contains(m.Location))
{
Expand Down
10 changes: 5 additions & 5 deletions Projects/Server/Maps/Map.ItemEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ public bool MoveNext()
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;
Expand Down Expand Up @@ -277,11 +282,6 @@ public bool MoveNext()
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;
Expand Down
10 changes: 5 additions & 5 deletions Projects/Server/Maps/Map.MobileEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ public bool MoveNext()
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;
Expand Down Expand Up @@ -276,11 +281,6 @@ public bool MoveNext()
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;
Expand Down
1 change: 0 additions & 1 deletion Projects/UOContent/Items/Resources/Tailor/Hides.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ModernUO.Serialization;
using Server.Engines.Craft;

namespace Server.Items;

Check notice on line 3 in Projects/UOContent/Items/Resources/Tailor/Hides.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Namespace does not correspond to file location

Namespace does not correspond to file location, must be: 'Server.Items.Resources.Tailor'

Expand Down

0 comments on commit b4611ab

Please sign in to comment.