Get rid of struct plnstr member pln_nuktype

pln_nuktype is redundant; it can be computed from the nuke's
nuk_plane.

Make plane selector nuketype virtual and NSC_EXTRA.  It should have
been NSC_EXTRA all along.  This changes xdump plane.

Don't set it in arm(), disarm(), build_plane(), pln_damage() and
nuk_fixup().  The latter no longer does anything, remove it.

Deprecate edit key 'n' in doplane(), and don't show it in pr_plane().
The key never made much sense.

eff_bomb(), comm_bomb(), ship_bomb(), plane_bomb(), land_bomb(),
strat_bomb(), mission_pln_equip(), air_damage(), msl_hit(),
pln_equip() tested pln_nuketype to check whether a plane carries a
nuke.  Test nuk_on_plane() instead.

pdump(), plan(), trade_desc() print whether and what kind of nuke a
plane carries.  Adapt that to use nuk_on_plane().
This commit is contained in:
Markus Armbruster 2008-09-06 22:15:41 -04:00
parent 4086c25a15
commit 8b1470e3a8
13 changed files with 40 additions and 56 deletions

View file

@ -111,7 +111,6 @@ arm(void)
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);
@ -159,7 +158,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);

View file

@ -42,6 +42,7 @@
#include "item.h"
#include "land.h"
#include "news.h"
#include "nuke.h"
#include "optlist.h"
#include "path.h"
#include "plane.h"
@ -342,7 +343,7 @@ eff_bomb(struct emp_qelem *list, struct sctstr *target)
plp = (struct plist *)qp;
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
continue;
if (plp->bombs || plp->plane.pln_nuketype != -1)
if (plp->bombs || nuk_on_plane(&plp->plane) >= 0)
dam += pln_damage(&plp->plane, target->sct_x, target->sct_y,
'p', &nukedam, 1);
}
@ -419,7 +420,7 @@ comm_bomb(struct emp_qelem *list, struct sctstr *target)
plp = (struct plist *)qp;
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
continue;
if (plp->bombs || plp->plane.pln_nuketype != -1)
if (plp->bombs || nuk_on_plane(&plp->plane) >= 0)
dam += pln_damage(&plp->plane, target->sct_x, target->sct_y,
'p', &nukedam, 1);
}
@ -532,7 +533,7 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
}
dam = 0;
if (plp->plane.pln_nuketype != -1)
if (nuk_on_plane(&plp->plane) >= 0)
hitchance = 100;
else {
hitchance = pln_hitchance(&plp->plane,
@ -636,7 +637,7 @@ plane_bomb(struct emp_qelem *list, struct sctstr *target)
if (planeno < 0)
continue;
dam = 0;
if (plp->plane.pln_nuketype != -1)
if (nuk_on_plane(&plp->plane) >= 0)
hitchance = 100;
else {
hitchance = pln_hitchance(&plp->plane, 0, EF_PLANE);
@ -747,7 +748,7 @@ land_bomb(struct emp_qelem *list, struct sctstr *target)
}
dam = 0;
if (plp->plane.pln_nuketype != -1)
if (nuk_on_plane(&plp->plane) >= 0)
hitchance = 100;
else {
hitchance = pln_hitchance(&plp->plane,
@ -796,7 +797,7 @@ strat_bomb(struct emp_qelem *list, struct sctstr *target)
plp = (struct plist *)qp;
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
continue;
if (plp->bombs || plp->plane.pln_nuketype != -1)
if (plp->bombs || nuk_on_plane(&plp->plane) >= 0)
dam += pln_damage(&plp->plane, target->sct_x, target->sct_y,
's', &nukedam, 1);
}

View file

@ -778,7 +778,6 @@ build_plane(struct sctstr *sp, struct plchrstr *pp, short *vec, int tlev)
plane.pln_wing = 0;
plane.pln_ship = -1;
plane.pln_land = -1;
plane.pln_nuketype = -1;
plane.pln_harden = 0;
plane.pln_flags = 0;
pln_set_tech(&plane, tlev);

View file

@ -332,7 +332,6 @@ pr_plane(struct plnstr *plane)
pr("Flags <f>: %d\n", plane->pln_flags);
pr("Ship <s>: %d\t\t", plane->pln_ship);
pr("Land Unit <y>: %d\t", plane->pln_land);
pr("Nuke Type <n>: %d\n", plane->pln_nuketype);
}
static void
@ -981,7 +980,7 @@ doplane(char op, int arg, char *p, struct plnstr *plane)
switch (op) {
case 'n':
plane->pln_nuketype = arg;
warn_deprecated(op);
break;
case 'U':
ef_set_uid(EF_PLANE, plane, arg);

View file

@ -45,6 +45,7 @@ pdump(void)
int nplanes;
struct nstr_item np;
struct plnstr plane;
struct nukstr nuke;
int field[128];
struct natstr *natp;
int n, i;
@ -266,8 +267,8 @@ pdump(void)
? " Y" : " N");
break;
case 20:
if (plane.pln_nuketype != -1) {
pr(" %.5s", nchr[(int)plane.pln_nuketype].n_name);
if (getnuke(nuk_on_plane(&plane), &nuke)) {
pr(" %.5s", nchr[nuke.nuk_type].n_name);
break;
} else
pr(" N/A");

View file

@ -46,6 +46,7 @@ plan(void)
int nplanes, noff;
struct nstr_item np;
struct plnstr plane;
struct nukstr nuke;
if (!snxtitem(&np, EF_PLANE, player->argp[1], NULL))
return RET_SYN;
@ -76,9 +77,9 @@ plan(void)
pr(" ");
if (pln_is_in_orbit(&plane))
pr((plane.pln_flags & PLN_SYNCHRONOUS) ? " geosync" : " orbit");
else if (plane.pln_nuketype >= 0)
else if (getnuke(nuk_on_plane(&plane), &nuke))
pr(" %-5.5s %c",
nchr[(int)plane.pln_nuketype].n_name,
nchr[nuke.nuk_type].n_name,
plane.pln_flags & PLN_AIRBURST ? 'A' : 'G');
pr("\n");
}