Use relations_with() for getrel(NP, THEM) where NP isn't THEM
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Feb 2011 09:27:45 +0000 (10:27 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Fri, 18 Feb 2011 17:46:05 +0000 (18:46 +0100)
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.

src/lib/commands/cede.c
src/lib/commands/decl.c
src/lib/commands/play.c
src/lib/subs/rej.c
src/lib/update/nat.c

index 82a3dc325d0925d6363873b09a194d79a944e1a3..3f5ceef6929b0155142134f8a0b9bd1db7c0232b 100644 (file)
@@ -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;
     }
index 40190b2920ee447d43dd9d956c33f5d3d837bd3c..fca20c4fa7111a1aea18045e2bd713a006c84eec 100644 (file)
@@ -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);
     }
index e8a64fa249db6785c11209528e3fa6aefb9b4866..8775ad2388fa27ad24b03f1b263270d72477e29d 100644 (file)
@@ -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;
        }
index 8c3fbca9745a0bcde69f741a1fe7517731c2f050..fc1b5efe794d75bf2b262bab3cc9e4599f3ba518 100644 (file)
@@ -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)
index bb45748c31b07b85ba423b1031473a6511bc6903..4a6230fe5f0413314ad9e49bea76c5d0c0352e8a 100644 (file)
@@ -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];