fix: Fixes wrong sector shift for tilematrix iteration (#1623)

This commit is contained in:
Stefano Merotta 2023-12-02 01:09:26 +01:00 committed by GitHub
parent 130a5674bf
commit fec78040bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View file

@ -20,7 +20,7 @@ namespace Server;
public partial class Map
{
public ref struct StaticTileEnumerable
public readonly ref struct StaticTileEnumerable
{
public static StaticTileEnumerable Empty
{
@ -69,7 +69,7 @@ public partial class Map
if (includeStatics)
{
var tiles = map.Tiles.GetStaticBlock(p.X >> SectorShift, p.Y >> SectorShift);
var tiles = map.Tiles.GetStaticBlock(p.X >> TileMatrix.SectorShift, p.Y >> TileMatrix.SectorShift);
_tiles = tiles[p.X & 0x7][p.Y & 0x7];
_index = -1;
}

View file

@ -13,19 +13,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using Server.Logging;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
using Server.Logging;
namespace Server;
public class TileMatrix
{
public const int SectorShift = 3;
private static readonly ILogger logger = LogFactory.GetLogger(typeof(TileMatrix));
private static readonly List<TileMatrix> _instances = new();
@ -82,8 +82,8 @@ public class TileMatrix
}
_fileIndex = fileIndex;
BlockWidth = width >> 3;
BlockHeight = height >> 3;
BlockWidth = width >> SectorShift;
BlockHeight = height >> SectorShift;
_map = owner;
@ -296,7 +296,7 @@ public class TileMatrix
public LandTile GetLandTile(int x, int y)
{
var tiles = GetLandBlock(x >> 3, y >> 3);
var tiles = GetLandBlock(x >> SectorShift, y >> SectorShift);
return tiles[((y & 0x7) << 3) + (x & 0x7)];
}