]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/orde.c
Update copyright notice
[empserver] / src / lib / commands / orde.c
index 9c2bf70e17df9e6a7dc652fd77a8b6fb8f747bd8..af80de947c9b8df4348dc781f881ab31677f0260 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2012, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                Ken Stevens, Steve McClure, Markus Armbruster
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  Empire is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  ---
  *
@@ -30,6 +29,7 @@
  *  Known contributors to this file:
  *     Chad Zabel, 1994
  *     Steve McClure, 2000
+ *     Markus Armbruster, 2004-2011
  */
 
 #include <config.h>
@@ -131,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;
                }
@@ -285,15 +280,14 @@ orde(void)
     return RET_OK;
 }
 
-static void
-eta_calc(struct shpstr *sp, char *path, int *len, int *nupdates)
+static int
+eta_calc(struct shpstr *sp, int len)
 {
     double mobcost, mobil;
-    int i;
+    int i, nupdates;
 
-    i = strlen(path);
-    *len = i;
-    *nupdates = 1;
+    i = len;
+    nupdates = 1;
 
     mobcost = shp_mobcost(sp);
     mobil = sp->shp_mobil;
@@ -303,9 +297,10 @@ eta_calc(struct shpstr *sp, char *path, int *len, int *nupdates)
            i--;
        } else {
            mobil += (ship_mob_scale * (float)etu_per_update);
-           (*nupdates)++;
+           nupdates++;
        }
     }
+    return nupdates;
 }
 
 static void
@@ -386,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;
@@ -431,17 +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 */
-                   eta_calc(&ship, c, &len, &updates);
+                   len = (int)c;
+                   updates = eta_calc(&ship, len);
                    pr(" %3d %4d", len, updates);
                }
            }