Use relations_with() for getrel(NP, THEM) where NP isn't THEM

Replacing getrel(NP, THEM), where NP is known to be getnatp(US), by
relations_with(US, THEM) makes a difference only when US equals THEM.
Replace in places where it's obvious that they're not equal.

Adds a few calls to getnatp() hidden in relations_with().  Keeping
that optimized isn't worth it.
This commit is contained in:
Markus Armbruster 2011-02-06 10:27:45 +01:00
parent bdf63bc5fa
commit 6852ec6bc5
5 changed files with 6 additions and 6 deletions

View file

@ -99,7 +99,7 @@ cede(void)
pr("You can only give to normal countries...\n"); pr("You can only give to normal countries...\n");
return RET_FAIL; return RET_FAIL;
} }
if (getrel(natp, player->cnum) < FRIENDLY) { if (relations_with(n, player->cnum) < FRIENDLY) {
pr("You can only cede to a country that is friendly towards you...\n"); pr("You can only cede to a country that is friendly towards you...\n");
return RET_FAIL; return RET_FAIL;
} }

View file

@ -93,7 +93,7 @@ decl(void)
continue; continue;
} }
} }
if (getrel(natp, (natid)ni.cur) == rel) if (relations_with(who, (natid)ni.cur) == rel)
continue; continue;
setrel(who, (natid)ni.cur, rel); setrel(who, (natid)ni.cur, rel);
} }

View file

@ -90,7 +90,7 @@ play_list(struct player *joe)
/* This isn't us. Can we see it? */ /* This isn't us. Can we see it? */
if (natp->nat_stat == STAT_VIS) { if (natp->nat_stat == STAT_VIS) {
/* Yes, we can see visitors are logged on */ /* Yes, we can see visitors are logged on */
} else if (getrel(natp, player->cnum) < ALLIED) { } else if (relations_with(joe->cnum, player->cnum) < ALLIED) {
/* This is a non-allied country, don't show it. */ /* This is a non-allied country, don't show it. */
return 0; return 0;
} }

View file

@ -60,7 +60,7 @@ setrel(natid us, natid them, int rel)
return; return;
if (us == them) if (us == them)
return; return;
oldrel = getrel(mynp, them); oldrel = relations_with(us, them);
if (oldrel == rel) if (oldrel == rel)
return; return;
if (rel > oldrel) if (rel > oldrel)

View file

@ -245,9 +245,9 @@ share_incr(double *res, double *tech)
continue; continue;
} }
if (!opt_ALL_BLEED) { if (!opt_ALL_BLEED) {
if (getrel(np, j) != ALLIED) if (relations_with(i, j) != ALLIED)
continue; continue;
if (getrel(other, i) != ALLIED) if (relations_with(j, i) != ALLIED)
continue; continue;
res[i] += levels[j][NAT_RLEV]; res[i] += levels[j][NAT_RLEV];
tech[i] += levels[j][NAT_TLEV]; tech[i] += levels[j][NAT_TLEV];