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
|
|
@ -125,7 +125,7 @@ namespace Server.Multis
|
|||
SetInitialState();
|
||||
}
|
||||
|
||||
return m_Current.Components;
|
||||
return m_Current!.Components;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -137,8 +137,6 @@ namespace Server.Multis
|
|||
var landTile = map.Tiles.GetLandTile(tileX, tileY);
|
||||
var landID = landTile.ID & TileData.MaxLandValue;
|
||||
|
||||
var oldTiles = map.Tiles.GetStaticTiles(tileX, tileY, true);
|
||||
|
||||
items.Clear();
|
||||
|
||||
foreach (var item in map.GetItemsAt(tileX, tileY))
|
||||
|
|
@ -202,13 +200,12 @@ namespace Server.Multis
|
|||
hasSurface = true;
|
||||
}
|
||||
|
||||
for (var j = 0; j < oldTiles.Length; ++j)
|
||||
foreach (var tile in map.Tiles.GetStaticAndMultiTiles(tileX, tileY))
|
||||
{
|
||||
var oldTile = oldTiles[j];
|
||||
var id = TileData.ItemTable[oldTile.ID & TileData.MaxItemValue];
|
||||
var id = TileData.ItemTable[tile.ID & TileData.MaxItemValue];
|
||||
|
||||
if ((id.Impassable || id.Surface && !id.Background) &&
|
||||
addTileTop > oldTile.Z && oldTile.Z + id.CalcHeight > addTileZ)
|
||||
addTileTop > tile.Z && tile.Z + id.CalcHeight > addTileZ)
|
||||
{
|
||||
return HousePlacementResult.BadStatic; // Broke rule #2
|
||||
}
|
||||
|
|
@ -341,11 +338,8 @@ namespace Server.Multis
|
|||
}
|
||||
}
|
||||
|
||||
var tiles = map.Tiles.GetStaticTiles(borderPoint.X, borderPoint.Y, true);
|
||||
|
||||
for (var j = 0; j < tiles.Length; ++j)
|
||||
foreach (var tile in map.Tiles.GetStaticAndMultiTiles(borderPoint.X, borderPoint.Y))
|
||||
{
|
||||
var tile = tiles[j];
|
||||
var id = TileData.ItemTable[tile.ID & TileData.MaxItemValue];
|
||||
|
||||
if (id.Impassable || id.Surface && !id.Background && tile.Z + id.CalcHeight > center.Z + 2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue