Skip to content

Commit

Permalink
fix: Fixes searching null map crash (#1975)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman authored Oct 16, 2024
1 parent 9f985b0 commit 3fc55e4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
11 changes: 7 additions & 4 deletions Projects/Server/Maps/Map.ClientEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
11 changes: 7 additions & 4 deletions Projects/Server/Maps/Map.ItemEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
11 changes: 7 additions & 4 deletions Projects/Server/Maps/Map.MobileEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
13 changes: 8 additions & 5 deletions Projects/Server/Maps/Map.MultiEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 3fc55e4

Please sign in to comment.