diff --git a/Projects/Server/Maps/Map.ClientEnumerator.cs b/Projects/Server/Maps/Map.ClientEnumerator.cs index 4321a0fc5d..ae53010a1b 100644 --- a/Projects/Server/Maps/Map.ClientEnumerator.cs +++ b/Projects/Server/Maps/Map.ClientEnumerator.cs @@ -195,11 +195,14 @@ public MobileEnumerator(Map map, Rectangle2D bounds, bool makeBoundsInclusive) _bounds = bounds; - map.CalculateSectors(bounds, out _sectorStartX, out var _sectorStartY, out _sectorEndX, out _sectorEndY); + if (map != null) + { + map.CalculateSectors(bounds, out _sectorStartX, out var _sectorStartY, out _sectorEndX, out _sectorEndY); - // We start the X sector one short because it gets incremented immediately in MoveNext() - _currentSectorX = _sectorStartX - 1; - _currentSectorY = _sectorStartY; + // We start the X sector one short because it gets incremented immediately in MoveNext() + _currentSectorX = _sectorStartX - 1; + _currentSectorY = _sectorStartY; + } } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/Projects/Server/Maps/Map.ItemEnumerator.cs b/Projects/Server/Maps/Map.ItemEnumerator.cs index 9eab2effb9..4bf8f42029 100644 --- a/Projects/Server/Maps/Map.ItemEnumerator.cs +++ b/Projects/Server/Maps/Map.ItemEnumerator.cs @@ -226,11 +226,14 @@ public ItemEnumerator(Map map, Rectangle2D bounds, bool makeBoundsInclusive) _bounds = bounds; - map.CalculateSectors(bounds, out _sectorStartX, out var _sectorStartY, out _sectorEndX, out _sectorEndY); + if (map != null) + { + map.CalculateSectors(bounds, out _sectorStartX, out var _sectorStartY, out _sectorEndX, out _sectorEndY); - // We start the X sector one short because it gets incremented immediately in MoveNext() - _currentSectorX = _sectorStartX - 1; - _currentSectorY = _sectorStartY; + // We start the X sector one short because it gets incremented immediately in MoveNext() + _currentSectorX = _sectorStartX - 1; + _currentSectorY = _sectorStartY; + } } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/Projects/Server/Maps/Map.MobileEnumerator.cs b/Projects/Server/Maps/Map.MobileEnumerator.cs index 9e7edee15e..cac64ce3a6 100644 --- a/Projects/Server/Maps/Map.MobileEnumerator.cs +++ b/Projects/Server/Maps/Map.MobileEnumerator.cs @@ -225,11 +225,14 @@ public MobileEnumerator(Map map, Rectangle2D bounds, bool makeBoundsInclusive) _bounds = bounds; - map.CalculateSectors(bounds, out _sectorStartX, out var _sectorStartY, out _sectorEndX, out _sectorEndY); + if (map != null) + { + map.CalculateSectors(bounds, out _sectorStartX, out var _sectorStartY, out _sectorEndX, out _sectorEndY); - // We start the X sector one short because it gets incremented immediately in MoveNext() - _currentSectorX = _sectorStartX - 1; - _currentSectorY = _sectorStartY; + // We start the X sector one short because it gets incremented immediately in MoveNext() + _currentSectorX = _sectorStartX - 1; + _currentSectorY = _sectorStartY; + } } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/Projects/Server/Maps/Map.MultiEnumerator.cs b/Projects/Server/Maps/Map.MultiEnumerator.cs index d7e9f9eaf4..bc1f7b018b 100644 --- a/Projects/Server/Maps/Map.MultiEnumerator.cs +++ b/Projects/Server/Maps/Map.MultiEnumerator.cs @@ -189,12 +189,15 @@ public MultiBoundsEnumerator(Map map, Rectangle2D bounds, bool makeBoundsInclusi _bounds = bounds; - map.CalculateSectors(bounds, out _sectorStartX, out var _sectorStartY, out _sectorEndX, out _sectorEndY); + if (map != null) + { + map.CalculateSectors(bounds, out _sectorStartX, out var _sectorStartY, out _sectorEndX, out _sectorEndY); - // We start the X sector one short because it gets incremented immediately in MoveNext() - _currentSectorX = _sectorStartX - 1; - _currentSectorY = _sectorStartY; - _index = 0; + // We start the X sector one short because it gets incremented immediately in MoveNext() + _currentSectorX = _sectorStartX - 1; + _currentSectorY = _sectorStartY; + _index = 0; + } } [MethodImpl(MethodImplOptions.AggressiveInlining)]