/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2012, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure, Markus Armbruster
*
* Empire is free software: you can redistribute it and/or modify
* Known contributors to this file:
* Chad Zabel, 1994
* Steve McClure, 2000
+ * Markus Armbruster, 2004-2011
*/
#include <config.h>
if (!*p || !strcmp(p, "-")) {
pr("A one-way order has been accepted.\n");
} else if (!strncmp(p, "s", 1)) {
- if (opt_TRADESHIPS) {
- if (!(mchr[(int)ship.shp_type].m_flags & M_TRADE)) {
- pr("You can't auto-scuttle that ship!\n");
- return RET_SYN;
- }
- } else {
+ if (!(mchr[(int)ship.shp_type].m_flags & M_TRADE)) {
pr("You can't auto-scuttle that ship!\n");
return RET_SYN;
}
return RET_OK;
}
-static void
-eta_calc(struct shpstr *sp, int len, int *nupdates)
+static int
+eta_calc(struct shpstr *sp, int len)
{
double mobcost, mobil;
- int i;
+ int i, nupdates;
i = len;
- *nupdates = 1;
+ nupdates = 1;
mobcost = shp_mobcost(sp);
mobil = sp->shp_mobil;
i--;
} else {
mobil += (ship_mob_scale * (float)etu_per_update);
- (*nupdates)++;
+ nupdates++;
}
}
+ return nupdates;
}
static 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;
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);
- eta_calc(&ship, len, &updates);
+ len = (int)c;
+ updates = eta_calc(&ship, len);
pr(" %3d %4d", len, updates);
}
}