]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/tran.c
Clean up superfluous includes
[empserver] / src / lib / commands / tran.c
index d810c0c5d3411e903836114337d509be49c152d5..40e4052d9c7d114cca0f524e9b95b634f8270476 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2011, 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/>.
  *
  *  ---
  *
  *  ---
  *
  *  tran.c: Transport nuclear devices and planes
- * 
+ *
  *  Known contributors to this file:
  *     Steve McClure, 2000
- *     Markus Armbruster, 2006
+ *     Markus Armbruster, 2006-2011
  */
 
 #include <config.h>
 
 #include "commands.h"
-#include "land.h"
+#include "map.h"
 #include "nuke.h"
 #include "plane.h"
-#include "ship.h"
 
-static int tran_pmap(coord curx, coord cury, char *arg);
-static int tran_nmap(coord curx, coord cury, char *arg);
+static int tran_pmap(coord, coord, char *, char *);
+static int tran_nmap(coord, coord, char *, char *);
 static int tran_nuke(void);
 static int tran_plane(void);
 
@@ -53,7 +51,7 @@ tran(void)
 
     what = getstarg(player->argp[1], "transport what (nuke or plane): ",
                    buf);
-    if (what == 0)
+    if (!what)
        return RET_SYN;
     if (*what == 'n')
        return tran_nuke();
@@ -77,7 +75,7 @@ tran_nuke(void)
 
     weight = 0;
     count = 0;
-    if (!snxtitem(&nstr, EF_NUKE, player->argp[2]))
+    if (!snxtitem(&nstr, EF_NUKE, player->argp[2], NULL))
        return RET_SYN;
     while (nxtitem(&nstr, &nuke)) {
        if (!player->owner)
@@ -134,8 +132,9 @@ tran_nuke(void)
     else
        pr("No mobility used\n");
     getsect(srcx, srcy, &sect);
-    sect.sct_mobil -= mcost;
-    if (sect.sct_mobil < 0)
+    if (sect.sct_mobil >= mcost)
+       sect.sct_mobil -= mcost;
+    else
        sect.sct_mobil = 0;
     putsect(&sect);
     return RET_OK;
@@ -156,7 +155,7 @@ tran_plane(void)
 
     weight = 0;
     count = 0;
-    if (!snxtitem(&nstr, EF_PLANE, player->argp[2]))
+    if (!snxtitem(&nstr, EF_PLANE, player->argp[2], NULL))
        return RET_SYN;
     /*
      * First do some sanity checks: make sure that they are all in the,
@@ -169,14 +168,18 @@ tran_plane(void)
            continue;
        type = plane.pln_type;
        if (plane.pln_ship >= 0) {
-           pr("%s is at sea and can't be transported\n", prplane(&plane));
+           pr("%s is stowed on ship #%d, and can't be transported\n",
+              prplane(&plane), plane.pln_ship);
+           return RET_FAIL;
+       } else if (plane.pln_land >= 0) {
+           pr("%s is stowed on land #%d, and can't be transported\n",
+              prplane(&plane), plane.pln_land);
            return RET_FAIL;
        } else if (plane.pln_harden != 0) {
            pr("%s has been hardened and can't be transported\n",
               prplane(&plane));
            return RET_FAIL;
-       } else if ((plane.pln_flags & PLN_LAUNCHED) &&
-                  (plchr[type].pl_flags & P_O)) {
+       } else if (pln_is_in_orbit(&plane)) {
            pr("%s is in space and can't be transported\n",
               prplane(&plane));
            return RET_FAIL;
@@ -230,8 +233,9 @@ tran_plane(void)
     else
        pr("No mobility used\n");
     getsect(srcx, srcy, &sect);
-    sect.sct_mobil -= mcost;
-    if (sect.sct_mobil < 0)
+    if (sect.sct_mobil >= mcost)
+       sect.sct_mobil -= mcost;
+    else
        sect.sct_mobil = 0;
     putsect(&sect);
     return RET_OK;
@@ -244,14 +248,13 @@ tran_plane(void)
  */
 /*ARGSUSED*/
 static int
-tran_pmap(coord curx, coord cury, char *arg)
+tran_pmap(coord curx, coord cury, char *arg1, char *arg2)
 {
-    return display_region_map("pmap", curx, cury, arg);
+    return display_region_map(0, EF_PLANE, curx, cury, arg1, arg2);
 }
 
 static int
-tran_nmap(coord curx, coord cury, char *arg)
+tran_nmap(coord curx, coord cury, char *arg1, char *arg2)
 {
-    return display_region_map("nmap", curx, cury, arg);
+    return display_region_map(0, EF_NUKE, curx, cury, arg1, arg2);
 }
-