Skip to content

Commit 8eb7ab1

Browse files
author
erwan-joly
committed
fix #84 rename length
1 parent c28c594 commit 8eb7ab1

11 files changed

Lines changed: 20 additions & 20 deletions

File tree

src/NosCore.PathFinder.Gui/Dtos/MapDto.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public short Width
3838
}
3939
}
4040

41-
public short Length
41+
public short Height
4242
{
4343
get
4444
{
@@ -58,7 +58,7 @@ public short Length
5858

5959
public bool IsWalkable(short mapX, short mapY)
6060
{
61-
if ((mapX >= Width) || (mapX < 0) || (mapY >= Length) || (mapY < 0))
61+
if ((mapX >= Width) || (mapX < 0) || (mapY >= Height) || (mapY < 0))
6262
{
6363
return false;
6464
}

src/NosCore.PathFinder.Gui/GuiWindow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class GuiWindow : GameWindow
4646
private Dictionary<Color, Vector2[]>? _brushFirePixels;
4747

4848
public GuiWindow(MapDto map, int width, int height, string title, DataAccessHelper dbContextBuilder)
49-
: base(width, (height < width / map.Width * map.Length) ? width / map.Width * map.Length : height,
49+
: base(width, (height < width / map.Width * map.Height) ? width / map.Width * map.Height : height,
5050
GraphicsMode.Default, title)
5151
{
5252
var dbContextBuilder1 = dbContextBuilder;
@@ -86,7 +86,7 @@ public GuiWindow(MapDto map, int width, int height, string title, DataAccessHelp
8686
Parallel.ForEach(_npcs, npc => _ = npc.StartLife(CancellationToken.None));
8787

8888
var wallpixels = new List<Vector2[]>();
89-
for (short y = 0; y < _map.Length; y++)
89+
for (short y = 0; y < _map.Height; y++)
9090
{
9191
for (short x = 0; x < _map.Width; x++)
9292
{

src/NosCore.PathFinder.Gui/PathfinderGui.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static async Task Main(string[] args)
4949
}
5050
var map = await mapDao.FirstOrDefaultAsync(m => m.MapId == askMapId).ConfigureAwait(false);
5151

52-
if ((!(map?.Width > 0)) || (map.Length <= 0))
52+
if ((!(map?.Width > 0)) || (map.Height <= 0))
5353
{
5454
continue;
5555
}

src/NosCore.PathFinder/Brushfire/IMapGridExtension.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static class IMapGridExtension
2525
var currentX = (short)(cell.X + delta.X);
2626
var currentY = (short)(cell.Y + delta.Y);
2727
return currentX >= 0 && currentX < grid.Width &&
28-
currentY >= 0 && currentY < grid.Length &&
28+
currentY >= 0 && currentY < grid.Height &&
2929
(includeWalls || grid.IsWalkable(currentX, currentY)
3030
);
3131
}).Select(delta => ((short)(cell.X + delta.X), (short)(cell.Y + delta.Y)));
@@ -34,14 +34,14 @@ public static class IMapGridExtension
3434
public static BrushFire LoadBrushFire(this IMapGrid mapGrid, (short X, short Y) user, IHeuristic heuristic, short maxDistance = 22)
3535
{
3636
if (user.X < 0 || user.X >= mapGrid.Width ||
37-
user.Y < 0 || user.Y >= mapGrid.Length)
37+
user.Y < 0 || user.Y >= mapGrid.Height)
3838
{
39-
return new BrushFire(user, new Dictionary<(short X, short Y), Node?>(), mapGrid.Width, mapGrid.Length);
39+
return new BrushFire(user, new Dictionary<(short X, short Y), Node?>(), mapGrid.Width, mapGrid.Height);
4040
}
4141

4242
var path = new MinHeap();
4343
var cellGrid = new Dictionary<(short X, short Y), Node?>();
44-
var grid = new Node?[mapGrid.Width, mapGrid.Length];
44+
var grid = new Node?[mapGrid.Width, mapGrid.Height];
4545
grid[user.X, user.Y] = new Node(user, mapGrid[user.X, user.Y])
4646
{
4747
Closed = true
@@ -82,7 +82,7 @@ public static BrushFire LoadBrushFire(this IMapGrid mapGrid, (short X, short Y)
8282
neighbors[i]!.Closed = true;
8383
}
8484
}
85-
return new BrushFire(user, cellGrid, mapGrid.Width, mapGrid.Length);
85+
return new BrushFire(user, cellGrid, mapGrid.Width, mapGrid.Height);
8686
}
8787

8888
}

src/NosCore.PathFinder/Interfaces/IMapGrid.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ namespace NosCore.PathFinder.Interfaces
99
public interface IMapGrid
1010
{
1111
public short Width { get; }
12-
public short Length { get; }
12+
public short Height { get; }
1313
public byte this[short x, short y] { get; }
1414
bool IsWalkable(short currentX, short currentY);
1515
}
16-
}
16+
}

src/NosCore.PathFinder/Pathfinder/JumpPointSearchPathfinder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public JumpPointSearchPathfinder(IMapGrid mapGrid, IHeuristic heuristic)
7474

7575
internal IEnumerable<(short X, short Y)> GetJumpList((short X, short Y) start, (short X, short Y) end)
7676
{
77-
var nodes = new JumpNode?[_mapGrid.Width, _mapGrid.Length];
77+
var nodes = new JumpNode?[_mapGrid.Width, _mapGrid.Height];
7878
if (_mapGrid.IsWalkable(start.X, start.Y) && _mapGrid.IsWalkable(end.X, end.Y))
7979
{
8080
var startNode = new JumpNode(start, _mapGrid[start.X, start.Y]) { F = 0, G = 0, Opened = true };

test/NosCore.PathFinder.Tests/BrushFireTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ public void Test_BrushFire()
2323
{
2424
(short X, short Y) characterPosition = (6, 10);
2525
var brushFire = _map.LoadBrushFire(characterPosition, new OctileDistanceHeuristic());
26-
var bitmap = new Bitmap(_map.Width * TestHelper.Scale, _map.Length * TestHelper.Scale);
26+
var bitmap = new Bitmap(_map.Width * TestHelper.Scale, _map.Height * TestHelper.Scale);
2727
var listPixel = new List<Color>();
2828
TestHelper.DrawMap(_map, TestHelper.Scale, listPixel, bitmap, (0, 0), characterPosition);
2929
using var graphics = Graphics.FromImage(bitmap);
3030

3131

32-
for (short y = 0; y < _map.Length; y++)
32+
for (short y = 0; y < _map.Height; y++)
3333
{
3434
for (short x = 0; x < _map.Width; x++)
3535
{

test/NosCore.PathFinder.Tests/GoalBasedPathfinderTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ public GoalBasedPathfinderTests()
3535
[TestMethod]
3636
public void Test_GoalBasedPathfinder()
3737
{
38-
var bitmap = new Bitmap(_map.Width * TestHelper.Scale, _map.Length * TestHelper.Scale);
38+
var bitmap = new Bitmap(_map.Width * TestHelper.Scale, _map.Height * TestHelper.Scale);
3939
(short X, short Y) target = (15, 16);
4040
var listPixel = new List<Color>();
4141
TestHelper.DrawMap(_map, TestHelper.Scale, listPixel, bitmap, target, _characterPosition);
4242
using var graphics = Graphics.FromImage(bitmap);
4343

4444

45-
for (short y = 0; y < _map.Length; y++)
45+
for (short y = 0; y < _map.Height; y++)
4646
{
4747
for (short x = 0; x < _map.Width; x++)
4848
{

test/NosCore.PathFinder.Tests/JumpPointSearchPathfinderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public JumpPointSearchPathfinderTests()
3131
[TestMethod]
3232
public void Test_JumpPointSearchPathfinder()
3333
{
34-
var bitmap = new Bitmap(_map.Width * TestHelper.Scale, _map.Length * TestHelper.Scale);
34+
var bitmap = new Bitmap(_map.Width * TestHelper.Scale, _map.Height * TestHelper.Scale);
3535
(short X, short Y) target = (15, 16);
3636
var listPixel = new List<Color>();
3737
TestHelper.DrawMap(_map, TestHelper.Scale, listPixel, bitmap, target, _characterPosition);

test/NosCore.PathFinder.Tests/TestHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static void VerifyFile(string linearPathfinderPng, Bitmap bitmap, List<Co
7171
public static void DrawMap(TestMap map, int scale, List<Color> listPixel, Bitmap bitmap, (short X, short Y) monster, (short X, short Y) character)
7272
{
7373
using var graphics = Graphics.FromImage(bitmap);
74-
for (short y = 0; y < map.Length; y++)
74+
for (short y = 0; y < map.Height; y++)
7575
{
7676
for (short x = 0; x < map.Width; x++)
7777
{

0 commit comments

Comments
 (0)