]> git.pond.sub.org Git - empserver/commitdiff
Use path_find() directly in sorde()
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 21 Mar 2011 19:45:04 +0000 (20:45 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 12 Apr 2011 19:51:32 +0000 (21:51 +0200)
Don't compute the distance from the path, use the path cost.  The
actual path is no longer needed, and we can use path_find() instead of
BestShipPath().

Destinations are no longer treated as unreachable when the best path
is longer than 1023 characters.

src/lib/commands/orde.c

index 1d1b3313ca45b221999841699d5b3f1283303221..8a96c063429050d9a6f035af659519bad4ee6cae 100644 (file)
@@ -29,6 +29,7 @@
  *  Known contributors to this file:
  *     Chad Zabel, 1994
  *     Steve McClure, 2000
  *  Known contributors to this file:
  *     Chad Zabel, 1994
  *     Steve McClure, 2000
+ *     Markus Armbruster, 2004-2011
  */
 
 #include <config.h>
  */
 
 #include <config.h>
@@ -385,10 +386,9 @@ sorde(void)
 {
     int nships = 0;
     int len, updates;
 {
     int nships = 0;
     int len, updates;
-    char *c;
+    double c;
     struct nstr_item nb;
     struct shpstr ship;
     struct nstr_item nb;
     struct shpstr ship;
-    char buf[1024];
 
     if (!snxtitem(&nb, EF_SHIP, player->argp[1], NULL))
        return RET_SYN;
 
     if (!snxtitem(&nb, EF_SHIP, player->argp[1], NULL))
        return RET_SYN;
@@ -430,17 +430,16 @@ sorde(void)
                pr(" loading");
            else {
                /* ETA calculation */
                pr(" loading");
            else {
                /* ETA calculation */
-
-               c = BestShipPath(buf, ship.shp_x, ship.shp_y,
-                                ship.shp_destx[0], ship.shp_desty[0],
-                                ship.shp_own);
-               if (!c)
+               c = path_find(ship.shp_x, ship.shp_y,
+                             ship.shp_destx[0], ship.shp_desty[0],
+                             ship.shp_own, MOB_SAIL);
+               if (c < 0)
                    pr(" no route possible");
                    pr(" no route possible");
-               else if (*c == 'h')
+               else if (c == 0)
                    pr(" has arrived");
                else {
                    /* distance to destination */
                    pr(" has arrived");
                else {
                    /* distance to destination */
-                   len = strlen(c);
+                   len = (int)c;
                    updates = eta_calc(&ship, len);
                    pr(" %3d %4d", len, updates);
                }
                    updates = eta_calc(&ship, len);
                    pr(" %3d %4d", len, updates);
                }