]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/nuke.c
commands: Rename the command functions
[empserver] / src / lib / commands / nuke.c
index 0902b77ff1945ec2d52174895f8d705f24e368eb..d8b3e335449c2651810db6a511a91be10e4985fd 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-2021, 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/>.
  *
  *  ---
  *
  *  ---
  *
  *  nuke.c: Display a listing of your nuclear arsenal
- * 
+ *
  *  Known contributors to this file:
  *     Dave Pare, 1986
+ *     Markus Armbruster, 2006-2010
  */
 
 #include <config.h>
 
-#include "misc.h"
-#include "player.h"
-#include "sect.h"
-#include "nuke.h"
-#include "xy.h"
-#include "nsc.h"
-#include "nat.h"
-#include "file.h"
 #include "commands.h"
+#include "nuke.h"
+#include "plane.h"
 
 int
-nuke(void)
+c_nuke(void)
 {
-    int first_line = 0;
-    int show_comm;
-    int i;
+    int nnukes, noff;
     struct nstr_item nstr;
     struct nukstr nuk;
-    struct sctstr sect;
+    struct plnstr plane;
 
-    if (!snxtitem(&nstr, EF_NUKE, player->argp[1]))
+    if (!snxtitem(&nstr, EF_NUKE, player->argp[1], NULL))
        return RET_SYN;
-
+    nnukes = noff = 0;
     while (nxtitem(&nstr, &nuk)) {
-       if (!player->god && !player->owner)
+       if (!player->owner || nuk.nuk_own == 0)
            continue;
-       if (nuk.nuk_own == 0)
-           continue;
-       if (first_line++ == 0) {
+       if (nnukes++ == 0) {
            if (player->god)
                pr("own ");
-           pr("  sect        eff num nuke-type         lcm   hcm   oil   rad avail\n");
+           pr("   # nuke type              x,y    s   eff tech carry burst\n");
        }
-       getsect(nuk.nuk_x, nuk.nuk_y, &sect);
-       show_comm = 0;
-       if (sect.sct_type == SCT_NUKE && sect.sct_effic >= 60)
-           show_comm = 1;
+       if (nuk.nuk_off)
+           noff++;
        if (player->god)
            pr("%-3d ", nuk.nuk_own);
-       prxy("%4d,%-4d", sect.sct_x, sect.sct_y, player->cnum);
-       pr(" %c", dchr[sect.sct_type].d_mnem);
-       if (sect.sct_newtype != sect.sct_type)
-           pr("%c", dchr[sect.sct_newtype].d_mnem);
-       else
-           pr(" ");
-       pr("%4d%%", sect.sct_effic);
-
-       pr("%3d ", 1);
-       pr("%-16.16s ", nchr[(int)nuk.nuk_type].n_name);
-
-       if (show_comm) {
-           pr("%5d ", sect.sct_item[I_LCM]);
-           pr("%5d ", sect.sct_item[I_HCM]);
-           pr("%5d ", sect.sct_item[I_OIL]);
-           pr("%5d ", sect.sct_item[I_RAD]);
-           pr("%5d", sect.sct_avail);
-           show_comm = 0;
+       pr("%4d %-19.19s ", nstr.cur, nchr[(int)nuk.nuk_type].n_name);
+       prxy("%4d,%-4d", nuk.nuk_x, nuk.nuk_y);
+       pr(" %1.1s %c%3d%% %4d",
+          &nuk.nuk_stockpile, nuk.nuk_off ? '!' : ' ', nuk.nuk_effic,
+          nuk.nuk_tech);
+       if (nuk.nuk_plane >= 0) {
+           getplane(nuk.nuk_plane, &plane);
+           pr("%5dP %s",
+              nuk.nuk_plane,
+              plane.pln_flags & PLN_AIRBURST ? "  air" : "ground");
        }
        pr("\n");
     }
+
+    if (nnukes == 0) {
+       if (player->argp[1])
+           pr("%s: No nuke(s)\n", player->argp[1]);
+       else
+           pr("%s: No nuke(s)\n", "");
+       return RET_FAIL;
+    } else {
+       pr("%d nuke%s", nnukes, splur(nnukes));
+       if (noff)
+           pr(", %d stopped (eff marked with !)", noff);
+       pr("\n");
+    }
+
     return RET_OK;
 }