diff --git a/src/lib/commands/load.c b/src/lib/commands/load.c index fadb17ad..4e46212a 100644 --- a/src/lib/commands/load.c +++ b/src/lib/commands/load.c @@ -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", diff --git a/src/lib/commands/upgr.c b/src/lib/commands/upgr.c index 2d4c38c0..33278ff8 100644 --- a/src/lib/commands/upgr.c +++ b/src/lib/commands/upgr.c @@ -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; diff --git a/src/lib/subs/lndsub.c b/src/lib/subs/lndsub.c index f35116ca..d7218c32 100644 --- a/src/lib/subs/lndsub.c +++ b/src/lib/subs/lndsub.c @@ -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); diff --git a/src/lib/subs/shpsub.c b/src/lib/subs/shpsub.c index d5063bc7..07fe00b2 100644 --- a/src/lib/subs/shpsub.c +++ b/src/lib/subs/shpsub.c @@ -749,8 +749,9 @@ shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor, getsect(newx, newy, §); navigate = shp_check_nav(§, &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) diff --git a/src/lib/update/ship.c b/src/lib/update/ship.c index e0db6194..39f22c0e 100644 --- a/src/lib/update/ship.c +++ b/src/lib/update/ship.c @@ -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)