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:
parent
3b1637b2da
commit
f21c9687b2
23 changed files with 359 additions and 512 deletions
|
|
@ -431,12 +431,8 @@ namespace Server
|
|||
|
||||
public static bool IsEastFrame(int x, int y, int z)
|
||||
{
|
||||
var tiles = m_Map.Tiles.GetStaticTiles(x, y);
|
||||
|
||||
for (var i = 0; i < tiles.Length; ++i)
|
||||
foreach (var tile in m_Map.Tiles.GetStaticTiles(x, y))
|
||||
{
|
||||
var tile = tiles[i];
|
||||
|
||||
if (tile.Z == z && IsEastFrame(tile.ID))
|
||||
{
|
||||
return true;
|
||||
|
|
@ -448,12 +444,8 @@ namespace Server
|
|||
|
||||
public static bool IsSouthFrame(int x, int y, int z)
|
||||
{
|
||||
var tiles = m_Map.Tiles.GetStaticTiles(x, y);
|
||||
|
||||
for (var i = 0; i < tiles.Length; ++i)
|
||||
foreach (var tile in m_Map.Tiles.GetStaticTiles(x, y))
|
||||
{
|
||||
var tile = tiles[i];
|
||||
|
||||
if (tile.Z == z && IsSouthFrame(tile.ID))
|
||||
{
|
||||
return true;
|
||||
|
|
@ -510,12 +502,8 @@ namespace Server
|
|||
var vx = rx + region.X;
|
||||
var vy = ry + region.Y;
|
||||
|
||||
var tiles = m_Map.Tiles.GetStaticTiles(vx, vy);
|
||||
|
||||
for (var i = 0; i < tiles.Length; ++i)
|
||||
foreach (var tile in m_Map.Tiles.GetStaticTiles(vx, vy))
|
||||
{
|
||||
var tile = tiles[i];
|
||||
|
||||
var id = tile.ID;
|
||||
var z = tile.Z;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue