From f2a99859f0c66ba17765c036a173e7f29927327a Mon Sep 17 00:00:00 2001 From: Kirill Petrashin Date: Thu, 16 Apr 2026 22:15:51 +0300 Subject: Fix costs --- map.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'map.c') diff --git a/map.c b/map.c index a0d0f23..121970c 100644 --- a/map.c +++ b/map.c @@ -37,7 +37,7 @@ unsigned int neighbours_4dir(Position neighbour_array[4], size_t cost_array[4], neighbour_array[cur].x = pos.x - 1; neighbour_array[cur].y = pos.y; if (cost_array != NULL) { - if (costs != NULL) cost_array[cur] = costs[pos.y][pos.x - 1]; + if (costs != NULL) cost_array[cur] = costs[pos.y][pos.x - 1] * COST_ORTHOGONAL; else cost_array[cur] = COST_ORTHOGONAL; } cur += 1; @@ -46,7 +46,7 @@ unsigned int neighbours_4dir(Position neighbour_array[4], size_t cost_array[4], neighbour_array[cur].x = pos.x + 1; neighbour_array[cur].y = pos.y; if (cost_array != NULL) { - if (costs != NULL) cost_array[cur] = costs[pos.y][pos.x + 1]; + if (costs != NULL) cost_array[cur] = costs[pos.y][pos.x + 1] * COST_ORTHOGONAL; else cost_array[cur] = COST_ORTHOGONAL; } cur += 1; @@ -55,7 +55,7 @@ unsigned int neighbours_4dir(Position neighbour_array[4], size_t cost_array[4], neighbour_array[cur].x = pos.x; neighbour_array[cur].y = pos.y - 1; if (cost_array != NULL) { - if (costs != NULL) cost_array[cur] = costs[pos.y - 1][pos.x]; + if (costs != NULL) cost_array[cur] = costs[pos.y - 1][pos.x] * COST_ORTHOGONAL; else cost_array[cur] = COST_ORTHOGONAL; } cur += 1; @@ -64,7 +64,7 @@ unsigned int neighbours_4dir(Position neighbour_array[4], size_t cost_array[4], neighbour_array[cur].x = pos.x; neighbour_array[cur].y = pos.y + 1; if (cost_array != NULL) { - if (costs != NULL) cost_array[cur] = costs[pos.y + 1][pos.x]; + if (costs != NULL) cost_array[cur] = costs[pos.y + 1][pos.x] * COST_ORTHOGONAL; else cost_array[cur] = COST_ORTHOGONAL; } cur += 1; @@ -80,7 +80,7 @@ unsigned int neighbours_8dir(Position neighbour_array[8], size_t cost_array[8], neighbour_array[cur].x = pos.x - 1; neighbour_array[cur].y = pos.y; if (cost_array != NULL) { - if (costs != NULL) cost_array[cur] = costs[pos.y][pos.x - 1]; + if (costs != NULL) cost_array[cur] = costs[pos.y][pos.x - 1] * COST_ORTHOGONAL; else cost_array[cur] = COST_ORTHOGONAL; } cur += 1; @@ -89,7 +89,7 @@ unsigned int neighbours_8dir(Position neighbour_array[8], size_t cost_array[8], neighbour_array[cur].x = pos.x + 1; neighbour_array[cur].y = pos.y; if (cost_array != NULL) { - if (costs != NULL) cost_array[cur] = costs[pos.y][pos.x + 1]; + if (costs != NULL) cost_array[cur] = costs[pos.y][pos.x + 1] * COST_ORTHOGONAL; else cost_array[cur] = COST_ORTHOGONAL; } cur += 1; @@ -98,7 +98,7 @@ unsigned int neighbours_8dir(Position neighbour_array[8], size_t cost_array[8], neighbour_array[cur].x = pos.x; neighbour_array[cur].y = pos.y - 1; if (cost_array != NULL) { - if (costs != NULL) cost_array[cur] = costs[pos.y - 1][pos.x]; + if (costs != NULL) cost_array[cur] = costs[pos.y - 1][pos.x] * COST_ORTHOGONAL; else cost_array[cur] = COST_ORTHOGONAL; } cur += 1; @@ -107,7 +107,7 @@ unsigned int neighbours_8dir(Position neighbour_array[8], size_t cost_array[8], neighbour_array[cur].x = pos.x; neighbour_array[cur].y = pos.y + 1; if (cost_array != NULL) { - if (costs != NULL) cost_array[cur] = costs[pos.y + 1][pos.x]; + if (costs != NULL) cost_array[cur] = costs[pos.y + 1][pos.x] * COST_ORTHOGONAL; else cost_array[cur] = COST_ORTHOGONAL; } cur += 1; @@ -117,7 +117,7 @@ unsigned int neighbours_8dir(Position neighbour_array[8], size_t cost_array[8], neighbour_array[cur].x = pos.x - 1; neighbour_array[cur].y = pos.y - 1; if (cost_array != NULL) { - if (costs != NULL) cost_array[cur] = costs[pos.y - 1][pos.x - 1]; + if (costs != NULL) cost_array[cur] = costs[pos.y - 1][pos.x - 1] * COST_DIAGONAL; else cost_array[cur] = COST_DIAGONAL; } cur += 1; @@ -126,7 +126,7 @@ unsigned int neighbours_8dir(Position neighbour_array[8], size_t cost_array[8], neighbour_array[cur].x = pos.x + 1; neighbour_array[cur].y = pos.y - 1; if (cost_array != NULL) { - if (costs != NULL) cost_array[cur] = costs[pos.y - 1][pos.x + 1]; + if (costs != NULL) cost_array[cur] = costs[pos.y - 1][pos.x + 1] * COST_DIAGONAL; else cost_array[cur] = COST_DIAGONAL; } cur += 1; @@ -135,7 +135,7 @@ unsigned int neighbours_8dir(Position neighbour_array[8], size_t cost_array[8], neighbour_array[cur].x = pos.x + 1; neighbour_array[cur].y = pos.y + 1; if (cost_array != NULL) { - if (costs != NULL) cost_array[cur] = costs[pos.y + 1][pos.x + 1]; + if (costs != NULL) cost_array[cur] = costs[pos.y + 1][pos.x + 1] * COST_DIAGONAL; else cost_array[cur] = COST_DIAGONAL; } cur += 1; @@ -144,7 +144,7 @@ unsigned int neighbours_8dir(Position neighbour_array[8], size_t cost_array[8], neighbour_array[cur].x = pos.x - 1; neighbour_array[cur].y = pos.y + 1; if (cost_array != NULL) { - if (costs != NULL) cost_array[cur] = costs[pos.y + 1][pos.x - 1]; + if (costs != NULL) cost_array[cur] = costs[pos.y + 1][pos.x - 1] * COST_DIAGONAL; else cost_array[cur] = COST_DIAGONAL; } cur += 1; -- cgit v1.2.3