summaryrefslogtreecommitdiff
path: root/src/map/path.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/path.cpp')
-rw-r--r--src/map/path.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/map/path.cpp b/src/map/path.cpp
index f0204a4..6950797 100644
--- a/src/map/path.cpp
+++ b/src/map/path.cpp
@@ -22,19 +22,23 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <cassert>
+#include <cstddef>
+#include <cstdlib>
#include "../compat/nullpo.hpp"
-#include "../generic/random.hpp"
+#include "../strings/literal.hpp"
#include "../io/cxxstdio.hpp"
-#include "battle.hpp"
+#include "clif.t.hpp"
+#include "map.hpp"
#include "../poison.hpp"
-//#define PATH_STANDALONETEST
+namespace tmwa
+{
constexpr int MAX_HEAP = 150;
struct tmp_path
{
@@ -58,9 +62,9 @@ void push_heap_path(int *heap, struct tmp_path *tp, int index)
{
int i, h;
- if (heap == NULL || tp == NULL)
+ if (heap == nullptr || tp == nullptr)
{
- PRINTF("push_heap_path nullpo\n");
+ PRINTF("push_heap_path nullpo\n"_fmt);
return;
}
@@ -90,7 +94,7 @@ void update_heap_path(int *heap, struct tmp_path *tp, int index)
break;
if (h == heap[0])
{
- FPRINTF(stderr, "update_heap_path bug\n");
+ FPRINTF(stderr, "update_heap_path bug\n"_fmt);
exit(1);
}
for (i = (h - 1) / 2;
@@ -144,7 +148,7 @@ int calc_cost(struct tmp_path *p, int x1, int y1)
{
int xd, yd;
- nullpo_ret(p);
+ nullpo_retz(p);
xd = x1 - p->x;
if (xd < 0)
@@ -165,8 +169,8 @@ int add_path(int *heap, struct tmp_path *tp, int x, int y, int dist,
{
int i;
- nullpo_ret(heap);
- nullpo_ret(tp);
+ nullpo_retz(heap);
+ nullpo_retz(tp);
i = calc_index(x, y);
@@ -210,7 +214,7 @@ int add_path(int *heap, struct tmp_path *tp, int x, int y, int dist,
static
bool can_place(struct map_local *m, int x, int y)
{
- nullpo_ret(m);
+ nullpo_retz(m);
return !bool(read_gatp(m, x, y) & MapCell::UNWALKABLE);
}
@@ -222,7 +226,7 @@ bool can_place(struct map_local *m, int x, int y)
static
int can_move(struct map_local *m, int x0, int y0, int x1, int y1)
{
- nullpo_ret(m);
+ nullpo_retz(m);
if (x0 - x1 < -1 || x0 - x1 > 1 || y0 - y1 < -1 || y0 - y1 > 1)
return 0;
@@ -249,7 +253,7 @@ int path_search(struct walkpath_data *wpd, map_local *m, int x0, int y0, int x1,
int i, rp, x, y;
int dx, dy;
- nullpo_ret(wpd);
+ nullpo_retz(wpd);
assert (m->gat);
map_local *md = m;
@@ -357,3 +361,4 @@ int path_search(struct walkpath_data *wpd, map_local *m, int x0, int y0, int x1,
return -1;
}
}
+} // namespace tmwa