]> git.pond.sub.org Git - empserver/commitdiff
relations: Eliminate getrel()
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 31 Oct 2016 14:29:21 +0000 (15:29 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 18:09:21 +0000 (20:09 +0200)
Most uses of getrel() have been replaced by the safer relations_with()
in commit 0c60e57..67b9135, v4.3.27.  Eliminate the remaining ones:

* Convert rela() to use relations_with().  The case of relations to
  self, where the two differ, doesn't occur.  The code becomes more
  easier to understand, even.

* relations_with() is then getrel()'s last user.  Inline.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
include/nat.h
src/lib/commands/rela.c
src/lib/common/nat.c

index c0e5fdd13b56a88489babe865ab08ff32e2860a3..a1700cedf344f2d52de1efea13b2a93a3b94c0e5 100644 (file)
@@ -200,7 +200,6 @@ extern double techfact(int level, double mult);
 /* src/lib/common/nat.c */
 extern char *cname(natid n);
 extern char *natstate(struct natstr *np);
-extern enum relations getrel(struct natstr *np, natid them);
 extern enum relations relations_with(natid, natid);
 extern char *relations_string(enum relations);
 extern int nat_accepts(natid, natid, enum rej_comm);
index 4f505457dbb01c9965db15fb14ef241b435a3a74..9fe1946ed1ee66f640b78b77cf18bc8931fc516a 100644 (file)
@@ -43,7 +43,6 @@
 int
 rela(void)
 {
-    struct natstr *natp;
     struct natstr *np;
     natid cn;
     natid as;
@@ -56,7 +55,6 @@ rela(void)
            return RET_SYN;
        as = (natid)n;
     }
-    natp = getnatp(as);
     pr("\t%s Diplomatic Relations Report\t", cname(as));
     prdate();
     pr("\n  Formal Relations         %5s      theirs\n",
@@ -76,8 +74,8 @@ rela(void)
        }
        pr("%3d) %-20.20s  ", cn, cname(cn));
        pr("%-10s %s\n",
-          relations_string(getrel(natp, cn)),
-          relations_string(getrel(np, as)));
+          relations_string(relations_with(as, cn)),
+          relations_string(relations_with(cn, as)));
     }
     return RET_OK;
 }
index ecaffe90571fa87f4f3d97201f09eb61a6a4d457..b51eb66f3298d884143d5b6ff83db82139ae09f1 100644 (file)
@@ -61,13 +61,6 @@ natstate(struct natstr *np)
     return stnam[np->nat_stat];
 }
 
-/* This returns the relations that np has with them */
-enum relations
-getrel(struct natstr *np, natid them)
-{
-    return np->nat_relate[them];
-}
-
 /*
  * Return relations @us has with @them.
  * Countries are considered allied to themselves.
@@ -75,7 +68,7 @@ getrel(struct natstr *np, natid them)
 enum relations
 relations_with(natid us, natid them)
 {
-    return us == them ? ALLIED : getrel(getnatp(us), them);
+    return us == them ? ALLIED : getnatp(us)->nat_relate[them];
 }
 
 char *