]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/orde.c
Update copyright notice
[empserver] / src / lib / commands / orde.c
index b6f019f09ffc75af73089979c4433f1bd470431b..af80de947c9b8df4348dc781f881ab31677f0260 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  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
@@ -29,6 +29,7 @@
  *  Known contributors to this file:
  *     Chad Zabel, 1994
  *     Steve McClure, 2000
+ *     Markus Armbruster, 2004-2011
  */
 
 #include <config.h>
@@ -130,12 +131,7 @@ orde(void)
            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;
                }
@@ -284,14 +280,14 @@ orde(void)
     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;
@@ -301,9 +297,10 @@ eta_calc(struct shpstr *sp, int len, int *nupdates)
            i--;
        } else {
            mobil += (ship_mob_scale * (float)etu_per_update);
-           (*nupdates)++;
+           nupdates++;
        }
     }
+    return nupdates;
 }
 
 static void
@@ -384,10 +381,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;
@@ -429,18 +425,17 @@ 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);
-                   eta_calc(&ship, len, &updates);
+                   len = (int)c;
+                   updates = eta_calc(&ship, len);
                    pr(" %3d %4d", len, updates);
                }
            }