]> git.pond.sub.org Git - empserver/commitdiff
(pln_onewaymission, carriersatxy): Change to match ordinary sorties:
authorMarkus Armbruster <armbru@pond.sub.org>
Tue, 17 Aug 2004 18:34:53 +0000 (18:34 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 17 Aug 2004 18:34:53 +0000 (18:34 +0000)
offer carriers regardless of the sector they're in, require carriers
to be efficient.  Closes #875376.

src/lib/subs/list.c
src/lib/subs/plnsub.c

index 6e6728f2d8e913f135fe33fd5e4f80db1e922273..08faef5e2ab7af7ff607f24abbd9df848ee2010c 100644 (file)
@@ -94,7 +94,6 @@ carriersatxy(coord x, coord y, int wantflags, int nowantflags, natid own)
     struct nstr_item ni;
     struct mchrstr *mp;
     struct shpstr ship;
-    int allied;
 
     first = 1;
     ships = 0;
@@ -102,8 +101,10 @@ carriersatxy(coord x, coord y, int wantflags, int nowantflags, natid own)
     while (nxtitem(&ni, (s_char *)&ship)) {
        if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
            continue;
-       allied = (getrel(getnatp(ship.shp_own), own) == ALLIED);
-       if ((ship.shp_own != own) && !allied)
+       if (ship.shp_own != own
+           && getrel(getnatp(ship.shp_own), own) != ALLIED)
+           continue;
+       if (ship.shp_effic < SHP_AIROPS_EFF)
            continue;
        mp = &mchr[(int)ship.shp_type];
        if (wantflags) {
index 09c5af4d48ea442131d183a7a32997a7ef731fba..6bfe67261aa21ad8cf1cf742e1d2efcdef702915 100644 (file)
@@ -60,57 +60,22 @@ pln_onewaymission(struct sctstr *target, int *shipno, int *flagp)
     int nships;
     int cno;
     int flags;
-    int n;
     struct shpstr ship;
-    s_char buf[1024];
-    s_char *p;
+    char buf[1024];
+    char *p;
 
     flags = *flagp;
-    if ((target->sct_own && target->sct_own != player->cnum &&
-        (getrel(getnatp(target->sct_own), player->cnum) != ALLIED)) &&
-       (target->sct_type != SCT_HARBR) &&
-       (target->sct_type != SCT_BSPAN)) {
-       pr("Nowhere to land at sector %s!\n",
-          xyas(target->sct_x, target->sct_y, player->cnum));
-       return -1;
-    }
-    if (target->sct_type == SCT_MOUNT) {
-       pr("Nowhere to land at sector %s!\n",
-          xyas(target->sct_x, target->sct_y, player->cnum));
-       return -1;
-    }
-    cno = -1;
-    if (target->sct_type != SCT_AIRPT || target->sct_effic < 60)
-       flags |= P_V;
-    if (target->sct_type == SCT_WATER || target->sct_type == SCT_HARBR
-       || target->sct_type == SCT_BSPAN) {
-       nships = carriersatxy(target->sct_x, target->sct_y,
-                             M_FLY | M_CHOPPER, 0, player->cnum);
-       if (nships <= 0) {
-           if (target->sct_type == SCT_WATER) {
-               pr("Nowhere to land at sector %s!\n",
-                  xyas(target->sct_x, target->sct_y, player->cnum));
-               return -1;
-           } else {
-               if ((target->sct_own && target->sct_own != player->cnum)
-                   && (getrel(getnatp(target->sct_own), player->cnum) !=
-                       ALLIED)) {
-                   pr("Nowhere to land at sector %s!\n",
-                      xyas(target->sct_x, target->sct_y, player->cnum));
-                   return -1;
-               }
-               *shipno = cno;
-               *flagp = flags;
-               return 0;
-           }
-       }
-       cno = (-1);
-       n = (-1);
-       while (cno < 0) {
+
+    /* offer carriers */
+    nships = carriersatxy(target->sct_x, target->sct_y,
+                         M_FLY | M_CHOPPER, 0, player->cnum);
+    if (nships) {
+       for (;;) {
            if (!(p = getstarg(0, "Carrier #? ", buf)) || !*p)
                break;
-           n = atoi(p);
-           if (n < 0 || !getship(n, &ship)
+           cno = atoi(p);
+           if (cno < 0
+               || !getship(cno, &ship)
                || (!player->owner
                    && (getrel(getnatp(ship.shp_own), player->cnum)
                        != ALLIED))) {
@@ -118,43 +83,49 @@ pln_onewaymission(struct sctstr *target, int *shipno, int *flagp)
                continue;
            }
            if (ship.shp_x != target->sct_x || ship.shp_y != target->sct_y) {
-               pr("Ship #%d not in %s\n", n,
+               pr("Ship #%d not in %s\n", cno,
                   xyas(target->sct_x, target->sct_y, player->cnum));
                continue;
            }
-           if (!(mchr[(int)ship.shp_type].m_flags & M_FLY)
-               && !(mchr[(int)ship.shp_type].m_flags & M_XLIGHT)
-               && !(mchr[(int)ship.shp_type].m_flags & M_CHOPPER)
-               ) {
+           if ((!(mchr[(int)ship.shp_type].m_flags & M_FLY)
+                && !(mchr[(int)ship.shp_type].m_flags & M_XLIGHT)
+                && !(mchr[(int)ship.shp_type].m_flags & M_CHOPPER))
+               || ship.shp_effic < SHP_AIROPS_EFF) {
                pr("Can't land on %s.\n", prship(&ship));
                continue;
            }
-           pr("landing on carrier %d\n", n);
-           cno = n;
-           flags &= ~P_V;
+
+           /* clear to land on ship#CNO */
+           pr("landing on carrier %d\n", cno);
            if (mchr[(int)ship.shp_type].m_flags & M_FLY)
                flags |= P_L;
            if (mchr[(int)ship.shp_type].m_flags & M_CHOPPER)
                flags |= P_K;
            if (mchr[(int)ship.shp_type].m_flags & M_XLIGHT)
                flags |= P_E;
-       }
-       if ((target->sct_own && target->sct_own != player->cnum) &&
-           (getrel(getnatp(target->sct_own), player->cnum) != ALLIED) &&
-           (cno == -1)) {
-           pr("Nowhere to land at sector %s!\n",
-              xyas(target->sct_x, target->sct_y, player->cnum));
-           return -1;
+           *shipno = cno;
+           *flagp = flags;
+           return 0;
        }
     }
 
-    if ((target->sct_own == 0) && (cno < 0)) {
+    /* try to land at sector */
+    if (target->sct_own != player->cnum
+       && getrel(getnatp(target->sct_own), player->cnum) != ALLIED) {
        pr("Nowhere to land at sector %s!\n",
           xyas(target->sct_x, target->sct_y, player->cnum));
        return -1;
     }
+    if (target->sct_type == SCT_MOUNT) {
+       pr("Nowhere to land at sector %s!\n",
+          xyas(target->sct_x, target->sct_y, player->cnum));
+       return -1;
+    }
+    if (target->sct_type != SCT_AIRPT || target->sct_effic < 60)
+       flags |= P_V;
 
-    *shipno = cno;
+    /* clear to land at sector */
+    *shipno = -1;
     *flagp = flags;
     return 0;
 }