]> git.pond.sub.org Git - empserver/commitdiff
Pass only PM_* mission flags to ac_encounter()
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 21 Sep 2008 14:25:59 +0000 (10:25 -0400)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 1 Feb 2009 16:14:38 +0000 (17:14 +0100)
Since the previous two commits, ac_encounter() checks its
mission_flags argument only for proper mission flags PM_R and PM_S,
not for plane flags P_A, P_S, P_I.

This makes the code to put plane flags into mission flags useless.
Remove it from bomb(), drop(), fly(), para(), reco(),
perform_mission(), mission_pln_arm(), air_defense(), pln_arm().

Much of that code was useless even before: P_X and P_H since Chainsaw
3 option STEALTHV became mandatory in Empire 2, and P_MINE since
commit cc0c3e4f (v4.3.0) cleaned up mine drops.

include/prototypes.h
src/lib/commands/bomb.c
src/lib/commands/drop.c
src/lib/commands/fly.c
src/lib/commands/para.c
src/lib/commands/reco.c
src/lib/subs/mission.c
src/lib/subs/plnsub.c

index 2b8631d71ba58f2c22865bc11bc3c71478d588e4..ac11292246b5941c6218e123e5214aef3163dbb6 100644 (file)
@@ -552,8 +552,7 @@ extern int pln_airbase_ok(struct plnstr *, int, int);
 extern int carrier_planes(struct shpstr *, int);
 extern void pln_sel(struct nstr_item *, struct emp_qelem *,
                    struct sctstr *, int, int, int, int);
-extern int pln_arm(struct emp_qelem *, int, char, struct ichrstr *,
-                  int, int);
+extern void pln_arm(struct emp_qelem *, int, char, struct ichrstr *, int);
 extern int pln_mobcost(int, struct plnstr *, int);
 extern void pln_put(struct emp_qelem *);
 extern void pln_put1(struct plist *);
index 59b19373740aa744cb09814cb7c2762565747968..87c29d4676f5b60cbda8f0a479dfa9d662685dc8 100644 (file)
@@ -81,7 +81,6 @@ int
 bomb(void)
 {
     char *p;
-    int mission_flags;
     coord tx, ty;
     coord ax, ay;
     int ap_to_target;
@@ -128,7 +127,6 @@ bomb(void)
     /*
      * select planes within range
      */
-    mission_flags = 0;
     pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target,
            2, wantflags, P_M | P_O);
     pln_sel(&ni_esc, &esc_list, &ap_sect, ap_to_target,
@@ -136,18 +134,13 @@ bomb(void)
     /*
      * now arm and equip the bombers, transports, whatever.
      */
-    mission_flags |= P_X;      /* stealth (shhh) */
-    mission_flags |= P_H;      /* gets turned off if not all choppers */
-    mission_flags = pln_arm(&bomb_list, 2 * ap_to_target, mission,
-                           ip, 0, mission_flags);
+    pln_arm(&bomb_list, 2 * ap_to_target, mission, ip, 0);
     if (QEMPTY(&bomb_list)) {
        pr("No planes could be equipped for the mission.\n");
        return RET_FAIL;
     }
-    mission_flags = pln_arm(&esc_list, 2 * ap_to_target, mission,
-                           ip, P_F | P_ESC, mission_flags);
-    ac_encounter(&bomb_list, &esc_list, ax, ay,
-                flightpath, mission_flags, 0);
+    pln_arm(&esc_list, 2 * ap_to_target, mission, ip, P_F | P_ESC);
+    ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath, 0, 0);
     if (QEMPTY(&bomb_list)) {
        pr("No planes got through fighter defenses\n");
     } else if (target.sct_type == SCT_SANCT) {
index 7c8dcaf3bea77d73d9e5f25561c5e72866000643..2c8806eb4afcd5c8b0590f1ab705b1250ba05515 100644 (file)
@@ -42,7 +42,6 @@
 int
 drop(void)
 {
-    int mission_flags;
     coord tx, ty;
     coord ax, ay;
     int ap_to_target;
@@ -97,7 +96,6 @@ drop(void)
     /*
      * select planes within range
      */
-    mission_flags = 0;
     pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target,
            2, wantflags, P_M | P_O);
     if (QEMPTY(&bomb_list)) {
@@ -109,20 +107,15 @@ drop(void)
     /*
      * now arm and equip the bombers, transports, whatever.
      */
-    mission_flags |= P_X;      /* stealth (shhh) */
-    mission_flags |= P_H;      /* gets turned off if not all choppers */
-    mission_flags |= P_MINE;
-    mission_flags = pln_arm(&bomb_list, 2 * ap_to_target,
-                           wantflags & P_MINE ? 'm' : 'd',
-                           ip, 0, mission_flags);
+    pln_arm(&bomb_list, 2 * ap_to_target,
+           wantflags & P_MINE ? 'm' : 'd',
+           ip, 0);
     if (QEMPTY(&bomb_list)) {
        pr("No planes could be equipped for the mission.\n");
        return RET_FAIL;
     }
-    mission_flags = pln_arm(&esc_list, 2 * ap_to_target, 'd',
-                           ip, P_ESC | P_F, mission_flags);
-    ac_encounter(&bomb_list, &esc_list, ax, ay,
-                flightpath, mission_flags, 0);
+    pln_arm(&esc_list, 2 * ap_to_target, 'd', ip, P_ESC | P_F);
+    ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath, 0, 0);
     if (QEMPTY(&bomb_list)) {
        pr("No planes got through fighter defenses\n");
     } else {
index e8713481a8f8ffc3cc26b024dfa6bbd82ba39337..efc60696fd4a34e2519050d54fcb095fa27d488b 100644 (file)
@@ -44,7 +44,6 @@
 int
 fly(void)
 {
-    int mission_flags;
     coord tx, ty;
     coord ax, ay;
     int ap_to_target;
@@ -95,7 +94,6 @@ fly(void)
     /*
      * select planes within range
      */
-    mission_flags = 0;
     pln_sel(&ni_bomb, &bomb_list, &ap_sect, ap_to_target,
            1, wantflags, P_M | P_O);
     if (QEMPTY(&bomb_list)) {
@@ -113,18 +111,14 @@ fly(void)
     /*
      * now arm and equip the bombers, transports, whatever.
      */
-    mission_flags |= P_X;      /* stealth (shhh) */
-    mission_flags |= P_H;      /* gets turned off if not all choppers */
-    mission_flags = pln_arm(&bomb_list, ap_to_target, 't',
-                           ip, 0, mission_flags);
+    pln_arm(&bomb_list, ap_to_target, 't', ip, 0);
     if (QEMPTY(&bomb_list)) {
        pr("No planes could be equipped for the mission.\n");
        return RET_FAIL;
     }
-    mission_flags = pln_arm(&esc_list, ap_to_target, 't',
-                           ip, P_ESC | P_F, mission_flags);
+    pln_arm(&esc_list, ap_to_target, 't', ip, P_ESC | P_F);
     ac_encounter(&bomb_list, &esc_list, ax, ay,
-                flightpath, mission_flags, 0);
+                flightpath, 0, 0);
     if (QEMPTY(&bomb_list)) {
        pr("No planes got through fighter defenses\n");
     } else {
index 0918eee6e6770ff9d00954ac75f9dcda01008cd0..8299f33a3ac33ce82e04c14f5812a85775742328 100644 (file)
@@ -48,7 +48,6 @@ static int paradrop(struct emp_qelem *list, coord x, coord y);
 int
 para(void)
 {
-    int mission_flags;
     coord tx, ty;
     coord ax, ay;
     int ap_to_target;
@@ -91,19 +90,13 @@ para(void)
     /*
      * now arm and equip the bombers, transports, whatever.
      */
-    mission_flags = 0;
-    mission_flags |= P_X;      /* stealth (shhh) */
-    mission_flags |= P_H;      /* gets turned off if not all choppers */
-    mission_flags = pln_arm(&bomb_list, 2 * ap_to_target, 'a',
-                           &ichr[I_MILIT], 0, mission_flags);
+    pln_arm(&bomb_list, 2 * ap_to_target, 'a', &ichr[I_MILIT], 0);
     if (QEMPTY(&bomb_list)) {
        pr("No planes could be equipped for the mission.\n");
        return RET_FAIL;
     }
-    mission_flags = pln_arm(&esc_list, 2 * ap_to_target, 'a',
-                           &ichr[I_MILIT], P_ESC | P_F, mission_flags);
-    ac_encounter(&bomb_list, &esc_list, ax, ay,
-                flightpath, mission_flags, 0);
+    pln_arm(&esc_list, 2 * ap_to_target, 'a', &ichr[I_MILIT], P_ESC | P_F);
+    ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath, 0, 0);
     if (QEMPTY(&bomb_list)) {
        pr("No planes got through fighter defenses\n");
     } else {
index 26c145c45680cb36c4d4a83c773889515ea7d72f..e60b0229e252dc3beb0b12f1be778eb613c01f62 100644 (file)
@@ -41,7 +41,6 @@
 int
 reco(void)
 {
-    int mission_flags;
     coord tx, ty;
     coord ax, ay;
     int ap_to_target;
@@ -72,7 +71,6 @@ reco(void)
     pr("target is %s\n", xyas(tx, ty, player->cnum));
     getsect(tx, ty, &target);
     cno = -1;
-    mission_flags = 0;
     if (pln_onewaymission(&target, &cno, &wantflags) < 0)
        return RET_SYN;
     ap_to_target = strlen(flightpath);
@@ -99,23 +97,15 @@ reco(void)
     /*
      * now arm and equip the bombers, transports, whatever.
      */
-    mission_flags |= P_X;      /* stealth (shhh) */
-    mission_flags |= P_H;      /* gets turned off if not all choppers */
-    mission_flags = pln_arm(&bomb_list, ap_to_target, 'r',
-                           0, P_S | P_I, mission_flags);
+    pln_arm(&bomb_list, ap_to_target, 'r', 0, P_S | P_I);
     if (QEMPTY(&bomb_list)) {
        pr("No planes could be equipped for the mission.\n");
        return RET_FAIL;
     }
-    mission_flags = pln_arm(&esc_list, ap_to_target, 'r',
-                           0, P_F | P_ESC, mission_flags);
-    mission_flags |= PM_R;
-
-    if (*player->argp[0] == 's')
-       mission_flags |= PM_S;
-
-    ac_encounter(&bomb_list, &esc_list, ax, ay,
-                flightpath, mission_flags, 0);
+    pln_arm(&esc_list, ap_to_target, 'r', 0, P_F | P_ESC);
+    ac_encounter(&bomb_list, &esc_list, ax, ay, flightpath,
+                *player->argp[0] == 's' ? PM_R | PM_S : PM_R,
+                0);
     if (QEMPTY(&bomb_list)) {
        pr("No planes got through fighter defenses\n");
     } else {
index a2a178f57a58ec74d46678a22727767631264b9b..e3d78f8c7d0a75a1479d807f5dfefea327d65a09 100644 (file)
@@ -69,8 +69,8 @@ static void build_mission_list_type(struct genlist *, coord, coord, int,
 static void divide(struct emp_qelem *, struct emp_qelem *, coord, coord);
 static int dosupport(struct genlist *, coord, coord, natid, natid);
 static int find_airport(struct emp_qelem *, coord, coord);
-static int mission_pln_arm(struct emp_qelem *, coord, coord, int,
-                          int, struct ichrstr *, int, int);
+static void mission_pln_arm(struct emp_qelem *, coord, coord, int,
+                           int, struct ichrstr *, int);
 static void mission_pln_sel(struct emp_qelem *, int, int, int);
 static int perform_mission(coord, coord, natid, struct emp_qelem *, int,
                           char *, int);
@@ -386,7 +386,7 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
     struct sctstr sect;
     struct mchrstr *mcp;
     struct plchrstr *pcp;
-    int dam = 0, dam2, mission_flags;
+    int dam = 0, dam2;
     natid plane_owner = 0;
     int md, range, air_dam = 0;
     double hitchance, vrange;
@@ -609,18 +609,12 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
        /* Split off the escorts at this base into e */
        divide(&escorts, &e, air->x, air->y);
 
-       mission_flags = 0;
-       mission_flags |= P_X;   /* stealth (shhh) */
-       mission_flags |= P_H;   /* gets turned off if not all choppers */
-
-       mission_flags = mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', 0,
-                                       0, mission_flags);
+       mission_pln_arm(&b, air->x, air->y, 2 * md, 'p', 0, 0);
 
        if (QEMPTY(&b))
            continue;
 
-       mission_flags = mission_pln_arm(&e, air->x, air->y, 2 * md, 'p', 0,
-                                       P_F | P_ESC, mission_flags);
+       mission_pln_arm(&e, air->x, air->y, 2 * md, 'p', 0, P_F | P_ESC);
 
        pp = BestAirPath(buf, air->x, air->y, x, y);
        if (CANT_HAPPEN(!pp))
@@ -636,7 +630,7 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
               xyas(x, y, air->own));
        }
 
-       ac_encounter(&b, &e, air->x, air->y, pp, mission_flags, 0);
+       ac_encounter(&b, &e, air->x, air->y, pp, 0, 0);
 
        if (!QEMPTY(&b))
            air_dam +=
@@ -843,10 +837,9 @@ mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags,
 /*
  * Arm only the planes at x,y
  */
-static int
+static void
 mission_pln_arm(struct emp_qelem *list, coord x, coord y, int dist,
-               int mission, struct ichrstr *ip, int flags,
-               int mission_flags)
+               int mission, struct ichrstr *ip, int flags)
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
@@ -869,28 +862,11 @@ mission_pln_arm(struct emp_qelem *list, coord x, coord y, int dist,
            free(qp);
            continue;
        }
-       if (flags & (P_S | P_I)) {
-           if (plp->pcp->pl_flags & P_S)
-               mission_flags |= P_S;
-           if (plp->pcp->pl_flags & P_I)
-               mission_flags |= P_I;
-       }
-       if (!(plp->pcp->pl_flags & P_H))
-           /* no stealth on this mission */
-           mission_flags &= ~P_H;
-       if (!(plp->pcp->pl_flags & P_X))
-           /* no stealth on this mission */
-           mission_flags &= ~P_X;
-       if (!(plp->pcp->pl_flags & P_MINE)) {
-           /* no asw on this mission */
-           mission_flags &= ~P_MINE;
-       }
 
        pp->pln_flags |= PLN_LAUNCHED;
        pp->pln_mobil -= pln_mobcost(dist, pp, flags);
        putplane(pp->pln_uid, pp);
     }
-    return mission_flags;
 }
 
 int
@@ -1146,7 +1122,7 @@ air_defense(coord x, coord y, natid victim, struct emp_qelem *bomb_list,
            struct emp_qelem *esc_list)
 {
     int dam = 0, cn;
-    int mission_flags, combat = 0, rel, dist, z;
+    int combat = 0, rel, dist, z;
     struct emp_qelem *qp, interceptors, airp, i, empty, *next;
     struct plist *plp;
     struct genlist *glp;
@@ -1256,10 +1232,6 @@ air_defense(coord x, coord y, natid victim, struct emp_qelem *bomb_list,
            /* Split off the interceptors at this base into i */
            divide(&interceptors, &i, air->x, air->y);
 
-           mission_flags = 0;
-           mission_flags |= P_X;       /* stealth (shhh) */
-           /* gets turned off if not all choppers */
-           mission_flags |= P_H;
            sam_intercept(bomb_list, &i, cn, victim, x, y, 0);
            sam_intercept(esc_list, &i, cn, victim, x, y, 1);
 
@@ -1273,9 +1245,7 @@ air_defense(coord x, coord y, natid victim, struct emp_qelem *bomb_list,
                pln_put(&i);
                continue;
            }
-           mission_flags =
-               mission_pln_arm(&i, air->x, air->y, 2 * dist, 0, 0, P_F,
-                               mission_flags);
+           mission_pln_arm(&i, air->x, air->y, 2 * dist, 0, 0, P_F);
 
            /* Did we run out of interceptors? */
            if (QEMPTY(&i))
@@ -1306,8 +1276,7 @@ air_defense(coord x, coord y, natid victim, struct emp_qelem *bomb_list,
 
            /* Now, fly the planes to the sector */
            emp_initque(&empty);
-           ac_encounter(&i, &empty, air->x, air->y,
-                        path, mission_flags, 1);
+           ac_encounter(&i, &empty, air->x, air->y, path, 0, 1);
 
            /* If none made it, continue */
            if (QEMPTY(&i))
index cbbd5792007b6df8f6308756e969509c0f743572..d839d1aecb733b146123b870df836fe5281fd7b4 100644 (file)
@@ -562,9 +562,9 @@ pln_sel(struct nstr_item *ni, struct emp_qelem *list, struct sctstr *ap,
     }
 }
 
-int
+void
 pln_arm(struct emp_qelem *list, int dist, char mission, struct ichrstr *ip,
-       int flags, int mission_flags)
+       int flags)
 {
     struct emp_qelem *qp;
     struct emp_qelem *next;
@@ -582,29 +582,11 @@ pln_arm(struct emp_qelem *list, int dist, char mission, struct ichrstr *ip,
            free(qp);
            continue;
        }
-       if (flags & (P_S | P_I)) {
-           if (plp->pcp->pl_flags & P_S)
-               mission_flags |= P_S;
-           if (plp->pcp->pl_flags & P_I)
-               mission_flags |= P_I;
-       }
-       if (!(plp->pcp->pl_flags & P_H))
-           /* no stealth on this mission */
-           mission_flags &= ~P_H;
-       if (!(plp->pcp->pl_flags & P_X))
-           /* no stealth on this mission */
-           mission_flags &= ~P_X;
-       if (!(plp->pcp->pl_flags & P_MINE)) {
-           /* no asw on this mission */
-           mission_flags &= ~P_MINE;
-           /* FIXME no effect */
-       }
        pp->pln_flags |= PLN_LAUNCHED;
        pp->pln_mobil -= pln_mobcost(dist, pp, flags);
        putplane(pp->pln_uid, pp);
        pr("%s equipped\n", prplane(pp));
     }
-    return mission_flags;
 }
 
 static int