aboutsummaryrefslogtreecommitdiff
path: root/map.c
diff options
context:
space:
mode:
authorKirill Petrashin <kirill8201@yandex.ru>2026-04-16 22:15:51 +0300
committerKirill Petrashin <kirill8201@yandex.ru>2026-04-16 22:15:51 +0300
commitf2a99859f0c66ba17765c036a173e7f29927327a (patch)
tree88f05aaf4944f0fa5a575f9bc2ea852fa1d71e1c /map.c
parentc6db3a75f756d790ede966c34adc3dbc793803d1 (diff)
downloadastar-f2a99859f0c66ba17765c036a173e7f29927327a.tar.xz
Fix costs
Diffstat (limited to 'map.c')
-rw-r--r--map.c24
1 files changed, 12 insertions, 12 deletions
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;