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.
This commit is contained in:
Markus Armbruster 2011-03-21 20:45:04 +01:00
parent ec1d91a34f
commit 957a6a74df

View file

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