From: Markus Armbruster Date: Mon, 21 Mar 2011 19:45:04 +0000 (+0100) Subject: Use path_find() directly in sorde() X-Git-Tag: v4.3.27~87 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=957a6a74dfcd9a838f58ecc11cd06c77ca9a1bba Use path_find() directly in sorde() 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. --- diff --git a/src/lib/commands/orde.c b/src/lib/commands/orde.c index 1d1b3313c..8a96c0634 100644 --- a/src/lib/commands/orde.c +++ b/src/lib/commands/orde.c @@ -29,6 +29,7 @@ * Known contributors to this file: * Chad Zabel, 1994 * Steve McClure, 2000 + * Markus Armbruster, 2004-2011 */ #include @@ -385,10 +386,9 @@ sorde(void) { int nships = 0; int len, updates; - char *c; + double c; struct nstr_item nb; struct shpstr ship; - char buf[1024]; if (!snxtitem(&nb, EF_SHIP, player->argp[1], NULL)) return RET_SYN; @@ -430,17 +430,16 @@ sorde(void) 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"); - else if (*c == 'h') + else if (c == 0) pr(" has arrived"); else { /* distance to destination */ - len = strlen(c); + len = (int)c; updates = eta_calc(&ship, len); pr(" %3d %4d", len, updates); }