]> git.pond.sub.org Git - empserver/commitdiff
bomb: Eliminate bombcomm[], it's redundant
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 29 May 2016 10:14:05 +0000 (12:14 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 17:59:56 +0000 (19:59 +0200)
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>
src/lib/commands/bomb.c

index 1de00905f3f24352c07dd8e16ab81c02eb396606..26f76b9e281307425dc7836f46b3313189427d8c 100644 (file)
@@ -60,24 +60,6 @@ static int changed_plane_aborts(struct plist *);
 static int pinflak_planedamage(struct plnstr *, struct plchrstr *,
                               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
 bomb(void)
 {
@@ -236,12 +218,11 @@ pin_bomb(struct emp_qelem *list, struct sctstr *target)
        ship_bomb(list, target);
        break;
     case 'c':
-       for (i = 0; i < nbomb; i++) {
-           if (!target->sct_item[bombcomm[i]])
-               continue;
-           break;
+       for (i = I_NONE + 1; i <= I_MAX; i++) {
+           if (target->sct_item[i])
+               break;
        }
-       if (i >= nbomb) {
+       if (i > I_MAX) {
            pr("No bombable commodities in %s\n",
               xyas(target->sct_x, target->sct_y, player->cnum));
            goto retry;
@@ -308,13 +289,12 @@ comm_bomb(struct emp_qelem *list, struct sctstr *target)
     struct sctstr sect;
     int dam = 0;
 
-    for (i = 0; i < nbomb; i++) {
-       if (target->sct_item[bombcomm[i]] == 0)
+    for (i = I_NONE + 1; i <= I_MAX; i++) {
+       if (!target->sct_item[i])
            continue;
-       if (opt_SUPER_BARS && bombcomm[i] == I_BAR)
+       if (opt_SUPER_BARS && i == I_BAR)
            continue;
-       ip = &ichr[bombcomm[i]];
-       pr("some %s\n", ip->i_name);
+       pr("some %s\n", ichr[i].i_name);
     }
     for (;;) {
        ip = whatitem(NULL, "commodity to bomb? ");
@@ -323,13 +303,13 @@ comm_bomb(struct emp_qelem *list, struct sctstr *target)
        if (!ip)
            continue;
 
-       for (i = 0; i < nbomb; i++) {
-           if (opt_SUPER_BARS && bombcomm[i] == I_BAR)
+       for (i = I_NONE + 1; i <= I_MAX; i++) {
+           if (opt_SUPER_BARS && i == I_BAR)
                continue;
-           if (&ichr[bombcomm[i]] == ip)
+           if (&ichr[i] == ip)
                break;
        }
-       if (i == nbomb)
+       if (i > I_MAX)
            pr("You can't bomb %s!\n", ip->i_name);
        else
            break;