fix: Refactors getting static tiles to use enumerators (#1611)

### Summary
* Refactors getting static/multi tiles to not use allocations.
* `TileList` is now only used during bootstrapping and uses rented buffers to eliminate extra allocations.
* Replaces `StaticTile[] GetStaticTiles` with:
    ```cs
        Map.StaticTileEnumerable GetStaticTiles(int x, int y);
        Map.StaticTileEnumerable GetStaticAndMultiTiles(int x, int y);
        Map.StaticTileEnumerable GetMultiTiles(int x, int y);
    ```
* Removes `Synchronized` and `lock` from TileMatrix. It is no longer considered a multi-thread safe system.
This commit is contained in:
Kamron Batman 2023-11-26 09:39:46 -08:00 • committed by GitHub
parent 3b1637b2da
commit f21c9687b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 359 additions and 512 deletions

View file

@ -1462,10 +1462,9 @@ namespace Server.Multis
}
var landTile = map.Tiles.GetLandTile(tx, ty);
var tiles = map.Tiles.GetStaticTiles(tx, ty, true);
var hasWater = landTile.Z == p.Z &&
(landTile.ID >= 168 && landTile.ID <= 171 || landTile.ID >= 310 && landTile.ID <= 311);
landTile.ID is >= 168 and <= 171 or >= 310 and <= 311;
// int z = p.Z;
@ -1476,9 +1475,8 @@ namespace Server.Multis
// if (!landTile.Ignored && top > landZ && landTop > z)
// return false;
for (var i = 0; i < tiles.Length; ++i)
foreach (var tile in map.Tiles.GetStaticAndMultiTiles(tx, ty))
{
var tile = tiles[i];
var isWater = tile.ID >= 0x1796 && tile.ID <= 0x17B2;
if (tile.Z == p.Z && isWater)