From: Markus Armbruster Date: Sun, 6 Feb 2011 09:27:45 +0000 (+0100) Subject: Use relations_with() for getrel(NP, THEM) where NP isn't THEM X-Git-Tag: v4.3.27~125 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=6852ec6bc5b8521f35e133521eedb2ec317d10ef 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. --- diff --git a/src/lib/commands/cede.c b/src/lib/commands/cede.c index 82a3dc325..3f5ceef69 100644 --- a/src/lib/commands/cede.c +++ b/src/lib/commands/cede.c @@ -99,7 +99,7 @@ cede(void) pr("You can only give to normal countries...\n"); 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"); return RET_FAIL; } diff --git a/src/lib/commands/decl.c b/src/lib/commands/decl.c index 40190b292..fca20c4fa 100644 --- a/src/lib/commands/decl.c +++ b/src/lib/commands/decl.c @@ -93,7 +93,7 @@ decl(void) continue; } } - if (getrel(natp, (natid)ni.cur) == rel) + if (relations_with(who, (natid)ni.cur) == rel) continue; setrel(who, (natid)ni.cur, rel); } diff --git a/src/lib/commands/play.c b/src/lib/commands/play.c index e8a64fa24..8775ad238 100644 --- a/src/lib/commands/play.c +++ b/src/lib/commands/play.c @@ -90,7 +90,7 @@ play_list(struct player *joe) /* This isn't us. Can we see it? */ if (natp->nat_stat == STAT_VIS) { /* 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. */ return 0; } diff --git a/src/lib/subs/rej.c b/src/lib/subs/rej.c index 8c3fbca97..fc1b5efe7 100644 --- a/src/lib/subs/rej.c +++ b/src/lib/subs/rej.c @@ -60,7 +60,7 @@ setrel(natid us, natid them, int rel) return; if (us == them) return; - oldrel = getrel(mynp, them); + oldrel = relations_with(us, them); if (oldrel == rel) return; if (rel > oldrel) diff --git a/src/lib/update/nat.c b/src/lib/update/nat.c index bb45748c3..4a6230fe5 100644 --- a/src/lib/update/nat.c +++ b/src/lib/update/nat.c @@ -245,9 +245,9 @@ share_incr(double *res, double *tech) continue; } if (!opt_ALL_BLEED) { - if (getrel(np, j) != ALLIED) + if (relations_with(i, j) != ALLIED) continue; - if (getrel(other, i) != ALLIED) + if (relations_with(j, i) != ALLIED) continue; res[i] += levels[j][NAT_RLEV]; tech[i] += levels[j][NAT_TLEV];