]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/sail.c
Update copyright notice.
[empserver] / src / lib / commands / sail.c
index 23b5ed870acecd75cefe30905d2341c6e059fd70..47ed3fe9661349cbb2796dd52ae210211e8427af 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2005, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -19,9 +19,9 @@
  *
  *  ---
  *
- *  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
- *  related information and legal notices. It is expected that any future
- *  projects/authors will amend these files as needed.
+ *  See files README, COPYING and CREDITS in the root of the source
+ *  tree for related information and legal notices.  It is expected
+ *  that future projects/authors will amend these files as needed.
  *
  *  ---
  *
  *     Robert Forsman
  */
 
+#include <config.h>
+
 #include <ctype.h>
-#include "misc.h"
-#include "player.h"
-#include "ship.h"
-#include "path.h"
-#include "xy.h"
-#include "nsc.h"
-#include "file.h"
 #include "commands.h"
 #include "optlist.h"
+#include "path.h"
+#include "ship.h"
 
 static int
 show_sail(struct nstr_item *nstr)
@@ -51,10 +48,6 @@ show_sail(struct nstr_item *nstr)
     while (nxtitem(nstr, &ship)) {
        if (!player->owner || ship.shp_own == 0)
            continue;
-       if (ship.shp_type < 0 || ship.shp_type > shp_maxno) {
-           pr("bad ship type %d (#%d)\n", ship.shp_type, nstr->cur);
-           continue;
-       }
        if (count++ == 0) {
            if (player->god)
                pr("own ");
@@ -70,17 +63,15 @@ show_sail(struct nstr_item *nstr)
        pr("   %3d     ", ship.shp_mobquota);
        pr("   %3d   ", ship.shp_follow);
        if (ship.shp_path[0]) {
-           pr(ship.shp_path);
+           pr("%s", ship.shp_path);
        } else if ((ship.shp_autonav & AN_AUTONAV)) {
            pr("Has orders");
        }
        pr("\n");
-       if (opt_SHIPNAMES) {
-           if (ship.shp_name[0] != 0) {
-               if (player->god)
-                   pr("    ");
-               pr("       %s\n", ship.shp_name);
-           }
+       if (ship.shp_name[0] != 0) {
+           if (player->god)
+               pr("    ");
+           pr("       %s\n", ship.shp_name);
        }
     }
     if (count == 0) {
@@ -103,10 +94,6 @@ cmd_unsail_ship(struct nstr_item *nstr)
     while (nxtitem(nstr, &ship)) {
        if (!player->owner || ship.shp_own == 0)
            continue;
-       if (ship.shp_type < 0 || ship.shp_type > shp_maxno) {
-           pr("bad ship type %d (#%d)\n", ship.shp_type, nstr->cur);
-           continue;
-       }
        if (ship.shp_path[0]) {
            pr("Ship #%d unsailed\n", ship.shp_uid);
            count++;
@@ -120,17 +107,13 @@ cmd_unsail_ship(struct nstr_item *nstr)
 static int
 cmd_sail_ship(struct nstr_item *nstr)
 {
-    s_char *cp;
+    char *cp;
     struct shpstr ship;
     char navpath[MAX_PATH_LEN];
 
     while (!player->aborted && nxtitem(nstr, &ship)) {
        if (!player->owner || ship.shp_own == 0)
            continue;
-       if (ship.shp_type < 0 || ship.shp_type > shp_maxno) {
-           pr("bad ship type %d (#%d)\n", ship.shp_type, nstr->cur);
-           continue;
-       }
        if ((ship.shp_autonav & AN_AUTONAV) &&
            !(ship.shp_autonav & AN_STANDBY)) {
            pr("Ship #%d has other orders!\n", ship.shp_uid);
@@ -140,7 +123,7 @@ cmd_sail_ship(struct nstr_item *nstr)
        pr("Ship #%d at %s\n", ship.shp_uid,
           xyas(ship.shp_x, ship.shp_y, ship.shp_own));
        cp = getpath(navpath, player->argp[2],
-                    ship.shp_x, ship.shp_y, 0, 0, 0, P_SAILING);
+                    ship.shp_x, ship.shp_y, 0, 0, P_SAILING);
        if (!check_ship_ok(&ship))
            continue;
        if (!player->aborted) {
@@ -155,7 +138,7 @@ cmd_sail_ship(struct nstr_item *nstr)
 int
 sail(void)
 {
-    s_char *cp;
+    char *cp;
     struct nstr_item nstr;
 
     if (!opt_SAIL) {
@@ -165,11 +148,9 @@ sail(void)
     if (!snxtitem(&nstr, EF_SHIP, player->argp[1]))
        return RET_SYN;
     cp = player->argp[2];
-    if ((*player->argp[0] == 'q') /*qsail command */ ||(cp && *cp == 'q')) {
-       return show_sail(&nstr);
-    } else if (*player->argp[0] == 'u' /*unsail command */
-              || (cp && *cp == '-')) {
+    if (*player->argp[0] == 'u' || (cp && !strcmp(cp, "-")))
        return cmd_unsail_ship(&nstr);
-    } else
-       return cmd_sail_ship(&nstr);
+    if (cp && *cp == 'q')
+       return show_sail(&nstr);
+    return cmd_sail_ship(&nstr);
 }