]> git.pond.sub.org Git - empserver/commitdiff
Use relations_with() for US==THEM || getrel(NP, THEM)
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Feb 2011 09:06:38 +0000 (10:06 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Fri, 18 Feb 2011 17:46:05 +0000 (18:46 +0100)
Replace patterns like "US == THEM || getrel(NP, THEM)...", where NP is
known to be getnatp(US), by "relations_with(US, THEM)...".  No
functional change.

Adds a few calls to getnatp() hidden in relations_with(), though.
Keeping that optimized isn't worth it.

src/lib/commands/coun.c
src/lib/commands/flash.c
src/lib/commands/orig.c

index 1464d77b4ef0dac7ea71d7084353bb932d21d8d1..c6a3fe8deb563785ef6781c7e26e436c144464f5 100644 (file)
@@ -68,7 +68,7 @@ coun_list(struct natstr *natp)
     if (getplayer(cn)
        && (player->god
            || natp->nat_stat == STAT_GOD
-           || cn == player->cnum || getrel(natp, player->cnum) == ALLIED))
+           || relations_with(cn, player->cnum) == ALLIED))
        pr(" Now logged on                     ");
     else if (player->god) {
        if (natp->nat_last_login == 0)
index ffdba7a517a733d7a2c2a6a0d7db8ea10e1a5b42..87c244a89ee4df26b2857fd76631629a23996818 100644 (file)
@@ -63,8 +63,8 @@ flash(void)
        }
     } else {
        /* Ok, we are a normal country, can we flash them? */
-       if (to->nat_stat != STAT_GOD && tocn != player->cnum
-           && getrel(to, player->cnum) < FRIENDLY) {
+       if (to->nat_stat != STAT_GOD
+           && relations_with(tocn, player->cnum) < FRIENDLY) {
            pr("%s is not a deity or friendly with us.\n", to->nat_cnam);
            return RET_SYN;
        }
@@ -166,8 +166,8 @@ sendmessage(struct natstr *to, char *message, int verbose)
 
     if (to) {
        /* flash */
-       if (player->god || to->nat_cnum == player->cnum
-           || getrel(to, player->cnum) == ALLIED) {
+       if (player->god
+           || relations_with(to->nat_cnum, player->cnum) == ALLIED) {
            /* Can see TO logged in anyway, so it's okay to tell */
            if (rejected)
                pr("%s is not accepting flashes\n", to->nat_cnam);
index 55f7f39e70cfcb54511e15c54554f7e37f7f866e..9dfb8b92d928cc8d8e0b7d58a43c9e269547a67b 100644 (file)
@@ -67,8 +67,7 @@ orig(void)
        cnum = natarg(p, NULL);
        if (!(np = getnatp(cnum)))
            return RET_SYN;
-       if (!player->god && player->cnum != cnum
-           && getrel(np, player->cnum) != ALLIED) {
+       if (!player->god && relations_with(cnum, player->cnum) != ALLIED) {
            pr("Country %s is not allied with you!\n", np->nat_cnam);
            return RET_FAIL;
        }