From 48342a62c60d329832a3b699ee42965ec86470ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Wed, 7 May 2014 17:37:38 +0200 Subject: [PATCH] =?UTF-8?q?Alle=20uint=20zu=20int=20ge=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Pathfinder.cs | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Pathfinder.cs b/src/Pathfinder.cs index bd0d14a..a2e48d3 100644 --- a/src/Pathfinder.cs +++ b/src/Pathfinder.cs @@ -8,45 +8,45 @@ namespace WorldOfPeacecraft [StructLayout(LayoutKind.Sequential)] private struct PathNode { - [MarshalAs(UnmanagedType.U4)] - public uint X; - [MarshalAs(UnmanagedType.U4)] - public uint Y; + [MarshalAs(UnmanagedType.I4)] + public int X; + [MarshalAs(UnmanagedType.I4)] + public int Y; } public static unsafe LinkedList FindPath (Coordinate posFrom, Coordinate posTo, Map map) { PathNode nFrom; - nFrom.X = (uint) posFrom.X; - nFrom.Y = (uint) posFrom.Y; + nFrom.X = posFrom.X; + nFrom.Y = posFrom.Y; PathNode nTo; - nTo.X = (uint) posTo.X; - nTo.Y = (uint) posTo.Y; + nTo.X = posTo.X; + nTo.Y = posTo.Y; Tile[,] tiles = map.GetTiles(); - uint mapWidth = (uint) tiles.GetLength (0); - uint mapHeight = (uint) tiles.GetLength (1); - bool* boolMap = stackalloc bool[(int)(mapWidth * mapHeight)]; + int mapWidth = tiles.GetLength (0); + int mapHeight = tiles.GetLength (1); + bool* boolMap = stackalloc bool[mapWidth * mapHeight]; for (int y = 0; y < mapHeight; y++) { for (int x = 0; x < mapWidth; x++) { boolMap [x + y * mapWidth] = tiles [x, y].IsWalkable (); } } - PathNode* result = stackalloc PathNode[(int) (mapHeight * mapWidth)]; - uint noSteps = findPath (nFrom, nTo, mapWidth, mapHeight, boolMap, result); + PathNode* result = stackalloc PathNode[mapHeight * mapWidth]; + int noSteps = findPath (nFrom, nTo, mapWidth, mapHeight, boolMap, result); LinkedList mappedResult = new LinkedList(); for (int i = 0; i < noSteps; i++) { - mappedResult.AddLast(new Coordinate((int) result[i].X, (int) result[i].Y)); + mappedResult.AddLast(new Coordinate(result[i].X, result[i].Y)); } return mappedResult; } [DllImport("pathfinding")] - [return: MarshalAs(UnmanagedType.U4)] - private static extern unsafe uint findPath( + [return: MarshalAs(UnmanagedType.I4)] + private static extern unsafe int findPath( PathNode posFrom, PathNode posTo, - [MarshalAs(UnmanagedType.U4)] uint mapWidth, - [MarshalAs(UnmanagedType.U4)] uint mapHeight, + [MarshalAs(UnmanagedType.I4)] int mapWidth, + [MarshalAs(UnmanagedType.I4)] int mapHeight, bool* map, PathNode* result); }