/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
* ---
*
* orde.c: Turn on/off autonavigation
- *
+ *
* Known contributors to this file:
* Chad Zabel, 1994
* Steve McClure, 2000
#include <config.h>
-#include <string.h>
-#include <ctype.h>
-#include "misc.h"
-#include "player.h"
-#include "ship.h"
-#include "sect.h"
-#include "xy.h"
-#include "nsc.h"
-#include "nat.h"
-#include "path.h"
-#include "file.h"
-#include "item.h"
#include "commands.h"
+#include "item.h"
#include "optlist.h"
+#include "path.h"
+#include "ship.h"
/*
-** Command syntax:
-**
-** ORDER <ship> Show orders
-** ORDER <ship> c[ancel] Cancel orders
-** ORDER <ship> s[top] Suspend orders
-** ORDER <ship> r[esume] Resume orders
-** ORDER <ship> d[eclare] <dest1> Set destination
-** d[eclare] <dest1> <dest2>
-** ORDER <ship> l[evel] <field> <start/end> <comm> <level>
-**
-**
-** New syntax:
-** qorder <ship> display cargo levels
-** sorder <ship> display statistical info
+ * Command syntax:
+ *
+ * ORDER <ship> Show orders
+ * ORDER <ship> c[ancel] Cancel orders
+ * ORDER <ship> s[top] Suspend orders
+ * ORDER <ship> r[esume] Resume orders
+ * ORDER <ship> d[eclare] <dest1> Set destination
+ * d[eclare] <dest1> <dest2>
+ * ORDER <ship> l[evel] <field> <start/end> <comm> <level>
+ *
+ * New syntax:
+ * qorder <ship> display cargo levels
+ * sorder <ship> display statistical info
*/
int
struct ichrstr *i1;
coord p0x, p0y, p1x, p1y;
int i;
- s_char *p, *p1, *dest;
- s_char buf1[128];
- s_char buf[1024];
- s_char prompt[128];
+ char *p, *p1, *dest;
+ char buf1[128];
+ char buf[1024];
+ char prompt[128];
- if (!snxtitem(&nb, EF_SHIP, player->argp[1]))
+ if (!snxtitem(&nb, EF_SHIP, player->argp[1], NULL))
return RET_SYN;
while (!player->aborted && nxtitem(&nb, (&ship))) {
if (!player->owner || ship.shp_own == 0)
if (!orders) {
p = getstarg(player->argp[4], "Second dest? ", buf);
- if (!p || !*p || !strcmp(p, "-")) {
+ if (!p)
+ return RET_FAIL;
+ if (!*p || !strcmp(p, "-")) {
orders = 1;
pr("A one-way order has been accepted.\n");
} else if (!strncmp(p, "s", 1)) {
break;
}
- /* to keep sub in range of our arrays
+ /* to keep sub in range of our arrays
subtract 1 so the new range is 0-(TMAX-1)
*/
sub = sub - 1;;
ship.shp_autonav |= AN_LOADING;
- /* swap variables, this keeps
+ /* swap variables, this keeps
the load_it() procedure happy. CZ
*/
tcord = ship.shp_destx[0];
}
static void
-eta_calc(struct shpstr *sp, s_char *path, int *len, int *nupdates)
+eta_calc(struct shpstr *sp, char *path, int *len, int *nupdates)
{
double mobcost, mobil;
int i;
*len = i;
*nupdates = 1;
- mobcost = sp->shp_effic * 0.01 * sp->shp_speed;
- mobcost = 480.0 / (mobcost + techfact(sp->shp_tech, mobcost));
+ mobcost = shp_mobcost(sp);
mobil = sp->shp_mobil;
while (i) {
if (mobil > 0) {
struct nstr_item nb;
struct shpstr ship;
- if (!snxtitem(&nb, EF_SHIP, player->argp[1]))
+ if (!snxtitem(&nb, EF_SHIP, player->argp[1], NULL))
return RET_SYN;
while (nxtitem(&nb, (&ship))) {
if (!player->owner || ship.shp_own == 0)
{
int nships = 0;
int len, updates;
- s_char *c;
+ char *c;
struct nstr_item nb;
struct shpstr ship;
- s_char buf[1024];
+ char buf[1024];
- if (!snxtitem(&nb, EF_SHIP, player->argp[1]))
+ if (!snxtitem(&nb, EF_SHIP, player->argp[1], NULL))
return RET_SYN;
while (nxtitem(&nb, (&ship))) {
if (!player->owner || ship.shp_own == 0)
if (ship.shp_autonav & AN_AUTONAV) {
/* Destination 1 */
- prxy(" %3d,%-3d", ship.shp_destx[1],
- ship.shp_desty[1], player->cnum);
+ prxy(" %3d,%-3d",
+ ship.shp_destx[1], ship.shp_desty[1], player->cnum);
/* Destination 2 */
if ((ship.shp_destx[1] != ship.shp_destx[0])
|| (ship.shp_desty[1] != ship.shp_desty[0])) {
- prxy(" %3d,%-3d", ship.shp_destx[0],
- ship.shp_desty[0], player->cnum);
+ prxy(" %3d,%-3d",
+ ship.shp_destx[0], ship.shp_desty[0], player->cnum);
} else
pr(" ");
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)
+ c = BestShipPath(buf, ship.shp_x, ship.shp_y,
+ ship.shp_destx[0], ship.shp_desty[0],
+ ship.shp_own);
+ if (!c)
pr(" no route possible");
else if (*c == 'h')
pr(" has arrived");
- else if (*c == '?')
- pr(" route too long");
else {
/* distance to destination */
eta_calc(&ship, c, &len, &updates);