]> git.pond.sub.org Git - empserver/commitdiff
relations: Encapsulate relates[] in relations_string()
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 31 Oct 2016 14:24:09 +0000 (15:24 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 18:09:21 +0000 (20:09 +0200)
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
include/nat.h
src/lib/common/nat.c
src/lib/subs/rej.c

index 0d5683ae2dbf8d64b3bd7caea1f703fc90be2aaf..f3993054336a7848a59d1b44e42656a249c3093e 100644 (file)
@@ -177,8 +177,6 @@ struct rejectstr {
     unsigned char rej_rejects[MAXNOC];
 };
 
-extern char *relates[];
-
 /* procedures relating to nation stuff */
 
 #define putnat(p) ef_write(EF_NATION, (p)->nat_cnum, (p))
@@ -205,6 +203,7 @@ extern char *relatename(struct natstr *np, natid other);
 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);
 extern int in_contact(natid, natid);
 extern void agecontact(struct natstr *np);
index 35b941fe7d783a8aeedad6e9458d3f9deac1f125..35fdb2c4ad9d8682c90081d9efe221ab55b443fd 100644 (file)
 #include "sect.h"
 #include "tel.h"
 
-char *relates[] = {
-    /* must match enum relations */
-    "At War", "Hostile", "Neutral", "Friendly", "Allied"
-};
-
 char *
 cname(natid n)
 {
@@ -59,7 +54,7 @@ cname(natid n)
 char *
 relatename(struct natstr *np, natid other)
 {
-    return relates[getrel(np, other)];
+    return relations_string(getrel(np, other));
 }
 
 char *
@@ -89,6 +84,17 @@ relations_with(natid us, natid them)
     return us == them ? ALLIED : getrel(getnatp(us), them);
 }
 
+char *
+relations_string(enum relations rel)
+{
+    static char *relates[] = {
+       /* must match enum relations */
+       "At War", "Hostile", "Neutral", "Friendly", "Allied"
+    };
+
+    return relates[rel];
+}
+
 int
 nat_accepts(natid us, natid them, enum rej_comm what)
 {
index c72fcb32917d020672936777636dc060ba7bb10d..3f63dc6f2bf4f523ab533728a0639ae22c52427e 100644 (file)
@@ -86,11 +86,11 @@ setrel(natid us, natid them, enum relations rel)
     if (addendum && us == player->cnum && !update_running)
        pr("%s\n", addendum);
     mpr(us, "Diplomatic relations with %s %s to \"%s\".\n",
-       cname(them), whichway, relates[rel]);
+       cname(them), whichway, relations_string(rel));
     if (nat_accepts(them, us, REJ_TELE))
        mpr(them,
            "Country %s has %s their relations with you to \"%s\"!\n",
-           prnat(mynp), whichway, relates[rel]);
+           prnat(mynp), whichway, relations_string(rel));
 
     mynp->nat_relate[them] = rel;
     putnat(mynp);