]> git.pond.sub.org Git - empserver/commitdiff
Replace laun()'s base checking code by pln_airbase_ok()
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 24 Mar 2008 16:17:53 +0000 (17:17 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 26 Mar 2008 21:13:17 +0000 (22:13 +0100)
This outlaws launch from unowned sectors.  Also, non-VTOL missiles
require an efficient airfield now, except that such missiles don't
exist currently, because init_plchr() makes all missiles VTOL.

src/lib/commands/laun.c

index 20eb31bc072a0f2e343d9735e0daa6651fc90b16..702af83e415b72122ee932865ddd710f94e4fb9d 100644 (file)
@@ -57,11 +57,9 @@ laun(void)
     struct nstr_item nstr;
     struct plnstr plane;
     struct shpstr ship;
     struct nstr_item nstr;
     struct plnstr plane;
     struct shpstr ship;
-    struct sctstr sect;
     int sublaunch;
     struct plchrstr *pcp;
     int sublaunch;
     struct plchrstr *pcp;
-    int rel, retval, gone;
-    struct natstr *natp;
+    int retval, gone;
 
     if (!snxtitem(&nstr, EF_PLANE, player->argp[1]))
        return RET_SYN;
 
     if (!snxtitem(&nstr, EF_PLANE, player->argp[1]))
        return RET_SYN;
@@ -94,41 +92,17 @@ laun(void)
            }
        }
 
            }
        }
 
+       if (plane.pln_effic < 60) {
+           pr("%s is damaged (%d%%)\n", prplane(&plane), plane.pln_effic);
+           continue;
+       }
+       if (!pln_airbase_ok(&plane, 1, 1))
+           continue;
        sublaunch = 0;
        if (plane.pln_ship >= 0) {
            getship(plane.pln_ship, &ship);
        sublaunch = 0;
        if (plane.pln_ship >= 0) {
            getship(plane.pln_ship, &ship);
-           if (!ship.shp_own) {
-               pr("%s: ship #%d was sunk!\n",
-                  prplane(&plane), ship.shp_uid);
-               plane.pln_effic = 0;
-               putplane(plane.pln_uid, &plane);
-               continue;
-           }
-           natp = getnatp(ship.shp_own);
-           rel = getrel(natp, player->cnum);
-           if (ship.shp_own != player->cnum && rel != ALLIED) {
-               pr("%s: you or an ally do not own ship #%d\n",
-                  prplane(&plane), ship.shp_uid);
-               continue;
-           }
            if (mchr[(int)ship.shp_type].m_flags & M_SUB)
                sublaunch = 1;
            if (mchr[(int)ship.shp_type].m_flags & M_SUB)
                sublaunch = 1;
-       } else {
-           sublaunch = 0;
-           getsect(plane.pln_x, plane.pln_y, &sect);
-           natp = getnatp(sect.sct_own);
-           rel = getrel(natp, player->cnum);
-           if (sect.sct_own && sect.sct_own != player->cnum
-               && rel != ALLIED) {
-               pr("%s: you or an ally do not own sector %s!\n",
-                  prplane(&plane), xyas(plane.pln_x, plane.pln_y,
-                                        player->cnum));
-               continue;
-           }
-       }
-       if (plane.pln_effic < 60) {
-           pr("%s is damaged (%d%%)\n", prplane(&plane), plane.pln_effic);
-           continue;
        }
        pr("%s at %s; range %d, eff %d%%\n", prplane(&plane),
           xyas(plane.pln_x, plane.pln_y, player->cnum),
        }
        pr("%s at %s; range %d, eff %d%%\n", prplane(&plane),
           xyas(plane.pln_x, plane.pln_y, player->cnum),