Use relations_with() for US==THEM || getrel(getnatp(US), THEM)

Replacing getrel(getnatp(US), THEM) by relations_with(US, THEM) makes
a difference only when US equals THEM.

Replace patterns like "us == them || getrel(getnatp(us), them)..." by
"relations_with(us, them)...".
This commit is contained in:
Markus Armbruster 2011-01-26 19:41:28 +01:00 committed by Markus Armbruster
parent ef7b9cedc3
commit 8e75b22e0d
Notes: Markus Armbruster 2013-01-26 12:01:24 +01:00
Author: Markus Armbruster <armbru@pond.sub.org>

Same guy, wrong e-mail address.
13 changed files with 25 additions and 46 deletions

View file

@ -102,8 +102,7 @@ carriersatxy(coord x, coord y, natid own)
while (nxtitem(&ni, &ship)) {
if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
continue;
if (ship.shp_own != own
&& getrel(getnatp(ship.shp_own), own) != ALLIED)
if (relations_with(ship.shp_own, own) != ALLIED)
continue;
if ((carrier_planes(&ship, 0) & (P_L | P_K)) == 0)
continue;

View file

@ -501,8 +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 != actor &&
getrel(getnatp(sect.sct_own), actor) != ALLIED &&
if (relations_with(sect.sct_own, actor) != ALLIED &&
!(lchr[(int)llp->unit.land.lnd_type].l_flags & L_SPY) &&
sect.sct_own) {
sprintf(mess, "has been kidnapped by %s", cname(sect.sct_own));
@ -782,8 +781,7 @@ lnd_fort_interdiction(struct emp_qelem *list,
while (nxtsct(&ns, &fsect)) {
if (fsect.sct_own == 0)
continue;
if (fsect.sct_own == victim
|| getrel(getnatp(fsect.sct_own), victim) >= NEUTRAL)
if (relations_with(fsect.sct_own, victim) >= NEUTRAL)
continue;
range = roundrange(fortrange(&fsect));
trange = mapdist(newx, newy, fsect.sct_x, fsect.sct_y);
@ -1170,7 +1168,7 @@ has_helpful_engineer(coord x, coord y, natid cn)
snxtitem_xy(&ni, EF_LAND, x, y);
while (nxtitem(&ni, &land)) {
if (land.lnd_own != cn && getrel(getnatp(land.lnd_own), cn) != ALLIED)
if (relations_with(land.lnd_own, cn) != ALLIED)
continue;
if (lchr[(int)land.lnd_type].l_flags & L_ENGINEER)
return 1;

View file

@ -102,8 +102,7 @@ get_assembly_point(char *input, struct sctstr *ap_sect, char *buf)
return NULL;
/* over own or allied sector is fine */
if (ap_sect->sct_own == player->cnum
|| getrel(getnatp(ap_sect->sct_own), player->cnum) == ALLIED)
if (relations_with(ap_sect->sct_own, player->cnum) == ALLIED)
return ap_sect;
/* over own or allied ship is fine */
@ -111,8 +110,7 @@ get_assembly_point(char *input, struct sctstr *ap_sect, char *buf)
while (nxtitem(&ni, &ship)) {
if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
continue;
if (ship.shp_own == player->cnum
|| getrel(getnatp(ship.shp_own), player->cnum) == ALLIED)
if (relations_with(ship.shp_own, player->cnum) == ALLIED)
return ap_sect;
}
@ -170,8 +168,7 @@ pln_onewaymission(struct sctstr *target, int *shipno, int *flagp)
}
/* try to land at sector */
if (target->sct_own != player->cnum
&& getrel(getnatp(target->sct_own), player->cnum) != ALLIED) {
if (relations_with(target->sct_own, player->cnum) != ALLIED) {
pr("Nowhere to land at sector %s!\n",
xyas(target->sct_x, target->sct_y, player->cnum));
return -1;
@ -285,8 +282,7 @@ pln_dropoff(struct emp_qelem *list, struct ichrstr *ip, coord tx, coord ty,
pr("Your %s vanish without a trace.\n", ip->i_name);
return;
}
if (sect.sct_own != player->cnum
&& getrel(getnatp(sect.sct_own), player->cnum) != ALLIED) {
if (relations_with(sect.sct_own, player->cnum) != ALLIED) {
pr("You don't own %s! Cargo jettisoned...\n",
xyas(tx, ty, player->cnum));
return;
@ -461,8 +457,7 @@ pln_airbase_ok(struct plnstr *pp, int oneway, int noisy)
CANT_REACH();
return 0;
}
if (ship.shp_own != pp->pln_own
&& getrel(getnatp(ship.shp_own), pp->pln_own) != ALLIED) {
if (relations_with(ship.shp_own, pp->pln_own) != ALLIED) {
if (noisy)
pr("(note) An ally does not own the ship %s is on\n",
prplane(pp));
@ -477,8 +472,7 @@ pln_airbase_ok(struct plnstr *pp, int oneway, int noisy)
CANT_REACH();
return 0;
}
if (land.lnd_own != pp->pln_own
&& getrel(getnatp(land.lnd_own), pp->pln_own) != ALLIED) {
if (relations_with(land.lnd_own, pp->pln_own) != ALLIED) {
if (noisy)
pr("(note) An ally does not own the unit %s is on\n",
prplane(pp));
@ -496,8 +490,7 @@ pln_airbase_ok(struct plnstr *pp, int oneway, int noisy)
return 0;
}
if (sect.sct_own != pp->pln_own
&& getrel(getnatp(sect.sct_own), pp->pln_own) != ALLIED) {
if (relations_with(sect.sct_own, pp->pln_own) != ALLIED) {
if (noisy)
pr("(note) An ally does not own the sector %s is in\n",
prplane(pp));

View file

@ -249,8 +249,8 @@ retreat_ship1(struct shpstr *sp, char code, int orig)
getsect(newx, newy, &sect);
if (shp_check_nav(&sect, sp) != CN_NAVIGABLE ||
(sect.sct_own && sect.sct_own != sp->shp_own &&
getrel(getnatp(sect.sct_own), sp->shp_own) < FRIENDLY)) {
(sect.sct_own
&& relations_with(sect.sct_own, sp->shp_own) < FRIENDLY)) {
wu(0, sp->shp_own, "%s %s,\nbut could not retreat to %s!\n",
prship(sp), conditions[findcondition(code)].desc[orig],
xyas(newx, newy, sp->shp_own));

View file

@ -750,8 +750,7 @@ shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor,
navigate = shp_check_nav(&sect, &mlp->unit.ship);
if (navigate != CN_NAVIGABLE ||
(sect.sct_own
&& sect.sct_own != actor
&& getrel(getnatp(sect.sct_own), actor) < FRIENDLY)) {
&& relations_with(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)