]> git.pond.sub.org Git - empserver/blobdiff - src/lib/common/path.c
Use the new path finder for sea & air, drop bestownedpath()
[empserver] / src / lib / common / path.c
index a5f18c731930494cb2db629beea65ea1447205e5..ecd91c304089bec1fe673f8173c4e107537b2506 100644 (file)
@@ -86,16 +86,29 @@ BestDistPath(char *path,
 char *
 BestShipPath(char *path, int fx, int fy, int tx, int ty, int owner)
 {
-    char *map;
+    size_t len;
 
-    map = ef_ptr(EF_BMAP, owner);
-    if (!map)
+    if (path_find(fx, fy, tx, ty, owner, MOB_SAIL) < 0)
+       return NULL;
+    len = path_find_route(path, 100, fx, fy, tx, ty);
+    if (len >= 100)
        return NULL;
-    return bestownedpath(path, map, fx, fy, tx, ty, owner);
+    if (len == 0)
+       strcpy(path, "h");
+    return path;
 }
 
 char *
 BestAirPath(char *path, int fx, int fy, int tx, int ty)
 {
-    return bestownedpath(path, NULL, fx, fy, tx, ty, -1);
+    size_t len;
+
+    if (path_find(fx, fy, tx, ty, 0, MOB_FLY) < 0)
+       return NULL;
+    len = path_find_route(path, 100, fx, fy, tx, ty);
+    if (len >= 100)
+       return NULL;
+    if (len == 0)
+       strcpy(path, "h");
+    return path;
 }