bomb: Eliminate bombcomm[], it's redundant

bombcomm[] used to contain the commodities that can be p-bombed.  In
BSD Empire 1.1, it contained I_SHELL, I_GUN, I_MILIT, I_PETROL, I_OIL,
I_RAD.  In Chainsaw, it contained either everything or everything but
I_BAR, depending on option preprocessor symbol SUPER_BARS.  When
Empire 2 replaced the compile time variable SUPER_BARS by the run time
variable opt_SUPER_BARS, bombcomm[] became a redundant indirection.
Eliminate it.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-05-29 12:14:05 +02:00
parent 4b8c429d00
commit 846399ab7f

View file

@ -60,24 +60,6 @@ static int changed_plane_aborts(struct plist *);
static int pinflak_planedamage(struct plnstr *, struct plchrstr *, static int pinflak_planedamage(struct plnstr *, struct plchrstr *,
natid, int); natid, int);
static i_type bombcomm[] = {
I_CIVIL,
I_MILIT,
I_SHELL,
I_GUN,
I_PETROL,
I_IRON,
I_DUST,
I_BAR,
I_FOOD,
I_OIL,
I_LCM,
I_HCM,
I_UW,
I_RAD
};
static int nbomb = sizeof(bombcomm) / sizeof(*bombcomm);
int int
bomb(void) bomb(void)
{ {
@ -236,12 +218,11 @@ pin_bomb(struct emp_qelem *list, struct sctstr *target)
ship_bomb(list, target); ship_bomb(list, target);
break; break;
case 'c': case 'c':
for (i = 0; i < nbomb; i++) { for (i = I_NONE + 1; i <= I_MAX; i++) {
if (!target->sct_item[bombcomm[i]]) if (target->sct_item[i])
continue; break;
break;
} }
if (i >= nbomb) { if (i > I_MAX) {
pr("No bombable commodities in %s\n", pr("No bombable commodities in %s\n",
xyas(target->sct_x, target->sct_y, player->cnum)); xyas(target->sct_x, target->sct_y, player->cnum));
goto retry; goto retry;
@ -308,13 +289,12 @@ comm_bomb(struct emp_qelem *list, struct sctstr *target)
struct sctstr sect; struct sctstr sect;
int dam = 0; int dam = 0;
for (i = 0; i < nbomb; i++) { for (i = I_NONE + 1; i <= I_MAX; i++) {
if (target->sct_item[bombcomm[i]] == 0) if (!target->sct_item[i])
continue; continue;
if (opt_SUPER_BARS && bombcomm[i] == I_BAR) if (opt_SUPER_BARS && i == I_BAR)
continue; continue;
ip = &ichr[bombcomm[i]]; pr("some %s\n", ichr[i].i_name);
pr("some %s\n", ip->i_name);
} }
for (;;) { for (;;) {
ip = whatitem(NULL, "commodity to bomb? "); ip = whatitem(NULL, "commodity to bomb? ");
@ -323,13 +303,13 @@ comm_bomb(struct emp_qelem *list, struct sctstr *target)
if (!ip) if (!ip)
continue; continue;
for (i = 0; i < nbomb; i++) { for (i = I_NONE + 1; i <= I_MAX; i++) {
if (opt_SUPER_BARS && bombcomm[i] == I_BAR) if (opt_SUPER_BARS && i == I_BAR)
continue; continue;
if (&ichr[bombcomm[i]] == ip) if (&ichr[i] == ip)
break; break;
} }
if (i == nbomb) if (i > I_MAX)
pr("You can't bomb %s!\n", ip->i_name); pr("You can't bomb %s!\n", ip->i_name);
else else
break; break;