]> git.pond.sub.org Git - empserver/commitdiff
Rearrange uses of getrel() slightly
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 29 Jan 2011 08:57:21 +0000 (09:57 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 16 Feb 2011 06:50:26 +0000 (07:50 +0100)
Just to make the next few commits easier to review.

src/lib/commands/load.c
src/lib/commands/upgr.c
src/lib/subs/lndsub.c
src/lib/subs/shpsub.c
src/lib/update/ship.c

index fadb17ad18794c50333e202bb0018804993bb2e5..4e46212a98cca224b17edd63bc483b05a4f041be 100644 (file)
@@ -143,7 +143,8 @@ load(void)
                   xyas(sect.sct_x, sect.sct_y, player->cnum));
            continue;
        }
-       if (!player->owner && load_unload == UNLOAD
+       if (load_unload == UNLOAD
+           && !player->owner
            && getrel(getnatp(sect.sct_own), player->cnum) < FRIENDLY) {
            if (noisy)
                pr("You can't unload into an unfriendly %s\n",
index 2d4c38c04cd754c598d25207823aed4a47f9c0e9..33278ff8c87c1efbc227e88046a6e63eddddcc27 100644 (file)
@@ -100,8 +100,8 @@ lupgr(void)
            continue;
        if (sect.sct_type != SCT_HEADQ || sect.sct_effic < 60)
            continue;
-       if (getrel(getnatp(land.lnd_own), sect.sct_own) < FRIENDLY
-           && sect.sct_own != land.lnd_own) {
+       if (land.lnd_own != sect.sct_own
+           && getrel(getnatp(land.lnd_own), sect.sct_own) < FRIENDLY) {
            pr("You are not on friendly terms with the owner of unit %d!\n",
               land.lnd_uid);
            continue;
@@ -181,8 +181,8 @@ supgr(void)
            continue;
        if (sect.sct_type != SCT_HARBR || sect.sct_effic < 60)
            continue;
-       if (getrel(getnatp(ship.shp_own), sect.sct_own) < FRIENDLY
-           && sect.sct_own != ship.shp_own) {
+       if (ship.shp_own != sect.sct_own
+           && getrel(getnatp(ship.shp_own), sect.sct_own) < FRIENDLY) {
            pr("You are not on friendly terms with the owner of ship %d!\n",
               ship.shp_uid);
            continue;
@@ -261,8 +261,8 @@ pupgr(void)
            continue;
        if (sect.sct_type != SCT_AIRPT || sect.sct_effic < 60)
            continue;
-       if (getrel(getnatp(plane.pln_own), sect.sct_own) < FRIENDLY
-           && sect.sct_own != plane.pln_own) {
+       if (plane.pln_own != sect.sct_own
+           && getrel(getnatp(plane.pln_own), sect.sct_own) < FRIENDLY) {
            pr("You are not on friendly terms with the owner of plane %d!\n",
               plane.pln_uid);
            continue;
index f35116ca6c1843576fea91bf31ecb992b35ce09e..d7218c32f66899dce154d27179fee0ba70ca2bf1 100644 (file)
@@ -501,7 +501,7 @@ lnd_mar(struct emp_qelem *list, double *minmobp, double *maxmobp,
            lnd_stays(actor, "has no mil on it to guide it", llp);
            continue;
        }
-       if (sect.sct_own != land.lnd_own &&
+       if (sect.sct_own != actor &&
            getrel(getnatp(sect.sct_own), actor) != ALLIED &&
            !(lchr[(int)llp->unit.land.lnd_type].l_flags & L_SPY) &&
            sect.sct_own) {
@@ -782,9 +782,8 @@ lnd_fort_interdiction(struct emp_qelem *list,
     while (nxtsct(&ns, &fsect)) {
        if (fsect.sct_own == 0)
            continue;
-       if (fsect.sct_own == victim)
-           continue;
-       if (getrel(getnatp(fsect.sct_own), victim) >= NEUTRAL)
+       if (fsect.sct_own == victim
+           || getrel(getnatp(fsect.sct_own), victim) >= NEUTRAL)
            continue;
        range = roundrange(fortrange(&fsect));
        trange = mapdist(newx, newy, fsect.sct_x, fsect.sct_y);
index d5063bc7b055fdcb31fcf95af10947092e1a6ba0..07fe00b297a661b8880efe43ffd94da364065d7f 100644 (file)
@@ -749,8 +749,9 @@ shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor,
        getsect(newx, newy, &sect);
        navigate = shp_check_nav(&sect, &mlp->unit.ship);
        if (navigate != CN_NAVIGABLE ||
-           (sect.sct_own && actor != sect.sct_own &&
-            getrel(getnatp(sect.sct_own), actor) < FRIENDLY)) {
+           (sect.sct_own
+            && sect.sct_own != actor
+            && getrel(getnatp(sect.sct_own), actor) < FRIENDLY)) {
            if (dchr[sect.sct_type].d_nav == NAV_CANAL &&
                !(((struct mchrstr *)mlp->chrp)->m_flags & M_CANAL) &&
                navigate == CN_LANDLOCKED)
index e0db619439064c93b332124cffdd9f205b4b1285..39f22c0e2e115bf1227e79aa42a24c5497eae9ba 100644 (file)
@@ -267,10 +267,10 @@ shiprepair(struct shpstr *ship, struct natstr *np, struct bp *bp, int etus)
     mp = &mchr[(int)ship->shp_type];
     sp = getsectp(ship->shp_x, ship->shp_y);
 
-    if ((sp->sct_own != ship->shp_own) && (sp->sct_own != 0)) {
-       if (getrel(getnatp(sp->sct_own), ship->shp_own) < FRIENDLY)
-           return;
-    }
+    if (sp->sct_own != 0
+       && sp->sct_own != ship->shp_own
+       && getrel(getnatp(sp->sct_own), ship->shp_own) < FRIENDLY)
+       return;
 
     /* only military can work on a military boat */
     if (mp->m_glim != 0)