]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/arm.c
Limit nukes to strategic missions
[empserver] / src / lib / commands / arm.c
index e689e87be866675bd919112fbfac62d0eb2aeea0..144336cd729cf9c91bb25a50228b5f1610e9c9bf 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -26,7 +26,7 @@
  *  ---
  *
  *  arm.c: Arm planes (missiles) with nuclear devices
- * 
+ *
  *  Known contributors to this file:
  *     Dave Pare, 1986
  *     Ken Stevens, 1995
@@ -55,14 +55,15 @@ arm(void)
     char buf[1024];
     char prompt[128];
 
-    if (!snxtitem(&ni, EF_PLANE, player->argp[1]))
+    if (!snxtitem(&ni, EF_PLANE, player->argp[1], NULL))
        return RET_SYN;
     while (nxtitem(&ni, &pl)) {
        if (!player->owner
            && getrel(getnatp(pl.pln_own), player->cnum) != ALLIED)
            continue;
        plc = &plchr[(int)pl.pln_type];
-       if ((plc->pl_flags & (P_O | P_M)) == (P_O | P_M)) {
+       if ((plc->pl_flags & (P_O | P_N | P_MAR))
+           || (plc->pl_flags & (P_M | P_F)) == (P_M | P_F)) {
            pr("A %s cannot carry nuclear devices!\n", plc->pl_name);
            return RET_FAIL;
        }
@@ -73,7 +74,7 @@ arm(void)
                return RET_FAIL;
            }
        }
-       if (pl.pln_nuketype < 0) {
+       if (!getnuke(nuk_on_plane(&pl), &nuke)) {
            sprintf(prompt, "Nuclear device for %s: ", prplane(&pl));
            p = getstarg(player->argp[2], prompt, buf);
            if (!p || !*p)
@@ -83,11 +84,6 @@ arm(void)
            nukno = atoi(p);
            if (!getnuke(nukno, &nuke) || !player->owner)
                return RET_FAIL;
-       } else {
-           if (nuk_on_plane(&nuke, pl.pln_uid) < 0) {
-               CANT_REACH();
-               continue;
-           }
        }
        ncp = &nchr[nuke.nuk_type];
        if (pln_load(&pl) < ncp->n_weight) {
@@ -97,7 +93,7 @@ arm(void)
        }
        p = getstarg(player->argp[3], "Airburst [n]? ", buf);
        if (!p)
-           return RET_SYN;
+           return RET_FAIL;
 
        if (!check_plane_ok(&pl) || !check_nuke_ok(&nuke))
            return RET_FAIL;
@@ -112,11 +108,11 @@ arm(void)
            pl.pln_flags |= PLN_AIRBURST;
        else
            pl.pln_flags &= ~PLN_AIRBURST;
+       pl.pln_mission = 0;
 
        snprintf(buf, sizeof(buf), "armed on your %s in %s",
                 prplane(&pl), xyas(pl.pln_x, pl.pln_y, pl.pln_own));
        gift(pl.pln_own, player->cnum, &nuke, buf);
-       pl.pln_nuketype = nuke.nuk_type;
        nuke.nuk_plane = pl.pln_uid;
        putplane(pl.pln_uid, &pl);
        putnuke(nuke.nuk_uid, &nuke);
@@ -138,12 +134,12 @@ disarm(void)
     struct sctstr sect;
     char buf[128];
 
-    if (!snxtitem(&ni, EF_PLANE, player->argp[1]))
+    if (!snxtitem(&ni, EF_PLANE, player->argp[1], NULL))
        return RET_SYN;
     while (nxtitem(&ni, &pl)) {
        if (!player->owner)
            continue;
-       if (pl.pln_nuketype == -1)
+       if (!getnuke(nuk_on_plane(&pl), &nuke))
            continue;
        if (opt_MARKET) {
            if (ontradingblock(EF_PLANE, &pl)) {
@@ -152,10 +148,6 @@ disarm(void)
                return RET_FAIL;
            }
        }
-       if (nuk_on_plane(&nuke, pl.pln_uid) < 0) {
-           CANT_REACH();
-           continue;
-       }
        getsect(nuke.nuk_x, nuke.nuk_y, &sect);
        if (!player->owner
            && getrel(getnatp(sect.sct_own), player->cnum) != ALLIED) {
@@ -168,7 +160,6 @@ disarm(void)
                 xyas(sect.sct_x, sect.sct_y, sect.sct_own));
        gift(sect.sct_own, player->cnum, &nuke, buf);
        nuke.nuk_plane = -1;
-       pl.pln_nuketype = -1;
        pl.pln_flags &= ~PLN_AIRBURST;
        putplane(pl.pln_uid, &pl);
        putnuke(nuke.nuk_uid, &nuke);