]> git.pond.sub.org Git - empserver/commitdiff
Distinguish between planes "in orbit" and "launched"
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 22 Mar 2008 17:38:51 +0000 (18:38 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 26 Mar 2008 21:09:09 +0000 (22:09 +0100)
Use new pln_is_in_orbit() when we want to test for orbit specifically,
and test PLN_LAUNCHED when we want to test whether the plane not
sitting in the sector (because it is flying).  This distinction is
pointless at this time, because the only way PLN_LAUNCHED gets set is
when a satellite goes into orbit.  It will become useful in a later
commit, which will use PLN_LAUNCHED to mark flying planes.

12 files changed:
include/prototypes.h
src/lib/commands/laun.c
src/lib/commands/pdump.c
src/lib/commands/plan.c
src/lib/commands/sate.c
src/lib/commands/skyw.c
src/lib/commands/trad.c
src/lib/commands/tran.c
src/lib/commands/upgr.c
src/lib/subs/plnsub.c
src/lib/subs/radmap.c
src/lib/update/plane.c

index 4950e4a8d5cbd1ebebd1b0a7dcbe80a589142089..5fa5cb37a6ad1637529b7b05bfa7101b514d3676 100644 (file)
@@ -569,6 +569,7 @@ extern int put_plane_on_land(struct plnstr *, struct lndstr *);
 extern int pln_hitchance(struct plnstr *, int, int);
 extern int pln_damage(struct plnstr *, coord, coord, char, int *, int);
 extern int pln_identchance(struct plnstr *, int, int);
+extern int pln_is_in_orbit(struct plnstr *);
 extern void pln_set_tech(struct plnstr *, int);
 /* pr.c */
 extern void pr(char *, ...) ATTRIBUTE((format (printf, 1, 2)));
index f51e17ba9f8d0799c73730a2c7b6474b34d8e397..3913196863ab619608c4676d846e1388f4d615f6 100644 (file)
@@ -82,7 +82,7 @@ laun(void)
               prplane(&plane));
            continue;
        }
-       if ((plane.pln_flags & PLN_LAUNCHED) && (pcp->pl_flags & P_O)) {
+       if (pln_is_in_orbit(&plane)) {
            pr("%s already in orbit!\n", prplane(&plane));
            continue;
        }
@@ -193,7 +193,7 @@ launch_as(struct plnstr *pp)
     while (!goodtarget && nxtitem(&ni, &plane)) {
        if (!plane.pln_own)
            continue;
-       if (!(plane.pln_flags & PLN_LAUNCHED))
+       if (!pln_is_in_orbit(&plane))
            continue;
        goodtarget = 1;
 
index 7869420409adade2eefd66e6454ae7ffc87e74f4..6c21a65f196e5ec73ba0bb3158e2044ef926f42b 100644 (file)
@@ -258,20 +258,12 @@ pdump(void)
                pr(" %d", plane.pln_land);
                break;
            case 18:
-               if ((plchr[(int)plane.pln_type].pl_flags & (P_O | P_M)) ==
-                   P_O) {
-                   pr(" %c",
-                      (plane.pln_flags & PLN_LAUNCHED) ? 'Y' : 'N');
-               } else
-                   pr(" N");
+               pr(pln_is_in_orbit(&plane) ? " Y" : " N");
                break;
            case 19:
-               if ((plchr[(int)plane.pln_type].pl_flags & (P_O | P_M)) ==
-                   P_O) {
-                   pr(" %c",
-                      (plane.pln_flags & PLN_SYNCHRONOUS) ? 'Y' : 'N');
-               } else
-                   pr(" N");
+               pr(pln_is_in_orbit(&plane)
+                  && (plane.pln_flags & PLN_SYNCHRONOUS)
+                   ? " Y" : " N");
                break;
            case 20:
                if (plane.pln_nuketype != -1) {
index 3b9b9fa4deb31fd4b9e8fe4641bd11e09c759c2f..136896eca851f83ef2fbcf5d01b25b1498aabcd0 100644 (file)
@@ -74,10 +74,8 @@ plan(void)
            pr("%5dL", plane.pln_land);
        else
            pr("      ");
-       if (plane.pln_flags & PLN_SYNCHRONOUS)
-           pr(" geosync");
-       else if (plane.pln_flags & PLN_LAUNCHED)
-           pr(" orbit");
+       if (pln_is_in_orbit(&plane))
+           pr((plane.pln_flags & PLN_SYNCHRONOUS) ? " geosync" : " orbit");
        else if (plane.pln_nuketype >= 0)
            pr(" %-5.5s %c",
               nchr[(int)plane.pln_nuketype].n_name,
index 24b77a22412ad66413a17c75623d1caf3e93c93f..8c574e5dc0e8bb047bc4f405488308b31edc6230 100644 (file)
@@ -65,7 +65,7 @@ sate(void)
        return RET_FAIL;
     }
 
-    if (!(plane.pln_flags & PLN_LAUNCHED)) {
+    if (!pln_is_in_orbit(&plane)) {
        pr("%s isn't in orbit\n", prplane(&plane));
        return RET_FAIL;
     }
index 6cecd8f06e78859a3bdcc3aec16ba9e7f4c5692d..62f231201409d4c691ae1d1abf784e2585137217 100644 (file)
@@ -74,7 +74,7 @@ skyw(void)
     while (nxtitem(&ni, &skyp->s_sat)) {
        if (!skyp->s_sat.pln_own)
            continue;
-       if (!(skyp->s_sat.pln_flags & PLN_LAUNCHED))
+       if (!pln_is_in_orbit(&skyp->s_sat))
            continue;
        getsect(skyp->s_sat.pln_x, skyp->s_sat.pln_y, &sect);
        n = scthash(skyp->s_sat.pln_x, skyp->s_sat.pln_y, TSIZE);
index 80fe723042c7b878eb93cbdcc3f6faf8206d9e0d..b6ef02d72e3f78d9340590e7883dc731abf494d3 100644 (file)
@@ -184,7 +184,7 @@ trad(void)
      * actually made, except for satellites in orbit.  Must be owned
      * and must be a 60% airfield (except for VTOL planes).
      */
-    if (((trade.trd_type == EF_PLANE) && !(tg.plane.pln_flags & PLN_LAUNCHED))
+    if (((trade.trd_type == EF_PLANE) && !pln_is_in_orbit(&tg.plane))
        || (trade.trd_type == EF_NUKE)) {
        while (1) {
            p = getstring("Destination sector: ", buf);
@@ -364,7 +364,7 @@ check_trade(void)
                        tg.nuke.nuk_x, tg.nuke.nuk_y);
            break;
        case EF_PLANE:
-           if ((tg.plane.pln_flags & PLN_LAUNCHED) == 0) {
+           if (!pln_is_in_orbit(&tg.plane)) {
                tg.plane.pln_x = trade.trd_x;
                tg.plane.pln_y = trade.trd_y;
            }
index ec7374021344fc612846dced906d25e2658a3633..b2da0d093d6b33fc949086a23debcac48f7eef79 100644 (file)
@@ -175,8 +175,7 @@ tran_plane(void)
            pr("%s has been hardened and can't be transported\n",
               prplane(&plane));
            return RET_FAIL;
-       } else if ((plane.pln_flags & PLN_LAUNCHED) &&
-                  (plchr[type].pl_flags & P_O)) {
+       } else if (pln_is_in_orbit(&plane)) {
            pr("%s is in space and can't be transported\n",
               prplane(&plane));
            return RET_FAIL;
index 119fb912b74fd494dba6553a42493fa26212e113..3216f7fc97bb687172e70b98dd72949d7aeb5a02 100644 (file)
@@ -272,10 +272,12 @@ pupgr(void)
               plane.pln_uid);
            continue;
        }
-       if (plane.pln_flags & PLN_LAUNCHED) {
+       if (pln_is_in_orbit(&plane)) {
            pr("Plane %s is in orbit!\n", prplane(&plane));
            continue;
        }
+       if (plane.pln_flags & PLN_LAUNCHED)
+           continue;
        n++;
        pp = &plchr[(int)plane.pln_type];
        avail = (PLN_BLD_WORK(pp->pl_lcm, pp->pl_hcm) * UPGR_COST + 99) / 100;
index 2eddb817829eda51002d7ad50b46058b4860748b..d54643fce3706ff30fb45a3cbdbea0dfb32576ff 100644 (file)
@@ -1236,6 +1236,13 @@ pln_mobcost(int dist, struct plnstr *pp, int flags)
     return ldround(cost * dist / pln_range_max(pp) + 5, 1);
 }
 
+int
+pln_is_in_orbit(struct plnstr *pp)
+{
+    return (plchr[pp->pln_type].pl_flags & (P_M | P_O)) == P_O
+       && (pp->pln_flags & PLN_LAUNCHED);
+}
+
 /*
  * Set PP's tech to TLEV along with everything else that depends on it.
  */
index ea5579caefe75968acca71a9fe121d59a151a099..0ab3c12b3fc678f2a64e863e7bd4a47560ce2d08 100644 (file)
@@ -145,7 +145,7 @@ radmap2(int owner,
        x = deltx(&ns.range, (int)plane.pln_x);
        y = delty(&ns.range, (int)plane.pln_y);
 
-       if ((plane.pln_flags & PLN_LAUNCHED) && plane.pln_own != owner) {
+       if (pln_is_in_orbit(&plane) && plane.pln_own != owner) {
            vis[y][x] = 100;
            rad[y][x] = '$';
        }
index 6ac47b4a52347d4712572e9e30f4079456378629..a0392298a6bb37f100a5e8210f0a1ddf841de4ab 100644 (file)
@@ -66,7 +66,7 @@ prod_plane(int etus, int natnum, struct bp *bp, int buildem)
            continue;
        }
 
-       if (pp->pln_flags & PLN_LAUNCHED) {
+       if (pln_is_in_orbit(pp)) {
            if (!player->simulation && buildem == 0
                && !(pp->pln_flags & PLN_SYNCHRONOUS))
                move_sat(pp);