]> git.pond.sub.org Git - empserver/commitdiff
(pln_airbase_ok, mission_pln_airbase_ok): Oops when plane's carrier is
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 3 Nov 2007 08:09:38 +0000 (08:09 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 3 Nov 2007 08:09:38 +0000 (08:09 +0000)
bad.  Before, the plane was destroyed, and the player got a message.

(pln_airbase_ok, mission_pln_airbase_ok): Oops when plane's base
sector is bad.

(pln_airbase_ok): Oops when the player doesn't own the plane.  Before,
this was checked only for planes on carriers, and the plane was
destroyed, and the player got a misleading message.

src/lib/subs/mission.c
src/lib/subs/plnsub.c

index dd6b30c41ea9f49fffc599c82cdb080ae05b7a8b..c67c34d576edb91dc38c3b30afa0c0e9eae6e32c 100644 (file)
@@ -912,17 +912,13 @@ mission_pln_airbase_ok(struct plnstr *pp)
 
     if (pp->pln_ship >= 0) {
        if (!getship(pp->pln_ship, &ship)) {
-       shipsunk:
-           pp->pln_effic = 0;
-           putplane(pp->pln_uid, pp);
+           CANT_REACH();
            return 0;
        }
-       if (!could_be_on_ship(pp, &ship)) {
-           goto shipsunk;
-       }
-       if (ship.shp_effic < SHIP_MINEFF) {
-           goto shipsunk;
-       }
+       if (CANT_HAPPEN(ship.shp_effic < SHIP_MINEFF
+                       || !could_be_on_ship(pp, &ship)))
+           return 0;
+
        /* Can't fly off of inefficient or non-owned, non-allied ships */
        if ((ship.shp_effic < SHP_AIROPS_EFF) ||
            ((ship.shp_own != pp->pln_own) &&
@@ -932,15 +928,12 @@ mission_pln_airbase_ok(struct plnstr *pp)
 
     } else if (pp->pln_land >= 0) {
        if (!getland(pp->pln_land, &land)) {
-       landdead:
-           pp->pln_effic = 0;
-           putplane(pp->pln_uid, pp);
+           CANT_REACH();
            return 0;
        }
-       if (!(pcp->pl_flags & P_E))
-           goto landdead;
-       if (land.lnd_effic < LAND_MINEFF)
-           goto landdead;
+       if (CANT_HAPPEN(land.lnd_effic < LAND_MINEFF
+                       || !(pcp->pl_flags & P_E)))
+           return 0;
 
        /* Can't fly off of inefficient or non-owned, non-allied units */
        if ((land.lnd_effic < LND_AIROPS_EFF) ||
@@ -955,8 +948,8 @@ mission_pln_airbase_ok(struct plnstr *pp)
        }
 
     } else {
-       /* If we can't get the sector, we can't check it, and can't fly */
        if (!getsect(pp->pln_x, pp->pln_y, &sect)) {
+           CANT_REACH();
            return 0;
        }
        /* First, check allied status */
index 9e1daa93f64b88bf14c98619eefd8519865fa397..8d572cdc250943b600542ff67e461c179b969dc4 100644 (file)
@@ -393,19 +393,18 @@ pln_airbase_ok(struct plnstr *pp, int oneway)
     struct sctstr sect;
     struct plchrstr *pcp = plchr + pp->pln_type;
 
+    if (CANT_HAPPEN(pp->pln_own != player->cnum))
+       return 0;
+
     if (pp->pln_ship >= 0) {
-       if (!getship(pp->pln_ship, &ship) ||
-           pp->pln_own != player->cnum) {
-       shipsunk:
-           pp->pln_effic = 0;
-           pr("(note) ship not valid for %s\n", prplane(pp));
-           putplane(pp->pln_uid, pp);
+       if (!getship(pp->pln_ship, &ship)) {
+           CANT_REACH();
            return 0;
        }
-       if (!could_be_on_ship(pp, &ship))
-           goto shipsunk;
-       if (ship.shp_effic < SHIP_MINEFF)
-           goto shipsunk;
+       if (CANT_HAPPEN(ship.shp_effic < SHIP_MINEFF
+                       || !could_be_on_ship(pp, &ship)))
+           return 0;
+
        if (ship.shp_effic < SHP_AIROPS_EFF)
            return 0;
        /* Can't fly off non-owned ships or non-allied ship */
@@ -417,18 +416,14 @@ pln_airbase_ok(struct plnstr *pp, int oneway)
        }
 
     } else if (pp->pln_land >= 0) {
-       if (!getland(pp->pln_land, &land) ||
-           (pp->pln_own != player->cnum)) {
-       landdead:
-           pp->pln_effic = 0;
-           pr("(note) land unit not valid for %s\n", prplane(pp));
-           putplane(pp->pln_uid, pp);
+       if (!getland(pp->pln_land, &land)) {
+           CANT_REACH();
            return 0;
        }
-       if (!(plchr[(int)pp->pln_type].pl_flags & P_E))
-           goto landdead;
-       if (land.lnd_effic < LAND_MINEFF)
-           goto landdead;
+       if (CANT_HAPPEN(land.lnd_effic < LAND_MINEFF
+                       || !(pcp->pl_flags & P_E)))
+           return 0;
+
        if (land.lnd_effic < LND_AIROPS_EFF)
            return 0;
        /* Can't fly off units in ships or other units */
@@ -443,8 +438,10 @@ pln_airbase_ok(struct plnstr *pp, int oneway)
        }
 
     } else {
-       if (!getsect(pp->pln_x, pp->pln_y, &sect))
+       if (!getsect(pp->pln_x, pp->pln_y, &sect)) {
+           CANT_REACH();
            return 0;
+       }
        /* First, check allied status */
        /* Can't fly from non-owned sectors or non-allied sectors */
        if ((sect.sct_own != player->cnum) &&